2 tm6000-cards.c - driver for TM5600/TM6000/TM6010 USB video capture devices
4 Copyright (C) 2006-2007 Mauro Carvalho Chehab <mchehab@infradead.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation version 2
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <linux/init.h>
21 #include <linux/module.h>
22 #include <linux/pci.h>
23 #include <linux/delay.h>
24 #include <linux/i2c.h>
25 #include <linux/usb.h>
26 #include <linux/version.h>
27 #include <media/v4l2-common.h>
28 #include <media/tuner.h>
29 #include <media/tvaudio.h>
30 #include <media/i2c-addr.h>
33 #include "tm6000-regs.h"
34 #include "tuner-xc2028.h"
37 #define TM6000_BOARD_UNKNOWN 0
38 #define TM5600_BOARD_GENERIC 1
39 #define TM6000_BOARD_GENERIC 2
40 #define TM6010_BOARD_GENERIC 3
41 #define TM5600_BOARD_10MOONS_UT821 4
42 #define TM5600_BOARD_10MOONS_UT330 5
43 #define TM6000_BOARD_ADSTECH_DUAL_TV 6
44 #define TM6000_BOARD_FREECOM_AND_SIMILAR 7
45 #define TM6000_BOARD_ADSTECH_MINI_DUAL_TV 8
46 #define TM6010_BOARD_HAUPPAUGE_900H 9
47 #define TM6010_BOARD_BEHOLD_WANDER 10
48 #define TM6010_BOARD_BEHOLD_VOYAGER 11
49 #define TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE 12
50 #define TM6010_BOARD_TWINHAN_TU501 13
52 #define TM6000_MAXBOARDS 16
53 static unsigned int card[] = {[0 ... (TM6000_MAXBOARDS - 1)] = UNSET };
55 module_param_array(card, int, NULL, 0444);
57 static unsigned long tm6000_devused;
63 struct tm6000_capabilities caps;
65 enum tm6000_devtype type; /* variant of the chipset */
66 int tuner_type; /* type of the tuner */
67 int tuner_addr; /* tuner address */
68 int demod_addr; /* demodulator address */
70 struct tm6000_gpio gpio;
73 struct tm6000_board tm6000_boards[] = {
74 [TM6000_BOARD_UNKNOWN] = {
75 .name = "Unknown tm6000 video grabber",
80 .tuner_reset = TM6000_GPIO_1,
83 [TM5600_BOARD_GENERIC] = {
84 .name = "Generic tm5600 board",
86 .tuner_type = TUNER_XC2028,
87 .tuner_addr = 0xc2 >> 1,
92 .tuner_reset = TM6000_GPIO_1,
95 [TM6000_BOARD_GENERIC] = {
96 .name = "Generic tm6000 board",
97 .tuner_type = TUNER_XC2028,
98 .tuner_addr = 0xc2 >> 1,
104 .tuner_reset = TM6000_GPIO_1,
107 [TM6010_BOARD_GENERIC] = {
108 .name = "Generic tm6010 board",
110 .tuner_type = TUNER_XC2028,
111 .tuner_addr = 0xc2 >> 1,
112 .demod_addr = 0x1e >> 1,
121 .tuner_reset = TM6010_GPIO_2,
122 .tuner_on = TM6010_GPIO_3,
123 .demod_reset = TM6010_GPIO_1,
124 .demod_on = TM6010_GPIO_4,
125 .power_led = TM6010_GPIO_7,
126 .dvb_led = TM6010_GPIO_5,
130 [TM5600_BOARD_10MOONS_UT821] = {
131 .name = "10Moons UT 821",
132 .tuner_type = TUNER_XC2028,
134 .tuner_addr = 0xc2 >> 1,
140 .tuner_reset = TM6000_GPIO_1,
143 [TM5600_BOARD_10MOONS_UT330] = {
144 .name = "10Moons UT 330",
145 .tuner_type = TUNER_PHILIPS_FQ1216AME_MK4,
146 .tuner_addr = 0xc8 >> 1,
154 [TM6000_BOARD_ADSTECH_DUAL_TV] = {
155 .name = "ADSTECH Dual TV USB",
156 .tuner_type = TUNER_XC2028,
157 .tuner_addr = 0xc8 >> 1,
166 [TM6000_BOARD_FREECOM_AND_SIMILAR] = {
167 .name = "Freecom Hybrid Stick / Moka DVB-T Receiver Dual",
168 .tuner_type = TUNER_XC2028, /* has a XC3028 */
169 .tuner_addr = 0xc2 >> 1,
170 .demod_addr = 0x1e >> 1,
179 .tuner_reset = TM6000_GPIO_4,
182 [TM6000_BOARD_ADSTECH_MINI_DUAL_TV] = {
183 .name = "ADSTECH Mini Dual TV USB",
184 .tuner_type = TUNER_XC2028, /* has a XC3028 */
185 .tuner_addr = 0xc8 >> 1,
186 .demod_addr = 0x1e >> 1,
194 .tuner_reset = TM6000_GPIO_4,
197 [TM6010_BOARD_HAUPPAUGE_900H] = {
198 .name = "Hauppauge WinTV HVR-900H / WinTV USB2-Stick",
199 .tuner_type = TUNER_XC2028, /* has a XC3028 */
200 .tuner_addr = 0xc2 >> 1,
201 .demod_addr = 0x1e >> 1,
211 .tuner_reset = TM6010_GPIO_2,
212 .tuner_on = TM6010_GPIO_3,
213 .demod_reset = TM6010_GPIO_1,
214 .demod_on = TM6010_GPIO_4,
215 .power_led = TM6010_GPIO_7,
216 .dvb_led = TM6010_GPIO_5,
220 [TM6010_BOARD_BEHOLD_WANDER] = {
221 .name = "Beholder Wander DVB-T/TV/FM USB2.0",
222 .tuner_type = TUNER_XC5000,
223 .tuner_addr = 0xc2 >> 1,
224 .demod_addr = 0x1e >> 1,
234 .tuner_reset = TM6000_GPIO_2,
237 [TM6010_BOARD_BEHOLD_VOYAGER] = {
238 .name = "Beholder Voyager TV/FM USB2.0",
239 .tuner_type = TUNER_XC5000,
240 .tuner_addr = 0xc2 >> 1,
250 .tuner_reset = TM6000_GPIO_2,
253 [TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE] = {
254 .name = "Terratec Cinergy Hybrid XE / Cinergy Hybrid-Stick",
255 .tuner_type = TUNER_XC2028, /* has a XC3028 */
256 .tuner_addr = 0xc2 >> 1,
257 .demod_addr = 0x1e >> 1,
267 .tuner_reset = TM6010_GPIO_2,
268 .tuner_on = TM6010_GPIO_3,
269 .demod_reset = TM6010_GPIO_1,
270 .demod_on = TM6010_GPIO_4,
271 .power_led = TM6010_GPIO_7,
272 .dvb_led = TM6010_GPIO_5,
276 [TM6010_BOARD_TWINHAN_TU501] = {
277 .name = "Twinhan TU501(704D1)",
278 .tuner_type = TUNER_XC2028, /* has a XC3028 */
279 .tuner_addr = 0xc2 >> 1,
280 .demod_addr = 0x1e >> 1,
290 .tuner_reset = TM6010_GPIO_2,
291 .tuner_on = TM6010_GPIO_3,
292 .demod_reset = TM6010_GPIO_1,
293 .demod_on = TM6010_GPIO_4,
294 .power_led = TM6010_GPIO_7,
295 .dvb_led = TM6010_GPIO_5,
301 /* table of devices that work with this driver */
302 struct usb_device_id tm6000_id_table [] = {
303 { USB_DEVICE(0x6000, 0x0001), .driver_info = TM5600_BOARD_10MOONS_UT821 },
304 { USB_DEVICE(0x6000, 0x0002), .driver_info = TM6010_BOARD_GENERIC },
305 { USB_DEVICE(0x06e1, 0xf332), .driver_info = TM6000_BOARD_ADSTECH_DUAL_TV },
306 { USB_DEVICE(0x14aa, 0x0620), .driver_info = TM6000_BOARD_FREECOM_AND_SIMILAR },
307 { USB_DEVICE(0x06e1, 0xb339), .driver_info = TM6000_BOARD_ADSTECH_MINI_DUAL_TV },
308 { USB_DEVICE(0x2040, 0x6600), .driver_info = TM6010_BOARD_HAUPPAUGE_900H },
309 { USB_DEVICE(0x2040, 0x6601), .driver_info = TM6010_BOARD_HAUPPAUGE_900H },
310 { USB_DEVICE(0x2040, 0x6610), .driver_info = TM6010_BOARD_HAUPPAUGE_900H },
311 { USB_DEVICE(0x2040, 0x6611), .driver_info = TM6010_BOARD_HAUPPAUGE_900H },
312 { USB_DEVICE(0x6000, 0xdec0), .driver_info = TM6010_BOARD_BEHOLD_WANDER },
313 { USB_DEVICE(0x6000, 0xdec1), .driver_info = TM6010_BOARD_BEHOLD_VOYAGER },
314 { USB_DEVICE(0x0ccd, 0x0086), .driver_info = TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE },
315 { USB_DEVICE(0x0ccd, 0x00A5), .driver_info = TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE },
316 { USB_DEVICE(0x13d3, 0x3240), .driver_info = TM6010_BOARD_TWINHAN_TU501 },
317 { USB_DEVICE(0x13d3, 0x3241), .driver_info = TM6010_BOARD_TWINHAN_TU501 },
318 { USB_DEVICE(0x13d3, 0x3243), .driver_info = TM6010_BOARD_TWINHAN_TU501 },
319 { USB_DEVICE(0x13d3, 0x3264), .driver_info = TM6010_BOARD_TWINHAN_TU501 },
323 /* Tuner callback to provide the proper gpio changes needed for xc2028 */
325 int tm6000_tuner_callback(void *ptr, int component, int command, int arg)
328 struct tm6000_core *dev = ptr;
330 if (dev->tuner_type!=TUNER_XC2028)
334 case XC2028_RESET_CLK:
335 tm6000_set_reg (dev, REQ_04_EN_DISABLE_MCU_INT,
338 rc=tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
343 rc=tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
346 case XC2028_TUNER_RESET:
347 /* Reset codes during load firmware */
350 /* newer tuner can faster reset */
351 switch (dev->model) {
352 case TM5600_BOARD_10MOONS_UT821:
353 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
354 dev->gpio.tuner_reset, 0x01);
355 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
358 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
359 dev->gpio.tuner_reset, 0x00);
360 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
363 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
364 dev->gpio.tuner_reset, 0x01);
365 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
368 case TM6010_BOARD_HAUPPAUGE_900H:
369 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
370 case TM6010_BOARD_TWINHAN_TU501:
371 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
372 dev->gpio.tuner_reset, 0x01);
374 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
375 dev->gpio.tuner_reset, 0x00);
377 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
378 dev->gpio.tuner_reset, 0x01);
382 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
383 dev->gpio.tuner_reset, 0x00);
385 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
386 dev->gpio.tuner_reset, 0x01);
392 tm6000_set_reg (dev, REQ_04_EN_DISABLE_MCU_INT,
398 rc=tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
403 rc=tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
412 int tm6000_cards_setup(struct tm6000_core *dev)
417 * Board-specific initialization sequence. Handles all GPIO
418 * initialization sequences that are board-specific.
419 * Up to now, all found devices use GPIO1 and GPIO4 at the same way.
420 * Probably, they're all based on some reference device. Due to that,
421 * there's a common routine at the end to handle those GPIO's. Devices
422 * that use different pinups or init sequences can just return at
423 * the board-specific session.
425 switch (dev->model) {
426 case TM6010_BOARD_HAUPPAUGE_900H:
427 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
428 case TM6010_BOARD_TWINHAN_TU501:
429 case TM6010_BOARD_GENERIC:
430 /* Turn xceive 3028 on */
431 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.tuner_on, 0x01);
433 /* Turn zarlink zl10353 on */
434 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_on, 0x00);
436 /* Reset zarlink zl10353 */
437 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_reset, 0x00);
439 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_reset, 0x01);
441 /* Turn zarlink zl10353 off */
442 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_on, 0x01);
445 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.ir, 0x01);
447 /* Power led on (blue) */
448 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.power_led, 0x00);
450 /* DVB led off (orange) */
451 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.dvb_led, 0x01);
453 /* Turn zarlink zl10353 on */
454 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_on, 0x00);
462 * Default initialization. Most of the devices seem to use GPIO1
463 * and GPIO4.on the same way, so, this handles the common sequence
464 * used by most devices.
465 * If a device uses a different sequence or different GPIO pins for
466 * reset, just add the code at the board-specific part
468 for (i = 0; i < 2; i++) {
469 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
470 dev->gpio.tuner_reset, 0x00);
472 printk(KERN_ERR "Error %i doing GPIO1 reset\n", rc);
476 msleep(10); /* Just to be conservative */
477 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
478 dev->gpio.tuner_reset, 0x01);
480 printk(KERN_ERR "Error %i doing GPIO1 reset\n", rc);
485 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_4, 0);
487 printk(KERN_ERR "Error %i doing GPIO4 reset\n", rc);
492 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_4, 1);
494 printk(KERN_ERR "Error %i doing GPIO4 reset\n", rc);
499 rc = tm6000_get_reg32(dev, REQ_40_GET_VERSION, 0, 0);
501 printk(KERN_DEBUG "board=0x%08x\n", rc);
510 static void tm6000_config_tuner (struct tm6000_core *dev)
512 struct tuner_setup tun_setup;
514 /* Load tuner module */
515 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
516 "tuner", "tuner",dev->tuner_addr, NULL);
518 memset(&tun_setup, 0, sizeof(tun_setup));
519 tun_setup.type = dev->tuner_type;
520 tun_setup.addr = dev->tuner_addr;
521 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO | T_DIGITAL_TV;
522 tun_setup.tuner_callback = tm6000_tuner_callback;
524 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup);
526 if (dev->tuner_type == TUNER_XC2028) {
527 struct v4l2_priv_tun_config xc2028_cfg;
528 struct xc2028_ctrl ctl;
530 memset(&xc2028_cfg, 0, sizeof(xc2028_cfg));
531 memset (&ctl,0,sizeof(ctl));
534 ctl.read_not_reliable = 0;
536 ctl.demod = XC3028_FE_ZARLINK456;
539 xc2028_cfg.tuner = TUNER_XC2028;
540 xc2028_cfg.priv = &ctl;
543 case TM6010_BOARD_HAUPPAUGE_900H:
544 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
545 case TM6010_BOARD_TWINHAN_TU501:
546 ctl.fname = "xc3028L-v36.fw";
549 if (dev->dev_type == TM6010)
550 ctl.fname = "xc3028-v27.fw";
552 ctl.fname = "tm6000-xc3028.fw";
555 printk(KERN_INFO "Setting firmware parameters for xc2028\n");
557 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config,
562 static int tm6000_init_dev(struct tm6000_core *dev)
564 struct v4l2_frequency f;
567 mutex_init(&dev->lock);
569 mutex_lock(&dev->lock);
571 /* Initializa board-specific data */
572 dev->dev_type = tm6000_boards[dev->model].type;
573 dev->tuner_type = tm6000_boards[dev->model].tuner_type;
574 dev->tuner_addr = tm6000_boards[dev->model].tuner_addr;
576 dev->gpio = tm6000_boards[dev->model].gpio;
578 dev->demod_addr = tm6000_boards[dev->model].demod_addr;
580 dev->caps = tm6000_boards[dev->model].caps;
582 /* initialize hardware */
583 rc=tm6000_init (dev);
587 rc = v4l2_device_register(&dev->udev->dev, &dev->v4l2_dev);
591 /* register i2c bus */
592 rc=tm6000_i2c_register(dev);
596 /* Default values for STD and resolutions */
599 dev->norm = V4L2_STD_PAL_M;
601 /* Configure tuner */
602 tm6000_config_tuner (dev);
604 /* Set video standard */
605 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm);
607 /* Set tuner frequency - also loads firmware on xc2028/xc3028 */
609 f.type = V4L2_TUNER_ANALOG_TV;
610 f.frequency = 3092; /* 193.25 MHz */
611 dev->freq = f.frequency;
612 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
614 if (dev->caps.has_tda9874)
615 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
616 "tvaudio", "tvaudio", I2C_ADDR_TDA9874, NULL);
618 /* register and initialize V4L2 */
619 rc=tm6000_v4l2_register(dev);
623 if(dev->caps.has_dvb) {
624 dev->dvb = kzalloc(sizeof(*(dev->dvb)), GFP_KERNEL);
630 #ifdef CONFIG_VIDEO_TM6000_DVB
631 rc = tm6000_dvb_register(dev);
639 mutex_unlock(&dev->lock);
643 v4l2_device_unregister(&dev->v4l2_dev);
646 mutex_unlock(&dev->lock);
650 /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
651 #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
653 static void get_max_endpoint ( struct usb_device *usbdev,
655 struct usb_host_endpoint *curr_e,
656 unsigned int *maxsize,
657 struct usb_host_endpoint **ep )
659 u16 tmp = le16_to_cpu(curr_e->desc.wMaxPacketSize);
660 unsigned int size = tmp & 0x7ff;
662 if (usbdev->speed == USB_SPEED_HIGH)
663 size = size * hb_mult (tmp);
668 printk("tm6000: %s endpoint: 0x%02x (max size=%u bytes)\n",
669 msgtype, curr_e->desc.bEndpointAddress,
676 * checks for supported devices
678 static int tm6000_usb_probe(struct usb_interface *interface,
679 const struct usb_device_id *id)
681 struct usb_device *usbdev;
682 struct tm6000_core *dev = NULL;
688 usbdev=usb_get_dev(interface_to_usbdev(interface));
690 /* Selects the proper interface */
691 rc=usb_set_interface(usbdev,0,1);
695 /* Check to see next free device and mark as used */
696 nr=find_first_zero_bit(&tm6000_devused,TM6000_MAXBOARDS);
697 if (nr >= TM6000_MAXBOARDS) {
698 printk ("tm6000: Supports only %i tm60xx boards.\n",TM6000_MAXBOARDS);
703 /* Create and initialize dev struct */
704 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
706 printk ("tm6000" ": out of memory!\n");
710 spin_lock_init(&dev->slock);
712 /* Increment usage count */
713 tm6000_devused|=1<<nr;
714 snprintf(dev->name, 29, "tm6000 #%d", nr);
716 dev->model=id->driver_info;
717 if ((card[nr]>=0) && (card[nr]<ARRAY_SIZE(tm6000_boards))) {
721 INIT_LIST_HEAD(&dev->tm6000_corelist);
725 switch (usbdev->speed) {
729 case USB_SPEED_UNKNOWN:
743 for (i = 0; i < interface->num_altsetting; i++) {
746 for (ep = 0; ep < interface->altsetting[i].desc.bNumEndpoints; ep++) {
747 struct usb_host_endpoint *e;
750 e = &interface->altsetting[i].endpoint[ep];
752 dir_out = ((e->desc.bEndpointAddress &
753 USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
755 printk("tm6000: alt %d, interface %i, class %i\n",
757 interface->altsetting[i].desc.bInterfaceNumber,
758 interface->altsetting[i].desc.bInterfaceClass);
760 switch (e->desc.bmAttributes) {
761 case USB_ENDPOINT_XFER_BULK:
763 get_max_endpoint (usbdev, "Bulk IN", e,
767 get_max_endpoint (usbdev, "Bulk OUT", e,
772 case USB_ENDPOINT_XFER_ISOC:
774 get_max_endpoint (usbdev, "ISOC IN", e,
778 get_max_endpoint (usbdev, "ISOC OUT", e,
788 printk("tm6000: New video device @ %s Mbps (%04x:%04x, ifnum %d)\n",
790 le16_to_cpu(dev->udev->descriptor.idVendor),
791 le16_to_cpu(dev->udev->descriptor.idProduct),
792 interface->altsetting->desc.bInterfaceNumber);
794 /* check if the the device has the iso in endpoint at the correct place */
796 printk("tm6000: probing error: no IN ISOC endpoint!\n");
802 /* save our data pointer in this interface device */
803 usb_set_intfdata(interface, dev);
805 printk("tm6000: Found %s\n", tm6000_boards[dev->model].name);
807 rc=tm6000_init_dev(dev);
815 printk("tm6000: Error %d while registering\n", rc);
817 tm6000_devused&=~(1<<nr);
825 * tm6000_usb_disconnect()
826 * called when the device gets diconencted
827 * video device will be unregistered on v4l2_close in case it is still open
829 static void tm6000_usb_disconnect(struct usb_interface *interface)
831 struct tm6000_core *dev = usb_get_intfdata(interface);
832 usb_set_intfdata(interface, NULL);
837 printk("tm6000: disconnecting %s\n", dev->name);
839 mutex_lock(&dev->lock);
841 #ifdef CONFIG_VIDEO_TM6000_DVB
843 tm6000_dvb_unregister(dev);
848 tm6000_v4l2_unregister(dev);
850 tm6000_i2c_unregister(dev);
852 v4l2_device_unregister(&dev->v4l2_dev);
854 // wake_up_interruptible_all(&dev->open);
856 dev->state |= DEV_DISCONNECTED;
858 usb_put_dev(dev->udev);
860 mutex_unlock(&dev->lock);
864 static struct usb_driver tm6000_usb_driver = {
866 .probe = tm6000_usb_probe,
867 .disconnect = tm6000_usb_disconnect,
868 .id_table = tm6000_id_table,
871 static int __init tm6000_module_init(void)
875 printk(KERN_INFO "tm6000" " v4l2 driver version %d.%d.%d loaded\n",
876 (TM6000_VERSION >> 16) & 0xff,
877 (TM6000_VERSION >> 8) & 0xff, TM6000_VERSION & 0xff);
879 /* register this driver with the USB subsystem */
880 result = usb_register(&tm6000_usb_driver);
883 " usb_register failed. Error number %d.\n", result);
888 static void __exit tm6000_module_exit(void)
890 /* deregister at USB subsystem */
891 usb_deregister(&tm6000_usb_driver);
894 module_init(tm6000_module_init);
895 module_exit(tm6000_module_exit);
897 MODULE_DESCRIPTION("Trident TVMaster TM5600/TM6000/TM6010 USB2 adapter");
898 MODULE_AUTHOR("Mauro Carvalho Chehab");
899 MODULE_LICENSE("GPL");