]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/em28xx/em28xx-cards.c
V4L/DVB (7607): CodingStyle fixes
[linux-2.6-omap-h63xx.git] / drivers / media / video / em28xx / em28xx-cards.c
index 2159d0160df248aaf28cc5325dc25d3a02d712b6..7dfea3ac9b2f392e70473db89b5bbe31f2fc99b0 100644 (file)
@@ -36,7 +36,6 @@
 #include <media/v4l2-common.h>
 
 #include "em28xx.h"
-#include "tuner-xc2028.h"
 
 static int tuner = -1;
 module_param(tuner, int, 0444);
@@ -52,26 +51,6 @@ struct em28xx_hash_table {
        unsigned int  tuner;
 };
 
-/* Boards supported by driver */
-
-#define EM2800_BOARD_UNKNOWN                   0
-#define EM2820_BOARD_UNKNOWN                   1
-#define EM2820_BOARD_TERRATEC_CINERGY_250      2
-#define EM2820_BOARD_PINNACLE_USB_2            3
-#define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2      4
-#define EM2820_BOARD_MSI_VOX_USB_2              5
-#define EM2800_BOARD_TERRATEC_CINERGY_200       6
-#define EM2800_BOARD_LEADTEK_WINFAST_USBII      7
-#define EM2800_BOARD_KWORLD_USB2800             8
-#define EM2820_BOARD_PINNACLE_DVC_90           9
-#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900   10
-#define EM2880_BOARD_TERRATEC_HYBRID_XS                11
-#define EM2820_BOARD_KWORLD_PVRTV2800RF                12
-#define EM2880_BOARD_TERRATEC_PRODIGY_XS       13
-#define EM2820_BOARD_PROLINK_PLAYTV_USB2       14
-#define EM2800_BOARD_VGEAR_POCKETTV             15
-#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950   16
-
 struct em28xx_board em28xx_boards[] = {
        [EM2800_BOARD_UNKNOWN] = {
                .name         = "Unknown EM2800 video grabber",
@@ -200,6 +179,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type     = TUNER_XC2028,
                .mts_firmware   = 1,
                .has_12mhz_i2s  = 1,
+               .has_dvb        = 1,
                .decoder        = EM28XX_TVP5150,
                .input          = { {
                        .type     = EM28XX_VMUX_TELEVISION,
@@ -214,9 +194,6 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = TVP5150_SVIDEO,
                        .amux     = 1,
                } },
-
-               /* gpio's 4, 1, 0 */
-               .analog_gpio = 0x003d2d,
        },
        [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
                .name         = "Terratec Hybrid XS",
@@ -331,7 +308,7 @@ struct em28xx_board em28xx_boards[] = {
                .name         = "Kworld USB2800",
                .is_em2800    = 1,
                .vchannels    = 3,
-               .tuner_type   = TUNER_PHILIPS_ATSC,
+               .tuner_type   = TUNER_PHILIPS_FCV1236D,
                .tda9887_conf = TDA9887_PRESENT,
                .decoder      = EM28XX_SAA7113,
                .input          = { {
@@ -393,15 +370,15 @@ struct em28xx_board em28xx_boards[] = {
                .input          = { {
                        .type     = EM28XX_VMUX_TELEVISION,
                        .vmux     = SAA7115_COMPOSITE2,
-                       .amux     = 1,
+                       .amux     = EM28XX_AMUX_LINE_IN,
                }, {
                        .type     = EM28XX_VMUX_COMPOSITE1,
                        .vmux     = SAA7115_COMPOSITE0,
-                       .amux     = 1,
+                       .amux     = EM28XX_AMUX_LINE_IN,
                }, {
                        .type     = EM28XX_VMUX_SVIDEO,
                        .vmux     = SAA7115_SVIDEO3,
-                       .amux     = 1,
+                       .amux     = EM28XX_AMUX_LINE_IN,
                } },
        },
 };
@@ -441,6 +418,8 @@ struct usb_device_id em28xx_id_table [] = {
                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
        { USB_DEVICE(0x2040, 0x6500),
                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
+       { USB_DEVICE(0x2040, 0x6502),
+                       .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
        { USB_DEVICE(0x2040, 0x6513),
                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
        { USB_DEVICE(0x0ccd, 0x0042),
@@ -451,7 +430,30 @@ struct usb_device_id em28xx_id_table [] = {
 };
 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
 
-/* EEPROM hash table for devices with generic USB IDs */
+/*
+ *  Reset sequences for analog/digital modes
+ */
+
+/* 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},
+};
+/* 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},
+};
+
+/*
+ * EEPROM hash table for devices with generic USB IDs
+ */
 static struct em28xx_hash_table em28xx_eeprom_hash [] = {
        /* P/N: SA 60002070465 Tuner: TVF7533-MF */
        {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
@@ -463,17 +465,74 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = {
        {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
 };
 
+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;
+
+       if (command != XC2028_TUNER_RESET)
+               return 0;
+
+       if (dev->mode == EM28XX_ANALOG_MODE)
+               gpio = dev->analog_gpio;
+       else
+               gpio = dev->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);
+
+static void em28xx_set_model(struct em28xx *dev)
+{
+       dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
+       dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
+       dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
+       dev->decoder = em28xx_boards[dev->model].decoder;
+       dev->video_inputs = em28xx_boards[dev->model].vchannels;
+       dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
+       dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
+       dev->has_dvb = em28xx_boards[dev->model].has_dvb;
+}
+
 /* Since em28xx_pre_card_setup() requires a proper dev->model,
  * this won't work for boards with generic PCI IDs
  */
 void em28xx_pre_card_setup(struct em28xx *dev)
 {
+       em28xx_set_model(dev);
+
        /* request some modules */
        switch (dev->model) {
        case EM2880_BOARD_TERRATEC_PRODIGY_XS:
        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
-       case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
        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);
@@ -486,56 +545,36 @@ void em28xx_pre_card_setup(struct em28xx *dev)
                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;
+
                break;
        }
 }
 
-static int em28xx_tuner_callback(void *ptr, int command, int arg)
+void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
 {
-       int rc = 0;
-       struct em28xx *dev = ptr;
-
-       if (dev->tuner_type != TUNER_XC2028)
-               return 0;
-
-       switch (command) {
-       case XC2028_TUNER_RESET:
-       {
-               /* GPIO and initialization codes for analog TV and radio
-                  This code should be complemented for DTV, since reset
-                  codes are different.
-                */
-
-               dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
-               dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
+       memset(ctl, 0, sizeof(*ctl));
 
-               if (dev->analog_gpio) {
-                       char gpio0 = dev->analog_gpio & 0xff;
-                       char gpio1 = (dev->analog_gpio >> 8) & 0xff;
-                       char gpio4 = dev->analog_gpio >> 24;
-
-                       if (gpio4) {
-                               dev->em28xx_write_regs(dev, 0x04, &gpio4, 1);
-                               msleep(140);
-                       }
-
-                       msleep(6);
-                       dev->em28xx_write_regs(dev, 0x08, &gpio0, 1);
-                       msleep(10);
-                       dev->em28xx_write_regs(dev, 0x08, &gpio1, 1);
-                       msleep(5);
-               }
+       ctl->fname   = XC2028_DEFAULT_FIRMWARE;
+       ctl->max_len = 64;
+       ctl->mts = em28xx_boards[dev->model].mts_firmware;
 
+       switch (dev->model) {
+       /* Add card-specific parameters for xc3028 here */
+       case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
+               ctl->demod = XC3028_FE_DEFAULT;
                break;
+       default:
+               ctl->demod = XC3028_FE_OREN538;
        }
-       }
-       return rc;
 }
+EXPORT_SYMBOL_GPL(em28xx_setup_xc3028);
 
 static void em28xx_config_tuner(struct em28xx *dev)
 {
        struct v4l2_priv_tun_config  xc2028_cfg;
-       struct xc2028_ctrl           ctl;
        struct tuner_setup           tun_setup;
        struct v4l2_frequency        f;
 
@@ -550,11 +589,9 @@ static void em28xx_config_tuner(struct em28xx *dev)
        em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
 
        if (dev->tuner_type == TUNER_XC2028) {
-               memset(&ctl, 0, sizeof(ctl));
+               struct xc2028_ctrl           ctl;
 
-               ctl.fname   = XC2028_DEFAULT_FIRMWARE;
-               ctl.max_len = 64;
-               ctl.mts = em28xx_boards[dev->model].mts_firmware;
+               em28xx_setup_xc3028(dev, &ctl);
 
                xc2028_cfg.tuner = TUNER_XC2028;
                xc2028_cfg.priv  = &ctl;
@@ -652,19 +689,6 @@ static int em28xx_hint_board(struct em28xx *dev)
        return -1;
 }
 
-
-static void em28xx_set_model(struct em28xx *dev)
-{
-       dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
-       dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
-       dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
-       dev->decoder = em28xx_boards[dev->model].decoder;
-       dev->video_inputs = em28xx_boards[dev->model].vchannels;
-       dev->analog_gpio = em28xx_boards[dev->model].analog_gpio;
-       dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
-       dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
-}
-
 /* ----------------------------------------------------------------------- */
 void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
 {