From nobody Sun May 11 22:30:58 2025 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1606216042; cv=none; d=zohomail.com; s=zohoarc; b=I6cgZcyDJ7NepBbwBhpzd7A18BPFyLYReqO9cRePOsqZDn0k1Zp87OyUIugdEe4Wjqo/aXKh+RzlxXAfemY9bu3fSKO3X4Mp7dZeJqfaioExpVQ0HqTRnTmAHnxnbs0rWhRpTrFYFp0wGzoDbSYQWKnd+gT35ARMhH+ciyD/qEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606216042; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R2gbS3pTJ6kTVZR6qy23EG0hru73NOhrQCje1pBX6Ok=; b=PJ7V+r8rtE7us6kcPVV2fLKRslpSdkNaxoo1Svl3n7WItHbwz7f+tH1EHwvV6xHKYJZ01fjlHhAbinYgfdcc2lzaOLcQMGRbsEKzQdJ/RoVJob1RXkcEgMzZ53hDWny4cAITEOYAh9AXlbyUO5yU8LcyjhKHQcLbMJdFJgUuY3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1606216042821991.3388894807022; Tue, 24 Nov 2020 03:07:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732591AbgKXLGr (ORCPT ); Tue, 24 Nov 2020 06:06:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:33788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732498AbgKXLGg (ORCPT ); Tue, 24 Nov 2020 06:06:36 -0500 Received: from mail.kernel.org (ip5f5ad5c3.dynamic.kabel-deutschland.de [95.90.213.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E296B208B8; Tue, 24 Nov 2020 11:06:30 +0000 (UTC) Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1khW9U-000FZh-QD; Tue, 24 Nov 2020 12:06:28 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606215991; bh=BOo9Ud6/SZEyAGwmAofjSAAtOyficzIngj2AUKfJ/8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qVGkaa/eFHDB0CZf+tux4py2y1js+Jr0eVsJXNsupiA2lxs8s1pHuTxWGSuUdSle7 eyrU6/8CVqtbR7gS17c+TJ8dKr+prM1IsDGihpDMdjwQjxot8ctGmZ7X8mOWo43WIh wCDD9cAL7VI04YS7u/4Qm02/ph4IfV67Vjl90Qv0= From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , "Daniel W. S. Almeida" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 09/31] media: vidtv: do some cleanups at the driver Date: Tue, 24 Nov 2020 12:06:05 +0100 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Do some cleanups at the coding style of the driver: - remove "inline" declarations; - use reverse xmas-tree for local var declarations; - Adjust some indent to avoid breaking 80-cols; - Cleanup some comments. No functional changes. Signed-off-by: Mauro Carvalho Chehab --- .../media/test-drivers/vidtv/vidtv_bridge.c | 80 ++++---- .../media/test-drivers/vidtv/vidtv_channel.c | 68 +++---- .../media/test-drivers/vidtv/vidtv_encoder.h | 2 +- drivers/media/test-drivers/vidtv/vidtv_mux.c | 37 ++-- drivers/media/test-drivers/vidtv/vidtv_psi.c | 180 ++++++++---------- .../media/test-drivers/vidtv/vidtv_s302m.c | 14 +- 6 files changed, 187 insertions(+), 194 deletions(-) diff --git a/drivers/media/test-drivers/vidtv/vidtv_bridge.c b/drivers/medi= a/test-drivers/vidtv/vidtv_bridge.c index 3fc7bf00a3e5..807baf59db8d 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_bridge.c +++ b/drivers/media/test-drivers/vidtv/vidtv_bridge.c @@ -4,7 +4,8 @@ * validate the existing APIs in the media subsystem. It can also aid * developers working on userspace applications. * - * When this module is loaded, it will attempt to modprobe 'dvb_vidtv_tune= r' and 'dvb_vidtv_demod'. + * When this module is loaded, it will attempt to modprobe 'dvb_vidtv_tune= r' + * and 'dvb_vidtv_demod'. * * Copyright (C) 2020 Daniel W. S. Almeida */ @@ -24,18 +25,21 @@ #include "vidtv_ts.h" #include "vidtv_tuner.h" =20 -//#define MUX_BUF_MAX_SZ -//#define MUX_BUF_MIN_SZ +#define MUX_BUF_MIN_SZ 90164 +#define MUX_BUF_MAX_SZ (MUX_BUF_MIN_SZ * 10) #define TUNER_DEFAULT_ADDR 0x68 #define DEMOD_DEFAULT_ADDR 0x60 #define VIDTV_DEFAULT_NETWORK_ID 0x744 #define VIDTV_DEFAULT_NETWORK_NAME "LinuxTV.org" =20 -/* LNBf fake parameters: ranges used by an Universal (extended) European L= NBf */ -#define LNB_CUT_FREQUENCY 11700000 -#define LNB_LOW_FREQ 9750000 -#define LNB_HIGH_FREQ 10600000 - +/* + * The LNBf fake parameters here are the ranges used by an + * Universal (extended) European LNBf, which is likely the most common LNBf + * found on Satellite digital TV system nowadays. + */ +#define LNB_CUT_FREQUENCY 11700000 /* high IF frequency */ +#define LNB_LOW_FREQ 9750000 /* low IF frequency */ +#define LNB_HIGH_FREQ 10600000 /* transition frequency */ =20 static unsigned int drop_tslock_prob_on_low_snr; module_param(drop_tslock_prob_on_low_snr, uint, 0); @@ -94,7 +98,8 @@ MODULE_PARM_DESC(si_period_msec, "How often to send SI pa= ckets. Default: 40ms"); =20 static unsigned int pcr_period_msec =3D 40; module_param(pcr_period_msec, uint, 0); -MODULE_PARM_DESC(pcr_period_msec, "How often to send PCR packets. Default:= 40ms"); +MODULE_PARM_DESC(pcr_period_msec, + "How often to send PCR packets. Default: 40ms"); =20 static unsigned int mux_rate_kbytes_sec =3D 4096; module_param(mux_rate_kbytes_sec, uint, 0); @@ -106,16 +111,14 @@ MODULE_PARM_DESC(pcr_pid, "PCR PID for all channels: = defaults to 0x200"); =20 static unsigned int mux_buf_sz_pkts; module_param(mux_buf_sz_pkts, uint, 0); -MODULE_PARM_DESC(mux_buf_sz_pkts, "Size for the internal mux buffer in mul= tiples of 188 bytes"); - -#define MUX_BUF_MIN_SZ 90164 -#define MUX_BUF_MAX_SZ (MUX_BUF_MIN_SZ * 10) +MODULE_PARM_DESC(mux_buf_sz_pkts, + "Size for the internal mux buffer in multiples of 188 bytes"); =20 static u32 vidtv_bridge_mux_buf_sz_for_mux_rate(void) { u32 max_elapsed_time_msecs =3D VIDTV_MAX_SLEEP_USECS / USEC_PER_MSEC; - u32 nbytes_expected; u32 mux_buf_sz =3D mux_buf_sz_pkts * TS_PACKET_LEN; + u32 nbytes_expected; =20 nbytes_expected =3D mux_rate_kbytes_sec; nbytes_expected *=3D max_elapsed_time_msecs; @@ -145,14 +148,12 @@ static bool vidtv_bridge_check_demod_lock(struct vidt= v_dvb *dvb, u32 n) FE_HAS_LOCK); } =20 -static void -vidtv_bridge_on_new_pkts_avail(void *priv, u8 *buf, u32 npkts) +/* + * called on a separate thread by the mux when new packets become available + */ +static void vidtv_bridge_on_new_pkts_avail(void *priv, u8 *buf, u32 npkts) { - /* - * called on a separate thread by the mux when new packets become - * available - */ - struct vidtv_dvb *dvb =3D (struct vidtv_dvb *)priv; + struct vidtv_dvb *dvb =3D priv; =20 /* drop packets if we lose the lock */ if (vidtv_bridge_check_demod_lock(dvb, 0)) @@ -180,8 +181,10 @@ static int vidtv_start_streaming(struct vidtv_dvb *dvb) return 0; } =20 - mux_buf_sz =3D (mux_buf_sz_pkts) ? mux_buf_sz_pkts : - vidtv_bridge_mux_buf_sz_for_mux_rate(); + if (mux_buf_sz_pkts) + mux_buf_sz =3D mux_buf_sz_pkts; + else + mux_buf_sz =3D vidtv_bridge_mux_buf_sz_for_mux_rate(); =20 mux_args.mux_buf_sz =3D mux_buf_sz; =20 @@ -212,8 +215,8 @@ static int vidtv_start_feed(struct dvb_demux_feed *feed) { struct dvb_demux *demux =3D feed->demux; struct vidtv_dvb *dvb =3D demux->priv; + int ret; int rc; - int ret; =20 if (!demux->dmx.frontend) return -EINVAL; @@ -251,9 +254,9 @@ static int vidtv_stop_feed(struct dvb_demux_feed *feed) =20 static struct dvb_frontend *vidtv_get_frontend_ptr(struct i2c_client *c) { - /* the demod will set this when its probe function runs */ struct vidtv_demod_state *state =3D i2c_get_clientdata(c); =20 + /* the demod will set this when its probe function runs */ return &state->frontend; } =20 @@ -261,6 +264,11 @@ static int vidtv_master_xfer(struct i2c_adapter *i2c_a= dap, struct i2c_msg msgs[], int num) { + /* + * Right now, this virtual driver doesn't really send or receive + * messages from I2C. A real driver will require an implementation + * here. + */ return 0; } =20 @@ -328,11 +336,10 @@ static int vidtv_bridge_dmxdev_init(struct vidtv_dvb = *dvb) =20 static int vidtv_bridge_probe_demod(struct vidtv_dvb *dvb, u32 n) { - struct vidtv_demod_config cfg =3D {}; - - cfg.drop_tslock_prob_on_low_snr =3D drop_tslock_prob_on_low_snr; - cfg.recover_tslock_prob_on_good_snr =3D recover_tslock_prob_on_good_snr; - + struct vidtv_demod_config cfg =3D { + .drop_tslock_prob_on_low_snr =3D drop_tslock_prob_on_low_snr, + .recover_tslock_prob_on_good_snr =3D recover_tslock_prob_on_good_snr, + }; dvb->i2c_client_demod[n] =3D dvb_module_probe("dvb_vidtv_demod", NULL, &dvb->i2c_adapter, @@ -351,13 +358,14 @@ static int vidtv_bridge_probe_demod(struct vidtv_dvb = *dvb, u32 n) =20 static int vidtv_bridge_probe_tuner(struct vidtv_dvb *dvb, u32 n) { - struct vidtv_tuner_config cfg =3D {}; + struct vidtv_tuner_config cfg =3D { + .fe =3D dvb->fe[n], + .mock_power_up_delay_msec =3D mock_power_up_delay_msec, + .mock_tune_delay_msec =3D mock_tune_delay_msec, + }; u32 freq; int i; =20 - cfg.fe =3D dvb->fe[n]; - cfg.mock_power_up_delay_msec =3D mock_power_up_delay_msec; - cfg.mock_tune_delay_msec =3D mock_tune_delay_msec; =20 /* TODO: check if the frequencies are at a valid range */ =20 @@ -397,9 +405,7 @@ static int vidtv_bridge_probe_tuner(struct vidtv_dvb *d= vb, u32 n) =20 static int vidtv_bridge_dvb_init(struct vidtv_dvb *dvb) { - int ret; - int i; - int j; + int ret, i, j; =20 ret =3D vidtv_bridge_i2c_register_adap(dvb); if (ret < 0) diff --git a/drivers/media/test-drivers/vidtv/vidtv_channel.c b/drivers/med= ia/test-drivers/vidtv/vidtv_channel.c index d80b1a56c90c..eba9d9dd0808 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_channel.c +++ b/drivers/media/test-drivers/vidtv/vidtv_channel.c @@ -33,8 +33,8 @@ =20 static void vidtv_channel_encoder_destroy(struct vidtv_encoder *e) { - struct vidtv_encoder *curr =3D e; struct vidtv_encoder *tmp =3D NULL; + struct vidtv_encoder *curr =3D e; =20 while (curr) { /* forward the call to the derived type */ @@ -46,25 +46,25 @@ static void vidtv_channel_encoder_destroy(struct vidtv_= encoder *e) =20 #define ENCODING_ISO8859_15 "\x0b" =20 +/* + * init an audio only channel with a s302m encoder + */ struct vidtv_channel *vidtv_channel_s302m_init(struct vidtv_channel *head, u16 transport_stream= _id) { - /* - * init an audio only channel with a s302m encoder - */ - const u16 s302m_service_id =3D 0x880; - const u16 s302m_program_num =3D 0x880; - const u16 s302m_program_pid =3D 0x101; /* packet id for PMT*/ - const u16 s302m_es_pid =3D 0x111; /* packet id for the ES */ const __be32 s302m_fid =3D cpu_to_be32(VIDTV_S302M_FORMAT_ID= ENTIFIER); - char *name =3D ENCODING_ISO8859_15 "Beethoven"; - char *provider =3D ENCODING_ISO8859_15 "LinuxTV.org"; - char *iso_language_code =3D ENCODING_ISO8859_15 "eng"; - char *event_name =3D ENCODING_ISO8859_15 "Beethoven Music"; char *event_text =3D ENCODING_ISO8859_15 "Beethoven's F=C3=BCr Elise"; + char *event_name =3D ENCODING_ISO8859_15 "Beethoven Music"; + struct vidtv_s302m_encoder_init_args encoder_args =3D {}; + char *iso_language_code =3D ENCODING_ISO8859_15 "eng"; + char *provider =3D ENCODING_ISO8859_15 "LinuxTV.org"; + char *name =3D ENCODING_ISO8859_15 "Beethoven"; + const u16 s302m_es_pid =3D 0x111; /* packet id for the ES */ + const u16 s302m_program_pid =3D 0x101; /* packet id for PMT*/ + const u16 s302m_service_id =3D 0x880; + const u16 s302m_program_num =3D 0x880; const u16 s302m_beethoven_event_id =3D 1; struct vidtv_channel *s302m; - struct vidtv_s302m_encoder_init_args encoder_args =3D {}; =20 s302m =3D kzalloc(sizeof(*s302m), GFP_KERNEL); if (!s302m) @@ -159,11 +159,9 @@ static struct vidtv_psi_table_eit_event { /* Concatenate the events */ const struct vidtv_channel *cur_chnl =3D m->channels; - struct vidtv_psi_table_eit_event *curr =3D NULL; struct vidtv_psi_table_eit_event *head =3D NULL; struct vidtv_psi_table_eit_event *tail =3D NULL; - struct vidtv_psi_desc *desc =3D NULL; u16 event_id; =20 @@ -175,7 +173,8 @@ static struct vidtv_psi_table_eit_event =20 if (!curr) dev_warn_ratelimited(m->dev, - "No events found for channel %s\n", cur_chnl->name); + "No events found for channel %s\n", + cur_chnl->name); =20 while (curr) { event_id =3D be16_to_cpu(curr->event_id); @@ -221,7 +220,8 @@ static struct vidtv_psi_table_sdt_service =20 if (!curr) dev_warn_ratelimited(m->dev, - "No services found for channel %s\n", cur_chnl->name); + "No services found for channel %s\n", + cur_chnl->name); =20 while (curr) { service_id =3D be16_to_cpu(curr->service_id); @@ -300,26 +300,24 @@ vidtv_channel_pat_prog_cat_into_new(struct vidtv_mux = *m) return head; } =20 +/* + * Match channels to their respective PMT sections, then assign the + * streams + */ static void vidtv_channel_pmt_match_sections(struct vidtv_channel *channels, struct vidtv_psi_table_pmt **sections, u32 nsections) { - /* - * Match channels to their respective PMT sections, then assign the - * streams - */ struct vidtv_psi_table_pmt *curr_section =3D NULL; - struct vidtv_channel *cur_chnl =3D channels; - - struct vidtv_psi_table_pmt_stream *s =3D NULL; struct vidtv_psi_table_pmt_stream *head =3D NULL; struct vidtv_psi_table_pmt_stream *tail =3D NULL; - + struct vidtv_psi_table_pmt_stream *s =3D NULL; + struct vidtv_channel *cur_chnl =3D channels; struct vidtv_psi_desc *desc =3D NULL; - u32 j; - u16 curr_id; u16 e_pid; /* elementary stream pid */ + u16 curr_id; + u32 j; =20 while (cur_chnl) { for (j =3D 0; j < nsections; ++j) { @@ -345,7 +343,8 @@ vidtv_channel_pmt_match_sections(struct vidtv_channel *= channels, head =3D tail; =20 desc =3D vidtv_psi_desc_clone(s->descriptor); - vidtv_psi_desc_assign(&tail->descriptor, desc); + vidtv_psi_desc_assign(&tail->descriptor, + desc); =20 s =3D s->next; } @@ -359,7 +358,8 @@ vidtv_channel_pmt_match_sections(struct vidtv_channel *= channels, } } =20 -static void vidtv_channel_destroy_service_list(struct vidtv_psi_desc_servi= ce_list_entry *e) +static void +vidtv_channel_destroy_service_list(struct vidtv_psi_desc_service_list_entr= y *e) { struct vidtv_psi_desc_service_list_entry *tmp; =20 @@ -413,9 +413,9 @@ static struct vidtv_psi_desc_service_list_entry =20 int vidtv_channel_si_init(struct vidtv_mux *m) { + struct vidtv_psi_desc_service_list_entry *service_list =3D NULL; struct vidtv_psi_table_pat_program *programs =3D NULL; struct vidtv_psi_table_sdt_service *services =3D NULL; - struct vidtv_psi_desc_service_list_entry *service_list =3D NULL; struct vidtv_psi_table_eit_event *events =3D NULL; =20 m->si.pat =3D vidtv_psi_pat_table_init(m->transport_stream_id); @@ -450,7 +450,8 @@ int vidtv_channel_si_init(struct vidtv_mux *m) if (!m->si.nit) goto free_service_list; =20 - m->si.eit =3D vidtv_psi_eit_table_init(m->network_id, m->transport_stream= _id); + m->si.eit =3D vidtv_psi_eit_table_init(m->network_id, + m->transport_stream_id); if (!m->si.eit) goto free_nit; =20 @@ -464,7 +465,8 @@ int vidtv_channel_si_init(struct vidtv_mux *m) /* assemble all events and assign to EIT */ vidtv_psi_eit_event_assign(m->si.eit, events); =20 - m->si.pmt_secs =3D vidtv_psi_pmt_create_sec_for_each_pat_entry(m->si.pat,= m->pcr_pid); + m->si.pmt_secs =3D vidtv_psi_pmt_create_sec_for_each_pat_entry(m->si.pat, + m->pcr_pid); if (!m->si.pmt_secs) goto free_eit; =20 @@ -497,8 +499,8 @@ int vidtv_channel_si_init(struct vidtv_mux *m) =20 void vidtv_channel_si_destroy(struct vidtv_mux *m) { - u32 i; u16 num_programs =3D m->si.pat->programs; + u32 i; =20 vidtv_psi_pat_table_destroy(m->si.pat); =20 diff --git a/drivers/media/test-drivers/vidtv/vidtv_encoder.h b/drivers/med= ia/test-drivers/vidtv/vidtv_encoder.h index f742d566fbcb..0ac5b1e3f666 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_encoder.h +++ b/drivers/media/test-drivers/vidtv/vidtv_encoder.h @@ -28,7 +28,7 @@ struct vidtv_access_unit { struct vidtv_access_unit *next; }; =20 -/* Some musical notes, used by a tone generator */ +/* Some musical notes, used by a tone generator. Values are in Hz */ enum musical_notes { NOTE_SILENT =3D 0, =20 diff --git a/drivers/media/test-drivers/vidtv/vidtv_mux.c b/drivers/media/t= est-drivers/vidtv/vidtv_mux.c index eb24e27b7f5f..6df9cfd7f33b 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_mux.c +++ b/drivers/media/test-drivers/vidtv/vidtv_mux.c @@ -63,9 +63,9 @@ static struct vidtv_mux_pid_ctx =20 static void vidtv_mux_pid_ctx_destroy(struct vidtv_mux *m) { - int bkt; struct vidtv_mux_pid_ctx *ctx; struct hlist_node *tmp; + int bkt; =20 hash_for_each_safe(m->pid_ctx, bkt, tmp, ctx, h) { hash_del(&ctx->h); @@ -129,21 +129,18 @@ static void vidtv_mux_update_clk(struct vidtv_mux *m) =20 static u32 vidtv_mux_push_si(struct vidtv_mux *m) { - u32 initial_offset =3D m->mux_buf_offset; - - struct vidtv_mux_pid_ctx *pat_ctx; - struct vidtv_mux_pid_ctx *pmt_ctx; - struct vidtv_mux_pid_ctx *sdt_ctx; - struct vidtv_mux_pid_ctx *nit_ctx; - struct vidtv_mux_pid_ctx *eit_ctx; - struct vidtv_psi_pat_write_args pat_args =3D {}; struct vidtv_psi_pmt_write_args pmt_args =3D {}; struct vidtv_psi_sdt_write_args sdt_args =3D {}; struct vidtv_psi_nit_write_args nit_args =3D {}; struct vidtv_psi_eit_write_args eit_args =3D {}; - - u32 nbytes; /* the number of bytes written by this function */ + u32 initial_offset =3D m->mux_buf_offset; + struct vidtv_mux_pid_ctx *pat_ctx; + struct vidtv_mux_pid_ctx *pmt_ctx; + struct vidtv_mux_pid_ctx *sdt_ctx; + struct vidtv_mux_pid_ctx *nit_ctx; + struct vidtv_mux_pid_ctx *eit_ctx; + u32 nbytes; u16 pmt_pid; u32 i; =20 @@ -269,7 +266,6 @@ static bool vidtv_mux_should_push_si(struct vidtv_mux *= m) static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m, struct vidtv_encoder *e) { - u32 nbytes =3D 0; struct pes_write_args args =3D { .dest_buf =3D m->mux_buf, .dest_buf_sz =3D m->mux_buf_sz, @@ -279,10 +275,11 @@ static u32 vidtv_mux_packetize_access_units(struct vi= dtv_mux *m, .send_pts =3D true, /* forbidden value '01'... */ .send_dts =3D false, /* ...for PTS_DTS flags */ }; - u32 initial_offset =3D m->mux_buf_offset; struct vidtv_access_unit *au =3D e->access_units; - u8 *buf =3D NULL; + u32 initial_offset =3D m->mux_buf_offset; struct vidtv_mux_pid_ctx *pid_ctx; + u32 nbytes =3D 0; + u8 *buf =3D NULL; =20 /* see SMPTE 302M clause 6.4 */ if (args.encoder_id =3D=3D S302M) { @@ -318,10 +315,10 @@ static u32 vidtv_mux_packetize_access_units(struct vi= dtv_mux *m, =20 static u32 vidtv_mux_poll_encoders(struct vidtv_mux *m) { - u32 nbytes =3D 0; - u32 au_nbytes; struct vidtv_channel *cur_chnl =3D m->channels; struct vidtv_encoder *e =3D NULL; + u32 nbytes =3D 0; + u32 au_nbytes; =20 while (cur_chnl) { e =3D cur_chnl->encoders; @@ -347,9 +344,9 @@ static u32 vidtv_mux_pad_with_nulls(struct vidtv_mux *m= , u32 npkts) { struct null_packet_write_args args =3D {}; u32 initial_offset =3D m->mux_buf_offset; - u32 nbytes; /* the number of bytes written by this function */ - u32 i; struct vidtv_mux_pid_ctx *ctx; + u32 nbytes; + u32 i; =20 ctx =3D vidtv_mux_get_pid_ctx(m, TS_NULL_PACKET_PID); =20 @@ -388,9 +385,9 @@ static void vidtv_mux_tick(struct work_struct *work) struct vidtv_mux, mpeg_thread); struct dtv_frontend_properties *c =3D &m->fe->dtv_property_cache; - u32 nbytes; - u32 npkts; u32 tot_bits =3D 0; + u32 nbytes; + u32 npkts; =20 while (m->streaming) { nbytes =3D 0; diff --git a/drivers/media/test-drivers/vidtv/vidtv_psi.c b/drivers/media/t= est-drivers/vidtv/vidtv_psi.c index f92ff54fe19b..375e01480d3d 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_psi.c +++ b/drivers/media/test-drivers/vidtv/vidtv_psi.c @@ -76,7 +76,7 @@ static const u32 CRC_LUT[256] =3D { 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 }; =20 -static inline u32 dvb_crc32(u32 crc, u8 *data, u32 len) +static u32 dvb_crc32(u32 crc, u8 *data, u32 len) { /* from libdvbv5 */ while (len--) @@ -89,7 +89,8 @@ static void vidtv_psi_update_version_num(struct vidtv_psi= _table_header *h) h->version++; } =20 -static inline u16 vidtv_psi_sdt_serv_get_desc_loop_len(struct vidtv_psi_ta= ble_sdt_service *s) +static u16 +vidtv_psi_sdt_serv_get_desc_loop_len(struct vidtv_psi_table_sdt_service *s) { u16 mask; u16 ret; @@ -100,7 +101,8 @@ static inline u16 vidtv_psi_sdt_serv_get_desc_loop_len(= struct vidtv_psi_table_sd return ret; } =20 -static inline u16 vidtv_psi_pmt_stream_get_desc_loop_len(struct vidtv_psi_= table_pmt_stream *s) +static u16 +vidtv_psi_pmt_stream_get_desc_loop_len(struct vidtv_psi_table_pmt_stream *= s) { u16 mask; u16 ret; @@ -111,7 +113,7 @@ static inline u16 vidtv_psi_pmt_stream_get_desc_loop_le= n(struct vidtv_psi_table_ return ret; } =20 -static inline u16 vidtv_psi_pmt_get_desc_loop_len(struct vidtv_psi_table_p= mt *p) +static u16 vidtv_psi_pmt_get_desc_loop_len(struct vidtv_psi_table_pmt *p) { u16 mask; u16 ret; @@ -122,7 +124,7 @@ static inline u16 vidtv_psi_pmt_get_desc_loop_len(struc= t vidtv_psi_table_pmt *p) return ret; } =20 -static inline u16 vidtv_psi_get_sec_len(struct vidtv_psi_table_header *h) +static u16 vidtv_psi_get_sec_len(struct vidtv_psi_table_header *h) { u16 mask; u16 ret; @@ -133,7 +135,7 @@ static inline u16 vidtv_psi_get_sec_len(struct vidtv_ps= i_table_header *h) return ret; } =20 -inline u16 vidtv_psi_get_pat_program_pid(struct vidtv_psi_table_pat_progra= m *p) +u16 vidtv_psi_get_pat_program_pid(struct vidtv_psi_table_pat_program *p) { u16 mask; u16 ret; @@ -144,7 +146,7 @@ inline u16 vidtv_psi_get_pat_program_pid(struct vidtv_p= si_table_pat_program *p) return ret; } =20 -inline u16 vidtv_psi_pmt_stream_get_elem_pid(struct vidtv_psi_table_pmt_st= ream *s) +u16 vidtv_psi_pmt_stream_get_elem_pid(struct vidtv_psi_table_pmt_stream *s) { u16 mask; u16 ret; @@ -155,10 +157,11 @@ inline u16 vidtv_psi_pmt_stream_get_elem_pid(struct v= idtv_psi_table_pmt_stream * return ret; } =20 -static inline void vidtv_psi_set_desc_loop_len(__be16 *bitfield, u16 new_l= en, u8 desc_len_nbits) +static void vidtv_psi_set_desc_loop_len(__be16 *bitfield, u16 new_len, + u8 desc_len_nbits) { - u16 mask; __be16 new; + u16 mask; =20 mask =3D GENMASK(15, desc_len_nbits); =20 @@ -185,27 +188,22 @@ static void vidtv_psi_set_sec_len(struct vidtv_psi_ta= ble_header *h, u16 new_len) h->bitfield =3D new; } =20 +/* + * Packetize PSI sections into TS packets: + * push a TS header (4bytes) every 184 bytes + * manage the continuity_counter + * add stuffing (i.e. padding bytes) after the CRC + */ static u32 vidtv_psi_ts_psi_write_into(struct psi_write_args args) { - /* - * Packetize PSI sections into TS packets: - * push a TS header (4bytes) every 184 bytes - * manage the continuity_counter - * add stuffing (i.e. padding bytes) after the CRC - */ =20 u32 nbytes_past_boundary =3D (args.dest_offset % TS_PACKET_LEN); bool aligned =3D (nbytes_past_boundary =3D=3D 0); struct vidtv_mpeg_ts ts_header =3D {}; - - /* number of bytes written by this function */ - u32 nbytes =3D 0; - /* how much there is left to write */ u32 remaining_len =3D args.len; - /* how much we can be written in this packet */ u32 payload_write_len =3D 0; - /* where we are in the source */ u32 payload_offset =3D 0; + u32 nbytes =3D 0; =20 const u16 PAYLOAD_START =3D args.new_psi_section; =20 @@ -294,9 +292,10 @@ static u32 vidtv_psi_ts_psi_write_into(struct psi_writ= e_args args) =20 static u32 table_section_crc32_write_into(struct crc32_write_args args) { + struct psi_write_args psi_args =3D {}; + u32 nbytes =3D 0; + /* the CRC is the last entry in the section */ - u32 nbytes =3D 0; - struct psi_write_args psi_args =3D {}; =20 psi_args.dest_buf =3D args.dest_buf; psi_args.from =3D &args.crc; @@ -391,8 +390,8 @@ struct vidtv_psi_desc_registration struct vidtv_psi_desc_network_name *vidtv_psi_network_name_desc_init(struct vidtv_psi_desc *head, char *netwo= rk_name) { - struct vidtv_psi_desc_network_name *desc; u32 network_name_len =3D network_name ? strlen(network_name) : 0; + struct vidtv_psi_desc_network_name *desc; =20 desc =3D kzalloc(sizeof(*desc), GFP_KERNEL); if (!desc) @@ -413,10 +412,10 @@ struct vidtv_psi_desc_service_list *vidtv_psi_service_list_desc_init(struct vidtv_psi_desc *head, struct vidtv_psi_desc_service_list_entry *entry) { - struct vidtv_psi_desc_service_list *desc; struct vidtv_psi_desc_service_list_entry *curr_e =3D NULL; struct vidtv_psi_desc_service_list_entry *head_e =3D NULL; struct vidtv_psi_desc_service_list_entry *prev_e =3D NULL; + struct vidtv_psi_desc_service_list *desc; u16 length =3D 0; =20 desc =3D kzalloc(sizeof(*desc), GFP_KERNEL); @@ -465,10 +464,10 @@ struct vidtv_psi_desc_short_event char *event_name, char *text) { - struct vidtv_psi_desc_short_event *desc; + u32 iso_len =3D iso_language_code ? strlen(iso_language_code) : 0; u32 event_name_len =3D event_name ? strlen(event_name) : 0; + struct vidtv_psi_desc_short_event *desc; u32 text_len =3D text ? strlen(text) : 0; - u32 iso_len =3D iso_language_code ? strlen(iso_language_code) : 0; =20 desc =3D kzalloc(sizeof(*desc), GFP_KERNEL); if (!desc) @@ -502,14 +501,13 @@ struct vidtv_psi_desc_short_event =20 struct vidtv_psi_desc *vidtv_psi_desc_clone(struct vidtv_psi_desc *desc) { - struct vidtv_psi_desc *head =3D NULL; - struct vidtv_psi_desc *prev =3D NULL; - struct vidtv_psi_desc *curr =3D NULL; - - struct vidtv_psi_desc_service *service; struct vidtv_psi_desc_network_name *desc_network_name; struct vidtv_psi_desc_service_list *desc_service_list; struct vidtv_psi_desc_short_event *desc_short_event; + struct vidtv_psi_desc_service *service; + struct vidtv_psi_desc *head =3D NULL; + struct vidtv_psi_desc *prev =3D NULL; + struct vidtv_psi_desc *curr =3D NULL; =20 while (desc) { switch (desc->type) { @@ -571,10 +569,10 @@ struct vidtv_psi_desc *vidtv_psi_desc_clone(struct vi= dtv_psi_desc *desc) =20 void vidtv_psi_desc_destroy(struct vidtv_psi_desc *desc) { + struct vidtv_psi_desc_service_list_entry *sl_entry_tmp =3D NULL; + struct vidtv_psi_desc_service_list_entry *sl_entry =3D NULL; struct vidtv_psi_desc *curr =3D desc; struct vidtv_psi_desc *tmp =3D NULL; - struct vidtv_psi_desc_service_list_entry *sl_entry =3D NULL; - struct vidtv_psi_desc_service_list_entry *sl_entry_tmp =3D NULL; =20 while (curr) { tmp =3D curr; @@ -677,10 +675,10 @@ void vidtv_sdt_desc_assign(struct vidtv_psi_table_sdt= *sdt, =20 static u32 vidtv_psi_desc_write_into(struct desc_write_args args) { - /* the number of bytes written by this function */ - u32 nbytes =3D 0; - struct psi_write_args psi_args =3D {}; struct vidtv_psi_desc_service_list_entry *serv_list_entry =3D NULL; + struct psi_write_args psi_args =3D {}; + /* the number of bytes written by this function */ + u32 nbytes =3D 0; =20 psi_args.dest_buf =3D args.dest_buf; psi_args.from =3D &args.desc->type; @@ -799,9 +797,9 @@ static u32 vidtv_psi_desc_write_into(struct desc_write_= args args) static u32 vidtv_psi_table_header_write_into(struct header_write_args args) { + struct psi_write_args psi_args =3D {}; /* the number of bytes written by this function */ u32 nbytes =3D 0; - struct psi_write_args psi_args =3D {}; =20 psi_args.dest_buf =3D args.dest_buf; psi_args.from =3D args.h; @@ -822,9 +820,10 @@ vidtv_psi_table_header_write_into(struct header_write_= args args) void vidtv_psi_pat_table_update_sec_len(struct vidtv_psi_table_pat *pat) { + u16 length =3D 0; + u32 i; + /* see ISO/IEC 13818-1 : 2000 p.43 */ - u16 length =3D 0; - u32 i; =20 /* from immediately after 'section_length' until 'last_section_number'*/ length +=3D PAT_LEN_UNTIL_LAST_SECTION_NUMBER; @@ -841,10 +840,11 @@ vidtv_psi_pat_table_update_sec_len(struct vidtv_psi_t= able_pat *pat) =20 void vidtv_psi_pmt_table_update_sec_len(struct vidtv_psi_table_pmt *pmt) { - /* see ISO/IEC 13818-1 : 2000 p.46 */ - u16 length =3D 0; struct vidtv_psi_table_pmt_stream *s =3D pmt->stream; u16 desc_loop_len; + u16 length =3D 0; + + /* see ISO/IEC 13818-1 : 2000 p.46 */ =20 /* from immediately after 'section_length' until 'program_info_length'*/ length +=3D PMT_LEN_UNTIL_PROGRAM_INFO_LENGTH; @@ -875,10 +875,11 @@ void vidtv_psi_pmt_table_update_sec_len(struct vidtv_= psi_table_pmt *pmt) =20 void vidtv_psi_sdt_table_update_sec_len(struct vidtv_psi_table_sdt *sdt) { - /* see ETSI EN 300 468 V 1.10.1 p.24 */ - u16 length =3D 0; struct vidtv_psi_table_sdt_service *s =3D sdt->service; u16 desc_loop_len; + u16 length =3D 0; + + /* see ETSI EN 300 468 V 1.10.1 p.24 */ =20 /* * from immediately after 'section_length' until @@ -935,8 +936,8 @@ vidtv_psi_pat_program_init(struct vidtv_psi_table_pat_p= rogram *head, void vidtv_psi_pat_program_destroy(struct vidtv_psi_table_pat_program *p) { - struct vidtv_psi_table_pat_program *curr =3D p; struct vidtv_psi_table_pat_program *tmp =3D NULL; + struct vidtv_psi_table_pat_program *curr =3D p; =20 while (curr) { tmp =3D curr; @@ -945,14 +946,13 @@ vidtv_psi_pat_program_destroy(struct vidtv_psi_table_= pat_program *p) } } =20 +/* This function transfers ownership of p to the table */ void vidtv_psi_pat_program_assign(struct vidtv_psi_table_pat *pat, struct vidtv_psi_table_pat_program *p) { - /* This function transfers ownership of p to the table */ - + struct vidtv_psi_table_pat_program *program; u16 program_count; - struct vidtv_psi_table_pat_program *program; =20 do { program_count =3D 0; @@ -1010,16 +1010,13 @@ struct vidtv_psi_table_pat *vidtv_psi_pat_table_ini= t(u16 transport_stream_id) =20 u32 vidtv_psi_pat_write_into(struct vidtv_psi_pat_write_args args) { - /* the number of bytes written by this function */ - u32 nbytes =3D 0; - const u16 pat_pid =3D VIDTV_PAT_PID; - u32 crc =3D INITIAL_CRC; - struct vidtv_psi_table_pat_program *p =3D args.pat->program; - struct header_write_args h_args =3D {}; - struct psi_write_args psi_args =3D {}; + struct psi_write_args psi_args =3D {}; struct crc32_write_args c_args =3D {}; + const u16 pat_pid =3D VIDTV_PAT_PID; + u32 crc =3D INITIAL_CRC; + u32 nbytes =3D 0; =20 vidtv_psi_pat_table_update_sec_len(args.pat); =20 @@ -1114,8 +1111,8 @@ vidtv_psi_pmt_stream_init(struct vidtv_psi_table_pmt_= stream *head, =20 void vidtv_psi_pmt_stream_destroy(struct vidtv_psi_table_pmt_stream *s) { - struct vidtv_psi_table_pmt_stream *curr_stream =3D s; struct vidtv_psi_table_pmt_stream *tmp_stream =3D NULL; + struct vidtv_psi_table_pmt_stream *curr_stream =3D s; =20 while (curr_stream) { tmp_stream =3D curr_stream; @@ -1166,11 +1163,11 @@ struct vidtv_psi_table_pmt *vidtv_psi_pmt_table_ini= t(u16 program_number, u16 pcr_pid) { struct vidtv_psi_table_pmt *pmt; - const u16 SYNTAX =3D 0x1; - const u16 ZERO =3D 0x0; - const u16 ONES =3D 0x03; const u16 RESERVED1 =3D 0x07; const u16 RESERVED2 =3D 0x0f; + const u16 SYNTAX =3D 0x1; + const u16 ONES =3D 0x03; + const u16 ZERO =3D 0x0; u16 desc_loop_len; =20 pmt =3D kzalloc(sizeof(*pmt), GFP_KERNEL); @@ -1208,18 +1205,15 @@ struct vidtv_psi_table_pmt *vidtv_psi_pmt_table_ini= t(u16 program_number, =20 u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args args) { - /* the number of bytes written by this function */ - u32 nbytes =3D 0; - u32 crc =3D INITIAL_CRC; - struct vidtv_psi_desc *table_descriptor =3D args.pmt->descriptor; struct vidtv_psi_table_pmt_stream *stream =3D args.pmt->stream; struct vidtv_psi_desc *stream_descriptor; - struct header_write_args h_args =3D {}; struct psi_write_args psi_args =3D {}; struct desc_write_args d_args =3D {}; struct crc32_write_args c_args =3D {}; + u32 crc =3D INITIAL_CRC; + u32 nbytes =3D 0; =20 vidtv_psi_pmt_table_update_sec_len(args.pmt); =20 @@ -1317,10 +1311,10 @@ void vidtv_psi_pmt_table_destroy(struct vidtv_psi_t= able_pmt *pmt) struct vidtv_psi_table_sdt *vidtv_psi_sdt_table_init(u16 transport_stream_= id) { struct vidtv_psi_table_sdt *sdt; - const u16 SYNTAX =3D 0x1; - const u16 ONE =3D 0x1; - const u16 ONES =3D 0x03; const u16 RESERVED =3D 0xff; + const u16 SYNTAX =3D 0x1; + const u16 ONES =3D 0x03; + const u16 ONE =3D 0x1; =20 sdt =3D kzalloc(sizeof(*sdt), GFP_KERNEL); if (!sdt) @@ -1360,18 +1354,17 @@ struct vidtv_psi_table_sdt *vidtv_psi_sdt_table_ini= t(u16 transport_stream_id) =20 u32 vidtv_psi_sdt_write_into(struct vidtv_psi_sdt_write_args args) { - u32 nbytes =3D 0; - u16 sdt_pid =3D VIDTV_SDT_PID; /* see ETSI EN 300 468 v1.15.1 p. 11 */ - - u32 crc =3D INITIAL_CRC; - struct vidtv_psi_table_sdt_service *service =3D args.sdt->service; struct vidtv_psi_desc *service_desc; - struct header_write_args h_args =3D {}; struct psi_write_args psi_args =3D {}; struct desc_write_args d_args =3D {}; struct crc32_write_args c_args =3D {}; + u16 sdt_pid =3D VIDTV_SDT_PID; + u32 nbytes =3D 0; + u32 crc =3D INITIAL_CRC; + + /* see ETSI EN 300 468 v1.15.1 p. 11 */ =20 vidtv_psi_sdt_table_update_sec_len(args.sdt); =20 @@ -1520,15 +1513,16 @@ vidtv_psi_sdt_service_assign(struct vidtv_psi_table= _sdt *sdt, vidtv_psi_update_version_num(&sdt->header); } =20 +/* + * PMTs contain information about programs. For each program, + * there is one PMT section. This function will create a section + * for each program found in the PAT + */ struct vidtv_psi_table_pmt** -vidtv_psi_pmt_create_sec_for_each_pat_entry(struct vidtv_psi_table_pat *pa= t, u16 pcr_pid) +vidtv_psi_pmt_create_sec_for_each_pat_entry(struct vidtv_psi_table_pat *pa= t, + u16 pcr_pid) =20 { - /* - * PMTs contain information about programs. For each program, - * there is one PMT section. This function will create a section - * for each program found in the PAT - */ struct vidtv_psi_table_pat_program *program =3D pat->program; struct vidtv_psi_table_pmt **pmt_secs; u32 i =3D 0; @@ -1549,12 +1543,12 @@ vidtv_psi_pmt_create_sec_for_each_pat_entry(struct = vidtv_psi_table_pat *pat, u16 return pmt_secs; } =20 +/* find the PMT section associated with 'program_num' */ struct vidtv_psi_table_pmt *vidtv_psi_find_pmt_sec(struct vidtv_psi_table_pmt **pmt_sections, u16 nsections, u16 program_num) { - /* find the PMT section associated with 'program_num' */ struct vidtv_psi_table_pmt *sec =3D NULL; u32 i; =20 @@ -1616,11 +1610,11 @@ struct vidtv_psi_table_nit char *network_name, struct vidtv_psi_desc_service_list_entry *service_list) { - struct vidtv_psi_table_nit *nit; struct vidtv_psi_table_transport *transport; + struct vidtv_psi_table_nit *nit; const u16 SYNTAX =3D 0x1; - const u16 ONE =3D 0x1; const u16 ONES =3D 0x03; + const u16 ONE =3D 0x1; =20 nit =3D kzalloc(sizeof(*nit), GFP_KERNEL); if (!nit) @@ -1677,18 +1671,15 @@ struct vidtv_psi_table_nit =20 u32 vidtv_psi_nit_write_into(struct vidtv_psi_nit_write_args args) { - /* the number of bytes written by this function */ - u32 nbytes =3D 0; - u32 crc =3D INITIAL_CRC; - struct vidtv_psi_desc *table_descriptor =3D args.nit->descriptor; struct vidtv_psi_table_transport *transport =3D args.nit->transport; struct vidtv_psi_desc *transport_descriptor; - struct header_write_args h_args =3D {}; struct psi_write_args psi_args =3D {}; struct desc_write_args d_args =3D {}; struct crc32_write_args c_args =3D {}; + u32 crc =3D INITIAL_CRC; + u32 nbytes =3D 0; =20 vidtv_psi_nit_table_update_sec_len(args.nit); =20 @@ -1786,8 +1777,8 @@ u32 vidtv_psi_nit_write_into(struct vidtv_psi_nit_wri= te_args args) =20 static void vidtv_psi_transport_destroy(struct vidtv_psi_table_transport *= t) { - struct vidtv_psi_table_transport *curr_t =3D t; struct vidtv_psi_table_transport *tmp_t =3D NULL; + struct vidtv_psi_table_transport *curr_t =3D t; =20 while (curr_t) { tmp_t =3D curr_t; @@ -1806,9 +1797,9 @@ void vidtv_psi_nit_table_destroy(struct vidtv_psi_tab= le_nit *nit) =20 void vidtv_psi_eit_table_update_sec_len(struct vidtv_psi_table_eit *eit) { - u16 length =3D 0; struct vidtv_psi_table_eit_event *e =3D eit->event; u16 desc_loop_len; + u16 length =3D 0; =20 /* * from immediately after 'section_length' until @@ -1890,16 +1881,14 @@ struct vidtv_psi_table_eit =20 u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args args) { - u32 nbytes =3D 0; - u32 crc =3D INITIAL_CRC; - struct vidtv_psi_table_eit_event *event =3D args.eit->event; struct vidtv_psi_desc *event_descriptor; - struct header_write_args h_args =3D {}; struct psi_write_args psi_args =3D {}; struct desc_write_args d_args =3D {}; struct crc32_write_args c_args =3D {}; + u32 crc =3D INITIAL_CRC; + u32 nbytes =3D 0; =20 vidtv_psi_eit_table_update_sec_len(args.eit); =20 @@ -1978,9 +1967,8 @@ u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_wri= te_args args) struct vidtv_psi_table_eit_event *vidtv_psi_eit_event_init(struct vidtv_psi_table_eit_event *head, u16 even= t_id) { - struct vidtv_psi_table_eit_event *e; const u8 DURATION_ONE_HOUR[] =3D {1, 0, 0}; - + struct vidtv_psi_table_eit_event *e; =20 e =3D kzalloc(sizeof(*e), GFP_KERNEL); if (!e) @@ -2004,8 +1992,8 @@ struct vidtv_psi_table_eit_event =20 void vidtv_psi_eit_event_destroy(struct vidtv_psi_table_eit_event *e) { - struct vidtv_psi_table_eit_event *curr_e =3D e; struct vidtv_psi_table_eit_event *tmp_e =3D NULL; + struct vidtv_psi_table_eit_event *curr_e =3D e; =20 while (curr_e) { tmp_e =3D curr_e; diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media= /test-drivers/vidtv/vidtv_s302m.c index 569e7a50129f..ce7dd6cafc8b 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c +++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c @@ -201,10 +201,10 @@ static void vidtv_s302m_alloc_au(struct vidtv_encoder= *e) static void vidtv_s302m_compute_sample_count_from_video(struct vidtv_encoder *e) { - struct vidtv_access_unit *au =3D e->access_units; struct vidtv_access_unit *sync_au =3D e->sync->access_units; - u32 vau_duration_usecs; + struct vidtv_access_unit *au =3D e->access_units; u32 sample_duration_usecs; + u32 vau_duration_usecs; u32 s; =20 vau_duration_usecs =3D USEC_PER_SEC / e->sync->sampling_rate_hz; @@ -290,9 +290,9 @@ static u16 vidtv_s302m_get_sample(struct vidtv_encoder = *e) static u32 vidtv_s302m_write_frame(struct vidtv_encoder *e, u16 sample) { - u32 nbytes =3D 0; + struct vidtv_s302m_ctx *ctx =3D e->ctx; struct vidtv_s302m_frame_16 f =3D {}; - struct vidtv_s302m_ctx *ctx =3D e->ctx; + u32 nbytes =3D 0; =20 /* from ffmpeg: see s302enc.c */ =20 @@ -389,6 +389,8 @@ static void vidtv_s302m_write_frames(struct vidtv_encod= er *e) =20 static void *vidtv_s302m_encode(struct vidtv_encoder *e) { + struct vidtv_s302m_ctx *ctx =3D e->ctx; + /* * According to SMPTE 302M, an audio access unit is specified as those * AES3 words that are associated with a corresponding video frame. @@ -402,8 +404,6 @@ static void *vidtv_s302m_encode(struct vidtv_encoder *e) * ffmpeg */ =20 - struct vidtv_s302m_ctx *ctx =3D e->ctx; - vidtv_s302m_access_unit_destroy(e); vidtv_s302m_alloc_au(e); =20 @@ -441,9 +441,9 @@ static u32 vidtv_s302m_clear(struct vidtv_encoder *e) struct vidtv_encoder *vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args) { - struct vidtv_encoder *e; u32 priv_sz =3D sizeof(struct vidtv_s302m_ctx); struct vidtv_s302m_ctx *ctx; + struct vidtv_encoder *e; =20 e =3D kzalloc(sizeof(*e), GFP_KERNEL); if (!e) --=20 2.28.0