Skip to content

Commit

Permalink
V4L/DVB (6783): tuner: combine set_tv_freq and set_radio_freq into a …
Browse files Browse the repository at this point in the history
…single set_params method

We can tell whether we are tuning television or radio by testing for
struct analog_parameters *params->mode == V4L2_TUNER_RADIO

There is no longer any need for separate set_tv_freq and
set_radio_freq functions in the analog tuner demodulator modules.

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Michael Krufky authored and Mauro Carvalho Chehab committed Jan 25, 2008
1 parent 6881647 commit c7919d5
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 55 deletions.
53 changes: 20 additions & 33 deletions drivers/media/video/tda8290.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,31 +110,32 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close)

/*---------------------------------------------------------------------*/

static void set_audio(struct dvb_frontend *fe)
static void set_audio(struct dvb_frontend *fe,
struct analog_parameters *params)
{
struct tda8290_priv *priv = fe->analog_demod_priv;
struct tuner *t = priv->t;
char* mode;

if (t->std & V4L2_STD_MN) {
if (params->std & V4L2_STD_MN) {
priv->tda8290_easy_mode = 0x01;
mode = "MN";
} else if (t->std & V4L2_STD_B) {
} else if (params->std & V4L2_STD_B) {
priv->tda8290_easy_mode = 0x02;
mode = "B";
} else if (t->std & V4L2_STD_GH) {
} else if (params->std & V4L2_STD_GH) {
priv->tda8290_easy_mode = 0x04;
mode = "GH";
} else if (t->std & V4L2_STD_PAL_I) {
} else if (params->std & V4L2_STD_PAL_I) {
priv->tda8290_easy_mode = 0x08;
mode = "I";
} else if (t->std & V4L2_STD_DK) {
} else if (params->std & V4L2_STD_DK) {
priv->tda8290_easy_mode = 0x10;
mode = "DK";
} else if (t->std & V4L2_STD_SECAM_L) {
} else if (params->std & V4L2_STD_SECAM_L) {
priv->tda8290_easy_mode = 0x20;
mode = "L";
} else if (t->std & V4L2_STD_SECAM_LC) {
} else if (params->std & V4L2_STD_SECAM_LC) {
priv->tda8290_easy_mode = 0x40;
mode = "LC";
} else {
Expand All @@ -145,7 +146,8 @@ static void set_audio(struct dvb_frontend *fe)
tuner_dbg("setting tda829x to system %s\n", mode);
}

static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq)
static void tda8290_set_params(struct dvb_frontend *fe,
struct analog_parameters *params)
{
struct tda8290_priv *priv = fe->analog_demod_priv;
struct tuner *t = priv->t;
Expand All @@ -172,14 +174,7 @@ static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq)
pll_stat;
int i;

struct analog_parameters params = {
.frequency = freq,
.mode = t->mode,
.audmode = t->audmode,
.std = t->std
};

set_audio(fe);
set_audio(fe, params);

tuner_dbg("tda827xa config is 0x%02x\n", t->config);
tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2);
Expand All @@ -200,7 +195,7 @@ static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq)
tda8290_i2c_bridge(fe, 1);

if (fe->ops.tuner_ops.set_analog_params)
fe->ops.tuner_ops.set_analog_params(fe, &params);
fe->ops.tuner_ops.set_analog_params(fe, params);

for (i = 0; i < 3; i++) {
tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
Expand Down Expand Up @@ -363,23 +358,17 @@ static int tda8295_has_signal(struct dvb_frontend *fe)

/*---------------------------------------------------------------------*/

static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq)
static void tda8295_set_params(struct dvb_frontend *fe,
struct analog_parameters *params)
{
struct tda8290_priv *priv = fe->analog_demod_priv;
struct tuner *t = priv->t;

unsigned char blanking_mode[] = { 0x1d, 0x00 };

struct analog_parameters params = {
.frequency = freq,
.mode = t->mode,
.audmode = t->audmode,
.std = t->std
};

set_audio(fe);
set_audio(fe, params);

tuner_dbg("%s: freq = %d\n", __FUNCTION__, freq);
tuner_dbg("%s: freq = %d\n", __FUNCTION__, params->frequency);

tda8295_power(fe, 1);
tda8295_agc1_out(fe, 1);
Expand All @@ -396,7 +385,7 @@ static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq)
tda8295_i2c_bridge(fe, 1);

if (fe->ops.tuner_ops.set_analog_params)
fe->ops.tuner_ops.set_analog_params(fe, &params);
fe->ops.tuner_ops.set_analog_params(fe, params);

if (priv->cfg.agcf)
priv->cfg.agcf(fe);
Expand Down Expand Up @@ -673,17 +662,15 @@ static int tda8295_probe(struct tuner_i2c_props *i2c_props)
}

static struct analog_tuner_ops tda8290_tuner_ops = {
.set_tv_freq = tda8290_set_freq,
.set_radio_freq = tda8290_set_freq,
.set_params = tda8290_set_params,
.has_signal = tda8290_has_signal,
.standby = tda8290_standby,
.release = tda829x_release,
.i2c_gate_ctrl = tda8290_i2c_bridge,
};

static struct analog_tuner_ops tda8295_tuner_ops = {
.set_tv_freq = tda8295_set_freq,
.set_radio_freq = tda8295_set_freq,
.set_params = tda8295_set_params,
.has_signal = tda8295_has_signal,
.standby = tda8295_standby,
.release = tda829x_release,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/video/tda9887.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ static void tda9887_standby(struct dvb_frontend *fe)
tda9887_configure(fe);
}

static void tda9887_set_freq(struct dvb_frontend *fe, unsigned int freq)
static void tda9887_set_params(struct dvb_frontend *fe,
struct analog_parameters *params)
{
tda9887_configure(fe);
}
Expand All @@ -634,8 +635,7 @@ static void tda9887_release(struct dvb_frontend *fe)
}

static struct analog_tuner_ops tda9887_tuner_ops = {
.set_tv_freq = tda9887_set_freq,
.set_radio_freq = tda9887_set_freq,
.set_params = tda9887_set_params,
.standby = tda9887_standby,
.tuner_status = tda9887_tuner_status,
.get_afc = tda9887_get_afc,
Expand Down
41 changes: 24 additions & 17 deletions drivers/media/video/tuner-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,17 @@ MODULE_LICENSE("GPL");

/* ---------------------------------------------------------------------- */

static void fe_set_freq(struct dvb_frontend *fe, unsigned int freq)
static void fe_set_params(struct dvb_frontend *fe,
struct analog_parameters *params)
{
struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops;
struct tuner *t = fe->analog_demod_priv;

struct analog_parameters params = {
.frequency = freq,
.mode = t->mode,
.audmode = t->audmode,
.std = t->std
};

if (NULL == fe_tuner_ops->set_analog_params) {
tuner_warn("Tuner frontend module has no way to set freq\n");
return;
}
fe_tuner_ops->set_analog_params(fe, &params);
fe_tuner_ops->set_analog_params(fe, params);
}

static void fe_release(struct dvb_frontend *fe)
Expand Down Expand Up @@ -136,8 +130,7 @@ static int fe_has_signal(struct dvb_frontend *fe)
static void tuner_status(struct dvb_frontend *fe);

static struct analog_tuner_ops tuner_core_ops = {
.set_tv_freq = fe_set_freq,
.set_radio_freq = fe_set_freq,
.set_params = fe_set_params,
.standby = fe_standby,
.release = fe_release,
.has_signal = fe_has_signal,
Expand All @@ -150,11 +143,17 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
struct tuner *t = i2c_get_clientdata(c);
struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;

struct analog_parameters params = {
.mode = t->mode,
.audmode = t->audmode,
.std = t->std
};

if (t->type == UNSET) {
tuner_warn ("tuner type not set\n");
return;
}
if ((NULL == ops) || (NULL == ops->set_tv_freq)) {
if ((NULL == ops) || (NULL == ops->set_params)) {
tuner_warn ("Tuner has no way to set tv freq\n");
return;
}
Expand All @@ -169,19 +168,27 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
else
freq = tv_range[1] * 16;
}
ops->set_tv_freq(&t->fe, freq);
params.frequency = freq;

ops->set_params(&t->fe, &params);
}

static void set_radio_freq(struct i2c_client *c, unsigned int freq)
{
struct tuner *t = i2c_get_clientdata(c);
struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;

struct analog_parameters params = {
.mode = t->mode,
.audmode = t->audmode,
.std = t->std
};

if (t->type == UNSET) {
tuner_warn ("tuner type not set\n");
return;
}
if ((NULL == ops) || (NULL == ops->set_radio_freq)) {
if ((NULL == ops) || (NULL == ops->set_params)) {
tuner_warn ("tuner has no way to set radio frequency\n");
return;
}
Expand All @@ -196,8 +203,9 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
else
freq = radio_range[1] * 16000;
}
params.frequency = freq;

ops->set_radio_freq(&t->fe, freq);
ops->set_params(&t->fe, &params);
}

static void set_freq(struct i2c_client *c, unsigned long freq)
Expand Down Expand Up @@ -359,8 +367,7 @@ static void set_type(struct i2c_client *c, unsigned int type,

ops = t->fe.ops.analog_demod_ops;

if (((NULL == ops) ||
((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) &&
if (((NULL == ops) || (NULL == ops->set_params)) &&
(fe_tuner_ops->set_analog_params)) {
strlcpy(t->i2c->name, fe_tuner_ops->info.name,
sizeof(t->i2c->name));
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/tuner-driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ extern unsigned const int tuner_count;
struct tuner;

struct analog_tuner_ops {
void (*set_tv_freq)(struct dvb_frontend *fe, unsigned int freq);
void (*set_radio_freq)(struct dvb_frontend *fe, unsigned int freq);
void (*set_params)(struct dvb_frontend *fe,
struct analog_parameters *params);
int (*has_signal)(struct dvb_frontend *fe);
int (*is_stereo)(struct dvb_frontend *fe);
int (*get_afc)(struct dvb_frontend *fe);
Expand Down

0 comments on commit c7919d5

Please sign in to comment.