fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / media / dvb / frontends / l64781.c
index 031a1dd..1aeacb1 100644 (file)
@@ -2,7 +2,7 @@
     driver for LSI L64781 COFDM demodulator
 
     Copyright (C) 2001 Holger Waechtler for Convergence Integrated Media GmbH
     driver for LSI L64781 COFDM demodulator
 
     Copyright (C) 2001 Holger Waechtler for Convergence Integrated Media GmbH
-                       Marko Kohtala <marko.kohtala@luukku.com>
+                      Marko Kohtala <marko.kohtala@luukku.com>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 struct l64781_state {
        struct i2c_adapter* i2c;
 
 struct l64781_state {
        struct i2c_adapter* i2c;
-       struct dvb_frontend_ops ops;
        const struct l64781_config* config;
        struct dvb_frontend frontend;
 
        /* private demodulator data */
        const struct l64781_config* config;
        struct dvb_frontend frontend;
 
        /* private demodulator data */
-       int first:1;
+       unsigned int first:1;
 };
 
 #define dprintk(args...) \
 };
 
 #define dprintk(args...) \
@@ -141,7 +140,10 @@ static int apply_frontend_param (struct dvb_frontend* fe, struct dvb_frontend_pa
        u8 val0x06;
        int bw = p->bandwidth - BANDWIDTH_8_MHZ;
 
        u8 val0x06;
        int bw = p->bandwidth - BANDWIDTH_8_MHZ;
 
-       state->config->pll_set(fe, param);
+       if (fe->ops.tuner_ops.set_params) {
+               fe->ops.tuner_ops.set_params(fe, param);
+               if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
+       }
 
        if (param->inversion != INVERSION_ON &&
            param->inversion != INVERSION_OFF)
 
        if (param->inversion != INVERSION_ON &&
            param->inversion != INVERSION_OFF)
@@ -433,7 +435,7 @@ static int l64781_init(struct dvb_frontend* fe)
 {
        struct l64781_state* state = fe->demodulator_priv;
 
 {
        struct l64781_state* state = fe->demodulator_priv;
 
-        reset_and_configure (state);
+       reset_and_configure (state);
 
        /* Power up */
        l64781_writereg (state, 0x3e, 0xa5);
 
        /* Power up */
        l64781_writereg (state, 0x3e, 0xa5);
@@ -456,15 +458,13 @@ static int l64781_init(struct dvb_frontend* fe)
        l64781_writereg (state, 0x0d, 0x8c);
 
        /* With ppm=8000, it seems the DTR_SENSITIVITY will result in
        l64781_writereg (state, 0x0d, 0x8c);
 
        /* With ppm=8000, it seems the DTR_SENSITIVITY will result in
-           value of 2 with all possible bandwidths and guard
-           intervals, which is the initial value anyway. */
-        /*l64781_writereg (state, 0x19, 0x92);*/
+          value of 2 with all possible bandwidths and guard
+          intervals, which is the initial value anyway. */
+       /*l64781_writereg (state, 0x19, 0x92);*/
 
        /* Everything is two's complement, soft bit and CSI_OUT too */
        l64781_writereg (state, 0x1e, 0x09);
 
 
        /* Everything is two's complement, soft bit and CSI_OUT too */
        l64781_writereg (state, 0x1e, 0x09);
 
-       if (state->config->pll_init) state->config->pll_init(fe);
-
        /* delay a bit after first init attempt */
        if (state->first) {
                state->first = 0;
        /* delay a bit after first init attempt */
        if (state->first) {
                state->first = 0;
@@ -474,12 +474,13 @@ static int l64781_init(struct dvb_frontend* fe)
        return 0;
 }
 
        return 0;
 }
 
-static int l64781_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
+static int l64781_get_tune_settings(struct dvb_frontend* fe,
+                                   struct dvb_frontend_tune_settings* fesettings)
 {
 {
-        fesettings->min_delay_ms = 200;
-        fesettings->step_size = 166667;
-        fesettings->max_drift = 166667*2;
-        return 0;
+       fesettings->min_delay_ms = 4000;
+       fesettings->step_size = 0;
+       fesettings->max_drift = 0;
+       return 0;
 }
 
 static void l64781_release(struct dvb_frontend* fe)
 }
 
 static void l64781_release(struct dvb_frontend* fe)
@@ -507,7 +508,6 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
        /* setup the state */
        state->config = config;
        state->i2c = i2c;
        /* setup the state */
        state->config = config;
        state->i2c = i2c;
-       memcpy(&state->ops, &l64781_ops, sizeof(struct dvb_frontend_ops));
        state->first = 1;
 
        /**
        state->first = 1;
 
        /**
@@ -521,7 +521,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
 
        /* The chip always responds to reads */
        if (i2c_transfer(state->i2c, msg, 2) != 2) {
 
        /* The chip always responds to reads */
        if (i2c_transfer(state->i2c, msg, 2) != 2) {
-               dprintk("No response to read on I2C bus\n");
+               dprintk("No response to read on I2C bus\n");
                goto error;
        }
 
                goto error;
        }
 
@@ -530,7 +530,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
 
        /* Reading the POWER_DOWN register always returns 0 */
        if (reg0x3e != 0) {
 
        /* Reading the POWER_DOWN register always returns 0 */
        if (reg0x3e != 0) {
-               dprintk("Device doesn't look like L64781\n");
+               dprintk("Device doesn't look like L64781\n");
                goto error;
        }
 
                goto error;
        }
 
@@ -539,7 +539,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
 
        /* Responds to all reads with 0 */
        if (l64781_readreg(state, 0x1a) != 0) {
 
        /* Responds to all reads with 0 */
        if (l64781_readreg(state, 0x1a) != 0) {
-               dprintk("Read 1 returned unexpcted value\n");
+               dprintk("Read 1 returned unexpcted value\n");
                goto error;
        }
 
                goto error;
        }
 
@@ -548,17 +548,18 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
 
        /* Responds with register default value */
        if (l64781_readreg(state, 0x1a) != 0xa1) {
 
        /* Responds with register default value */
        if (l64781_readreg(state, 0x1a) != 0xa1) {
-               dprintk("Read 2 returned unexpcted value\n");
+               dprintk("Read 2 returned unexpcted value\n");
                goto error;
        }
 
        /* create dvb_frontend */
                goto error;
        }
 
        /* create dvb_frontend */
-       state->frontend.ops = &state->ops;
+       memcpy(&state->frontend.ops, &l64781_ops, sizeof(struct dvb_frontend_ops));
        state->frontend.demodulator_priv = state;
        return &state->frontend;
 
 error:
        state->frontend.demodulator_priv = state;
        return &state->frontend;
 
 error:
-       if (reg0x3e >= 0) l64781_writereg (state, 0x3e, reg0x3e);  /* restore reg 0x3e */
+       if (reg0x3e >= 0)
+               l64781_writereg (state, 0x3e, reg0x3e);  /* restore reg 0x3e */
        kfree(state);
        return NULL;
 }
        kfree(state);
        return NULL;
 }