summaryrefslogtreecommitdiff
path: root/drivers/media/test-drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-11-24 10:50:58 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-11-26 08:05:24 +0100
commitb087982886e24dd9b50457d4263910ae671be177 (patch)
tree55ace20ec2cc1c86b2bb3558fc98ac044fe4acbe /drivers/media/test-drivers
parent5a5b9fb1a1117b2cf71a162309e370850a626dbf (diff)
media: vidtv: simplify EIT write function
- pass struct vidtv_psi_eit_write_args as a pointer; - avoid initializing struct fields multiple times. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/test-drivers')
-rw-r--r--drivers/media/test-drivers/vidtv/vidtv_mux.c2
-rw-r--r--drivers/media/test-drivers/vidtv/vidtv_psi.c86
-rw-r--r--drivers/media/test-drivers/vidtv/vidtv_psi.h2
3 files changed, 46 insertions, 44 deletions
diff --git a/drivers/media/test-drivers/vidtv/vidtv_mux.c b/drivers/media/test-drivers/vidtv/vidtv_mux.c
index 77d691f4ff92..b51e6a3b8cbe 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_mux.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_mux.c
@@ -209,7 +209,7 @@ static u32 vidtv_mux_push_si(struct vidtv_mux *m)
eit_args.offset = m->mux_buf_offset;
eit_args.continuity_counter = &eit_ctx->cc;
- m->mux_buf_offset += vidtv_psi_eit_write_into(eit_args);
+ m->mux_buf_offset += vidtv_psi_eit_write_into(&eit_args);
nbytes = m->mux_buf_offset - initial_offset;
diff --git a/drivers/media/test-drivers/vidtv/vidtv_psi.c b/drivers/media/test-drivers/vidtv/vidtv_psi.c
index b03e235b0a67..4511a2a98405 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_psi.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_psi.c
@@ -1857,55 +1857,63 @@ struct vidtv_psi_table_eit
return eit;
}
-u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args args)
+u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args *args)
{
- struct vidtv_psi_table_eit_event *event = args.eit->event;
+ struct header_write_args h_args = {
+ .dest_buf = args->buf,
+ .dest_offset = args->offset,
+ .h = &args->eit->header,
+ .pid = VIDTV_EIT_PID,
+ .dest_buf_sz = args->buf_sz,
+ };
+ struct psi_write_args psi_args = {
+ .dest_buf = args->buf,
+ .len = sizeof_field(struct vidtv_psi_table_eit, transport_id) +
+ sizeof_field(struct vidtv_psi_table_eit, network_id) +
+ sizeof_field(struct vidtv_psi_table_eit, last_segment) +
+ sizeof_field(struct vidtv_psi_table_eit, last_table_id),
+ .pid = VIDTV_EIT_PID,
+ .new_psi_section = false,
+ .is_crc = false,
+ .dest_buf_sz = args->buf_sz,
+ };
+ struct desc_write_args d_args = {
+ .dest_buf = args->buf,
+ .pid = VIDTV_EIT_PID,
+ .dest_buf_sz = args->buf_sz,
+ };
+ struct crc32_write_args c_args = {
+ .dest_buf = args->buf,
+ .pid = VIDTV_EIT_PID,
+ .dest_buf_sz = args->buf_sz,
+ };
+ struct vidtv_psi_table_eit_event *event = args->eit->event;
struct vidtv_psi_desc *event_descriptor;
- struct header_write_args h_args = {};
- struct psi_write_args psi_args = {};
- struct desc_write_args d_args = {};
- struct crc32_write_args c_args = {};
u32 crc = INITIAL_CRC;
u32 nbytes = 0;
- vidtv_psi_eit_table_update_sec_len(args.eit);
+ vidtv_psi_eit_table_update_sec_len(args->eit);
- h_args.dest_buf = args.buf;
- h_args.dest_offset = args.offset;
- h_args.h = &args.eit->header;
- h_args.pid = VIDTV_EIT_PID;
- h_args.continuity_counter = args.continuity_counter;
- h_args.dest_buf_sz = args.buf_sz;
+ h_args.continuity_counter = args->continuity_counter;
h_args.crc = &crc;
nbytes += vidtv_psi_table_header_write_into(&h_args);
- psi_args.dest_buf = args.buf;
- psi_args.from = &args.eit->transport_id;
-
- psi_args.len = sizeof_field(struct vidtv_psi_table_eit, transport_id) +
- sizeof_field(struct vidtv_psi_table_eit, network_id) +
- sizeof_field(struct vidtv_psi_table_eit, last_segment) +
- sizeof_field(struct vidtv_psi_table_eit, last_table_id);
-
- psi_args.dest_offset = args.offset + nbytes;
- psi_args.pid = VIDTV_EIT_PID;
- psi_args.new_psi_section = false;
- psi_args.continuity_counter = args.continuity_counter;
- psi_args.is_crc = false;
- psi_args.dest_buf_sz = args.buf_sz;
+ psi_args.from = &args->eit->transport_id;
+ psi_args.dest_offset = args->offset + nbytes;
+ psi_args.continuity_counter = args->continuity_counter;
psi_args.crc = &crc;
nbytes += vidtv_psi_ts_psi_write_into(&psi_args);
+ /* skip both pointers at the end */
+ psi_args.len = sizeof(struct vidtv_psi_table_eit_event) -
+ sizeof(struct vidtv_psi_desc *) -
+ sizeof(struct vidtv_psi_table_eit_event *);
while (event) {
/* copy the events, if any */
psi_args.from = event;
- /* skip both pointers at the end */
- psi_args.len = sizeof(struct vidtv_psi_table_eit_event) -
- sizeof(struct vidtv_psi_desc *) -
- sizeof(struct vidtv_psi_table_eit_event *);
- psi_args.dest_offset = args.offset + nbytes;
+ psi_args.dest_offset = args->offset + nbytes;
nbytes += vidtv_psi_ts_psi_write_into(&psi_args);
@@ -1913,12 +1921,9 @@ u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args args)
while (event_descriptor) {
/* copy the event descriptors, if any */
- d_args.dest_buf = args.buf;
- d_args.dest_offset = args.offset + nbytes;
+ d_args.dest_offset = args->offset + nbytes;
d_args.desc = event_descriptor;
- d_args.pid = VIDTV_EIT_PID;
- d_args.continuity_counter = args.continuity_counter;
- d_args.dest_buf_sz = args.buf_sz;
+ d_args.continuity_counter = args->continuity_counter;
d_args.crc = &crc;
nbytes += vidtv_psi_desc_write_into(&d_args);
@@ -1929,12 +1934,9 @@ u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args args)
event = event->next;
}
- c_args.dest_buf = args.buf;
- c_args.dest_offset = args.offset + nbytes;
+ c_args.dest_offset = args->offset + nbytes;
c_args.crc = cpu_to_be32(crc);
- c_args.pid = VIDTV_EIT_PID;
- c_args.continuity_counter = args.continuity_counter;
- c_args.dest_buf_sz = args.buf_sz;
+ c_args.continuity_counter = args->continuity_counter;
/* Write the CRC at the end */
nbytes += table_section_crc32_write_into(&c_args);
diff --git a/drivers/media/test-drivers/vidtv/vidtv_psi.h b/drivers/media/test-drivers/vidtv/vidtv_psi.h
index 8e366ea44cca..7a5901f11a37 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_psi.h
+++ b/drivers/media/test-drivers/vidtv/vidtv_psi.h
@@ -773,7 +773,7 @@ struct vidtv_psi_eit_write_args {
* equal to the size of the EIT, since more space is needed for TS headers during TS
* encapsulation.
*/
-u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args args);
+u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args *args);
void vidtv_psi_eit_table_destroy(struct vidtv_psi_table_eit *eit);