blob: 23f9672d6937f8f3f2a7b1256479cdd6e2bf2986 [file] [log] [blame]
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -03001/*
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
30#include "tm6000.h"
Mauro Carvalho Chehabc85cba32007-07-19 11:09:58 -030031#include "tm6000-regs.h"
Mauro Carvalho Chehabd544f2c2007-10-24 09:22:08 -030032#include "tuner-xc2028.h"
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030033
Michel Ludwig0ec4acc2007-06-27 17:01:50 -030034#define TM6000_BOARD_UNKNOWN 0
35#define TM5600_BOARD_GENERIC 1
36#define TM6000_BOARD_GENERIC 2
Mauro Carvalho Chehab29c389b2008-01-08 11:19:22 -030037#define TM6010_BOARD_GENERIC 3
38#define TM5600_BOARD_10MOONS_UT821 4
39#define TM5600_BOARD_10MOONS_UT330 5
40#define TM6000_BOARD_ADSTECH_DUAL_TV 6
41#define TM6000_BOARD_FREECOM_AND_SIMILAR 7
42#define TM6000_BOARD_ADSTECH_MINI_DUAL_TV 8
Michel Ludwig0ec4acc2007-06-27 17:01:50 -030043
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030044#define TM6000_MAXBOARDS 16
45static unsigned int card[] = {[0 ... (TM6000_MAXBOARDS - 1)] = UNSET };
46
47module_param_array(card, int, NULL, 0444);
48
Mauro Carvalho Chehab7f9b1412007-10-01 06:45:22 -030049static unsigned long tm6000_devused;
50
Mauro Carvalho Chehabc85cba32007-07-19 11:09:58 -030051
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030052struct tm6000_board {
53 char *name;
54
55 struct tm6000_capabilities caps;
56
Mauro Carvalho Chehab29c389b2008-01-08 11:19:22 -030057 enum tm6000_devtype type; /* variant of the chipset */
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030058 int tuner_type; /* type of the tuner */
59 int tuner_addr; /* tuner address */
Michel Ludwig95a83822007-07-24 08:06:45 -030060 int demod_addr; /* demodulator address */
61 int gpio_addr_tun_reset; /* GPIO used for tuner reset */
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030062};
63
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030064struct tm6000_board tm6000_boards[] = {
65 [TM6000_BOARD_UNKNOWN] = {
66 .name = "Unknown tm6000 video grabber",
67 .caps = {
68 .has_tuner = 1,
69 },
Mauro Carvalho Chehabc85cba32007-07-19 11:09:58 -030070 .gpio_addr_tun_reset = TM6000_GPIO_1,
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030071 },
72 [TM5600_BOARD_GENERIC] = {
73 .name = "Generic tm5600 board",
Mauro Carvalho Chehab29c389b2008-01-08 11:19:22 -030074 .type = TM5600,
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030075 .tuner_type = TUNER_XC2028,
76 .tuner_addr = 0xc2,
77 .caps = {
78 .has_tuner = 1,
79 },
Mauro Carvalho Chehabc85cba32007-07-19 11:09:58 -030080 .gpio_addr_tun_reset = TM6000_GPIO_1,
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030081 },
82 [TM6000_BOARD_GENERIC] = {
83 .name = "Generic tm6000 board",
84 .tuner_type = TUNER_XC2028,
85 .tuner_addr = 0xc2,
86 .caps = {
87 .has_tuner = 1,
88 .has_dvb = 1,
89 },
Mauro Carvalho Chehabc85cba32007-07-19 11:09:58 -030090 .gpio_addr_tun_reset = TM6000_GPIO_1,
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -030091 },
Mauro Carvalho Chehab29c389b2008-01-08 11:19:22 -030092 [TM6010_BOARD_GENERIC] = {
93 .name = "Generic tm6010 board",
94 .type = TM6010,
95 .tuner_type = TUNER_XC2028,
96 .tuner_addr = 0xc2,
97 .caps = {
98 .has_tuner = 1,
99 .has_dvb = 1,
100 },
101 .gpio_addr_tun_reset = TM6010_GPIO_4,
102 },
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300103 [TM5600_BOARD_10MOONS_UT821] = {
104 .name = "10Moons UT 821",
105 .tuner_type = TUNER_XC2028,
Mauro Carvalho Chehab29c389b2008-01-08 11:19:22 -0300106 .type = TM5600,
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300107 .tuner_addr = 0xc2,
108 .caps = {
109 .has_tuner = 1,
110 .has_eeprom = 1,
111 },
Mauro Carvalho Chehabc85cba32007-07-19 11:09:58 -0300112 .gpio_addr_tun_reset = TM6000_GPIO_1,
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300113 },
Michel Ludwig95a83822007-07-24 08:06:45 -0300114 [TM5600_BOARD_10MOONS_UT330] = {
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300115 .name = "10Moons UT 330",
Michel Ludwig95a83822007-07-24 08:06:45 -0300116 .tuner_type = TUNER_PHILIPS_FQ1216AME_MK4,
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300117 .tuner_addr = 0xc8,
118 .caps = {
119 .has_tuner = 1,
Michel Ludwig95a83822007-07-24 08:06:45 -0300120 .has_dvb = 0,
121 .has_zl10353 = 0,
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300122 .has_eeprom = 1,
123 },
124 },
125 [TM6000_BOARD_ADSTECH_DUAL_TV] = {
126 .name = "ADSTECH Dual TV USB",
127 .tuner_type = TUNER_XC2028,
128 .tuner_addr = 0xc8,
129 .caps = {
130 .has_tuner = 1,
131 .has_tda9874 = 1,
132 .has_dvb = 1,
133 .has_zl10353 = 1,
134 .has_eeprom = 1,
135 },
136 },
Michel Ludwig0ec4acc2007-06-27 17:01:50 -0300137 [TM6000_BOARD_FREECOM_AND_SIMILAR] = {
138 .name = "Freecom Hybrid Stick / Moka DVB-T Receiver Dual",
Michel Ludwig43861362007-09-24 17:01:49 -0300139 .tuner_type = TUNER_XC2028, /* has a XC3028 */
Michel Ludwig0ec4acc2007-06-27 17:01:50 -0300140 .tuner_addr = 0xc2,
Michel Ludwig95a83822007-07-24 08:06:45 -0300141 .demod_addr = 0x1e,
Michel Ludwig0ec4acc2007-06-27 17:01:50 -0300142 .caps = {
143 .has_tuner = 1,
144 .has_dvb = 1,
145 .has_zl10353 = 1,
146 .has_eeprom = 0,
Michel Ludwig43861362007-09-24 17:01:49 -0300147 .has_remote = 1,
148 },
149 .gpio_addr_tun_reset = TM6000_GPIO_4,
150 },
151 [TM6000_BOARD_ADSTECH_MINI_DUAL_TV] = {
152 .name = "ADSTECH Mini Dual TV USB",
153 .tuner_type = TUNER_XC2028, /* has a XC3028 */
154 .tuner_addr = 0xc8,
155 .demod_addr = 0x1e,
156 .caps = {
157 .has_tuner = 1,
158 .has_dvb = 1,
159 .has_zl10353 = 1,
160 .has_eeprom = 0,
Michel Ludwig0ec4acc2007-06-27 17:01:50 -0300161 },
Michel Ludwig95a83822007-07-24 08:06:45 -0300162 .gpio_addr_tun_reset = TM6000_GPIO_4,
Michel Ludwig0ec4acc2007-06-27 17:01:50 -0300163 },
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300164};
165
166/* table of devices that work with this driver */
167struct usb_device_id tm6000_id_table [] = {
168 { USB_DEVICE(0x6000, 0x0001), .driver_info = TM5600_BOARD_10MOONS_UT821 },
Mauro Carvalho Chehab29c389b2008-01-08 11:19:22 -0300169 { USB_DEVICE(0x6000, 0x0002), .driver_info = TM6010_BOARD_GENERIC },
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300170 { USB_DEVICE(0x06e1, 0xf332), .driver_info = TM6000_BOARD_ADSTECH_DUAL_TV },
Mauro Carvalho Chehabc85cba32007-07-19 11:09:58 -0300171 { USB_DEVICE(0x14aa, 0x0620), .driver_info = TM6000_BOARD_FREECOM_AND_SIMILAR },
Michel Ludwig43861362007-09-24 17:01:49 -0300172 { USB_DEVICE(0x06e1, 0xb339), .driver_info = TM6000_BOARD_ADSTECH_MINI_DUAL_TV },
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300173 { },
174};
175
Mauro Carvalho Chehabd544f2c2007-10-24 09:22:08 -0300176static void tm6000_config_tuner (struct tm6000_core *dev)
177{
178 struct v4l2_priv_tun_config xc2028_cfg;
179 struct xc2028_ctrl ctl;
180
181 memset (&ctl,0,sizeof(ctl));
182
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300183 request_module ("tuner");
Mauro Carvalho Chehabd544f2c2007-10-24 09:22:08 -0300184
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300185 if (dev->tuner_type == TUNER_XC2028) {
Mauro Carvalho Chehab29c389b2008-01-08 11:19:22 -0300186 if (dev->dev_type == TM6010)
187 ctl.fname = "xc3028-v27.fw";
188 else
189 ctl.fname = "tm6000-xc3028.fw";
190
Mauro Carvalho Chehab3716ae32007-11-23 13:00:18 -0300191 ctl.mts = 1;
Mauro Carvalho Chehab2d5024a2009-09-14 10:23:20 -0300192 ctl.read_not_reliable = 1;
Mauro Carvalho Chehabd544f2c2007-10-24 09:22:08 -0300193
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300194 xc2028_cfg.tuner = TUNER_XC2028;
195 xc2028_cfg.priv = &ctl;
Mauro Carvalho Chehabd544f2c2007-10-24 09:22:08 -0300196
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300197 printk(KERN_INFO "Setting firmware parameters for xc2028\n");
198
199 tm6000_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
200 }
Mauro Carvalho Chehabd544f2c2007-10-24 09:22:08 -0300201}
202
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300203static int tm6000_init_dev(struct tm6000_core *dev)
204{
205 struct v4l2_frequency f;
206 int rc = 0;
207
208 mutex_init(&dev->lock);
209
210 mutex_lock(&dev->lock);
211
212 /* Initializa board-specific data */
Mauro Carvalho Chehab29c389b2008-01-08 11:19:22 -0300213 dev->dev_type = tm6000_boards[dev->model].type;
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300214 dev->tuner_type = tm6000_boards[dev->model].tuner_type;
215 dev->tuner_addr = tm6000_boards[dev->model].tuner_addr;
Michel Ludwig95a83822007-07-24 08:06:45 -0300216 dev->tuner_reset_gpio = tm6000_boards[dev->model].gpio_addr_tun_reset;
217
218 dev->demod_addr = tm6000_boards[dev->model].demod_addr;
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300219
220 dev->caps = tm6000_boards[dev->model].caps;
221
222 /* initialize hardware */
223 rc=tm6000_init (dev);
224 if (rc<0)
225 goto err;
226
227 /* register i2c bus */
228 rc=tm6000_i2c_register(dev);
229 if (rc<0)
230 goto err;
231
232 /* register and initialize V4L2 */
233 rc=tm6000_v4l2_register(dev);
234 if (rc<0)
235 goto err;
236
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300237 /* Default values for STD and resolutions */
238 dev->width = 720;
239 dev->height = 480;
240 dev->norm = V4L2_STD_PAL_M;
Mauro Carvalho Chehabd544f2c2007-10-24 09:22:08 -0300241
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300242 /* Configure tuner */
Mauro Carvalho Chehabd544f2c2007-10-24 09:22:08 -0300243 tm6000_config_tuner (dev);
244
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300245 /* Set video standard */
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300246 tm6000_i2c_call_clients(dev, VIDIOC_S_STD, &dev->norm);
247
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300248 /* Set tuner frequency - also loads firmware on xc2028/xc3028 */
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300249 f.tuner = 0;
250 f.type = V4L2_TUNER_ANALOG_TV;
251 f.frequency = 3092; /* 193.25 MHz */
252 dev->freq = f.frequency;
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300253 tm6000_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
Mauro Carvalho Chehabcc27a8c2007-11-02 11:23:14 -0300254
Michel Ludwig3169c9b2007-08-21 17:37:22 -0300255 if(dev->caps.has_dvb) {
256 dev->dvb = kzalloc(sizeof(*(dev->dvb)), GFP_KERNEL);
257 if(!dev->dvb) {
258 rc = -ENOMEM;
259 goto err;
260 }
Mauro Carvalho Chehab5c0d0b22007-08-25 08:35:31 -0300261#ifdef CONFIG_VIDEO_TM6000_DVB
Michel Ludwig3169c9b2007-08-21 17:37:22 -0300262 rc = tm6000_dvb_register(dev);
263 if(rc < 0) {
264 kfree(dev->dvb);
265 dev->dvb = NULL;
266 goto err;
267 }
Mauro Carvalho Chehab5c0d0b22007-08-25 08:35:31 -0300268#endif
Michel Ludwig3169c9b2007-08-21 17:37:22 -0300269 }
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300270err:
271 mutex_unlock(&dev->lock);
272 return rc;
273}
274
275/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
276#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
277
278static void get_max_endpoint ( struct usb_device *usbdev,
279 char *msgtype,
280 struct usb_host_endpoint *curr_e,
281 unsigned int *maxsize,
282 struct usb_host_endpoint **ep )
283{
284 u16 tmp = le16_to_cpu(curr_e->desc.wMaxPacketSize);
285 unsigned int size = tmp & 0x7ff;
286
287 if (usbdev->speed == USB_SPEED_HIGH)
288 size = size * hb_mult (tmp);
289
290 if (size>*maxsize) {
291 *ep = curr_e;
292 *maxsize = size;
293 printk("tm6000: %s endpoint: 0x%02x (max size=%u bytes)\n",
294 msgtype, curr_e->desc.bEndpointAddress,
295 size);
296 }
297}
298
299/*
300 * tm6000_usb_probe()
301 * checks for supported devices
302 */
303static int tm6000_usb_probe(struct usb_interface *interface,
304 const struct usb_device_id *id)
305{
306 struct usb_device *usbdev;
307 struct tm6000_core *dev = NULL;
308 int i,rc=0;
309 int nr=0;
310 char *speed;
311
312
313 usbdev=usb_get_dev(interface_to_usbdev(interface));
314
315 /* Selects the proper interface */
316 rc=usb_set_interface(usbdev,0,1);
317 if (rc<0)
318 goto err;
319
320 /* Check to see next free device and mark as used */
321 nr=find_first_zero_bit(&tm6000_devused,TM6000_MAXBOARDS);
322 if (nr >= TM6000_MAXBOARDS) {
323 printk ("tm6000: Supports only %i em28xx boards.\n",TM6000_MAXBOARDS);
324 usb_put_dev(usbdev);
325 return -ENOMEM;
326 }
327
328 /* Create and initialize dev struct */
329 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
330 if (dev == NULL) {
331 printk ("tm6000" ": out of memory!\n");
332 usb_put_dev(usbdev);
333 return -ENOMEM;
334 }
335 spin_lock_init(&dev->slock);
336
337 /* Increment usage count */
338 tm6000_devused|=1<<nr;
Michel Ludwig2cd4fd12007-06-17 17:12:32 -0300339 snprintf(dev->name, 29, "tm6000 #%d", nr);
340
341 dev->model=id->driver_info;
342 if ((card[nr]>=0) && (card[nr]<ARRAY_SIZE(tm6000_boards))) {
343 dev->model=card[nr];
344 }
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300345
Michel Ludwig22927e82007-06-14 17:19:59 -0300346 INIT_LIST_HEAD(&dev->tm6000_corelist);
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300347 dev->udev= usbdev;
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300348 dev->devno=nr;
349
350 switch (usbdev->speed) {
351 case USB_SPEED_LOW:
352 speed = "1.5";
353 break;
354 case USB_SPEED_UNKNOWN:
355 case USB_SPEED_FULL:
356 speed = "12";
357 break;
358 case USB_SPEED_HIGH:
359 speed = "480";
360 break;
361 default:
362 speed = "unknown";
363 }
364
365
366
367 /* Get endpoints */
368 for (i = 0; i < interface->num_altsetting; i++) {
369 int ep;
370
371 for (ep = 0; ep < interface->altsetting[i].desc.bNumEndpoints; ep++) {
372 struct usb_host_endpoint *e;
373 int dir_out;
374
375 e = &interface->altsetting[i].endpoint[ep];
376
377 dir_out = ((e->desc.bEndpointAddress &
378 USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
379
380 printk("tm6000: alt %d, interface %i, class %i\n",
381 i,
382 interface->altsetting[i].desc.bInterfaceNumber,
383 interface->altsetting[i].desc.bInterfaceClass);
384
385 switch (e->desc.bmAttributes) {
386 case USB_ENDPOINT_XFER_BULK:
387 if (!dir_out) {
388 get_max_endpoint (usbdev, "Bulk IN", e,
389 &dev->max_bulk_in,
390 &dev->bulk_in);
391 } else {
392 get_max_endpoint (usbdev, "Bulk OUT", e,
393 &dev->max_bulk_out,
394 &dev->bulk_out);
395 }
396 break;
397 case USB_ENDPOINT_XFER_ISOC:
398 if (!dir_out) {
399 get_max_endpoint (usbdev, "ISOC IN", e,
400 &dev->max_isoc_in,
401 &dev->isoc_in);
402 } else {
403 get_max_endpoint (usbdev, "ISOC OUT", e,
404 &dev->max_isoc_out,
405 &dev->isoc_out);
406 }
407 break;
408 }
409 }
410 }
411
412 if (interface->altsetting->desc.bAlternateSetting) {
413 printk("selecting alt setting %d\n",
414 interface->altsetting->desc.bAlternateSetting);
415 rc = usb_set_interface (usbdev,
416 interface->altsetting->desc.bInterfaceNumber,
417 interface->altsetting->desc.bAlternateSetting);
418 if (rc<0)
419 goto err;
420 }
421
422 printk("tm6000: New video device @ %s Mbps (%04x:%04x, ifnum %d)\n",
423 speed,
424 le16_to_cpu(dev->udev->descriptor.idVendor),
425 le16_to_cpu(dev->udev->descriptor.idProduct),
426 interface->altsetting->desc.bInterfaceNumber);
427
428/* check if the the device has the iso in endpoint at the correct place */
429 if (!dev->isoc_in) {
430 printk("tm6000: probing error: no IN ISOC endpoint!\n");
431 rc= -ENODEV;
432
433 goto err;
434 }
435
436 /* save our data pointer in this interface device */
437 usb_set_intfdata(interface, dev);
438
439 printk("tm6000: Found %s\n", tm6000_boards[dev->model].name);
440
441 rc=tm6000_init_dev(dev);
442
443 if (rc<0)
444 goto err;
445
446 return 0;
447
448err:
449 tm6000_devused&=~(1<<nr);
450 usb_put_dev(usbdev);
451
452 kfree(dev);
453 return rc;
454}
455
456/*
457 * tm6000_usb_disconnect()
458 * called when the device gets diconencted
459 * video device will be unregistered on v4l2_close in case it is still open
460 */
461static void tm6000_usb_disconnect(struct usb_interface *interface)
462{
463 struct tm6000_core *dev = usb_get_intfdata(interface);
464 usb_set_intfdata(interface, NULL);
465
466 if (!dev)
467 return;
468
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300469 printk("tm6000: disconnecting %s\n", dev->name);
470
471 mutex_lock(&dev->lock);
472
Mauro Carvalho Chehab5c0d0b22007-08-25 08:35:31 -0300473#ifdef CONFIG_VIDEO_TM6000_DVB
Michel Ludwig3169c9b2007-08-21 17:37:22 -0300474 if(dev->dvb) {
475 tm6000_dvb_unregister(dev);
476 kfree(dev->dvb);
477 }
Mauro Carvalho Chehab5c0d0b22007-08-25 08:35:31 -0300478#endif
Michel Ludwig3169c9b2007-08-21 17:37:22 -0300479
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300480 tm6000_v4l2_unregister(dev);
481
Michel Ludwig7c3f53e2007-06-16 23:21:48 -0300482 tm6000_i2c_unregister(dev);
483
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300484// wake_up_interruptible_all(&dev->open);
485
486 dev->state |= DEV_DISCONNECTED;
487
Michel Ludwig7c3f53e2007-06-16 23:21:48 -0300488 usb_put_dev(dev->udev);
489
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300490 mutex_unlock(&dev->lock);
Michel Ludwig22927e82007-06-14 17:19:59 -0300491 kfree(dev);
Mauro Carvalho Chehab9701dc92009-09-14 09:42:41 -0300492}
493
494static struct usb_driver tm6000_usb_driver = {
495 .name = "tm6000",
496 .probe = tm6000_usb_probe,
497 .disconnect = tm6000_usb_disconnect,
498 .id_table = tm6000_id_table,
499};
500
501static int __init tm6000_module_init(void)
502{
503 int result;
504
505 printk(KERN_INFO "tm6000" " v4l2 driver version %d.%d.%d loaded\n",
506 (TM6000_VERSION >> 16) & 0xff,
507 (TM6000_VERSION >> 8) & 0xff, TM6000_VERSION & 0xff);
508
509 /* register this driver with the USB subsystem */
510 result = usb_register(&tm6000_usb_driver);
511 if (result)
512 printk("tm6000"
513 " usb_register failed. Error number %d.\n", result);
514
515 return result;
516}
517
518static void __exit tm6000_module_exit(void)
519{
520 /* deregister at USB subsystem */
521 usb_deregister(&tm6000_usb_driver);
522}
523
524module_init(tm6000_module_init);
525module_exit(tm6000_module_exit);
526
527MODULE_DESCRIPTION("Trident TVMaster TM5600/TM6000 USB2 adapter");
528MODULE_AUTHOR("Mauro Carvalho Chehab");
529MODULE_LICENSE("GPL");