Skip to content

Commit db9569f

Browse files
committed
media: vidtv: cleanup PMT write table function
- Pass struct vidtv_psi_pmt_write_args as a pointer; - Avoid initializing structs multiple times. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 7f95751 commit db9569f

3 files changed

Lines changed: 46 additions & 49 deletions

File tree

drivers/media/test-drivers/vidtv/vidtv_mux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static u32 vidtv_mux_push_si(struct vidtv_mux *m)
193193
pmt_args.continuity_counter = &pmt_ctx->cc;
194194

195195
/* write each section into buffer */
196-
m->mux_buf_offset += vidtv_psi_pmt_write_into(pmt_args);
196+
m->mux_buf_offset += vidtv_psi_pmt_write_into(&pmt_args);
197197
}
198198

199199
sdt_args.offset = m->mux_buf_offset;

drivers/media/test-drivers/vidtv/vidtv_psi.c

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,81 +1159,81 @@ struct vidtv_psi_table_pmt *vidtv_psi_pmt_table_init(u16 program_number,
11591159
return pmt;
11601160
}
11611161

1162-
u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args args)
1162+
u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args *args)
11631163
{
1164-
struct vidtv_psi_desc *table_descriptor = args.pmt->descriptor;
1165-
struct vidtv_psi_table_pmt_stream *stream = args.pmt->stream;
1164+
struct vidtv_psi_desc *table_descriptor = args->pmt->descriptor;
1165+
struct vidtv_psi_table_pmt_stream *stream = args->pmt->stream;
11661166
struct vidtv_psi_desc *stream_descriptor;
1167-
struct header_write_args h_args = {};
1168-
struct psi_write_args psi_args = {};
1169-
struct desc_write_args d_args = {};
1170-
struct crc32_write_args c_args = {};
1167+
struct header_write_args h_args = {
1168+
.dest_buf = args->buf,
1169+
.dest_offset = args->offset,
1170+
.h = &args->pmt->header,
1171+
.pid = args->pid,
1172+
.continuity_counter = args->continuity_counter,
1173+
.dest_buf_sz = args->buf_sz,
1174+
};
1175+
struct psi_write_args psi_args = {
1176+
.dest_buf = args->buf,
1177+
.from = &args->pmt->bitfield,
1178+
.len = sizeof_field(struct vidtv_psi_table_pmt, bitfield) +
1179+
sizeof_field(struct vidtv_psi_table_pmt, bitfield2),
1180+
.pid = args->pid,
1181+
.new_psi_section = false,
1182+
.is_crc = false,
1183+
.dest_buf_sz = args->buf_sz,
1184+
};
1185+
struct desc_write_args d_args = {
1186+
.dest_buf = args->buf,
1187+
.desc = table_descriptor,
1188+
.pid = args->pid,
1189+
.dest_buf_sz = args->buf_sz,
1190+
};
1191+
struct crc32_write_args c_args = {
1192+
.dest_buf = args->buf,
1193+
.pid = args->pid,
1194+
.dest_buf_sz = args->buf_sz,
1195+
};
11711196
u32 crc = INITIAL_CRC;
11721197
u32 nbytes = 0;
11731198

1174-
vidtv_psi_pmt_table_update_sec_len(args.pmt);
1199+
vidtv_psi_pmt_table_update_sec_len(args->pmt);
11751200

1176-
h_args.dest_buf = args.buf;
1177-
h_args.dest_offset = args.offset;
1178-
h_args.h = &args.pmt->header;
1179-
h_args.pid = args.pid;
1180-
h_args.continuity_counter = args.continuity_counter;
1181-
h_args.dest_buf_sz = args.buf_sz;
11821201
h_args.crc = &crc;
11831202

11841203
nbytes += vidtv_psi_table_header_write_into(&h_args);
11851204

11861205
/* write the two bitfields */
1187-
psi_args.dest_buf = args.buf;
1188-
psi_args.from = &args.pmt->bitfield;
1189-
psi_args.len = sizeof_field(struct vidtv_psi_table_pmt, bitfield) +
1190-
sizeof_field(struct vidtv_psi_table_pmt, bitfield2);
1191-
1192-
psi_args.dest_offset = args.offset + nbytes;
1193-
psi_args.pid = args.pid;
1194-
psi_args.new_psi_section = false;
1195-
psi_args.continuity_counter = args.continuity_counter;
1196-
psi_args.is_crc = false;
1197-
psi_args.dest_buf_sz = args.buf_sz;
1198-
psi_args.crc = &crc;
1199-
1206+
psi_args.dest_offset = args->offset + nbytes;
1207+
psi_args.continuity_counter = args->continuity_counter;
12001208
nbytes += vidtv_psi_ts_psi_write_into(&psi_args);
12011209

12021210
while (table_descriptor) {
12031211
/* write the descriptors, if any */
1204-
d_args.dest_buf = args.buf;
1205-
d_args.dest_offset = args.offset + nbytes;
1206-
d_args.desc = table_descriptor;
1207-
d_args.pid = args.pid;
1208-
d_args.continuity_counter = args.continuity_counter;
1209-
d_args.dest_buf_sz = args.buf_sz;
1212+
d_args.dest_offset = args->offset + nbytes;
1213+
d_args.continuity_counter = args->continuity_counter;
12101214
d_args.crc = &crc;
12111215

12121216
nbytes += vidtv_psi_desc_write_into(&d_args);
12131217

12141218
table_descriptor = table_descriptor->next;
12151219
}
12161220

1221+
psi_args.len += sizeof_field(struct vidtv_psi_table_pmt_stream, type);
12171222
while (stream) {
12181223
/* write the streams, if any */
12191224
psi_args.from = stream;
1220-
psi_args.len = sizeof_field(struct vidtv_psi_table_pmt_stream, type) +
1221-
sizeof_field(struct vidtv_psi_table_pmt_stream, bitfield) +
1222-
sizeof_field(struct vidtv_psi_table_pmt_stream, bitfield2);
1223-
psi_args.dest_offset = args.offset + nbytes;
1225+
psi_args.dest_offset = args->offset + nbytes;
1226+
psi_args.continuity_counter = args->continuity_counter;
12241227

12251228
nbytes += vidtv_psi_ts_psi_write_into(&psi_args);
12261229

12271230
stream_descriptor = stream->descriptor;
12281231

12291232
while (stream_descriptor) {
12301233
/* write the stream descriptors, if any */
1231-
d_args.dest_buf = args.buf;
1232-
d_args.dest_offset = args.offset + nbytes;
1234+
d_args.dest_offset = args->offset + nbytes;
12331235
d_args.desc = stream_descriptor;
1234-
d_args.pid = args.pid;
1235-
d_args.continuity_counter = args.continuity_counter;
1236-
d_args.dest_buf_sz = args.buf_sz;
1236+
d_args.continuity_counter = args->continuity_counter;
12371237
d_args.crc = &crc;
12381238

12391239
nbytes += vidtv_psi_desc_write_into(&d_args);
@@ -1244,12 +1244,9 @@ u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args args)
12441244
stream = stream->next;
12451245
}
12461246

1247-
c_args.dest_buf = args.buf;
1248-
c_args.dest_offset = args.offset + nbytes;
1247+
c_args.dest_offset = args->offset + nbytes;
12491248
c_args.crc = cpu_to_be32(crc);
1250-
c_args.pid = args.pid;
1251-
c_args.continuity_counter = args.continuity_counter;
1252-
c_args.dest_buf_sz = args.buf_sz;
1249+
c_args.continuity_counter = args->continuity_counter;
12531250

12541251
/* Write the CRC32 at the end */
12551252
nbytes += table_section_crc32_write_into(&c_args);

drivers/media/test-drivers/vidtv/vidtv_psi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ struct vidtv_psi_pmt_write_args {
621621
* equal to the size of the PMT section, since more space is needed for TS headers
622622
* during TS encapsulation.
623623
*/
624-
u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args args);
624+
u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args *args);
625625

626626
/**
627627
* vidtv_psi_find_pmt_sec - Finds the PMT section for 'program_num'

0 commit comments

Comments
 (0)