Commit 5c82f449 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (6442): move std if setting from tda8290 to tda827x

Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Reviewed-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 1b29ceda
...@@ -38,10 +38,57 @@ struct tda827x_priv { ...@@ -38,10 +38,57 @@ struct tda827x_priv {
int i2c_addr; int i2c_addr;
struct i2c_adapter *i2c_adap; struct i2c_adapter *i2c_adap;
struct tda827x_config *cfg; struct tda827x_config *cfg;
unsigned int sgIF;
unsigned char lpsel;
u32 frequency; u32 frequency;
u32 bandwidth; u32 bandwidth;
}; };
static void tda827x_set_std(struct dvb_frontend *fe,
struct analog_parameters *params)
{
struct tda827x_priv *priv = fe->tuner_priv;
char *mode;
priv->lpsel = 0;
if (params->std & V4L2_STD_MN) {
priv->sgIF = 92;
priv->lpsel = 1;
mode = "MN";
} else if (params->std & V4L2_STD_B) {
priv->sgIF = 108;
mode = "B";
} else if (params->std & V4L2_STD_GH) {
priv->sgIF = 124;
mode = "GH";
} else if (params->std & V4L2_STD_PAL_I) {
priv->sgIF = 124;
mode = "I";
} else if (params->std & V4L2_STD_DK) {
priv->sgIF = 124;
mode = "DK";
} else if (params->std & V4L2_STD_SECAM_L) {
priv->sgIF = 124;
mode = "L";
} else if (params->std & V4L2_STD_SECAM_LC) {
priv->sgIF = 20;
mode = "LC";
} else {
priv->sgIF = 124;
mode = "xx";
}
if (params->mode == V4L2_TUNER_RADIO)
priv->sgIF = 88; /* if frequency is 5.5 MHz */
dprintk("setting tda827x to system %s\n", mode);
}
/* ------------------------------------------------------------------ */
struct tda827x_data { struct tda827x_data {
u32 lomax; u32 lomax;
u8 spd; u8 spd;
...@@ -189,10 +236,12 @@ static int tda827xo_set_analog_params(struct dvb_frontend *fe, ...@@ -189,10 +236,12 @@ static int tda827xo_set_analog_params(struct dvb_frontend *fe,
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0 }; struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0 };
unsigned int freq = params->frequency; unsigned int freq = params->frequency;
tda827x_set_std(fe, params);
if (params->mode == V4L2_TUNER_RADIO) if (params->mode == V4L2_TUNER_RADIO)
freq = freq / 1000; freq = freq / 1000;
N = freq + priv->cfg->sgIF; N = freq + priv->sgIF;
i = 0; i = 0;
while (tda827x_table[i].lomax < N * 62500) { while (tda827x_table[i].lomax < N * 62500) {
...@@ -207,7 +256,7 @@ static int tda827xo_set_analog_params(struct dvb_frontend *fe, ...@@ -207,7 +256,7 @@ static int tda827xo_set_analog_params(struct dvb_frontend *fe,
tuner_reg[1] = (unsigned char)(N>>8); tuner_reg[1] = (unsigned char)(N>>8);
tuner_reg[2] = (unsigned char) N; tuner_reg[2] = (unsigned char) N;
tuner_reg[3] = 0x40; tuner_reg[3] = 0x40;
tuner_reg[4] = 0x52 + (priv->cfg->tda827x_lpsel << 5); tuner_reg[4] = 0x52 + (priv->lpsel << 5);
tuner_reg[5] = (tda827x_table[i].spd << 6) + tuner_reg[5] = (tda827x_table[i].spd << 6) +
(tda827x_table[i].div1p5 << 5) + (tda827x_table[i].div1p5 << 5) +
(tda827x_table[i].bs << 3) + tda827x_table[i].bp; (tda827x_table[i].bs << 3) + tda827x_table[i].bp;
...@@ -550,13 +599,15 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe, ...@@ -550,13 +599,15 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe,
.buf = tuner_reg, .len = sizeof(tuner_reg) }; .buf = tuner_reg, .len = sizeof(tuner_reg) };
unsigned int freq = params->frequency; unsigned int freq = params->frequency;
tda827x_set_std(fe, params);
tda827xa_lna_gain(fe, 1, params); tda827xa_lna_gain(fe, 1, params);
msleep(10); msleep(10);
if (params->mode == V4L2_TUNER_RADIO) if (params->mode == V4L2_TUNER_RADIO)
freq = freq / 1000; freq = freq / 1000;
N = freq + priv->cfg->sgIF; N = freq + priv->sgIF;
i = 0; i = 0;
while (tda827xa_analog[i].lomax < N * 62500) { while (tda827xa_analog[i].lomax < N * 62500) {
...@@ -587,7 +638,7 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe, ...@@ -587,7 +638,7 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe,
tuner_reg[1] = 0xff; tuner_reg[1] = 0xff;
tuner_reg[2] = 0xe0; tuner_reg[2] = 0xe0;
tuner_reg[3] = 0; tuner_reg[3] = 0;
tuner_reg[4] = 0x99 + (priv->cfg->tda827x_lpsel << 1); tuner_reg[4] = 0x99 + (priv->lpsel << 1);
msg.len = 5; msg.len = 5;
i2c_transfer(priv->i2c_adap, &msg, 1); i2c_transfer(priv->i2c_adap, &msg, 1);
...@@ -627,7 +678,7 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe, ...@@ -627,7 +678,7 @@ static int tda827xa_set_analog_params(struct dvb_frontend *fe,
i2c_transfer(priv->i2c_adap, &msg, 1); i2c_transfer(priv->i2c_adap, &msg, 1);
tuner_reg[0] = 0xc0; tuner_reg[0] = 0xc0;
tuner_reg[1] = 0x19 + (priv->cfg->tda827x_lpsel << 1); tuner_reg[1] = 0x19 + (priv->lpsel << 1);
i2c_transfer(priv->i2c_adap, &msg, 1); i2c_transfer(priv->i2c_adap, &msg, 1);
priv->frequency = freq * 62500; priv->frequency = freq * 62500;
......
...@@ -35,9 +35,6 @@ struct tda827x_config ...@@ -35,9 +35,6 @@ struct tda827x_config
int (*sleep) (struct dvb_frontend *fe); int (*sleep) (struct dvb_frontend *fe);
/* interface to tda829x driver */ /* interface to tda829x driver */
unsigned char tda827x_lpsel;
unsigned int sgIF;
unsigned int *config; unsigned int *config;
int (*tuner_callback) (void *dev, int command, int arg); int (*tuner_callback) (void *dev, int command, int arg);
......
...@@ -104,45 +104,32 @@ static void set_audio(struct dvb_frontend *fe) ...@@ -104,45 +104,32 @@ static void set_audio(struct dvb_frontend *fe)
struct tuner *t = priv->t; struct tuner *t = priv->t;
char* mode; char* mode;
priv->cfg.tda827x_lpsel = 0;
if (t->std & V4L2_STD_MN) { if (t->std & V4L2_STD_MN) {
priv->cfg.sgIF = 92;
priv->tda8290_easy_mode = 0x01; priv->tda8290_easy_mode = 0x01;
priv->cfg.tda827x_lpsel = 1;
mode = "MN"; mode = "MN";
} else if (t->std & V4L2_STD_B) { } else if (t->std & V4L2_STD_B) {
priv->cfg.sgIF = 108;
priv->tda8290_easy_mode = 0x02; priv->tda8290_easy_mode = 0x02;
mode = "B"; mode = "B";
} else if (t->std & V4L2_STD_GH) { } else if (t->std & V4L2_STD_GH) {
priv->cfg.sgIF = 124;
priv->tda8290_easy_mode = 0x04; priv->tda8290_easy_mode = 0x04;
mode = "GH"; mode = "GH";
} else if (t->std & V4L2_STD_PAL_I) { } else if (t->std & V4L2_STD_PAL_I) {
priv->cfg.sgIF = 124;
priv->tda8290_easy_mode = 0x08; priv->tda8290_easy_mode = 0x08;
mode = "I"; mode = "I";
} else if (t->std & V4L2_STD_DK) { } else if (t->std & V4L2_STD_DK) {
priv->cfg.sgIF = 124;
priv->tda8290_easy_mode = 0x10; priv->tda8290_easy_mode = 0x10;
mode = "DK"; mode = "DK";
} else if (t->std & V4L2_STD_SECAM_L) { } else if (t->std & V4L2_STD_SECAM_L) {
priv->cfg.sgIF = 124;
priv->tda8290_easy_mode = 0x20; priv->tda8290_easy_mode = 0x20;
mode = "L"; mode = "L";
} else if (t->std & V4L2_STD_SECAM_LC) { } else if (t->std & V4L2_STD_SECAM_LC) {
priv->cfg.sgIF = 20;
priv->tda8290_easy_mode = 0x40; priv->tda8290_easy_mode = 0x40;
mode = "LC"; mode = "LC";
} else { } else {
priv->cfg.sgIF = 124;
priv->tda8290_easy_mode = 0x10; priv->tda8290_easy_mode = 0x10;
mode = "xx"; mode = "xx";
} }
if (t->mode == V4L2_TUNER_RADIO)
priv->cfg.sgIF = 88; /* if frequency is 5.5 MHz */
tuner_dbg("setting tda8290 to system %s\n", mode); tuner_dbg("setting tda8290 to system %s\n", mode);
} }
...@@ -368,7 +355,6 @@ static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq) ...@@ -368,7 +355,6 @@ static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq)
{ {
struct tda8290_priv *priv = fe->analog_demod_priv; struct tda8290_priv *priv = fe->analog_demod_priv;
struct tuner *t = priv->t; struct tuner *t = priv->t;
u16 ifc;
unsigned char blanking_mode[] = { 0x1d, 0x00 }; unsigned char blanking_mode[] = { 0x1d, 0x00 };
...@@ -381,9 +367,7 @@ static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq) ...@@ -381,9 +367,7 @@ static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq)
set_audio(fe); set_audio(fe);
ifc = priv->cfg.sgIF; /* FIXME */ tuner_dbg("%s: freq = %d\n", __FUNCTION__, freq);
tuner_dbg("%s: ifc = %u, freq = %d\n", __FUNCTION__, ifc, freq);
tda8295_power(fe, 1); tda8295_power(fe, 1);
tda8295_agc1_out(fe, 1); tda8295_agc1_out(fe, 1);
...@@ -625,7 +609,6 @@ int tda8290_attach(struct tuner *t) ...@@ -625,7 +609,6 @@ int tda8290_attach(struct tuner *t)
tuner_info("type set to %s\n", t->i2c.name); tuner_info("type set to %s\n", t->i2c.name);
priv->cfg.tda827x_lpsel = 0;
t->mode = V4L2_TUNER_ANALOG_TV; t->mode = V4L2_TUNER_ANALOG_TV;
tda8290_init_tuner(&t->fe); tda8290_init_tuner(&t->fe);
...@@ -715,7 +698,6 @@ int tda8295_attach(struct tuner *t) ...@@ -715,7 +698,6 @@ int tda8295_attach(struct tuner *t)
t->fe.ops.analog_demod_ops = &tda8295_tuner_ops; t->fe.ops.analog_demod_ops = &tda8295_tuner_ops;
priv->cfg.tda827x_lpsel = 0;
t->mode = V4L2_TUNER_ANALOG_TV; t->mode = V4L2_TUNER_ANALOG_TV;
tda8295_init_if(&t->fe); tda8295_init_if(&t->fe);
......
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