Merge to kernel-2.6.20-1.2949.fc6.vs2.2.0.1
[linux-2.6.git] / drivers / media / dvb / frontends / ves1820.c
index 70fb44b..9b57576 100644 (file)
@@ -18,7 +18,6 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#include <linux/config.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -35,7 +34,6 @@
 
 struct ves1820_state {
        struct i2c_adapter* i2c;
-       struct dvb_frontend_ops ops;
        /* configuration settings */
        const struct ves1820_config* config;
        struct dvb_frontend frontend;
@@ -140,25 +138,25 @@ static int ves1820_set_symbolrate(struct ves1820_state *state, u32 symbolrate)
        /* yeuch! */
        fpxin = state->config->xin * 10;
        fptmp = fpxin; do_div(fptmp, 123);
-       if (symbolrate < fptmp);
+       if (symbolrate < fptmp)
                SFIL = 1;
        fptmp = fpxin; do_div(fptmp, 160);
-       if (symbolrate < fptmp);
+       if (symbolrate < fptmp)
                SFIL = 0;
        fptmp = fpxin; do_div(fptmp, 246);
-       if (symbolrate < fptmp);
+       if (symbolrate < fptmp)
                SFIL = 1;
        fptmp = fpxin; do_div(fptmp, 320);
-       if (symbolrate < fptmp);
+       if (symbolrate < fptmp)
                SFIL = 0;
        fptmp = fpxin; do_div(fptmp, 492);
-       if (symbolrate < fptmp);
+       if (symbolrate < fptmp)
                SFIL = 1;
        fptmp = fpxin; do_div(fptmp, 640);
-       if (symbolrate < fptmp);
+       if (symbolrate < fptmp)
                SFIL = 0;
        fptmp = fpxin; do_div(fptmp, 984);
-       if (symbolrate < fptmp);
+       if (symbolrate < fptmp)
                SFIL = 1;
 
        fin = state->config->xin >> 4;
@@ -194,20 +192,16 @@ static int ves1820_init(struct dvb_frontend* fe)
 {
        struct ves1820_state* state = fe->demodulator_priv;
        int i;
-       int val;
 
        ves1820_writereg(state, 0, 0);
 
-       for (i = 0; i < 53; i++) {
-               val = ves1820_inittab[i];
-               if ((i == 2) && (state->config->selagc)) val |= 0x08;
-               ves1820_writereg(state, i, val);
-       }
+       for (i = 0; i < sizeof(ves1820_inittab); i++)
+               ves1820_writereg(state, i, ves1820_inittab[i]);
+       if (state->config->selagc)
+               ves1820_writereg(state, 2, ves1820_inittab[2] | 0x08);
 
        ves1820_writereg(state, 0x34, state->pwm);
 
-       if (state->config->pll_init) state->config->pll_init(fe);
-
        return 0;
 }
 
@@ -224,7 +218,11 @@ static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_p
        if (real_qam < 0 || real_qam > 4)
                return -EINVAL;
 
-       state->config->pll_set(fe, p);
+       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);
+       }
+
        ves1820_set_symbolrate(state, p->u.qam.symbol_rate);
        ves1820_writereg(state, 0x34, state->pwm);
 
@@ -234,7 +232,7 @@ static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_p
        ves1820_writereg(state, 0x09, reg0x09[real_qam]);
 
        ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion);
-
+       ves1820_writereg(state, 2, ves1820_inittab[2] | (state->config->selagc ? 0x08 : 0));
        return 0;
 }
 
@@ -381,7 +379,6 @@ struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
                goto error;
 
        /* setup the state */
-       memcpy(&state->ops, &ves1820_ops, sizeof(struct dvb_frontend_ops));
        state->reg0 = ves1820_inittab[0];
        state->config = config;
        state->i2c = i2c;
@@ -394,12 +391,12 @@ struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
        if (verbose)
                printk("ves1820: pwm=0x%02x\n", state->pwm);
 
-       state->ops.info.symbol_rate_min = (state->config->xin / 2) / 64;      /* SACLK/64 == (XIN/2)/64 */
-       state->ops.info.symbol_rate_max = (state->config->xin / 2) / 4;       /* SACLK/4 */
-
        /* create dvb_frontend */
-       state->frontend.ops = &state->ops;
+       memcpy(&state->frontend.ops, &ves1820_ops, sizeof(struct dvb_frontend_ops));
+       state->frontend.ops.info.symbol_rate_min = (state->config->xin / 2) / 64;      /* SACLK/64 == (XIN/2)/64 */
+       state->frontend.ops.info.symbol_rate_max = (state->config->xin / 2) / 4;       /* SACLK/4 */
        state->frontend.demodulator_priv = state;
+
        return &state->frontend;
 
 error: