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