V4L/DVB (13403): Add new TV cards of Beholder
[pandora-kernel.git] / drivers / staging / tm6000 / tm6000-cards.c
1 /*
2    tm6000-cards.c - driver for TM5600/TM6000 USB video capture devices
3
4    Copyright (C) 2006-2007 Mauro Carvalho Chehab <mchehab@infradead.org>
5
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
9
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.
14
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.
18  */
19
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>
31
32 #include "tm6000.h"
33 #include "tm6000-regs.h"
34 #include "tuner-xc2028.h"
35 #include "tuner-xc5000.h"
36
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
48 #define TM6000_MAXBOARDS        16
49 static unsigned int card[]     = {[0 ... (TM6000_MAXBOARDS - 1)] = UNSET };
50
51 module_param_array(card,  int, NULL, 0444);
52
53 static unsigned long tm6000_devused;
54
55
56 struct tm6000_board {
57         char            *name;
58
59         struct tm6000_capabilities caps;
60
61         enum            tm6000_devtype type;    /* variant of the chipset */
62         int             tuner_type;     /* type of the tuner */
63         int             tuner_addr;     /* tuner address */
64         int             demod_addr;     /* demodulator address */
65         int             gpio_addr_tun_reset;    /* GPIO used for tuner reset */
66 };
67
68 struct tm6000_board tm6000_boards[] = {
69         [TM6000_BOARD_UNKNOWN] = {
70                 .name         = "Unknown tm6000 video grabber",
71                 .caps = {
72                         .has_tuner    = 1,
73                 },
74                 .gpio_addr_tun_reset = TM6000_GPIO_1,
75         },
76         [TM5600_BOARD_GENERIC] = {
77                 .name         = "Generic tm5600 board",
78                 .type         = TM5600,
79                 .tuner_type   = TUNER_XC2028,
80                 .tuner_addr   = 0xc2 >> 1,
81                 .caps = {
82                         .has_tuner      = 1,
83                 },
84                 .gpio_addr_tun_reset = TM6000_GPIO_1,
85         },
86         [TM6000_BOARD_GENERIC] = {
87                 .name         = "Generic tm6000 board",
88                 .tuner_type   = TUNER_XC2028,
89                 .tuner_addr   = 0xc2 >> 1,
90                 .caps = {
91                         .has_tuner      = 1,
92                         .has_dvb        = 1,
93                 },
94                 .gpio_addr_tun_reset = TM6000_GPIO_1,
95         },
96         [TM6010_BOARD_GENERIC] = {
97                 .name         = "Generic tm6010 board",
98                 .type         = TM6010,
99                 .tuner_type   = TUNER_XC2028,
100                 .tuner_addr   = 0xc2 >> 1,
101                 .caps = {
102                         .has_tuner      = 1,
103                         .has_dvb        = 1,
104                 },
105                 .gpio_addr_tun_reset = TM6010_GPIO_4,
106         },
107         [TM5600_BOARD_10MOONS_UT821] = {
108                 .name         = "10Moons UT 821",
109                 .tuner_type   = TUNER_XC2028,
110                 .type         = TM5600,
111                 .tuner_addr   = 0xc2 >> 1,
112                 .caps = {
113                         .has_tuner    = 1,
114                         .has_eeprom   = 1,
115                 },
116                 .gpio_addr_tun_reset = TM6000_GPIO_1,
117         },
118         [TM5600_BOARD_10MOONS_UT330] = {
119                 .name         = "10Moons UT 330",
120                 .tuner_type   = TUNER_PHILIPS_FQ1216AME_MK4,
121                 .tuner_addr   = 0xc8 >> 1,
122                 .caps = {
123                         .has_tuner    = 1,
124                         .has_dvb      = 0,
125                         .has_zl10353  = 0,
126                         .has_eeprom   = 1,
127                 },
128         },
129         [TM6000_BOARD_ADSTECH_DUAL_TV] = {
130                 .name         = "ADSTECH Dual TV USB",
131                 .tuner_type   = TUNER_XC2028,
132                 .tuner_addr   = 0xc8 >> 1,
133                 .caps = {
134                         .has_tuner    = 1,
135                         .has_tda9874  = 1,
136                         .has_dvb      = 1,
137                         .has_zl10353  = 1,
138                         .has_eeprom   = 1,
139                 },
140         },
141         [TM6000_BOARD_FREECOM_AND_SIMILAR] = {
142                 .name         = "Freecom Hybrid Stick / Moka DVB-T Receiver Dual",
143                 .tuner_type   = TUNER_XC2028, /* has a XC3028 */
144                 .tuner_addr   = 0xc2 >> 1,
145                 .demod_addr   = 0x1e >> 1,
146                 .caps = {
147                         .has_tuner    = 1,
148                         .has_dvb      = 1,
149                         .has_zl10353  = 1,
150                         .has_eeprom   = 0,
151                         .has_remote   = 1,
152                 },
153                 .gpio_addr_tun_reset = TM6000_GPIO_4,
154         },
155         [TM6000_BOARD_ADSTECH_MINI_DUAL_TV] = {
156                 .name         = "ADSTECH Mini Dual TV USB",
157                 .tuner_type   = TUNER_XC2028, /* has a XC3028 */
158                 .tuner_addr   = 0xc8 >> 1,
159                 .demod_addr   = 0x1e >> 1,
160                 .caps = {
161                         .has_tuner    = 1,
162                         .has_dvb      = 1,
163                         .has_zl10353  = 1,
164                         .has_eeprom   = 0,
165                 },
166                 .gpio_addr_tun_reset = TM6000_GPIO_4,
167         },
168         [TM6010_BOARD_HAUPPAUGE_900H] = {
169                 .name         = "Hauppauge HVR-900H",
170                 .tuner_type   = TUNER_XC2028, /* has a XC3028 */
171                 .tuner_addr   = 0xc2 >> 1,
172                 .demod_addr   = 0x1e >> 1,
173                 .type         = TM6010,
174                 .caps = {
175                         .has_tuner    = 1,
176                         .has_dvb      = 1,
177                         .has_zl10353  = 1,
178                         .has_eeprom   = 1,
179                 },
180                 .gpio_addr_tun_reset = TM6000_GPIO_2,
181         },
182         [TM6010_BOARD_BEHOLD_WANDER] = {
183                 .name         = "Beholder Wander DVB-T/TV/FM USB2.0",
184                 .tuner_type   = TUNER_XC5000,
185                 .tuner_addr   = 0xc2 >> 1,
186                 .demod_addr   = 0x1e >> 1,
187                 .type         = TM6010,
188                 .caps = {
189                         .has_tuner    = 1,
190                         .has_dvb      = 1,
191                         .has_zl10353  = 1,
192                         .has_eeprom   = 1,
193                         .has_remote   = 1,
194                 },
195                 .gpio_addr_tun_reset = TM6000_GPIO_2,
196         },
197         [TM6010_BOARD_BEHOLD_VOYAGER] = {
198                 .name         = "Beholder Voyager TV/FM USB2.0",
199                 .tuner_type   = TUNER_XC5000,
200                 .tuner_addr   = 0xc2 >> 1,
201                 .type         = TM6010,
202                 .caps = {
203                         .has_tuner    = 1,
204                         .has_dvb      = 0,
205                         .has_zl10353  = 0,
206                         .has_eeprom   = 1,
207                         .has_remote   = 1,
208                 },
209                 .gpio_addr_tun_reset = TM6000_GPIO_2,
210         },
211
212 };
213
214 /* table of devices that work with this driver */
215 struct usb_device_id tm6000_id_table [] = {
216         { USB_DEVICE(0x6000, 0x0001), .driver_info = TM5600_BOARD_10MOONS_UT821 },
217         { USB_DEVICE(0x6000, 0x0002), .driver_info = TM6010_BOARD_GENERIC },
218         { USB_DEVICE(0x06e1, 0xf332), .driver_info = TM6000_BOARD_ADSTECH_DUAL_TV },
219         { USB_DEVICE(0x14aa, 0x0620), .driver_info = TM6000_BOARD_FREECOM_AND_SIMILAR },
220         { USB_DEVICE(0x06e1, 0xb339), .driver_info = TM6000_BOARD_ADSTECH_MINI_DUAL_TV },
221         { USB_DEVICE(0x2040, 0x6600), .driver_info = TM6010_BOARD_HAUPPAUGE_900H },
222         { USB_DEVICE(0x6000, 0xdec0), .driver_info = TM6010_BOARD_BEHOLD_WANDER },
223         { USB_DEVICE(0x6000, 0xdec1), .driver_info = TM6010_BOARD_BEHOLD_VOYAGER },
224         { },
225 };
226
227 /* Tuner callback to provide the proper gpio changes needed for xc2028 */
228
229 static int tm6000_tuner_callback(void *ptr, int component, int command, int arg)
230 {
231         int rc=0;
232         struct tm6000_core *dev = ptr;
233
234         if (dev->tuner_type!=TUNER_XC2028)
235                 return 0;
236
237         switch (command) {
238         case XC2028_RESET_CLK:
239                 tm6000_set_reg (dev, REQ_04_EN_DISABLE_MCU_INT,
240                                         0x02, arg);
241                 msleep(10);
242                 rc=tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
243                                         TM6000_GPIO_CLK, 0);
244                 if (rc<0)
245                         return rc;
246                 msleep(10);
247                 rc=tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
248                                         TM6000_GPIO_CLK, 1);
249                 break;
250         case XC2028_TUNER_RESET:
251                 /* Reset codes during load firmware */
252                 switch (arg) {
253                 case 0:
254                         tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
255                                         dev->tuner_reset_gpio, 0x00);
256                         msleep(130);
257                         tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
258                                         dev->tuner_reset_gpio, 0x01);
259                         msleep(130);
260                         break;
261                 case 1:
262                         tm6000_set_reg (dev, REQ_04_EN_DISABLE_MCU_INT,
263                                                 0x02, 0x01);
264                         msleep(10);
265                         break;
266
267                 case 2:
268                         rc=tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
269                                                 TM6000_GPIO_CLK, 0);
270                         if (rc<0)
271                                 return rc;
272                         msleep(100);
273                         rc=tm6000_set_reg (dev, REQ_03_SET_GET_MCU_PIN,
274                                                 TM6000_GPIO_CLK, 1);
275                         msleep(100);
276                         break;
277                 }
278         }
279         return (rc);
280 }
281
282 static void tm6000_config_tuner (struct tm6000_core *dev)
283 {
284         struct tuner_setup           tun_setup;
285
286         /* Load tuner module */
287         v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
288                 "tuner", "tuner",dev->tuner_addr, NULL);
289
290         memset(&tun_setup, 0, sizeof(tun_setup));
291         tun_setup.type   = dev->tuner_type;
292         tun_setup.addr   = dev->tuner_addr;
293         tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
294         tun_setup.tuner_callback = tm6000_tuner_callback;
295
296         v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup);
297
298         if (dev->tuner_type == TUNER_XC2028) {
299                 struct v4l2_priv_tun_config  xc2028_cfg;
300                 struct xc2028_ctrl           ctl;
301
302                 memset(&xc2028_cfg, 0, sizeof(xc2028_cfg));
303                 memset (&ctl,0,sizeof(ctl));
304
305                 ctl.mts   = 1;
306                 ctl.read_not_reliable = 1;
307                 ctl.msleep = 10;
308
309                 xc2028_cfg.tuner = TUNER_XC2028;
310                 xc2028_cfg.priv  = &ctl;
311
312                 switch(dev->model) {
313                 case TM6010_BOARD_HAUPPAUGE_900H:
314                         ctl.fname = "xc3028L-v36.fw";
315                         break;
316                 default:
317                         if (dev->dev_type == TM6010)
318                                 ctl.fname = "xc3028-v27.fw";
319                         else
320                                 ctl.fname = "tm6000-xc3028.fw";
321                 }
322
323                 printk(KERN_INFO "Setting firmware parameters for xc2028\n");
324
325                 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config,
326                                      &xc2028_cfg);
327         }
328 }
329
330 static int tm6000_init_dev(struct tm6000_core *dev)
331 {
332         struct v4l2_frequency f;
333         int rc = 0;
334
335         mutex_init(&dev->lock);
336
337         mutex_lock(&dev->lock);
338
339         /* Initializa board-specific data */
340         dev->dev_type   = tm6000_boards[dev->model].type;
341         dev->tuner_type = tm6000_boards[dev->model].tuner_type;
342         dev->tuner_addr = tm6000_boards[dev->model].tuner_addr;
343         dev->tuner_reset_gpio = tm6000_boards[dev->model].gpio_addr_tun_reset;
344
345         dev->demod_addr = tm6000_boards[dev->model].demod_addr;
346
347         dev->caps = tm6000_boards[dev->model].caps;
348
349         /* initialize hardware */
350         rc=tm6000_init (dev);
351         if (rc<0)
352                 goto err;
353
354         rc = v4l2_device_register(&dev->udev->dev, &dev->v4l2_dev);
355         if (rc < 0)
356                 goto err;
357
358         /* register i2c bus */
359         rc=tm6000_i2c_register(dev);
360         if (rc<0)
361                 goto err;
362
363         /* register and initialize V4L2 */
364         rc=tm6000_v4l2_register(dev);
365         if (rc<0)
366                 goto err;
367
368         /* Default values for STD and resolutions */
369         dev->width = 720;
370         dev->height = 480;
371         dev->norm = V4L2_STD_PAL_M;
372
373         /* Configure tuner */
374         tm6000_config_tuner (dev);
375
376         /* Set video standard */
377         v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm);
378
379         /* Set tuner frequency - also loads firmware on xc2028/xc3028 */
380         f.tuner = 0;
381         f.type = V4L2_TUNER_ANALOG_TV;
382         f.frequency = 3092;     /* 193.25 MHz */
383         dev->freq = f.frequency;
384         v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
385
386         if (dev->caps.has_tda9874)
387                 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
388                         "tvaudio", "tvaudio", I2C_ADDR_TDA9874, NULL);
389
390         if(dev->caps.has_dvb) {
391                 dev->dvb = kzalloc(sizeof(*(dev->dvb)), GFP_KERNEL);
392                 if(!dev->dvb) {
393                         rc = -ENOMEM;
394                         goto err2;
395                 }
396 #ifdef CONFIG_VIDEO_TM6000_DVB
397                 rc = tm6000_dvb_register(dev);
398                 if(rc < 0) {
399                         kfree(dev->dvb);
400                         dev->dvb = NULL;
401                         goto err2;
402                 }
403 #endif
404         }
405
406 err2:
407         v4l2_device_unregister(&dev->v4l2_dev);
408
409 err:
410         mutex_unlock(&dev->lock);
411         return rc;
412 }
413
414 /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
415 #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
416
417 static void get_max_endpoint (  struct usb_device *usbdev,
418                                 char *msgtype,
419                                 struct usb_host_endpoint *curr_e,
420                                 unsigned int *maxsize,
421                                 struct usb_host_endpoint **ep  )
422 {
423         u16 tmp = le16_to_cpu(curr_e->desc.wMaxPacketSize);
424         unsigned int size = tmp & 0x7ff;
425
426         if (usbdev->speed == USB_SPEED_HIGH)
427                 size = size * hb_mult (tmp);
428
429         if (size>*maxsize) {
430                 *ep = curr_e;
431                 *maxsize = size;
432                 printk("tm6000: %s endpoint: 0x%02x (max size=%u bytes)\n",
433                                         msgtype, curr_e->desc.bEndpointAddress,
434                                         size);
435         }
436 }
437
438 /*
439  * tm6000_usb_probe()
440  * checks for supported devices
441  */
442 static int tm6000_usb_probe(struct usb_interface *interface,
443                             const struct usb_device_id *id)
444 {
445         struct usb_device *usbdev;
446         struct tm6000_core *dev = NULL;
447         int i,rc=0;
448         int nr=0;
449         char *speed;
450
451
452         usbdev=usb_get_dev(interface_to_usbdev(interface));
453
454         /* Selects the proper interface */
455         rc=usb_set_interface(usbdev,0,1);
456         if (rc<0)
457                 goto err;
458
459         /* Check to see next free device and mark as used */
460         nr=find_first_zero_bit(&tm6000_devused,TM6000_MAXBOARDS);
461         if (nr >= TM6000_MAXBOARDS) {
462                 printk ("tm6000: Supports only %i em28xx boards.\n",TM6000_MAXBOARDS);
463                 usb_put_dev(usbdev);
464                 return -ENOMEM;
465         }
466
467         /* Create and initialize dev struct */
468         dev = kzalloc(sizeof(*dev), GFP_KERNEL);
469         if (dev == NULL) {
470                 printk ("tm6000" ": out of memory!\n");
471                 usb_put_dev(usbdev);
472                 return -ENOMEM;
473         }
474         spin_lock_init(&dev->slock);
475
476         /* Increment usage count */
477         tm6000_devused|=1<<nr;
478         snprintf(dev->name, 29, "tm6000 #%d", nr);
479
480         dev->model=id->driver_info;
481         if ((card[nr]>=0) && (card[nr]<ARRAY_SIZE(tm6000_boards))) {
482                 dev->model=card[nr];
483         }
484
485         INIT_LIST_HEAD(&dev->tm6000_corelist);
486         dev->udev= usbdev;
487         dev->devno=nr;
488
489         switch (usbdev->speed) {
490         case USB_SPEED_LOW:
491                 speed = "1.5";
492                 break;
493         case USB_SPEED_UNKNOWN:
494         case USB_SPEED_FULL:
495                 speed = "12";
496                 break;
497         case USB_SPEED_HIGH:
498                 speed = "480";
499                 break;
500         default:
501                 speed = "unknown";
502         }
503
504
505
506         /* Get endpoints */
507         for (i = 0; i < interface->num_altsetting; i++) {
508                 int ep;
509
510                 for (ep = 0; ep < interface->altsetting[i].desc.bNumEndpoints; ep++) {
511                         struct usb_host_endpoint        *e;
512                         int dir_out;
513
514                         e = &interface->altsetting[i].endpoint[ep];
515
516                         dir_out = ((e->desc.bEndpointAddress &
517                                         USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
518
519                         printk("tm6000: alt %d, interface %i, class %i\n",
520                                i,
521                                interface->altsetting[i].desc.bInterfaceNumber,
522                                interface->altsetting[i].desc.bInterfaceClass);
523
524                         switch (e->desc.bmAttributes) {
525                         case USB_ENDPOINT_XFER_BULK:
526                                 if (!dir_out) {
527                                         get_max_endpoint (usbdev, "Bulk IN", e,
528                                                         &dev->max_bulk_in,
529                                                         &dev->bulk_in);
530                                 } else {
531                                         get_max_endpoint (usbdev, "Bulk OUT", e,
532                                                         &dev->max_bulk_out,
533                                                         &dev->bulk_out);
534                                 }
535                                 break;
536                         case USB_ENDPOINT_XFER_ISOC:
537                                 if (!dir_out) {
538                                         get_max_endpoint (usbdev, "ISOC IN", e,
539                                                         &dev->max_isoc_in,
540                                                         &dev->isoc_in);
541                                 } else {
542                                         get_max_endpoint (usbdev, "ISOC OUT", e,
543                                                         &dev->max_isoc_out,
544                                                         &dev->isoc_out);
545                                 }
546                                 break;
547                         }
548                 }
549         }
550
551
552         printk("tm6000: New video device @ %s Mbps (%04x:%04x, ifnum %d)\n",
553                 speed,
554                 le16_to_cpu(dev->udev->descriptor.idVendor),
555                 le16_to_cpu(dev->udev->descriptor.idProduct),
556                 interface->altsetting->desc.bInterfaceNumber);
557
558 /* check if the the device has the iso in endpoint at the correct place */
559         if (!dev->isoc_in) {
560                 printk("tm6000: probing error: no IN ISOC endpoint!\n");
561                 rc= -ENODEV;
562
563                 goto err;
564         }
565
566         /* save our data pointer in this interface device */
567         usb_set_intfdata(interface, dev);
568
569         printk("tm6000: Found %s\n", tm6000_boards[dev->model].name);
570
571         rc=tm6000_init_dev(dev);
572
573         if (rc<0)
574                 goto err;
575
576         return 0;
577
578 err:
579         printk("tm6000: Error %d while registering\n", rc);
580
581         tm6000_devused&=~(1<<nr);
582         usb_put_dev(usbdev);
583
584         kfree(dev);
585         return rc;
586 }
587
588 /*
589  * tm6000_usb_disconnect()
590  * called when the device gets diconencted
591  * video device will be unregistered on v4l2_close in case it is still open
592  */
593 static void tm6000_usb_disconnect(struct usb_interface *interface)
594 {
595         struct tm6000_core *dev = usb_get_intfdata(interface);
596         usb_set_intfdata(interface, NULL);
597
598         if (!dev)
599                 return;
600
601         printk("tm6000: disconnecting %s\n", dev->name);
602
603         mutex_lock(&dev->lock);
604
605 #ifdef CONFIG_VIDEO_TM6000_DVB
606         if(dev->dvb) {
607                 tm6000_dvb_unregister(dev);
608                 kfree(dev->dvb);
609         }
610 #endif
611
612         tm6000_v4l2_unregister(dev);
613
614         tm6000_i2c_unregister(dev);
615
616         v4l2_device_unregister(&dev->v4l2_dev);
617
618 //      wake_up_interruptible_all(&dev->open);
619
620         dev->state |= DEV_DISCONNECTED;
621
622         usb_put_dev(dev->udev);
623
624         mutex_unlock(&dev->lock);
625         kfree(dev);
626 }
627
628 static struct usb_driver tm6000_usb_driver = {
629                 .name = "tm6000",
630                 .probe = tm6000_usb_probe,
631                 .disconnect = tm6000_usb_disconnect,
632                 .id_table = tm6000_id_table,
633 };
634
635 static int __init tm6000_module_init(void)
636 {
637         int result;
638
639         printk(KERN_INFO "tm6000" " v4l2 driver version %d.%d.%d loaded\n",
640                (TM6000_VERSION  >> 16) & 0xff,
641                (TM6000_VERSION  >> 8) & 0xff, TM6000_VERSION  & 0xff);
642
643         /* register this driver with the USB subsystem */
644         result = usb_register(&tm6000_usb_driver);
645         if (result)
646                 printk("tm6000"
647                            " usb_register failed. Error number %d.\n", result);
648
649         return result;
650 }
651
652 static void __exit tm6000_module_exit(void)
653 {
654         /* deregister at USB subsystem */
655         usb_deregister(&tm6000_usb_driver);
656 }
657
658 module_init(tm6000_module_init);
659 module_exit(tm6000_module_exit);
660
661 MODULE_DESCRIPTION("Trident TVMaster TM5600/TM6000 USB2 adapter");
662 MODULE_AUTHOR("Mauro Carvalho Chehab");
663 MODULE_LICENSE("GPL");