summaryrefslogtreecommitdiff
path: root/drivers/media/tuners/tda8290.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/tuners/tda8290.c')
-rw-r--r--drivers/media/tuners/tda8290.c75
1 files changed, 46 insertions, 29 deletions
diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index 8c4852114eeb..ab4106c17b4c 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -54,6 +54,7 @@ struct tda8290_priv {
#define TDA18271 16
struct tda827x_config cfg;
+ struct tda18271_std_map *tda18271_std_map;
};
/*---------------------------------------------------------------------*/
@@ -233,7 +234,8 @@ static void tda8290_set_params(struct dvb_frontend *fe,
}
- tda8290_i2c_bridge(fe, 1);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
if (fe->ops.tuner_ops.set_analog_params)
fe->ops.tuner_ops.set_analog_params(fe, params);
@@ -302,7 +304,8 @@ static void tda8290_set_params(struct dvb_frontend *fe,
}
}
- tda8290_i2c_bridge(fe, 0);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2);
}
@@ -388,7 +391,7 @@ static void tda8295_agc2_out(struct dvb_frontend *fe, int enable)
tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_val, 2);
}
-static int tda8295_has_signal(struct dvb_frontend *fe)
+static int tda8295_has_signal(struct dvb_frontend *fe, u16 *signal)
{
struct tda8290_priv *priv = fe->analog_demod_priv;
@@ -396,7 +399,8 @@ static int tda8295_has_signal(struct dvb_frontend *fe)
unsigned char ret;
tuner_i2c_xfer_send_recv(&priv->i2c_props, &hvpll_stat, 1, &ret, 1);
- return (ret & 0x01) ? 65535 : 0;
+ *signal = (ret & 0x01) ? 65535 : 0;
+ return 0;
}
/*---------------------------------------------------------------------*/
@@ -405,7 +409,7 @@ static void tda8295_set_params(struct dvb_frontend *fe,
struct analog_parameters *params)
{
struct tda8290_priv *priv = fe->analog_demod_priv;
-
+ u16 signal = 0;
unsigned char blanking_mode[] = { 0x1d, 0x00 };
set_audio(fe, params);
@@ -424,7 +428,8 @@ static void tda8295_set_params(struct dvb_frontend *fe,
tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2);
msleep(20);
- tda8295_i2c_bridge(fe, 1);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
if (fe->ops.tuner_ops.set_analog_params)
fe->ops.tuner_ops.set_analog_params(fe, params);
@@ -432,17 +437,19 @@ static void tda8295_set_params(struct dvb_frontend *fe,
if (priv->cfg.agcf)
priv->cfg.agcf(fe);
- if (tda8295_has_signal(fe))
+ tda8295_has_signal(fe, &signal);
+ if (signal)
tuner_dbg("tda8295 is locked\n");
else
tuner_dbg("tda8295 not locked, no signal?\n");
- tda8295_i2c_bridge(fe, 0);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
}
/*---------------------------------------------------------------------*/
-static int tda8290_has_signal(struct dvb_frontend *fe)
+static int tda8290_has_signal(struct dvb_frontend *fe, u16 *signal)
{
struct tda8290_priv *priv = fe->analog_demod_priv;
@@ -451,7 +458,8 @@ static int tda8290_has_signal(struct dvb_frontend *fe)
tuner_i2c_xfer_send_recv(&priv->i2c_props,
i2c_get_afc, ARRAY_SIZE(i2c_get_afc), &afc, 1);
- return (afc & 0x80)? 65535:0;
+ *signal = (afc & 0x80) ? 65535 : 0;
+ return 0;
}
/*---------------------------------------------------------------------*/
@@ -465,11 +473,13 @@ static void tda8290_standby(struct dvb_frontend *fe)
unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2};
- tda8290_i2c_bridge(fe, 1);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
if (priv->ver & TDA8275A)
cb1[1] = 0x90;
i2c_transfer(priv->i2c_props.adap, &msg, 1);
- tda8290_i2c_bridge(fe, 0);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2);
tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2);
}
@@ -489,7 +499,8 @@ static void tda8290_init_if(struct dvb_frontend *fe)
unsigned char set_GP00_CF[] = { 0x20, 0x01 };
unsigned char set_GP01_CF[] = { 0x20, 0x0B };
- if ((priv->cfg.config == 1) || (priv->cfg.config == 2))
+ if ((priv->cfg.config == TDA8290_LNA_GP0_HIGH_ON) ||
+ (priv->cfg.config == TDA8290_LNA_GP0_HIGH_OFF))
tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2);
else
tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2);
@@ -537,9 +548,11 @@ static void tda8290_init_tuner(struct dvb_frontend *fe)
if (priv->ver & TDA8275A)
msg.buf = tda8275a_init;
- tda8290_i2c_bridge(fe, 1);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
i2c_transfer(priv->i2c_props.adap, &msg, 1);
- tda8290_i2c_bridge(fe, 0);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
}
/*---------------------------------------------------------------------*/
@@ -565,19 +578,13 @@ static struct tda18271_config tda829x_tda18271_config = {
static int tda829x_find_tuner(struct dvb_frontend *fe)
{
struct tda8290_priv *priv = fe->analog_demod_priv;
- struct analog_demod_ops *analog_ops = &fe->ops.analog_ops;
int i, ret, tuners_found;
u32 tuner_addrs;
u8 data;
struct i2c_msg msg = { .flags = I2C_M_RD, .buf = &data, .len = 1 };
- if (!analog_ops->i2c_gate_ctrl) {
- printk(KERN_ERR "tda8290: no gate control were provided!\n");
-
- return -EINVAL;
- }
-
- analog_ops->i2c_gate_ctrl(fe, 1);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
/* probe for tuner chip */
tuners_found = 0;
@@ -595,7 +602,8 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
give a response now
*/
- analog_ops->i2c_gate_ctrl(fe, 0);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
if (tuners_found > 1)
for (i = 0; i < tuners_found; i++) {
@@ -618,18 +626,21 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
priv->tda827x_addr = tuner_addrs;
msg.addr = tuner_addrs;
- analog_ops->i2c_gate_ctrl(fe, 1);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
if (ret != 1) {
tuner_warn("tuner access failed!\n");
- analog_ops->i2c_gate_ctrl(fe, 0);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
return -EREMOTEIO;
}
if ((data == 0x83) || (data == 0x84)) {
priv->ver |= TDA18271;
tda829x_tda18271_config.config = priv->cfg.config;
+ tda829x_tda18271_config.std_map = priv->tda18271_std_map;
dvb_attach(tda18271_attach, fe, priv->tda827x_addr,
priv->i2c_props.adap, &tda829x_tda18271_config);
} else {
@@ -648,7 +659,8 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
if (fe->ops.tuner_ops.sleep)
fe->ops.tuner_ops.sleep(fe);
- analog_ops->i2c_gate_ctrl(fe, 0);
+ if (fe->ops.analog_ops.i2c_gate_ctrl)
+ fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
return 0;
}
@@ -740,8 +752,10 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
priv->i2c_props.addr = i2c_addr;
priv->i2c_props.adap = i2c_adap;
priv->i2c_props.name = "tda829x";
- if (cfg)
- priv->cfg.config = cfg->lna_cfg;
+ if (cfg) {
+ priv->cfg.config = cfg->lna_cfg;
+ priv->tda18271_std_map = cfg->tda18271_std_map;
+ }
if (tda8290_probe(&priv->i2c_props) == 0) {
priv->ver = TDA8290;
@@ -755,6 +769,9 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
sizeof(struct analog_demod_ops));
}
+ if (cfg && cfg->no_i2c_gate)
+ fe->ops.analog_ops.i2c_gate_ctrl = NULL;
+
if (!(cfg) || (TDA829X_PROBE_TUNER == cfg->probe_tuner)) {
tda8295_power(fe, 1);
if (tda829x_find_tuner(fe) < 0)