Commit a8bd461c authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: vidtv: do some cleanups at the driver

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: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 163d72a2
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
* validate the existing APIs in the media subsystem. It can also aid * validate the existing APIs in the media subsystem. It can also aid
* developers working on userspace applications. * developers working on userspace applications.
* *
* When this module is loaded, it will attempt to modprobe 'dvb_vidtv_tuner' and 'dvb_vidtv_demod'. * When this module is loaded, it will attempt to modprobe 'dvb_vidtv_tuner'
* and 'dvb_vidtv_demod'.
* *
* Copyright (C) 2020 Daniel W. S. Almeida * Copyright (C) 2020 Daniel W. S. Almeida
*/ */
...@@ -24,18 +25,21 @@ ...@@ -24,18 +25,21 @@
#include "vidtv_ts.h" #include "vidtv_ts.h"
#include "vidtv_tuner.h" #include "vidtv_tuner.h"
//#define MUX_BUF_MAX_SZ #define MUX_BUF_MIN_SZ 90164
//#define MUX_BUF_MIN_SZ #define MUX_BUF_MAX_SZ (MUX_BUF_MIN_SZ * 10)
#define TUNER_DEFAULT_ADDR 0x68 #define TUNER_DEFAULT_ADDR 0x68
#define DEMOD_DEFAULT_ADDR 0x60 #define DEMOD_DEFAULT_ADDR 0x60
#define VIDTV_DEFAULT_NETWORK_ID 0x744 #define VIDTV_DEFAULT_NETWORK_ID 0x744
#define VIDTV_DEFAULT_NETWORK_NAME "LinuxTV.org" #define VIDTV_DEFAULT_NETWORK_NAME "LinuxTV.org"
/* LNBf fake parameters: ranges used by an Universal (extended) European LNBf */ /*
#define LNB_CUT_FREQUENCY 11700000 * The LNBf fake parameters here are the ranges used by an
#define LNB_LOW_FREQ 9750000 * Universal (extended) European LNBf, which is likely the most common LNBf
#define LNB_HIGH_FREQ 10600000 * 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 */
static unsigned int drop_tslock_prob_on_low_snr; static unsigned int drop_tslock_prob_on_low_snr;
module_param(drop_tslock_prob_on_low_snr, uint, 0); 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 packets. Default: 40ms"); ...@@ -94,7 +98,8 @@ MODULE_PARM_DESC(si_period_msec, "How often to send SI packets. Default: 40ms");
static unsigned int pcr_period_msec = 40; static unsigned int pcr_period_msec = 40;
module_param(pcr_period_msec, uint, 0); 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");
static unsigned int mux_rate_kbytes_sec = 4096; static unsigned int mux_rate_kbytes_sec = 4096;
module_param(mux_rate_kbytes_sec, uint, 0); 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"); ...@@ -106,16 +111,14 @@ MODULE_PARM_DESC(pcr_pid, "PCR PID for all channels: defaults to 0x200");
static unsigned int mux_buf_sz_pkts; static unsigned int mux_buf_sz_pkts;
module_param(mux_buf_sz_pkts, uint, 0); module_param(mux_buf_sz_pkts, uint, 0);
MODULE_PARM_DESC(mux_buf_sz_pkts, "Size for the internal mux buffer in multiples of 188 bytes"); MODULE_PARM_DESC(mux_buf_sz_pkts,
"Size for the internal mux buffer in multiples of 188 bytes");
#define MUX_BUF_MIN_SZ 90164
#define MUX_BUF_MAX_SZ (MUX_BUF_MIN_SZ * 10)
static u32 vidtv_bridge_mux_buf_sz_for_mux_rate(void) static u32 vidtv_bridge_mux_buf_sz_for_mux_rate(void)
{ {
u32 max_elapsed_time_msecs = VIDTV_MAX_SLEEP_USECS / USEC_PER_MSEC; u32 max_elapsed_time_msecs = VIDTV_MAX_SLEEP_USECS / USEC_PER_MSEC;
u32 nbytes_expected;
u32 mux_buf_sz = mux_buf_sz_pkts * TS_PACKET_LEN; u32 mux_buf_sz = mux_buf_sz_pkts * TS_PACKET_LEN;
u32 nbytes_expected;
nbytes_expected = mux_rate_kbytes_sec; nbytes_expected = mux_rate_kbytes_sec;
nbytes_expected *= max_elapsed_time_msecs; nbytes_expected *= max_elapsed_time_msecs;
...@@ -145,14 +148,12 @@ static bool vidtv_bridge_check_demod_lock(struct vidtv_dvb *dvb, u32 n) ...@@ -145,14 +148,12 @@ static bool vidtv_bridge_check_demod_lock(struct vidtv_dvb *dvb, u32 n)
FE_HAS_LOCK); FE_HAS_LOCK);
} }
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
{
/*
* called on a separate thread by the mux when new packets become
* available
*/ */
struct vidtv_dvb *dvb = (struct vidtv_dvb *)priv; static void vidtv_bridge_on_new_pkts_avail(void *priv, u8 *buf, u32 npkts)
{
struct vidtv_dvb *dvb = priv;
/* drop packets if we lose the lock */ /* drop packets if we lose the lock */
if (vidtv_bridge_check_demod_lock(dvb, 0)) if (vidtv_bridge_check_demod_lock(dvb, 0))
...@@ -180,8 +181,10 @@ static int vidtv_start_streaming(struct vidtv_dvb *dvb) ...@@ -180,8 +181,10 @@ static int vidtv_start_streaming(struct vidtv_dvb *dvb)
return 0; return 0;
} }
mux_buf_sz = (mux_buf_sz_pkts) ? mux_buf_sz_pkts : if (mux_buf_sz_pkts)
vidtv_bridge_mux_buf_sz_for_mux_rate(); mux_buf_sz = mux_buf_sz_pkts;
else
mux_buf_sz = vidtv_bridge_mux_buf_sz_for_mux_rate();
mux_args.mux_buf_sz = mux_buf_sz; mux_args.mux_buf_sz = mux_buf_sz;
...@@ -212,8 +215,8 @@ static int vidtv_start_feed(struct dvb_demux_feed *feed) ...@@ -212,8 +215,8 @@ static int vidtv_start_feed(struct dvb_demux_feed *feed)
{ {
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
struct vidtv_dvb *dvb = demux->priv; struct vidtv_dvb *dvb = demux->priv;
int rc;
int ret; int ret;
int rc;
if (!demux->dmx.frontend) if (!demux->dmx.frontend)
return -EINVAL; return -EINVAL;
...@@ -251,9 +254,9 @@ static int vidtv_stop_feed(struct dvb_demux_feed *feed) ...@@ -251,9 +254,9 @@ static int vidtv_stop_feed(struct dvb_demux_feed *feed)
static struct dvb_frontend *vidtv_get_frontend_ptr(struct i2c_client *c) 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 = i2c_get_clientdata(c); struct vidtv_demod_state *state = i2c_get_clientdata(c);
/* the demod will set this when its probe function runs */
return &state->frontend; return &state->frontend;
} }
...@@ -261,6 +264,11 @@ static int vidtv_master_xfer(struct i2c_adapter *i2c_adap, ...@@ -261,6 +264,11 @@ static int vidtv_master_xfer(struct i2c_adapter *i2c_adap,
struct i2c_msg msgs[], struct i2c_msg msgs[],
int num) 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; return 0;
} }
...@@ -328,11 +336,10 @@ static int vidtv_bridge_dmxdev_init(struct vidtv_dvb *dvb) ...@@ -328,11 +336,10 @@ static int vidtv_bridge_dmxdev_init(struct vidtv_dvb *dvb)
static int vidtv_bridge_probe_demod(struct vidtv_dvb *dvb, u32 n) static int vidtv_bridge_probe_demod(struct vidtv_dvb *dvb, u32 n)
{ {
struct vidtv_demod_config cfg = {}; struct vidtv_demod_config cfg = {
.drop_tslock_prob_on_low_snr = drop_tslock_prob_on_low_snr,
cfg.drop_tslock_prob_on_low_snr = drop_tslock_prob_on_low_snr; .recover_tslock_prob_on_good_snr = recover_tslock_prob_on_good_snr,
cfg.recover_tslock_prob_on_good_snr = recover_tslock_prob_on_good_snr; };
dvb->i2c_client_demod[n] = dvb_module_probe("dvb_vidtv_demod", dvb->i2c_client_demod[n] = dvb_module_probe("dvb_vidtv_demod",
NULL, NULL,
&dvb->i2c_adapter, &dvb->i2c_adapter,
...@@ -351,14 +358,14 @@ static int vidtv_bridge_probe_demod(struct vidtv_dvb *dvb, u32 n) ...@@ -351,14 +358,14 @@ static int vidtv_bridge_probe_demod(struct vidtv_dvb *dvb, u32 n)
static int vidtv_bridge_probe_tuner(struct vidtv_dvb *dvb, u32 n) static int vidtv_bridge_probe_tuner(struct vidtv_dvb *dvb, u32 n)
{ {
struct vidtv_tuner_config cfg = {}; struct vidtv_tuner_config cfg = {
.fe = dvb->fe[n],
.mock_power_up_delay_msec = mock_power_up_delay_msec,
.mock_tune_delay_msec = mock_tune_delay_msec,
};
u32 freq; u32 freq;
int i; int i;
cfg.fe = dvb->fe[n];
cfg.mock_power_up_delay_msec = mock_power_up_delay_msec;
cfg.mock_tune_delay_msec = mock_tune_delay_msec;
/* TODO: check if the frequencies are at a valid range */ /* TODO: check if the frequencies are at a valid range */
memcpy(cfg.vidtv_valid_dvb_t_freqs, memcpy(cfg.vidtv_valid_dvb_t_freqs,
...@@ -397,9 +404,7 @@ static int vidtv_bridge_probe_tuner(struct vidtv_dvb *dvb, u32 n) ...@@ -397,9 +404,7 @@ static int vidtv_bridge_probe_tuner(struct vidtv_dvb *dvb, u32 n)
static int vidtv_bridge_dvb_init(struct vidtv_dvb *dvb) static int vidtv_bridge_dvb_init(struct vidtv_dvb *dvb)
{ {
int ret; int ret, i, j;
int i;
int j;
ret = vidtv_bridge_i2c_register_adap(dvb); ret = vidtv_bridge_i2c_register_adap(dvb);
if (ret < 0) if (ret < 0)
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
static void vidtv_channel_encoder_destroy(struct vidtv_encoder *e) static void vidtv_channel_encoder_destroy(struct vidtv_encoder *e)
{ {
struct vidtv_encoder *curr = e;
struct vidtv_encoder *tmp = NULL; struct vidtv_encoder *tmp = NULL;
struct vidtv_encoder *curr = e;
while (curr) { while (curr) {
/* forward the call to the derived type */ /* forward the call to the derived type */
...@@ -46,25 +46,25 @@ static void vidtv_channel_encoder_destroy(struct vidtv_encoder *e) ...@@ -46,25 +46,25 @@ static void vidtv_channel_encoder_destroy(struct vidtv_encoder *e)
#define ENCODING_ISO8859_15 "\x0b" #define ENCODING_ISO8859_15 "\x0b"
/*
* init an audio only channel with a s302m encoder
*/
struct vidtv_channel struct vidtv_channel
*vidtv_channel_s302m_init(struct vidtv_channel *head, u16 transport_stream_id) *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 = 0x880;
const u16 s302m_program_num = 0x880;
const u16 s302m_program_pid = 0x101; /* packet id for PMT*/
const u16 s302m_es_pid = 0x111; /* packet id for the ES */
const __be32 s302m_fid = cpu_to_be32(VIDTV_S302M_FORMAT_IDENTIFIER); const __be32 s302m_fid = cpu_to_be32(VIDTV_S302M_FORMAT_IDENTIFIER);
char *name = ENCODING_ISO8859_15 "Beethoven";
char *provider = ENCODING_ISO8859_15 "LinuxTV.org";
char *iso_language_code = ENCODING_ISO8859_15 "eng";
char *event_name = ENCODING_ISO8859_15 "Beethoven Music";
char *event_text = ENCODING_ISO8859_15 "Beethoven's Für Elise"; char *event_text = ENCODING_ISO8859_15 "Beethoven's Für Elise";
char *event_name = ENCODING_ISO8859_15 "Beethoven Music";
struct vidtv_s302m_encoder_init_args encoder_args = {};
char *iso_language_code = ENCODING_ISO8859_15 "eng";
char *provider = ENCODING_ISO8859_15 "LinuxTV.org";
char *name = ENCODING_ISO8859_15 "Beethoven";
const u16 s302m_es_pid = 0x111; /* packet id for the ES */
const u16 s302m_program_pid = 0x101; /* packet id for PMT*/
const u16 s302m_service_id = 0x880;
const u16 s302m_program_num = 0x880;
const u16 s302m_beethoven_event_id = 1; const u16 s302m_beethoven_event_id = 1;
struct vidtv_channel *s302m; struct vidtv_channel *s302m;
struct vidtv_s302m_encoder_init_args encoder_args = {};
s302m = kzalloc(sizeof(*s302m), GFP_KERNEL); s302m = kzalloc(sizeof(*s302m), GFP_KERNEL);
if (!s302m) if (!s302m)
...@@ -159,11 +159,9 @@ static struct vidtv_psi_table_eit_event ...@@ -159,11 +159,9 @@ static struct vidtv_psi_table_eit_event
{ {
/* Concatenate the events */ /* Concatenate the events */
const struct vidtv_channel *cur_chnl = m->channels; const struct vidtv_channel *cur_chnl = m->channels;
struct vidtv_psi_table_eit_event *curr = NULL; struct vidtv_psi_table_eit_event *curr = NULL;
struct vidtv_psi_table_eit_event *head = NULL; struct vidtv_psi_table_eit_event *head = NULL;
struct vidtv_psi_table_eit_event *tail = NULL; struct vidtv_psi_table_eit_event *tail = NULL;
struct vidtv_psi_desc *desc = NULL; struct vidtv_psi_desc *desc = NULL;
u16 event_id; u16 event_id;
...@@ -175,7 +173,8 @@ static struct vidtv_psi_table_eit_event ...@@ -175,7 +173,8 @@ static struct vidtv_psi_table_eit_event
if (!curr) if (!curr)
dev_warn_ratelimited(m->dev, 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);
while (curr) { while (curr) {
event_id = be16_to_cpu(curr->event_id); event_id = be16_to_cpu(curr->event_id);
...@@ -221,7 +220,8 @@ static struct vidtv_psi_table_sdt_service ...@@ -221,7 +220,8 @@ static struct vidtv_psi_table_sdt_service
if (!curr) if (!curr)
dev_warn_ratelimited(m->dev, 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);
while (curr) { while (curr) {
service_id = be16_to_cpu(curr->service_id); service_id = be16_to_cpu(curr->service_id);
...@@ -300,26 +300,24 @@ vidtv_channel_pat_prog_cat_into_new(struct vidtv_mux *m) ...@@ -300,26 +300,24 @@ vidtv_channel_pat_prog_cat_into_new(struct vidtv_mux *m)
return head; return head;
} }
/*
* Match channels to their respective PMT sections, then assign the
* streams
*/
static void static void
vidtv_channel_pmt_match_sections(struct vidtv_channel *channels, vidtv_channel_pmt_match_sections(struct vidtv_channel *channels,
struct vidtv_psi_table_pmt **sections, struct vidtv_psi_table_pmt **sections,
u32 nsections) u32 nsections)
{ {
/*
* Match channels to their respective PMT sections, then assign the
* streams
*/
struct vidtv_psi_table_pmt *curr_section = NULL; struct vidtv_psi_table_pmt *curr_section = NULL;
struct vidtv_channel *cur_chnl = channels;
struct vidtv_psi_table_pmt_stream *s = NULL;
struct vidtv_psi_table_pmt_stream *head = NULL; struct vidtv_psi_table_pmt_stream *head = NULL;
struct vidtv_psi_table_pmt_stream *tail = NULL; struct vidtv_psi_table_pmt_stream *tail = NULL;
struct vidtv_psi_table_pmt_stream *s = NULL;
struct vidtv_channel *cur_chnl = channels;
struct vidtv_psi_desc *desc = NULL; struct vidtv_psi_desc *desc = NULL;
u32 j;
u16 curr_id;
u16 e_pid; /* elementary stream pid */ u16 e_pid; /* elementary stream pid */
u16 curr_id;
u32 j;
while (cur_chnl) { while (cur_chnl) {
for (j = 0; j < nsections; ++j) { for (j = 0; j < nsections; ++j) {
...@@ -345,7 +343,8 @@ vidtv_channel_pmt_match_sections(struct vidtv_channel *channels, ...@@ -345,7 +343,8 @@ vidtv_channel_pmt_match_sections(struct vidtv_channel *channels,
head = tail; head = tail;
desc = vidtv_psi_desc_clone(s->descriptor); desc = vidtv_psi_desc_clone(s->descriptor);
vidtv_psi_desc_assign(&tail->descriptor, desc); vidtv_psi_desc_assign(&tail->descriptor,
desc);
s = s->next; s = s->next;
} }
...@@ -359,7 +358,8 @@ vidtv_channel_pmt_match_sections(struct vidtv_channel *channels, ...@@ -359,7 +358,8 @@ vidtv_channel_pmt_match_sections(struct vidtv_channel *channels,
} }
} }
static void vidtv_channel_destroy_service_list(struct vidtv_psi_desc_service_list_entry *e) static void
vidtv_channel_destroy_service_list(struct vidtv_psi_desc_service_list_entry *e)
{ {
struct vidtv_psi_desc_service_list_entry *tmp; struct vidtv_psi_desc_service_list_entry *tmp;
...@@ -412,9 +412,9 @@ static struct vidtv_psi_desc_service_list_entry ...@@ -412,9 +412,9 @@ static struct vidtv_psi_desc_service_list_entry
int vidtv_channel_si_init(struct vidtv_mux *m) int vidtv_channel_si_init(struct vidtv_mux *m)
{ {
struct vidtv_psi_desc_service_list_entry *service_list = NULL;
struct vidtv_psi_table_pat_program *programs = NULL; struct vidtv_psi_table_pat_program *programs = NULL;
struct vidtv_psi_table_sdt_service *services = NULL; struct vidtv_psi_table_sdt_service *services = NULL;
struct vidtv_psi_desc_service_list_entry *service_list = NULL;
struct vidtv_psi_table_eit_event *events = NULL; struct vidtv_psi_table_eit_event *events = NULL;
m->si.pat = vidtv_psi_pat_table_init(m->transport_stream_id); m->si.pat = vidtv_psi_pat_table_init(m->transport_stream_id);
...@@ -449,11 +449,11 @@ int vidtv_channel_si_init(struct vidtv_mux *m) ...@@ -449,11 +449,11 @@ int vidtv_channel_si_init(struct vidtv_mux *m)
if (!m->si.nit) if (!m->si.nit)
goto free_service_list; goto free_service_list;
m->si.eit = vidtv_psi_eit_table_init(m->network_id, m->transport_stream_id); m->si.eit = vidtv_psi_eit_table_init(m->network_id,
m->transport_stream_id);
if (!m->si.eit) if (!m->si.eit)
goto free_nit; goto free_nit;
/* assemble all programs and assign to PAT */ /* assemble all programs and assign to PAT */
vidtv_psi_pat_program_assign(m->si.pat, programs); vidtv_psi_pat_program_assign(m->si.pat, programs);
...@@ -463,7 +463,8 @@ int vidtv_channel_si_init(struct vidtv_mux *m) ...@@ -463,7 +463,8 @@ int vidtv_channel_si_init(struct vidtv_mux *m)
/* assemble all events and assign to EIT */ /* assemble all events and assign to EIT */
vidtv_psi_eit_event_assign(m->si.eit, events); vidtv_psi_eit_event_assign(m->si.eit, events);
m->si.pmt_secs = vidtv_psi_pmt_create_sec_for_each_pat_entry(m->si.pat, m->pcr_pid); m->si.pmt_secs = vidtv_psi_pmt_create_sec_for_each_pat_entry(m->si.pat,
m->pcr_pid);
if (!m->si.pmt_secs) if (!m->si.pmt_secs)
goto free_eit; goto free_eit;
...@@ -496,8 +497,8 @@ int vidtv_channel_si_init(struct vidtv_mux *m) ...@@ -496,8 +497,8 @@ int vidtv_channel_si_init(struct vidtv_mux *m)
void vidtv_channel_si_destroy(struct vidtv_mux *m) void vidtv_channel_si_destroy(struct vidtv_mux *m)
{ {
u32 i;
u16 num_programs = m->si.pat->programs; u16 num_programs = m->si.pat->programs;
u32 i;
vidtv_psi_pat_table_destroy(m->si.pat); vidtv_psi_pat_table_destroy(m->si.pat);
......
...@@ -193,7 +193,6 @@ static void vidtv_demod_update_stats(struct dvb_frontend *fe) ...@@ -193,7 +193,6 @@ static void vidtv_demod_update_stats(struct dvb_frontend *fe)
c->cnr.stat[0].svalue = state->tuner_cnr; c->cnr.stat[0].svalue = state->tuner_cnr;
c->cnr.stat[0].svalue -= prandom_u32_max(state->tuner_cnr / 50); c->cnr.stat[0].svalue -= prandom_u32_max(state->tuner_cnr / 50);
} }
static int vidtv_demod_read_status(struct dvb_frontend *fe, static int vidtv_demod_read_status(struct dvb_frontend *fe,
......
...@@ -28,7 +28,7 @@ struct vidtv_access_unit { ...@@ -28,7 +28,7 @@ struct vidtv_access_unit {
struct vidtv_access_unit *next; struct vidtv_access_unit *next;
}; };
/* Some musical notes, used by a tone generator */ /* Some musical notes, used by a tone generator. Values are in Hz */
enum musical_notes { enum musical_notes {
NOTE_SILENT = 0, NOTE_SILENT = 0,
......
...@@ -63,9 +63,9 @@ static struct vidtv_mux_pid_ctx ...@@ -63,9 +63,9 @@ static struct vidtv_mux_pid_ctx
static void vidtv_mux_pid_ctx_destroy(struct vidtv_mux *m) static void vidtv_mux_pid_ctx_destroy(struct vidtv_mux *m)
{ {
int bkt;
struct vidtv_mux_pid_ctx *ctx; struct vidtv_mux_pid_ctx *ctx;
struct hlist_node *tmp; struct hlist_node *tmp;
int bkt;
hash_for_each_safe(m->pid_ctx, bkt, tmp, ctx, h) { hash_for_each_safe(m->pid_ctx, bkt, tmp, ctx, h) {
hash_del(&ctx->h); hash_del(&ctx->h);
...@@ -129,21 +129,18 @@ static void vidtv_mux_update_clk(struct vidtv_mux *m) ...@@ -129,21 +129,18 @@ static void vidtv_mux_update_clk(struct vidtv_mux *m)
static u32 vidtv_mux_push_si(struct vidtv_mux *m) static u32 vidtv_mux_push_si(struct vidtv_mux *m)
{ {
struct vidtv_psi_pat_write_args pat_args = {};
struct vidtv_psi_pmt_write_args pmt_args = {};
struct vidtv_psi_sdt_write_args sdt_args = {};
struct vidtv_psi_nit_write_args nit_args = {};
struct vidtv_psi_eit_write_args eit_args = {};
u32 initial_offset = m->mux_buf_offset; u32 initial_offset = m->mux_buf_offset;
struct vidtv_mux_pid_ctx *pat_ctx; struct vidtv_mux_pid_ctx *pat_ctx;
struct vidtv_mux_pid_ctx *pmt_ctx; struct vidtv_mux_pid_ctx *pmt_ctx;
struct vidtv_mux_pid_ctx *sdt_ctx; struct vidtv_mux_pid_ctx *sdt_ctx;
struct vidtv_mux_pid_ctx *nit_ctx; struct vidtv_mux_pid_ctx *nit_ctx;
struct vidtv_mux_pid_ctx *eit_ctx; struct vidtv_mux_pid_ctx *eit_ctx;
u32 nbytes;
struct vidtv_psi_pat_write_args pat_args = {};
struct vidtv_psi_pmt_write_args pmt_args = {};
struct vidtv_psi_sdt_write_args sdt_args = {};
struct vidtv_psi_nit_write_args nit_args = {};
struct vidtv_psi_eit_write_args eit_args = {};
u32 nbytes; /* the number of bytes written by this function */
u16 pmt_pid; u16 pmt_pid;
u32 i; u32 i;
...@@ -269,7 +266,6 @@ static bool vidtv_mux_should_push_si(struct vidtv_mux *m) ...@@ -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, static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m,
struct vidtv_encoder *e) struct vidtv_encoder *e)
{ {
u32 nbytes = 0;
struct pes_write_args args = { struct pes_write_args args = {
.dest_buf = m->mux_buf, .dest_buf = m->mux_buf,
.dest_buf_sz = m->mux_buf_sz, .dest_buf_sz = m->mux_buf_sz,
...@@ -279,10 +275,11 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m, ...@@ -279,10 +275,11 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m,
.send_pts = true, /* forbidden value '01'... */ .send_pts = true, /* forbidden value '01'... */
.send_dts = false, /* ...for PTS_DTS flags */ .send_dts = false, /* ...for PTS_DTS flags */
}; };
u32 initial_offset = m->mux_buf_offset;
struct vidtv_access_unit *au = e->access_units; struct vidtv_access_unit *au = e->access_units;
u8 *buf = NULL; u32 initial_offset = m->mux_buf_offset;
struct vidtv_mux_pid_ctx *pid_ctx; struct vidtv_mux_pid_ctx *pid_ctx;
u32 nbytes = 0;
u8 *buf = NULL;
/* see SMPTE 302M clause 6.4 */ /* see SMPTE 302M clause 6.4 */
if (args.encoder_id == S302M) { if (args.encoder_id == S302M) {
...@@ -318,10 +315,10 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m, ...@@ -318,10 +315,10 @@ static u32 vidtv_mux_packetize_access_units(struct vidtv_mux *m,
static u32 vidtv_mux_poll_encoders(struct vidtv_mux *m) static u32 vidtv_mux_poll_encoders(struct vidtv_mux *m)
{ {
u32 nbytes = 0;
u32 au_nbytes;
struct vidtv_channel *cur_chnl = m->channels; struct vidtv_channel *cur_chnl = m->channels;
struct vidtv_encoder *e = NULL; struct vidtv_encoder *e = NULL;
u32 nbytes = 0;
u32 au_nbytes;
while (cur_chnl) { while (cur_chnl) {
e = cur_chnl->encoders; e = cur_chnl->encoders;
...@@ -347,9 +344,9 @@ static u32 vidtv_mux_pad_with_nulls(struct vidtv_mux *m, u32 npkts) ...@@ -347,9 +344,9 @@ static u32 vidtv_mux_pad_with_nulls(struct vidtv_mux *m, u32 npkts)
{ {
struct null_packet_write_args args = {}; struct null_packet_write_args args = {};
u32 initial_offset = m->mux_buf_offset; u32 initial_offset = m->mux_buf_offset;
u32 nbytes; /* the number of bytes written by this function */
u32 i;
struct vidtv_mux_pid_ctx *ctx; struct vidtv_mux_pid_ctx *ctx;
u32 nbytes;
u32 i;
ctx = vidtv_mux_get_pid_ctx(m, TS_NULL_PACKET_PID); ctx = vidtv_mux_get_pid_ctx(m, TS_NULL_PACKET_PID);
...@@ -388,9 +385,9 @@ static void vidtv_mux_tick(struct work_struct *work) ...@@ -388,9 +385,9 @@ static void vidtv_mux_tick(struct work_struct *work)
struct vidtv_mux, struct vidtv_mux,
mpeg_thread); mpeg_thread);
struct dtv_frontend_properties *c = &m->fe->dtv_property_cache; struct dtv_frontend_properties *c = &m->fe->dtv_property_cache;
u32 tot_bits = 0;
u32 nbytes; u32 nbytes;
u32 npkts; u32 npkts;
u32 tot_bits = 0;
while (m->streaming) { while (m->streaming) {
nbytes = 0; nbytes = 0;
......
...@@ -201,10 +201,10 @@ static void vidtv_s302m_alloc_au(struct vidtv_encoder *e) ...@@ -201,10 +201,10 @@ static void vidtv_s302m_alloc_au(struct vidtv_encoder *e)
static void static void
vidtv_s302m_compute_sample_count_from_video(struct vidtv_encoder *e) vidtv_s302m_compute_sample_count_from_video(struct vidtv_encoder *e)
{ {
struct vidtv_access_unit *au = e->access_units;
struct vidtv_access_unit *sync_au = e->sync->access_units; struct vidtv_access_unit *sync_au = e->sync->access_units;
u32 vau_duration_usecs; struct vidtv_access_unit *au = e->access_units;
u32 sample_duration_usecs; u32 sample_duration_usecs;
u32 vau_duration_usecs;
u32 s; u32 s;
vau_duration_usecs = USEC_PER_SEC / e->sync->sampling_rate_hz; vau_duration_usecs = USEC_PER_SEC / e->sync->sampling_rate_hz;
...@@ -290,9 +290,9 @@ static u16 vidtv_s302m_get_sample(struct vidtv_encoder *e) ...@@ -290,9 +290,9 @@ static u16 vidtv_s302m_get_sample(struct vidtv_encoder *e)
static u32 vidtv_s302m_write_frame(struct vidtv_encoder *e, static u32 vidtv_s302m_write_frame(struct vidtv_encoder *e,
u16 sample) u16 sample)
{ {
u32 nbytes = 0;
struct vidtv_s302m_frame_16 f = {};
struct vidtv_s302m_ctx *ctx = e->ctx; struct vidtv_s302m_ctx *ctx = e->ctx;
struct vidtv_s302m_frame_16 f = {};
u32 nbytes = 0;
/* from ffmpeg: see s302enc.c */ /* from ffmpeg: see s302enc.c */
...@@ -389,6 +389,8 @@ static void vidtv_s302m_write_frames(struct vidtv_encoder *e) ...@@ -389,6 +389,8 @@ static void vidtv_s302m_write_frames(struct vidtv_encoder *e)
static void *vidtv_s302m_encode(struct vidtv_encoder *e) static void *vidtv_s302m_encode(struct vidtv_encoder *e)
{ {
struct vidtv_s302m_ctx *ctx = e->ctx;
/* /*
* According to SMPTE 302M, an audio access unit is specified as those * According to SMPTE 302M, an audio access unit is specified as those
* AES3 words that are associated with a corresponding video frame. * AES3 words that are associated with a corresponding video frame.
...@@ -402,8 +404,6 @@ static void *vidtv_s302m_encode(struct vidtv_encoder *e) ...@@ -402,8 +404,6 @@ static void *vidtv_s302m_encode(struct vidtv_encoder *e)
* ffmpeg * ffmpeg
*/ */
struct vidtv_s302m_ctx *ctx = e->ctx;
vidtv_s302m_access_unit_destroy(e); vidtv_s302m_access_unit_destroy(e);
vidtv_s302m_alloc_au(e); vidtv_s302m_alloc_au(e);
...@@ -441,9 +441,9 @@ static u32 vidtv_s302m_clear(struct vidtv_encoder *e) ...@@ -441,9 +441,9 @@ static u32 vidtv_s302m_clear(struct vidtv_encoder *e)
struct vidtv_encoder struct vidtv_encoder
*vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args) *vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args)
{ {
struct vidtv_encoder *e;
u32 priv_sz = sizeof(struct vidtv_s302m_ctx); u32 priv_sz = sizeof(struct vidtv_s302m_ctx);
struct vidtv_s302m_ctx *ctx; struct vidtv_s302m_ctx *ctx;
struct vidtv_encoder *e;
e = kzalloc(sizeof(*e), GFP_KERNEL); e = kzalloc(sizeof(*e), GFP_KERNEL);
if (!e) if (!e)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment