]> Pileus Git - ~andy/linux/blobdiff - drivers/media/video/em28xx/em28xx-cards.c
[media] em28xx: Make em28xx-input.c a separate module
[~andy/linux] / drivers / media / video / em28xx / em28xx-cards.c
index 4561cd89938de422ff268b64d5a2734d27873daa..0ac117c23c47ca1d06d5ed19a46a0db7c68b93da 100644 (file)
@@ -353,6 +353,44 @@ static struct em28xx_reg_seq hauppauge_930c_digital[] = {
 };
 #endif
 
+/* 1b80:e425 MaxMedia UB425-TC
+ * GPIO_6 - demod reset, 0=active
+ * GPIO_7 - LED, 0=active
+ */
+static struct em28xx_reg_seq maxmedia_ub425_tc[] = {
+       {EM2874_R80_GPIO,  0x83,  0xff,  100},
+       {EM2874_R80_GPIO,  0xc3,  0xff,  100}, /* GPIO_6 = 1 */
+       {EM2874_R80_GPIO,  0x43,  0xff,  000}, /* GPIO_7 = 0 */
+       {-1,                 -1,    -1,   -1},
+};
+
+/* 2304:0242 PCTV QuatroStick (510e)
+ * GPIO_2: decoder reset, 0=active
+ * GPIO_4: decoder suspend, 0=active
+ * GPIO_6: demod reset, 0=active
+ * GPIO_7: LED, 1=active
+ */
+static struct em28xx_reg_seq pctv_510e[] = {
+       {EM2874_R80_GPIO, 0x10, 0xff, 100},
+       {EM2874_R80_GPIO, 0x14, 0xff, 100}, /* GPIO_2 = 1 */
+       {EM2874_R80_GPIO, 0x54, 0xff, 050}, /* GPIO_6 = 1 */
+       {             -1,   -1,   -1,  -1},
+};
+
+/* 2013:0251 PCTV QuatroStick nano (520e)
+ * GPIO_2: decoder reset, 0=active
+ * GPIO_4: decoder suspend, 0=active
+ * GPIO_6: demod reset, 0=active
+ * GPIO_7: LED, 1=active
+ */
+static struct em28xx_reg_seq pctv_520e[] = {
+       {EM2874_R80_GPIO, 0x10, 0xff, 100},
+       {EM2874_R80_GPIO, 0x14, 0xff, 100}, /* GPIO_2 = 1 */
+       {EM2874_R80_GPIO, 0x54, 0xff, 050}, /* GPIO_6 = 1 */
+       {EM2874_R80_GPIO, 0xd4, 0xff, 000}, /* GPIO_7 = 1 */
+       {             -1,   -1,   -1,  -1},
+};
+
 /*
  *  Board definitions
  */
@@ -1908,6 +1946,41 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_LINE_IN,
                } },
        },
+       /* 1b80:e425 MaxMedia UB425-TC
+        * Empia EM2874B + Micronas DRX 3913KA2 + NXP TDA18271HDC2 */
+       [EM2874_BOARD_MAXMEDIA_UB425_TC] = {
+               .name          = "MaxMedia UB425-TC",
+               .tuner_type    = TUNER_ABSENT,
+               .tuner_gpio    = maxmedia_ub425_tc,
+               .has_dvb       = 1,
+               .i2c_speed     = EM2874_I2C_SECONDARY_BUS_SELECT |
+                               EM28XX_I2C_CLK_WAIT_ENABLE |
+                               EM28XX_I2C_FREQ_400_KHZ,
+       },
+       /* 2304:0242 PCTV QuatroStick (510e)
+        * Empia EM2884 + Micronas DRX 3926K + NXP TDA18271HDC2 */
+       [EM2884_BOARD_PCTV_510E] = {
+               .name          = "PCTV QuatroStick (510e)",
+               .tuner_type    = TUNER_ABSENT,
+               .tuner_gpio    = pctv_510e,
+               .has_dvb       = 1,
+               .ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
+               .i2c_speed     = EM2874_I2C_SECONDARY_BUS_SELECT |
+                               EM28XX_I2C_CLK_WAIT_ENABLE |
+                               EM28XX_I2C_FREQ_400_KHZ,
+       },
+       /* 2013:0251 PCTV QuatroStick nano (520e)
+        * Empia EM2884 + Micronas DRX 3926K + NXP TDA18271HDC2 */
+       [EM2884_BOARD_PCTV_520E] = {
+               .name          = "PCTV QuatroStick nano (520e)",
+               .tuner_type    = TUNER_ABSENT,
+               .tuner_gpio    = pctv_520e,
+               .has_dvb       = 1,
+               .ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
+               .i2c_speed     = EM2874_I2C_SECONDARY_BUS_SELECT |
+                               EM28XX_I2C_CLK_WAIT_ENABLE |
+                               EM28XX_I2C_FREQ_400_KHZ,
+       },
 };
 const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
 
@@ -2059,6 +2132,12 @@ struct usb_device_id em28xx_id_table[] = {
                        .driver_info = EM2860_BOARD_HT_VIDBOX_NW03 },
        { USB_DEVICE(0x1b80, 0xe309), /* Sveon STV40 */
                        .driver_info = EM2860_BOARD_EASYCAP },
+       { USB_DEVICE(0x1b80, 0xe425),
+                       .driver_info = EM2874_BOARD_MAXMEDIA_UB425_TC },
+       { USB_DEVICE(0x2304, 0x0242),
+                       .driver_info = EM2884_BOARD_PCTV_510E },
+       { USB_DEVICE(0x2013, 0x0251),
+                       .driver_info = EM2884_BOARD_PCTV_520E },
        { },
 };
 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
@@ -2582,54 +2661,6 @@ static int em28xx_hint_board(struct em28xx *dev)
        return -1;
 }
 
-/* ----------------------------------------------------------------------- */
-void em28xx_register_i2c_ir(struct em28xx *dev)
-{
-       /* Leadtek winfast tv USBII deluxe can find a non working IR-device */
-       /* at address 0x18, so if that address is needed for another board in */
-       /* the future, please put it after 0x1f. */
-       struct i2c_board_info info;
-       const unsigned short addr_list[] = {
-                0x1f, 0x30, 0x47, I2C_CLIENT_END
-       };
-
-       if (disable_ir)
-               return;
-
-       memset(&info, 0, sizeof(struct i2c_board_info));
-       memset(&dev->init_data, 0, sizeof(dev->init_data));
-       strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
-
-       /* detect & configure */
-       switch (dev->model) {
-       case EM2800_BOARD_TERRATEC_CINERGY_200:
-       case EM2820_BOARD_TERRATEC_CINERGY_250:
-               dev->init_data.ir_codes = RC_MAP_EM_TERRATEC;
-               dev->init_data.get_key = em28xx_get_key_terratec;
-               dev->init_data.name = "i2c IR (EM28XX Terratec)";
-               break;
-       case EM2820_BOARD_PINNACLE_USB_2:
-               dev->init_data.ir_codes = RC_MAP_PINNACLE_GREY;
-               dev->init_data.get_key = em28xx_get_key_pinnacle_usb_grey;
-               dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)";
-               break;
-       case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
-               dev->init_data.ir_codes = RC_MAP_HAUPPAUGE;
-               dev->init_data.get_key = em28xx_get_key_em_haup;
-               dev->init_data.name = "i2c IR (EM2840 Hauppauge)";
-               break;
-       case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE:
-               dev->init_data.ir_codes = RC_MAP_WINFAST_USBII_DELUXE;
-               dev->init_data.get_key = em28xx_get_key_winfast_usbii_deluxe;
-               dev->init_data.name = "i2c IR (EM2820 Winfast TV USBII Deluxe)";
-               break;
-       }
-
-       if (dev->init_data.name)
-               info.platform_data = &dev->init_data;
-       i2c_new_probed_device(&dev->i2c_adap, &info, addr_list, NULL);
-}
-
 void em28xx_card_setup(struct em28xx *dev)
 {
        /*
@@ -2770,13 +2801,6 @@ void em28xx_card_setup(struct em28xx *dev)
                break;
        }
 
-#if defined(CONFIG_MODULES) && defined(MODULE)
-       if (dev->board.has_ir_i2c && !disable_ir)
-               request_module("ir-kbd-i2c");
-#endif
-       if (dev->board.has_snapshot_button)
-               em28xx_register_snapshot_button(dev);
-
        if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
                em28xx_errdev("\n\n");
                em28xx_errdev("The support for this board weren't "
@@ -2850,9 +2874,6 @@ void em28xx_card_setup(struct em28xx *dev)
        }
 
        em28xx_tuner_setup(dev);
-
-       if(!disable_ir)
-               em28xx_ir_init(dev);
 }
 
 
@@ -2869,6 +2890,8 @@ static void request_module_async(struct work_struct *work)
 
        if (dev->board.has_dvb)
                request_module("em28xx-dvb");
+       if (dev->board.has_ir_i2c && !disable_ir)
+               request_module("em28xx-rc");
 }
 
 static void request_modules(struct em28xx *dev)
@@ -2893,12 +2916,6 @@ static void flush_request_modules(struct em28xx *dev)
 */
 void em28xx_release_resources(struct em28xx *dev)
 {
-       if (dev->sbutton_input_dev)
-               em28xx_deregister_snapshot_button(dev);
-
-       if (dev->ir)
-               em28xx_ir_fini(dev);
-
        /*FIXME: I2C IR should be disconnected */
 
        em28xx_release_analog_resources(dev);
@@ -3122,7 +3139,6 @@ static int em28xx_usb_probe(struct usb_interface *interface,
        int i, nr;
        const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
        char *speed;
-       char descr[255] = "";
 
        udev = usb_get_dev(interface_to_usbdev(interface));
 
@@ -3227,21 +3243,11 @@ static int em28xx_usb_probe(struct usb_interface *interface,
                speed = "unknown";
        }
 
-       if (udev->manufacturer)
-               strlcpy(descr, udev->manufacturer, sizeof(descr));
-
-       if (udev->product) {
-               if (*descr)
-                       strlcat(descr, " ", sizeof(descr));
-               strlcat(descr, udev->product, sizeof(descr));
-       }
-
-       if (*descr)
-               strlcat(descr, " ", sizeof(descr));
-
        printk(KERN_INFO DRIVER_NAME
-               ": New device %s@ %s Mbps (%04x:%04x, interface %d, class %d)\n",
-               descr,
+               ": New device %s %s @ %s Mbps "
+               "(%04x:%04x, interface %d, class %d)\n",
+               udev->manufacturer ? udev->manufacturer : "",
+               udev->product ? udev->product : "",
                speed,
                le16_to_cpu(udev->descriptor.idVendor),
                le16_to_cpu(udev->descriptor.idProduct),
@@ -3307,6 +3313,17 @@ static int em28xx_usb_probe(struct usb_interface *interface,
                goto unlock_and_free;
        }
 
+       if (has_dvb) {
+               /* pre-allocate DVB isoc transfer buffers */
+               retval = em28xx_alloc_isoc(dev, EM28XX_DIGITAL_MODE,
+                                          EM28XX_DVB_MAX_PACKETS,
+                                          EM28XX_DVB_NUM_BUFS,
+                                          dev->dvb_max_pkt_size);
+               if (retval) {
+                       goto unlock_and_free;
+               }
+       }
+
        request_modules(dev);
 
        /* Should be the last thing to do, to avoid newer udev's to
@@ -3379,7 +3396,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
                     video_device_node_name(dev->vdev));
 
                dev->state |= DEV_MISCONFIGURED;
-               em28xx_uninit_isoc(dev);
+               em28xx_uninit_isoc(dev, dev->mode);
                dev->state |= DEV_DISCONNECTED;
                wake_up_interruptible(&dev->wait_frame);
                wake_up_interruptible(&dev->wait_stream);
@@ -3388,6 +3405,9 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
                em28xx_release_resources(dev);
        }
 
+       /* free DVB isoc buffers */
+       em28xx_uninit_isoc(dev, EM28XX_DIGITAL_MODE);
+
        mutex_unlock(&dev->lock);
 
        em28xx_close_extension(dev);