Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[linux-2.6.git] / drivers / media / video / au0828 / au0828-cards.c
index e10b1b9..1c6015a 100644 (file)
@@ -46,6 +46,7 @@ struct au0828_board au0828_boards[] = {
                .name   = "Hauppauge HVR850",
                .tuner_type = TUNER_XC5000,
                .tuner_addr = 0x61,
+               .i2c_clk_divider = AU0828_I2C_CLK_30KHZ,
                .input = {
                        {
                                .type = AU0828_VMUX_TELEVISION,
@@ -70,6 +71,13 @@ struct au0828_board au0828_boards[] = {
                .name   = "Hauppauge HVR950Q",
                .tuner_type = TUNER_XC5000,
                .tuner_addr = 0x61,
+               /* The au0828 hardware i2c implementation does not properly
+                  support the xc5000's i2c clock stretching.  So we need to
+                  lower the clock frequency enough where the 15us clock
+                  stretch fits inside of a normal clock cycle, or else the
+                  au0828 fails to set the STOP bit.  A 30 KHz clock puts the
+                  clock pulse width at 18us */
+               .i2c_clk_divider = AU0828_I2C_CLK_30KHZ,
                .input = {
                        {
                                .type = AU0828_VMUX_TELEVISION,
@@ -94,16 +102,19 @@ struct au0828_board au0828_boards[] = {
                .name   = "Hauppauge HVR950Q rev xxF8",
                .tuner_type = UNSET,
                .tuner_addr = ADDR_UNSET,
+               .i2c_clk_divider = AU0828_I2C_CLK_250KHZ,
        },
        [AU0828_BOARD_DVICO_FUSIONHDTV7] = {
                .name   = "DViCO FusionHDTV USB",
                .tuner_type = UNSET,
                .tuner_addr = ADDR_UNSET,
+               .i2c_clk_divider = AU0828_I2C_CLK_250KHZ,
        },
        [AU0828_BOARD_HAUPPAUGE_WOODBURY] = {
                .name = "Hauppauge Woodbury",
                .tuner_type = UNSET,
                .tuner_addr = ADDR_UNSET,
+               .i2c_clk_divider = AU0828_I2C_CLK_250KHZ,
        },
 };
 
@@ -125,9 +136,9 @@ int au0828_tuner_callback(void *priv, int component, int command, int arg)
                        /* Tuner Reset Command from xc5000 */
                        /* Drive the tuner into reset and out */
                        au0828_clear(dev, REG_001, 2);
-                       mdelay(200);
+                       mdelay(10);
                        au0828_set(dev, REG_001, 2);
-                       mdelay(50);
+                       mdelay(10);
                        return 0;
                } else {
                        printk(KERN_ERR
@@ -150,13 +161,16 @@ static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)
        /* Make sure we support the board model */
        switch (tv.model) {
        case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */
-       case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */
-       case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */
-       case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */
-       case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */
-       case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and basic analog video */
-       case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */
-       case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */
+       case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
+       case 72101: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
+       case 72201: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
+       case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
+       case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
+       case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
+       case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
+       case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
+       case 72261: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
+       case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */
        case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */
                break;
        default:
@@ -173,8 +187,8 @@ void au0828_card_setup(struct au0828_dev *dev)
 {
        static u8 eeprom[256];
        struct tuner_setup tun_setup;
-       unsigned int mode_mask = T_ANALOG_TV |
-                                T_DIGITAL_TV;
+       struct v4l2_subdev *sd;
+       unsigned int mode_mask = T_ANALOG_TV;
 
        dprintk(1, "%s()\n", __func__);
 
@@ -195,23 +209,30 @@ void au0828_card_setup(struct au0828_dev *dev)
                break;
        }
 
-       if (dev->board.input != NULL) {
+       if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {
                /* Load the analog demodulator driver (note this would need to
                   be abstracted out if we ever need to support a different
                   demod) */
-               request_module("au8522");
+               sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
+                               "au8522", 0x8e >> 1, NULL);
+               if (sd == NULL)
+                       printk(KERN_ERR "analog subdev registration failed\n");
        }
 
        /* Setup tuners */
        if (dev->board.tuner_type != TUNER_ABSENT) {
                /* Load the tuner module, which does the attach */
-               request_module("tuner");
+               sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
+                               "tuner", dev->board.tuner_addr, NULL);
+               if (sd == NULL)
+                       printk(KERN_ERR "tuner subdev registration fail\n");
 
                tun_setup.mode_mask      = mode_mask;
                tun_setup.type           = dev->board.tuner_type;
                tun_setup.addr           = dev->board.tuner_addr;
                tun_setup.tuner_callback = au0828_tuner_callback;
-               au0828_call_i2c_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
+               v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr,
+                                    &tun_setup);
        }
 }
 
@@ -306,6 +327,10 @@ struct usb_device_id au0828_usb_id_table[] = {
                .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
        { USB_DEVICE(0x2040, 0x8200),
                .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY },
+       { USB_DEVICE(0x2040, 0x7260),
+               .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
+       { USB_DEVICE(0x2040, 0x7213),
+               .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
        { },
 };