V4L/DVB (3856): Convert sp887x 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:41 +0000 (01:58 -0300)
Convert to tuner_ops calls.
Remove pll function pointers from structure.
Remove unneeded tuner calls.
Add i2c gate control function.

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

index eb8a602198ca99ad6990c783f31a305c368214b8..543dfa1450908b03362da66a99ad7df9fb9bae99 100644 (file)
@@ -208,15 +208,6 @@ static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware
        /* bit 0x010: enable data valid signal */
        sp887x_writereg(state, 0xd00, 0x010);
        sp887x_writereg(state, 0x0d1, 0x000);
-
-       /* setup the PLL */
-       if (state->config->pll_init) {
-               sp887x_writereg(state, 0x206, 0x001);
-               state->config->pll_init(fe);
-               sp887x_writereg(state, 0x206, 0x000);
-       }
-
-       printk ("done.\n");
        return 0;
 };
 
@@ -362,9 +353,16 @@ static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
        sp887x_microcontroller_stop(state);
 
        /* setup the PLL */
-       sp887x_writereg(state, 0x206, 0x001);
-       actual_freq = state->config->pll_set(fe, p);
-       sp887x_writereg(state, 0x206, 0x000);
+       if (fe->ops->tuner_ops.set_params) {
+               fe->ops->tuner_ops.set_params(fe, p);
+               if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0);
+       }
+       if (fe->ops->tuner_ops.get_frequency) {
+               fe->ops->tuner_ops.get_frequency(fe, &actual_freq);
+               if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0);
+       } else {
+               actual_freq = p->frequency;
+       }
 
        /* read status reg in order to clear <pending irqs */
        sp887x_readreg(state, 0x200);
@@ -486,6 +484,17 @@ static int sp887x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
        return 0;
 }
 
+static int sp887x_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
+{
+       struct sp887x_state* state = fe->demodulator_priv;
+
+       if (enable) {
+               return sp887x_writereg(state, 0x206, 0x001);
+       } else {
+               return sp887x_writereg(state, 0x206, 0x000);
+       }
+}
+
 static int sp887x_sleep(struct dvb_frontend* fe)
 {
        struct sp887x_state* state = fe->demodulator_priv;
@@ -589,6 +598,7 @@ static struct dvb_frontend_ops sp887x_ops = {
 
        .init = sp887x_init,
        .sleep = sp887x_sleep,
+       .i2c_gate_ctrl = sp887x_i2c_gate_ctrl,
 
        .set_frontend = sp887x_setup_frontend_parameters,
        .get_tune_settings = sp887x_get_tune_settings,
index 6a05d8f8e8cc4d4ef642188c5d87bafa0f340df4..c44b0ebdf1e220e32dd2c10a469e106ba1401c9f 100644 (file)
@@ -13,12 +13,6 @@ struct sp887x_config
        /* the demodulator's i2c address */
        u8 demod_address;
 
-       /* PLL maintenance */
-       int (*pll_init)(struct dvb_frontend* fe);
-
-       /* this should return the actual frequency tuned to */
-       int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
-
        /* request firmware for device */
        int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
 };