tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / media / dvb / dvb-usb / dibusb-mb.c
index 7a6ae8f..5c0126d 100644 (file)
  */
 #include "dibusb.h"
 
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+static int dib3000mb_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
+{
+       struct dvb_usb_adapter *adap = fe->dvb->priv;
+       struct dibusb_state *st = adap->priv;
+
+       return st->ops.tuner_pass_ctrl(fe, enable, st->tuner_addr);
+}
+
 static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_adapter *adap)
 {
        struct dib3000_config demod_cfg;
@@ -21,21 +31,34 @@ static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_adapter *adap)
 
        demod_cfg.demod_address = 0x8;
 
-       if ((adap->fe = dib3000mb_attach(&demod_cfg,&adap->dev->i2c_adap,&st->ops)) == NULL)
+       if ((adap->fe = dvb_attach(dib3000mb_attach, &demod_cfg,
+                                  &adap->dev->i2c_adap, &st->ops)) == NULL)
                return -ENODEV;
 
-       adap->fe->ops.tuner_ops.init       = dvb_usb_tuner_init_i2c;
-       adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
-
-       adap->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
+       adap->fe->ops.i2c_gate_ctrl = dib3000mb_i2c_gate_ctrl;
 
        return 0;
 }
 
 static int dibusb_thomson_tuner_attach(struct dvb_usb_adapter *adap)
 {
-       adap->pll_addr = 0x61;
-       adap->pll_desc = &dvb_pll_tua6010xs;
+       struct dibusb_state *st = adap->priv;
+
+       st->tuner_addr = 0x61;
+
+       dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
+                  DVB_PLL_TUA6010XS);
+       return 0;
+}
+
+static int dibusb_panasonic_tuner_attach(struct dvb_usb_adapter *adap)
+{
+       struct dibusb_state *st = adap->priv;
+
+       st->tuner_addr = 0x60;
+
+       dvb_attach(dvb_pll_attach, adap->fe, 0x60, &adap->dev->i2c_adap,
+                  DVB_PLL_TDA665X);
        return 0;
 }
 
@@ -50,30 +73,28 @@ static int dibusb_tuner_probe_and_attach(struct dvb_usb_adapter *adap)
                { .flags = 0,        .buf = b,  .len = 2 },
                { .flags = I2C_M_RD, .buf = b2, .len = 1 },
        };
+       struct dibusb_state *st = adap->priv;
 
        /* the Panasonic sits on I2C addrass 0x60, the Thomson on 0x61 */
-       msg[0].addr = msg[1].addr = 0x60;
+       msg[0].addr = msg[1].addr = st->tuner_addr = 0x60;
 
-       if (adap->tuner_pass_ctrl)
-               adap->tuner_pass_ctrl(adap->fe,1,msg[0].addr);
+       if (adap->fe->ops.i2c_gate_ctrl)
+               adap->fe->ops.i2c_gate_ctrl(adap->fe,1);
 
        if (i2c_transfer(&adap->dev->i2c_adap, msg, 2) != 2) {
                err("tuner i2c write failed.");
                ret = -EREMOTEIO;
        }
 
-       if (adap->tuner_pass_ctrl)
-               adap->tuner_pass_ctrl(adap->fe,0,msg[0].addr);
+       if (adap->fe->ops.i2c_gate_ctrl)
+               adap->fe->ops.i2c_gate_ctrl(adap->fe,0);
 
        if (b2[0] == 0xfe) {
                info("This device has the Thomson Cable onboard. Which is default.");
-               dibusb_thomson_tuner_attach(adap);
+               ret = dibusb_thomson_tuner_attach(adap);
        } else {
-               u8 bpll[4] = { 0x0b, 0xf5, 0x85, 0xab };
                info("This device has the Panasonic ENV77H11D5 onboard.");
-               adap->pll_addr = 0x60;
-               memcpy(adap->pll_init,bpll,4);
-               adap->pll_desc = &dvb_pll_tda665x;
+               ret = dibusb_panasonic_tuner_attach(adap);
        }
 
        return ret;
@@ -88,10 +109,14 @@ static struct dvb_usb_device_properties artec_t1_usb2_properties;
 static int dibusb_probe(struct usb_interface *intf,
                const struct usb_device_id *id)
 {
-       if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE,NULL) == 0 ||
-               dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE,NULL) == 0 ||
-               dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE,NULL) == 0 ||
-               dvb_usb_device_init(intf,&artec_t1_usb2_properties,THIS_MODULE,NULL) == 0)
+       if (0 == dvb_usb_device_init(intf, &dibusb1_1_properties,
+                                    THIS_MODULE, NULL, adapter_nr) ||
+           0 == dvb_usb_device_init(intf, &dibusb1_1_an2235_properties,
+                                    THIS_MODULE, NULL, adapter_nr) ||
+           0 == dvb_usb_device_init(intf, &dibusb2_0b_properties,
+                                    THIS_MODULE, NULL, adapter_nr) ||
+           0 == dvb_usb_device_init(intf, &artec_t1_usb2_properties,
+                                    THIS_MODULE, NULL, adapter_nr))
                return 0;
 
        return -EINVAL;
@@ -217,7 +242,7 @@ static struct dvb_usb_device_properties dibusb1_1_properties = {
                        { &dibusb_dib3000mb_table[9],  &dibusb_dib3000mb_table[11], NULL },
                        { &dibusb_dib3000mb_table[10], &dibusb_dib3000mb_table[12], NULL },
                },
-               {       "Unkown USB1.1 DVB-T device ???? please report the name to the author",
+               {       "Unknown USB1.1 DVB-T device ???? please report the name to the author",
                        { &dibusb_dib3000mb_table[13], NULL },
                        { &dibusb_dib3000mb_table[14], NULL },
                },