]> err.no Git - linux-2.6/blobdiff - drivers/media/dvb/frontends/dvb-pll.c
V4L/DVB (4311): Fix possible dvb-pll oops
[linux-2.6] / drivers / media / dvb / frontends / dvb-pll.c
index 5b96c2f280d5e9832aba7ab8b97f4aa4d14b732d..4c8a506479b4f1eb7dc11a8eb5be306b2f13559b 100644 (file)
@@ -194,11 +194,11 @@ struct dvb_pll_desc dvb_pll_tda665x = {
                {  253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0  10 */ },
                {  383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0  10 */ },
                {  443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0  10 */ },
-               {  444000000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0  11 */ },
-               {  583834000, 36249333, 166667, 0xca, 0x63 /* 011 0 0 0  11 */ },
-               {  793834000, 36249333, 166667, 0xca, 0xa3 /* 101 0 0 0  11 */ },
-               {  444834000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0  11 */ },
-               {  861000000, 36249333, 166667, 0xca, 0xe3 /* 111 0 0 0  11 */ },
+               {  444000000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1  00 */ },
+               {  583834000, 36249333, 166667, 0xca, 0x64 /* 011 0 0 1  00 */ },
+               {  793834000, 36249333, 166667, 0xca, 0xa4 /* 101 0 0 1  00 */ },
+               {  444834000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1  00 */ },
+               {  861000000, 36249333, 166667, 0xca, 0xe4 /* 111 0 0 1  00 */ },
        }
 };
 EXPORT_SYMBOL(dvb_pll_tda665x);
@@ -505,8 +505,8 @@ static int dvb_pll_sleep(struct dvb_frontend *fe)
        buf[2] = priv->pll_desc->entries[i].config;
        buf[3] = priv->pll_desc->entries[i].cb;
 
-       if (fe->ops->i2c_gate_ctrl)
-               fe->ops->i2c_gate_ctrl(fe, 1);
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
        if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) {
                return result;
        }
@@ -529,15 +529,15 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
                return -EINVAL;
 
        // DVBT bandwidth only just now
-       if (fe->ops->info.type == FE_OFDM) {
+       if (fe->ops.info.type == FE_OFDM) {
                bandwidth = params->u.ofdm.bandwidth;
        }
 
        if ((result = dvb_pll_configure(priv->pll_desc, buf, params->frequency, bandwidth)) != 0)
                return result;
 
-       if (fe->ops->i2c_gate_ctrl)
-               fe->ops->i2c_gate_ctrl(fe, 1);
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
        if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) {
                return result;
        }
@@ -555,7 +555,7 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
        return 0;
 }
 
-static int dvb_pll_pllbuf(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8 *buf, int buf_len)
+static int dvb_pll_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8 *buf, int buf_len)
 {
        struct dvb_pll_priv *priv = fe->tuner_priv;
        int result;
@@ -567,7 +567,7 @@ static int dvb_pll_pllbuf(struct dvb_frontend *fe, struct dvb_frontend_parameter
                return -EINVAL;
 
        // DVBT bandwidth only just now
-       if (fe->ops->info.type == FE_OFDM) {
+       if (fe->ops.info.type == FE_OFDM) {
                bandwidth = params->u.ofdm.bandwidth;
        }
 
@@ -606,14 +606,29 @@ static struct dvb_tuner_ops dvb_pll_tuner_ops = {
        .release = dvb_pll_release,
        .sleep = dvb_pll_sleep,
        .set_params = dvb_pll_set_params,
-       .pllbuf = dvb_pll_pllbuf,
+       .calc_regs = dvb_pll_calc_regs,
        .get_frequency = dvb_pll_get_frequency,
        .get_bandwidth = dvb_pll_get_bandwidth,
 };
 
 int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc)
 {
+       u8 b1 [] = { 0 };
+       struct i2c_msg msg [] = { { .addr = pll_addr, .flags = 0, .buf = NULL, .len = 0 },
+                                 { .addr = pll_addr, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
        struct dvb_pll_priv *priv = NULL;
+       int ret;
+
+       if (i2c != NULL) {
+               if (fe->ops.i2c_gate_ctrl)
+                       fe->ops.i2c_gate_ctrl(fe, 1);
+
+               ret = i2c_transfer (i2c, msg, 2);
+               if (ret != 2)
+                       return -1;
+               if (fe->ops.i2c_gate_ctrl)
+                            fe->ops.i2c_gate_ctrl(fe, 0);
+       }
 
        priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL);
        if (priv == NULL)
@@ -623,10 +638,10 @@ int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2
        priv->i2c = i2c;
        priv->pll_desc = desc;
 
-       memcpy(&fe->ops->tuner_ops, &dvb_pll_tuner_ops, sizeof(struct dvb_tuner_ops));
-       strncpy(fe->ops->tuner_ops.info.name, desc->name, 128);
-       fe->ops->tuner_ops.info.frequency_min = desc->min;
-       fe->ops->tuner_ops.info.frequency_min = desc->max;
+       memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops, sizeof(struct dvb_tuner_ops));
+       strncpy(fe->ops.tuner_ops.info.name, desc->name, 128);
+       fe->ops.tuner_ops.info.frequency_min = desc->min;
+       fe->ops.tuner_ops.info.frequency_min = desc->max;
 
        fe->tuner_priv = priv;
        return 0;