V4L/DVB (3858): Convert tda1004x to refactored tuner code
authorAndrew de Quincey <adq_dvb@lidskialf.net>
Tue, 18 Apr 2006 20:47:10 +0000 (17:47 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 25 Jun 2006 04:58:44 +0000 (01:58 -0300)
Convert to tuner_ops calls.
Remove pll function pointers from structure.
Remove unneeded tuner calls.
Add i2c gate control function.
Remove europa specific hack (moved into appropriate card driver)

Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/dvb/frontends/tda1004x.c
drivers/media/dvb/frontends/tda1004x.h

index b83dafa4e12cdcc79a023fe683f1394eeb05de72..d9abce753e528baa0b36901cbcdf5fb4cf040c8a 100644 (file)
@@ -600,13 +600,6 @@ static int tda10045_init(struct dvb_frontend* fe)
 
        tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0); // wake up the ADC
 
-       // Init the PLL
-       if (state->config->pll_init) {
-               tda1004x_enable_tuner_i2c(state);
-               state->config->pll_init(fe);
-               tda1004x_disable_tuner_i2c(state);
-       }
-
        // tda setup
        tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
        tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream
@@ -635,16 +628,6 @@ static int tda10046_init(struct dvb_frontend* fe)
                        return -EIO;
        }
 
-       // Init the tuner PLL
-       if (state->config->pll_init) {
-               tda1004x_enable_tuner_i2c(state);
-               if (state->config->pll_init(fe)) {
-                       printk(KERN_ERR "tda1004x: pll init failed\n");
-                       return  -EIO;
-               }
-               tda1004x_disable_tuner_i2c(state);
-       }
-
        // tda setup
        tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
        tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87);    // 100 ppm crystal, select HP stream
@@ -712,12 +695,10 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
        }
 
        // set frequency
-       tda1004x_enable_tuner_i2c(state);
-       if (state->config->pll_set(fe, fe_params)) {
-               printk(KERN_ERR "tda1004x: pll set failed\n");
-               return  -EIO;
+       if (fe->ops->tuner_ops.set_params) {
+               fe->ops->tuner_ops.set_params(fe, fe_params);
+               if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0);
        }
-       tda1004x_disable_tuner_i2c(state);
 
        // Hardcoded to use auto as much as possible on the TDA10045 as it
        // is very unreliable if AUTO mode is _not_ used.
@@ -1183,16 +1164,6 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
                break;
 
        case TDA1004X_DEMOD_TDA10046:
-               if (state->config->pll_sleep != NULL) {
-                       tda1004x_enable_tuner_i2c(state);
-                       state->config->pll_sleep(fe);
-                       if (state->config->if_freq != TDA10046_FREQ_052) {
-                               /* special hack for Philips EUROPA Based boards:
-                                * keep the I2c bridge open for tuner access in analog mode
-                                */
-                               tda1004x_disable_tuner_i2c(state);
-                       }
-               }
                /* set outputs to tristate */
                tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0xff);
                tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1);
@@ -1202,6 +1173,17 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
        return 0;
 }
 
+static int tda1004x_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
+{
+       struct tda1004x_state* state = fe->demodulator_priv;
+
+       if (enable) {
+               return tda1004x_enable_tuner_i2c(state);
+       } else {
+               return tda1004x_disable_tuner_i2c(state);
+       }
+}
+
 static int tda1004x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
 {
        fesettings->min_delay_ms = 800;
@@ -1235,6 +1217,7 @@ static struct dvb_frontend_ops tda10045_ops = {
 
        .init = tda10045_init,
        .sleep = tda1004x_sleep,
+       .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl,
 
        .set_frontend = tda1004x_set_fe,
        .get_frontend = tda1004x_get_fe,
index cc0c4af64067037312fde708aef5dea56c9b5459..b877b23ed734e07398f2ac9d2ee5d2ef58508fc0 100644 (file)
@@ -66,11 +66,6 @@ struct tda1004x_config
        /* AGC configuration */
        enum tda10046_agc agc_config;
 
-       /* PLL maintenance */
-       int (*pll_init)(struct dvb_frontend* fe);
-       void (*pll_sleep)(struct dvb_frontend* fe);
-       int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
-
        /* request firmware for device */
        /* set this to NULL if the card has a firmware EEPROM */
        int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);