]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/em28xx/em28xx-cards.c
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6-omap-h63xx.git] / drivers / media / video / em28xx / em28xx-cards.c
index 0c71e599c140289fb01734795eec77e83a05ab64..3e4f3c7e92e78ee62231feaebde1628d0cae27ff 100644 (file)
@@ -420,7 +420,13 @@ struct usb_device_id em28xx_id_table [] = {
                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
        { USB_DEVICE(0x2040, 0x6502),
                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
-       { USB_DEVICE(0x2040, 0x6513),
+       { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
+                       .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
+       { USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
+                       .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
+       { USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
+                       .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
+       { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
        { USB_DEVICE(0x0ccd, 0x0042),
                        .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
@@ -435,20 +441,26 @@ MODULE_DEVICE_TABLE(usb, em28xx_id_table);
  */
 
 /* Board Hauppauge WinTV HVR 900 analog */
-struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
-       {  -1,   -1,   6},
-       {0x08, 0x2d,  10},
-       {0x08, 0x3d,   5},
-       {  -1,   -1,  -1},
+static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
+       {EM28XX_R08_GPIO,       0x2d,   ~EM_GPIO_4,     10},
+       {0x05,                  0xff,   0x10,           10},
+       {  -1,                  -1,     -1,             -1},
 };
+
 /* Board Hauppauge WinTV HVR 900 digital */
-struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
-       {  -1,   -1,   6},
-       {0x08, 0x2e,   6},
-       {0x08, 0x3e,   6},
-       {0x04, 0x04,  10},
-       {0x04, 0x0c,  10},
-       { -1,    -1,  -1},
+static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
+       {EM28XX_R08_GPIO,       0x2e,   ~EM_GPIO_4,     10},
+       {EM2880_R04_GPO,        0x04,   0x0f,           10},
+       {EM2880_R04_GPO,        0x0c,   0x0f,           10},
+       { -1,                   -1,     -1,             -1},
+};
+
+/* Board Hauppauge WinTV HVR 900 tuner_callback */
+static struct em28xx_reg_seq hauppauge_wintv_hvr_900_tuner_callback[] = {
+       {EM28XX_R08_GPIO,       EM_GPIO_4,      EM_GPIO_4,      10},
+       {EM28XX_R08_GPIO,       0,              EM_GPIO_4,      10},
+       {EM28XX_R08_GPIO,       EM_GPIO_4,      EM_GPIO_4,      10},
+       {  -1,                  -1,             -1,             -1},
 };
 
 /*
@@ -469,7 +481,6 @@ int em28xx_tuner_callback(void *ptr, int command, int arg)
 {
        int rc = 0;
        struct em28xx *dev = ptr;
-       struct em28xx_reg_seq *gpio;
 
        if (dev->tuner_type != TUNER_XC2028)
                return 0;
@@ -478,32 +489,10 @@ int em28xx_tuner_callback(void *ptr, int command, int arg)
                return 0;
 
        if (dev->mode == EM28XX_ANALOG_MODE)
-               gpio = dev->analog_gpio;
+               rc = em28xx_gpio_set(dev, dev->tun_analog_gpio);
        else
-               gpio = dev->digital_gpio;
+               rc = em28xx_gpio_set(dev, dev->tun_digital_gpio);
 
-       /* djh - Not sure if these are still required */
-       dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
-       if (dev->mode == EM28XX_ANALOG_MODE)
-               dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
-       else
-               dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x37", 1);
-       msleep(6);
-
-       if (!gpio)
-               return rc;
-
-       /* Send GPIO reset sequences specified at board entry */
-       while (gpio->sleep >= 0) {
-               if (gpio->reg >= 0)
-                       rc = dev->em28xx_write_regs(dev,
-                                                   gpio->reg,
-                                                   &gpio->val, 1);
-               if (gpio->sleep > 0)
-                       msleep(gpio->sleep);
-
-               gpio++;
-       }
        return rc;
 }
 EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
@@ -527,11 +516,15 @@ void em28xx_pre_card_setup(struct em28xx *dev)
 {
        int rc;
 
+       rc = em28xx_read_reg(dev, EM2880_R04_GPO);
+       if (rc >= 0)
+               dev->reg_gpo = rc;
+
        dev->wait_after_write = 5;
-       rc = em28xx_read_reg(dev, CHIPID_REG);
+       rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
        if (rc > 0) {
                switch (rc) {
-               case 36:
+               case CHIP_ID_EM2883:
                        em28xx_info("chip ID is em2882/em2883\n");
                        dev->wait_after_write = 0;
                        break;
@@ -547,27 +540,27 @@ void em28xx_pre_card_setup(struct em28xx *dev)
        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
        case EM2880_BOARD_TERRATEC_HYBRID_XS:
        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
-               em28xx_write_regs(dev, XCLK_REG, "\x27", 1);
-               em28xx_write_regs(dev, I2C_CLK_REG, "\x40", 1);
-               em28xx_write_regs(dev, 0x08, "\xff", 1);
-               em28xx_write_regs(dev, 0x04, "\x00", 1);
-               msleep(100);
-               em28xx_write_regs(dev, 0x04, "\x08", 1);
-               msleep(100);
-               em28xx_write_regs(dev, 0x08, "\xff", 1);
+               em28xx_write_regs(dev, EM28XX_R0F_XCLK,    "\x27", 1);
+               em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
                msleep(50);
-               em28xx_write_regs(dev, 0x08, "\x2d", 1);
-               msleep(50);
-               em28xx_write_regs(dev, 0x08, "\x3d", 1);
 
-               dev->analog_gpio = hauppauge_wintv_hvr_900_analog;
-               dev->digital_gpio = hauppauge_wintv_hvr_900_digital;
+               /* Sets GPO/GPIO sequences for this device */
+               dev->analog_gpio      = hauppauge_wintv_hvr_900_analog;
+               dev->digital_gpio     = hauppauge_wintv_hvr_900_digital;
+               dev->tun_analog_gpio  = hauppauge_wintv_hvr_900_tuner_callback;
+               dev->tun_digital_gpio = hauppauge_wintv_hvr_900_tuner_callback;
 
                break;
        }
+
+       em28xx_gpio_set(dev, dev->tun_analog_gpio);
+       em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
+
+       /* Unlock device */
+       em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED);
 }
 
-void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
+static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
 {
        memset(ctl, 0, sizeof(*ctl));
 
@@ -576,15 +569,17 @@ void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
        ctl->mts = em28xx_boards[dev->model].mts_firmware;
 
        switch (dev->model) {
-       /* Add card-specific parameters for xc3028 here */
+       case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
+               ctl->demod = XC3028_FE_ZARLINK456;
+               break;
        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
+               /* FIXME: Better to specify the needed IF */
                ctl->demod = XC3028_FE_DEFAULT;
                break;
        default:
                ctl->demod = XC3028_FE_OREN538;
        }
 }
-EXPORT_SYMBOL_GPL(em28xx_setup_xc3028);
 
 static void em28xx_config_tuner(struct em28xx *dev)
 {