]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/dvb/frontends/ves1x93.c
[WATCHDOG] Merge code clean-up's from Alan Cox.
[linux-2.6-omap-h63xx.git] / drivers / media / dvb / frontends / ves1x93.c
index 821df8e839d056669d594ac1bcf47adb7d65e9b1..bd558960bd87222eed8a71e7f696554e461ea9be 100644 (file)
@@ -36,7 +36,6 @@
 
 struct ves1x93_state {
        struct i2c_adapter* i2c;
-       struct dvb_frontend_ops ops;
        /* configuration settings */
        const struct ves1x93_config* config;
        struct dvb_frontend frontend;
@@ -49,7 +48,7 @@ struct ves1x93_state {
        u8 demod_type;
 };
 
-static int debug = 0;
+static int debug;
 #define dprintk        if (debug) printk
 
 #define DEMOD_VES1893          0
@@ -99,7 +98,7 @@ static int ves1x93_writereg (struct ves1x93_state* state, u8 reg, u8 data)
        int err;
 
        if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
-               dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
+               dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __func__, err, reg, data);
                return -EREMOTEIO;
        }
 
@@ -180,7 +179,7 @@ static int ves1x93_set_symbolrate (struct ves1x93_state* state, u32 srate)
        u32 tmp;
        u32 FIN;
 
-       dprintk("%s: srate == %d\n", __FUNCTION__, (unsigned int) srate);
+       dprintk("%s: srate == %d\n", __func__, (unsigned int) srate);
 
        if (srate > state->config->xin/2)
                srate = state->config->xin/2;
@@ -267,7 +266,7 @@ static int ves1x93_init (struct dvb_frontend* fe)
        int i;
        int val;
 
-       dprintk("%s: init chip\n", __FUNCTION__);
+       dprintk("%s: init chip\n", __func__);
 
        for (i = 0; i < state->tab_size; i++) {
                if (state->init_1x93_wtab[i]) {
@@ -278,12 +277,6 @@ static int ves1x93_init (struct dvb_frontend* fe)
                }
        }
 
-       if (state->config->pll_init) {
-               ves1x93_writereg(state, 0x00, 0x11);
-               state->config->pll_init(fe);
-               ves1x93_writereg(state, 0x00, 0x01);
-       }
-
        return 0;
 }
 
@@ -313,7 +306,7 @@ static int ves1x93_read_status(struct dvb_frontend* fe, fe_status_t* status)
         * The ves1893 sometimes returns sync values that make no sense,
         * because, e.g., the SIGNAL bit is 0, while some of the higher
         * bits are 1 (and how can there be a CARRIER w/o a SIGNAL?).
-        * Tests showed that the the VITERBI and SYNC bits are returned
+        * Tests showed that the VITERBI and SYNC bits are returned
         * reliably, while the SIGNAL and CARRIER bits ar sometimes wrong.
         * If such a case occurs, we read the value again, until we get a
         * valid value.
@@ -395,9 +388,10 @@ static int ves1x93_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
 {
        struct ves1x93_state* state = fe->demodulator_priv;
 
-       ves1x93_writereg(state, 0x00, 0x11);
-       state->config->pll_set(fe, p);
-       ves1x93_writereg(state, 0x00, 0x01);
+       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);
+       }
        ves1x93_set_inversion (state, p->inversion);
        ves1x93_set_fec (state, p->u.qpsk.fec_inner);
        ves1x93_set_symbolrate (state, p->u.qpsk.symbol_rate);
@@ -442,6 +436,17 @@ static void ves1x93_release(struct dvb_frontend* fe)
        kfree(state);
 }
 
+static int ves1x93_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
+{
+       struct ves1x93_state* state = fe->demodulator_priv;
+
+       if (enable) {
+               return ves1x93_writereg(state, 0x00, 0x11);
+       } else {
+               return ves1x93_writereg(state, 0x00, 0x01);
+       }
+}
+
 static struct dvb_frontend_ops ves1x93_ops;
 
 struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
@@ -457,7 +462,6 @@ struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
        /* setup the state */
        state->config = config;
        state->i2c = i2c;
-       memcpy(&state->ops, &ves1x93_ops, sizeof(struct dvb_frontend_ops));
        state->inversion = INVERSION_OFF;
 
        /* check if the demod is there + identify it */
@@ -492,7 +496,7 @@ struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
        }
 
        /* create dvb_frontend */
-       state->frontend.ops = &state->ops;
+       memcpy(&state->frontend.ops, &ves1x93_ops, sizeof(struct dvb_frontend_ops));
        state->frontend.demodulator_priv = state;
        return &state->frontend;
 
@@ -523,6 +527,7 @@ static struct dvb_frontend_ops ves1x93_ops = {
 
        .init = ves1x93_init,
        .sleep = ves1x93_sleep,
+       .i2c_gate_ctrl = ves1x93_i2c_gate_ctrl,
 
        .set_frontend = ves1x93_set_frontend,
        .get_frontend = ves1x93_get_frontend,