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/slab.h>
27 #include <media/v4l2-common.h>
28 #include <media/tuner.h>
29 #include <media/tvaudio.h>
30 #include <media/i2c-addr.h>
31 #include <media/rc-map.h>
34 #include "tm6000-regs.h"
35 #include "tuner-xc2028.h"
38 #define TM6000_BOARD_UNKNOWN 0
39 #define TM5600_BOARD_GENERIC 1
40 #define TM6000_BOARD_GENERIC 2
41 #define TM6010_BOARD_GENERIC 3
42 #define TM5600_BOARD_10MOONS_UT821 4
43 #define TM5600_BOARD_10MOONS_UT330 5
44 #define TM6000_BOARD_ADSTECH_DUAL_TV 6
45 #define TM6000_BOARD_FREECOM_AND_SIMILAR 7
46 #define TM6000_BOARD_ADSTECH_MINI_DUAL_TV 8
47 #define TM6010_BOARD_HAUPPAUGE_900H 9
48 #define TM6010_BOARD_BEHOLD_WANDER 10
49 #define TM6010_BOARD_BEHOLD_VOYAGER 11
50 #define TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE 12
51 #define TM6010_BOARD_TWINHAN_TU501 13
52 #define TM6010_BOARD_BEHOLD_WANDER_LITE 14
53 #define TM6010_BOARD_BEHOLD_VOYAGER_LITE 15
54 #define TM5600_BOARD_TERRATEC_GRABSTER 16
56 #define is_generic(model) ((model == TM6000_BOARD_UNKNOWN) || \
57 (model == TM5600_BOARD_GENERIC) || \
58 (model == TM6000_BOARD_GENERIC) || \
59 (model == TM6010_BOARD_GENERIC))
61 #define TM6000_MAXBOARDS 16
62 static unsigned int card
[] = {[0 ... (TM6000_MAXBOARDS
- 1)] = UNSET
};
64 module_param_array(card
, int, NULL
, 0444);
66 static unsigned long tm6000_devused
;
71 char eename
[16]; /* EEPROM name */
72 unsigned eename_size
; /* size of EEPROM name */
73 unsigned eename_pos
; /* Position where it appears at ROM */
75 struct tm6000_capabilities caps
;
77 enum tm6000_devtype type
; /* variant of the chipset */
78 int tuner_type
; /* type of the tuner */
79 int tuner_addr
; /* tuner address */
80 int demod_addr
; /* demodulator address */
82 struct tm6000_gpio gpio
;
84 struct tm6000_input vinput
[3];
85 struct tm6000_input rinput
;
90 static struct tm6000_board tm6000_boards
[] = {
91 [TM6000_BOARD_UNKNOWN
] = {
92 .name
= "Unknown tm6000 video grabber",
98 .tuner_reset
= TM6000_GPIO_1
,
101 .type
= TM6000_INPUT_TV
,
102 .vmux
= TM6000_VMUX_VIDEO_B
,
103 .amux
= TM6000_AMUX_ADC1
,
105 .type
= TM6000_INPUT_COMPOSITE1
,
106 .vmux
= TM6000_VMUX_VIDEO_A
,
107 .amux
= TM6000_AMUX_ADC2
,
109 .type
= TM6000_INPUT_SVIDEO
,
110 .vmux
= TM6000_VMUX_VIDEO_AB
,
111 .amux
= TM6000_AMUX_ADC2
,
115 [TM5600_BOARD_GENERIC
] = {
116 .name
= "Generic tm5600 board",
118 .tuner_type
= TUNER_XC2028
,
119 .tuner_addr
= 0xc2 >> 1,
125 .tuner_reset
= TM6000_GPIO_1
,
128 .type
= TM6000_INPUT_TV
,
129 .vmux
= TM6000_VMUX_VIDEO_B
,
130 .amux
= TM6000_AMUX_ADC1
,
132 .type
= TM6000_INPUT_COMPOSITE1
,
133 .vmux
= TM6000_VMUX_VIDEO_A
,
134 .amux
= TM6000_AMUX_ADC2
,
136 .type
= TM6000_INPUT_SVIDEO
,
137 .vmux
= TM6000_VMUX_VIDEO_AB
,
138 .amux
= TM6000_AMUX_ADC2
,
142 [TM6000_BOARD_GENERIC
] = {
143 .name
= "Generic tm6000 board",
144 .tuner_type
= TUNER_XC2028
,
145 .tuner_addr
= 0xc2 >> 1,
151 .tuner_reset
= TM6000_GPIO_1
,
154 .type
= TM6000_INPUT_TV
,
155 .vmux
= TM6000_VMUX_VIDEO_B
,
156 .amux
= TM6000_AMUX_ADC1
,
158 .type
= TM6000_INPUT_COMPOSITE1
,
159 .vmux
= TM6000_VMUX_VIDEO_A
,
160 .amux
= TM6000_AMUX_ADC2
,
162 .type
= TM6000_INPUT_SVIDEO
,
163 .vmux
= TM6000_VMUX_VIDEO_AB
,
164 .amux
= TM6000_AMUX_ADC2
,
168 [TM6010_BOARD_GENERIC
] = {
169 .name
= "Generic tm6010 board",
171 .tuner_type
= TUNER_XC2028
,
172 .tuner_addr
= 0xc2 >> 1,
173 .demod_addr
= 0x1e >> 1,
182 .tuner_reset
= TM6010_GPIO_2
,
183 .tuner_on
= TM6010_GPIO_3
,
184 .demod_reset
= TM6010_GPIO_1
,
185 .demod_on
= TM6010_GPIO_4
,
186 .power_led
= TM6010_GPIO_7
,
187 .dvb_led
= TM6010_GPIO_5
,
191 .type
= TM6000_INPUT_TV
,
192 .vmux
= TM6000_VMUX_VIDEO_B
,
193 .amux
= TM6000_AMUX_SIF1
,
195 .type
= TM6000_INPUT_COMPOSITE1
,
196 .vmux
= TM6000_VMUX_VIDEO_A
,
197 .amux
= TM6000_AMUX_ADC2
,
199 .type
= TM6000_INPUT_SVIDEO
,
200 .vmux
= TM6000_VMUX_VIDEO_AB
,
201 .amux
= TM6000_AMUX_ADC2
,
205 [TM5600_BOARD_10MOONS_UT821
] = {
206 .name
= "10Moons UT 821",
207 .tuner_type
= TUNER_XC2028
,
208 .eename
= { '1', '0', 'M', 'O', 'O', 'N', 'S', '5', '6', '0', '0', 0xff, 0x45, 0x5b},
212 .tuner_addr
= 0xc2 >> 1,
218 .tuner_reset
= TM6000_GPIO_1
,
221 .type
= TM6000_INPUT_TV
,
222 .vmux
= TM6000_VMUX_VIDEO_B
,
223 .amux
= TM6000_AMUX_ADC1
,
225 .type
= TM6000_INPUT_COMPOSITE1
,
226 .vmux
= TM6000_VMUX_VIDEO_A
,
227 .amux
= TM6000_AMUX_ADC2
,
229 .type
= TM6000_INPUT_SVIDEO
,
230 .vmux
= TM6000_VMUX_VIDEO_AB
,
231 .amux
= TM6000_AMUX_ADC2
,
235 [TM5600_BOARD_10MOONS_UT330
] = {
236 .name
= "10Moons UT 330",
237 .tuner_type
= TUNER_PHILIPS_FQ1216AME_MK4
,
238 .tuner_addr
= 0xc8 >> 1,
246 .type
= TM6000_INPUT_TV
,
247 .vmux
= TM6000_VMUX_VIDEO_B
,
248 .amux
= TM6000_AMUX_ADC1
,
250 .type
= TM6000_INPUT_COMPOSITE1
,
251 .vmux
= TM6000_VMUX_VIDEO_A
,
252 .amux
= TM6000_AMUX_ADC2
,
254 .type
= TM6000_INPUT_SVIDEO
,
255 .vmux
= TM6000_VMUX_VIDEO_AB
,
256 .amux
= TM6000_AMUX_ADC2
,
260 [TM6000_BOARD_ADSTECH_DUAL_TV
] = {
261 .name
= "ADSTECH Dual TV USB",
262 .tuner_type
= TUNER_XC2028
,
263 .tuner_addr
= 0xc8 >> 1,
272 .type
= TM6000_INPUT_TV
,
273 .vmux
= TM6000_VMUX_VIDEO_B
,
274 .amux
= TM6000_AMUX_ADC1
,
276 .type
= TM6000_INPUT_COMPOSITE1
,
277 .vmux
= TM6000_VMUX_VIDEO_A
,
278 .amux
= TM6000_AMUX_ADC2
,
280 .type
= TM6000_INPUT_SVIDEO
,
281 .vmux
= TM6000_VMUX_VIDEO_AB
,
282 .amux
= TM6000_AMUX_ADC2
,
286 [TM6000_BOARD_FREECOM_AND_SIMILAR
] = {
287 .name
= "Freecom Hybrid Stick / Moka DVB-T Receiver Dual",
288 .tuner_type
= TUNER_XC2028
, /* has a XC3028 */
289 .tuner_addr
= 0xc2 >> 1,
290 .demod_addr
= 0x1e >> 1,
299 .tuner_reset
= TM6000_GPIO_4
,
302 .type
= TM6000_INPUT_TV
,
303 .vmux
= TM6000_VMUX_VIDEO_B
,
304 .amux
= TM6000_AMUX_ADC1
,
306 .type
= TM6000_INPUT_COMPOSITE1
,
307 .vmux
= TM6000_VMUX_VIDEO_A
,
308 .amux
= TM6000_AMUX_ADC2
,
310 .type
= TM6000_INPUT_SVIDEO
,
311 .vmux
= TM6000_VMUX_VIDEO_AB
,
312 .amux
= TM6000_AMUX_ADC2
,
316 [TM6000_BOARD_ADSTECH_MINI_DUAL_TV
] = {
317 .name
= "ADSTECH Mini Dual TV USB",
318 .tuner_type
= TUNER_XC2028
, /* has a XC3028 */
319 .tuner_addr
= 0xc8 >> 1,
320 .demod_addr
= 0x1e >> 1,
328 .tuner_reset
= TM6000_GPIO_4
,
331 .type
= TM6000_INPUT_TV
,
332 .vmux
= TM6000_VMUX_VIDEO_B
,
333 .amux
= TM6000_AMUX_ADC1
,
335 .type
= TM6000_INPUT_COMPOSITE1
,
336 .vmux
= TM6000_VMUX_VIDEO_A
,
337 .amux
= TM6000_AMUX_ADC2
,
339 .type
= TM6000_INPUT_SVIDEO
,
340 .vmux
= TM6000_VMUX_VIDEO_AB
,
341 .amux
= TM6000_AMUX_ADC2
,
345 [TM6010_BOARD_HAUPPAUGE_900H
] = {
346 .name
= "Hauppauge WinTV HVR-900H / WinTV USB2-Stick",
347 .eename
= { 'H', 0, 'V', 0, 'R', 0, '9', 0, '0', 0, '0', 0, 'H', 0 },
350 .tuner_type
= TUNER_XC2028
, /* has a XC3028 */
351 .tuner_addr
= 0xc2 >> 1,
352 .demod_addr
= 0x1e >> 1,
354 .ir_codes
= RC_MAP_HAUPPAUGE
,
363 .tuner_reset
= TM6010_GPIO_2
,
364 .tuner_on
= TM6010_GPIO_3
,
365 .demod_reset
= TM6010_GPIO_1
,
366 .demod_on
= TM6010_GPIO_4
,
367 .power_led
= TM6010_GPIO_7
,
368 .dvb_led
= TM6010_GPIO_5
,
372 .type
= TM6000_INPUT_TV
,
373 .vmux
= TM6000_VMUX_VIDEO_B
,
374 .amux
= TM6000_AMUX_SIF1
,
376 .type
= TM6000_INPUT_COMPOSITE1
,
377 .vmux
= TM6000_VMUX_VIDEO_A
,
378 .amux
= TM6000_AMUX_ADC2
,
380 .type
= TM6000_INPUT_SVIDEO
,
381 .vmux
= TM6000_VMUX_VIDEO_AB
,
382 .amux
= TM6000_AMUX_ADC2
,
386 [TM6010_BOARD_BEHOLD_WANDER
] = {
387 .name
= "Beholder Wander DVB-T/TV/FM USB2.0",
388 .tuner_type
= TUNER_XC5000
,
389 .tuner_addr
= 0xc2 >> 1,
390 .demod_addr
= 0x1e >> 1,
401 .tuner_reset
= TM6010_GPIO_0
,
402 .demod_reset
= TM6010_GPIO_1
,
403 .power_led
= TM6010_GPIO_6
,
406 .type
= TM6000_INPUT_TV
,
407 .vmux
= TM6000_VMUX_VIDEO_B
,
408 .amux
= TM6000_AMUX_SIF1
,
410 .type
= TM6000_INPUT_COMPOSITE1
,
411 .vmux
= TM6000_VMUX_VIDEO_A
,
412 .amux
= TM6000_AMUX_ADC2
,
414 .type
= TM6000_INPUT_SVIDEO
,
415 .vmux
= TM6000_VMUX_VIDEO_AB
,
416 .amux
= TM6000_AMUX_ADC2
,
420 .type
= TM6000_INPUT_RADIO
,
421 .amux
= TM6000_AMUX_ADC1
,
424 [TM6010_BOARD_BEHOLD_VOYAGER
] = {
425 .name
= "Beholder Voyager TV/FM USB2.0",
426 .tuner_type
= TUNER_XC5000
,
427 .tuner_addr
= 0xc2 >> 1,
438 .tuner_reset
= TM6010_GPIO_0
,
439 .power_led
= TM6010_GPIO_6
,
442 .type
= TM6000_INPUT_TV
,
443 .vmux
= TM6000_VMUX_VIDEO_B
,
444 .amux
= TM6000_AMUX_SIF1
,
446 .type
= TM6000_INPUT_COMPOSITE1
,
447 .vmux
= TM6000_VMUX_VIDEO_A
,
448 .amux
= TM6000_AMUX_ADC2
,
450 .type
= TM6000_INPUT_SVIDEO
,
451 .vmux
= TM6000_VMUX_VIDEO_AB
,
452 .amux
= TM6000_AMUX_ADC2
,
456 .type
= TM6000_INPUT_RADIO
,
457 .amux
= TM6000_AMUX_ADC1
,
460 [TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
] = {
461 .name
= "Terratec Cinergy Hybrid XE / Cinergy Hybrid-Stick",
462 .tuner_type
= TUNER_XC2028
, /* has a XC3028 */
463 .tuner_addr
= 0xc2 >> 1,
464 .demod_addr
= 0x1e >> 1,
475 .tuner_reset
= TM6010_GPIO_2
,
476 .tuner_on
= TM6010_GPIO_3
,
477 .demod_reset
= TM6010_GPIO_1
,
478 .demod_on
= TM6010_GPIO_4
,
479 .power_led
= TM6010_GPIO_7
,
480 .dvb_led
= TM6010_GPIO_5
,
483 .ir_codes
= RC_MAP_NEC_TERRATEC_CINERGY_XS
,
485 .type
= TM6000_INPUT_TV
,
486 .vmux
= TM6000_VMUX_VIDEO_B
,
487 .amux
= TM6000_AMUX_SIF1
,
489 .type
= TM6000_INPUT_COMPOSITE1
,
490 .vmux
= TM6000_VMUX_VIDEO_A
,
491 .amux
= TM6000_AMUX_ADC2
,
493 .type
= TM6000_INPUT_SVIDEO
,
494 .vmux
= TM6000_VMUX_VIDEO_AB
,
495 .amux
= TM6000_AMUX_ADC2
,
499 .type
= TM6000_INPUT_RADIO
,
500 .amux
= TM6000_AMUX_SIF1
,
503 [TM5600_BOARD_TERRATEC_GRABSTER
] = {
504 .name
= "Terratec Grabster AV 150/250 MX",
506 .tuner_type
= TUNER_ABSENT
,
508 .type
= TM6000_INPUT_TV
,
509 .vmux
= TM6000_VMUX_VIDEO_B
,
510 .amux
= TM6000_AMUX_ADC1
,
512 .type
= TM6000_INPUT_COMPOSITE1
,
513 .vmux
= TM6000_VMUX_VIDEO_A
,
514 .amux
= TM6000_AMUX_ADC2
,
516 .type
= TM6000_INPUT_SVIDEO
,
517 .vmux
= TM6000_VMUX_VIDEO_AB
,
518 .amux
= TM6000_AMUX_ADC2
,
522 [TM6010_BOARD_TWINHAN_TU501
] = {
523 .name
= "Twinhan TU501(704D1)",
524 .tuner_type
= TUNER_XC2028
, /* has a XC3028 */
525 .tuner_addr
= 0xc2 >> 1,
526 .demod_addr
= 0x1e >> 1,
536 .tuner_reset
= TM6010_GPIO_2
,
537 .tuner_on
= TM6010_GPIO_3
,
538 .demod_reset
= TM6010_GPIO_1
,
539 .demod_on
= TM6010_GPIO_4
,
540 .power_led
= TM6010_GPIO_7
,
541 .dvb_led
= TM6010_GPIO_5
,
545 .type
= TM6000_INPUT_TV
,
546 .vmux
= TM6000_VMUX_VIDEO_B
,
547 .amux
= TM6000_AMUX_SIF1
,
549 .type
= TM6000_INPUT_COMPOSITE1
,
550 .vmux
= TM6000_VMUX_VIDEO_A
,
551 .amux
= TM6000_AMUX_ADC2
,
553 .type
= TM6000_INPUT_SVIDEO
,
554 .vmux
= TM6000_VMUX_VIDEO_AB
,
555 .amux
= TM6000_AMUX_ADC2
,
559 [TM6010_BOARD_BEHOLD_WANDER_LITE
] = {
560 .name
= "Beholder Wander Lite DVB-T/TV/FM USB2.0",
561 .tuner_type
= TUNER_XC5000
,
562 .tuner_addr
= 0xc2 >> 1,
563 .demod_addr
= 0x1e >> 1,
574 .tuner_reset
= TM6010_GPIO_0
,
575 .demod_reset
= TM6010_GPIO_1
,
576 .power_led
= TM6010_GPIO_6
,
579 .type
= TM6000_INPUT_TV
,
580 .vmux
= TM6000_VMUX_VIDEO_B
,
581 .amux
= TM6000_AMUX_SIF1
,
585 .type
= TM6000_INPUT_RADIO
,
586 .amux
= TM6000_AMUX_ADC1
,
589 [TM6010_BOARD_BEHOLD_VOYAGER_LITE
] = {
590 .name
= "Beholder Voyager Lite TV/FM USB2.0",
591 .tuner_type
= TUNER_XC5000
,
592 .tuner_addr
= 0xc2 >> 1,
603 .tuner_reset
= TM6010_GPIO_0
,
604 .power_led
= TM6010_GPIO_6
,
607 .type
= TM6000_INPUT_TV
,
608 .vmux
= TM6000_VMUX_VIDEO_B
,
609 .amux
= TM6000_AMUX_SIF1
,
613 .type
= TM6000_INPUT_RADIO
,
614 .amux
= TM6000_AMUX_ADC1
,
619 /* table of devices that work with this driver */
620 static struct usb_device_id tm6000_id_table
[] = {
621 { USB_DEVICE(0x6000, 0x0001), .driver_info
= TM5600_BOARD_GENERIC
},
622 { USB_DEVICE(0x6000, 0x0002), .driver_info
= TM6010_BOARD_GENERIC
},
623 { USB_DEVICE(0x06e1, 0xf332), .driver_info
= TM6000_BOARD_ADSTECH_DUAL_TV
},
624 { USB_DEVICE(0x14aa, 0x0620), .driver_info
= TM6000_BOARD_FREECOM_AND_SIMILAR
},
625 { USB_DEVICE(0x06e1, 0xb339), .driver_info
= TM6000_BOARD_ADSTECH_MINI_DUAL_TV
},
626 { USB_DEVICE(0x2040, 0x6600), .driver_info
= TM6010_BOARD_HAUPPAUGE_900H
},
627 { USB_DEVICE(0x2040, 0x6601), .driver_info
= TM6010_BOARD_HAUPPAUGE_900H
},
628 { USB_DEVICE(0x2040, 0x6610), .driver_info
= TM6010_BOARD_HAUPPAUGE_900H
},
629 { USB_DEVICE(0x2040, 0x6611), .driver_info
= TM6010_BOARD_HAUPPAUGE_900H
},
630 { USB_DEVICE(0x6000, 0xdec0), .driver_info
= TM6010_BOARD_BEHOLD_WANDER
},
631 { USB_DEVICE(0x6000, 0xdec1), .driver_info
= TM6010_BOARD_BEHOLD_VOYAGER
},
632 { USB_DEVICE(0x0ccd, 0x0086), .driver_info
= TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
},
633 { USB_DEVICE(0x0ccd, 0x00A5), .driver_info
= TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
},
634 { USB_DEVICE(0x0ccd, 0x0079), .driver_info
= TM5600_BOARD_TERRATEC_GRABSTER
},
635 { USB_DEVICE(0x13d3, 0x3240), .driver_info
= TM6010_BOARD_TWINHAN_TU501
},
636 { USB_DEVICE(0x13d3, 0x3241), .driver_info
= TM6010_BOARD_TWINHAN_TU501
},
637 { USB_DEVICE(0x13d3, 0x3243), .driver_info
= TM6010_BOARD_TWINHAN_TU501
},
638 { USB_DEVICE(0x13d3, 0x3264), .driver_info
= TM6010_BOARD_TWINHAN_TU501
},
639 { USB_DEVICE(0x6000, 0xdec2), .driver_info
= TM6010_BOARD_BEHOLD_WANDER_LITE
},
640 { USB_DEVICE(0x6000, 0xdec3), .driver_info
= TM6010_BOARD_BEHOLD_VOYAGER_LITE
},
643 MODULE_DEVICE_TABLE(usb
, tm6000_id_table
);
645 /* Control power led for show some activity */
646 void tm6000_flash_led(struct tm6000_core
*dev
, u8 state
)
648 /* Power LED unconfigured */
649 if (!dev
->gpio
.power_led
)
654 switch (dev
->model
) {
655 case TM6010_BOARD_HAUPPAUGE_900H
:
656 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
:
657 case TM6010_BOARD_TWINHAN_TU501
:
658 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
659 dev
->gpio
.power_led
, 0x00);
661 case TM6010_BOARD_BEHOLD_WANDER
:
662 case TM6010_BOARD_BEHOLD_VOYAGER
:
663 case TM6010_BOARD_BEHOLD_WANDER_LITE
:
664 case TM6010_BOARD_BEHOLD_VOYAGER_LITE
:
665 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
666 dev
->gpio
.power_led
, 0x01);
672 switch (dev
->model
) {
673 case TM6010_BOARD_HAUPPAUGE_900H
:
674 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
:
675 case TM6010_BOARD_TWINHAN_TU501
:
676 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
677 dev
->gpio
.power_led
, 0x01);
679 case TM6010_BOARD_BEHOLD_WANDER
:
680 case TM6010_BOARD_BEHOLD_VOYAGER
:
681 case TM6010_BOARD_BEHOLD_WANDER_LITE
:
682 case TM6010_BOARD_BEHOLD_VOYAGER_LITE
:
683 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
684 dev
->gpio
.power_led
, 0x00);
690 /* Tuner callback to provide the proper gpio changes needed for xc5000 */
691 int tm6000_xc5000_callback(void *ptr
, int component
, int command
, int arg
)
694 struct tm6000_core
*dev
= ptr
;
696 if (dev
->tuner_type
!= TUNER_XC5000
)
700 case XC5000_TUNER_RESET
:
701 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
702 dev
->gpio
.tuner_reset
, 0x01);
704 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
705 dev
->gpio
.tuner_reset
, 0x00);
707 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
708 dev
->gpio
.tuner_reset
, 0x01);
713 EXPORT_SYMBOL_GPL(tm6000_xc5000_callback
);
715 /* Tuner callback to provide the proper gpio changes needed for xc2028 */
717 int tm6000_tuner_callback(void *ptr
, int component
, int command
, int arg
)
720 struct tm6000_core
*dev
= ptr
;
722 if (dev
->tuner_type
!= TUNER_XC2028
)
726 case XC2028_RESET_CLK
:
727 tm6000_ir_wait(dev
, 0);
729 tm6000_set_reg(dev
, REQ_04_EN_DISABLE_MCU_INT
,
732 rc
= tm6000_i2c_reset(dev
, 10);
734 case XC2028_TUNER_RESET
:
735 /* Reset codes during load firmware */
738 /* newer tuner can faster reset */
739 switch (dev
->model
) {
740 case TM5600_BOARD_10MOONS_UT821
:
741 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
742 dev
->gpio
.tuner_reset
, 0x01);
743 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
746 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
747 dev
->gpio
.tuner_reset
, 0x00);
748 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
751 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
752 dev
->gpio
.tuner_reset
, 0x01);
753 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
756 case TM6010_BOARD_HAUPPAUGE_900H
:
757 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
:
758 case TM6010_BOARD_TWINHAN_TU501
:
759 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
760 dev
->gpio
.tuner_reset
, 0x01);
762 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
763 dev
->gpio
.tuner_reset
, 0x00);
765 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
766 dev
->gpio
.tuner_reset
, 0x01);
770 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
771 dev
->gpio
.tuner_reset
, 0x00);
773 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
774 dev
->gpio
.tuner_reset
, 0x01);
779 tm6000_ir_wait(dev
, 1);
782 tm6000_set_reg(dev
, REQ_04_EN_DISABLE_MCU_INT
,
787 rc
= tm6000_i2c_reset(dev
, 100);
791 case XC2028_I2C_FLUSH
:
792 tm6000_set_reg(dev
, REQ_50_SET_START
, 0, 0);
793 tm6000_set_reg(dev
, REQ_51_SET_STOP
, 0, 0);
798 EXPORT_SYMBOL_GPL(tm6000_tuner_callback
);
800 int tm6000_cards_setup(struct tm6000_core
*dev
)
803 * Board-specific initialization sequence. Handles all GPIO
804 * initialization sequences that are board-specific.
805 * Up to now, all found devices use GPIO1 and GPIO4 at the same way.
806 * Probably, they're all based on some reference device. Due to that,
807 * there's a common routine at the end to handle those GPIO's. Devices
808 * that use different pinups or init sequences can just return at
809 * the board-specific session.
811 switch (dev
->model
) {
812 case TM6010_BOARD_HAUPPAUGE_900H
:
813 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
:
814 case TM6010_BOARD_TWINHAN_TU501
:
815 case TM6010_BOARD_GENERIC
:
816 /* Turn xceive 3028 on */
817 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.tuner_on
, 0x01);
819 /* Turn zarlink zl10353 on */
820 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.demod_on
, 0x00);
822 /* Reset zarlink zl10353 */
823 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.demod_reset
, 0x00);
825 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.demod_reset
, 0x01);
827 /* Turn zarlink zl10353 off */
828 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.demod_on
, 0x01);
831 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.ir
, 0x01);
833 /* Power led on (blue) */
834 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.power_led
, 0x00);
836 /* DVB led off (orange) */
837 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.dvb_led
, 0x01);
839 /* Turn zarlink zl10353 on */
840 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.demod_on
, 0x00);
843 case TM6010_BOARD_BEHOLD_WANDER
:
844 case TM6010_BOARD_BEHOLD_WANDER_LITE
:
845 /* Power led on (blue) */
846 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.power_led
, 0x01);
848 /* Reset zarlink zl10353 */
849 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.demod_reset
, 0x00);
851 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.demod_reset
, 0x01);
854 case TM6010_BOARD_BEHOLD_VOYAGER
:
855 case TM6010_BOARD_BEHOLD_VOYAGER_LITE
:
856 /* Power led on (blue) */
857 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
, dev
->gpio
.power_led
, 0x01);
865 * Default initialization. Most of the devices seem to use GPIO1
866 * and GPIO4.on the same way, so, this handles the common sequence
867 * used by most devices.
868 * If a device uses a different sequence or different GPIO pins for
869 * reset, just add the code at the board-specific part
872 if (dev
->gpio
.tuner_reset
) {
876 for (i
= 0; i
< 2; i
++) {
877 rc
= tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
878 dev
->gpio
.tuner_reset
, 0x00);
880 printk(KERN_ERR
"Error %i doing tuner reset\n", rc
);
884 msleep(10); /* Just to be conservative */
885 rc
= tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
886 dev
->gpio
.tuner_reset
, 0x01);
888 printk(KERN_ERR
"Error %i doing tuner reset\n", rc
);
893 printk(KERN_ERR
"Tuner reset is not configured\n");
902 static void tm6000_config_tuner(struct tm6000_core
*dev
)
904 struct tuner_setup tun_setup
;
906 /* Load tuner module */
907 v4l2_i2c_new_subdev(&dev
->v4l2_dev
, &dev
->i2c_adap
,
908 "tuner", dev
->tuner_addr
, NULL
);
910 memset(&tun_setup
, 0, sizeof(tun_setup
));
911 tun_setup
.type
= dev
->tuner_type
;
912 tun_setup
.addr
= dev
->tuner_addr
;
914 tun_setup
.mode_mask
= 0;
915 if (dev
->caps
.has_tuner
)
916 tun_setup
.mode_mask
|= (T_ANALOG_TV
| T_RADIO
);
918 switch (dev
->tuner_type
) {
920 tun_setup
.tuner_callback
= tm6000_tuner_callback
;
923 tun_setup
.tuner_callback
= tm6000_xc5000_callback
;
927 v4l2_device_call_all(&dev
->v4l2_dev
, 0, tuner
, s_type_addr
, &tun_setup
);
929 switch (dev
->tuner_type
) {
931 struct v4l2_priv_tun_config xc2028_cfg
;
932 struct xc2028_ctrl ctl
;
934 memset(&xc2028_cfg
, 0, sizeof(xc2028_cfg
));
935 memset(&ctl
, 0, sizeof(ctl
));
937 ctl
.demod
= XC3028_FE_ZARLINK456
;
939 xc2028_cfg
.tuner
= TUNER_XC2028
;
940 xc2028_cfg
.priv
= &ctl
;
942 switch (dev
->model
) {
943 case TM6010_BOARD_HAUPPAUGE_900H
:
944 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
:
945 case TM6010_BOARD_TWINHAN_TU501
:
947 ctl
.fname
= "xc3028L-v36.fw";
950 if (dev
->dev_type
== TM6010
)
951 ctl
.fname
= "xc3028-v27.fw";
953 ctl
.fname
= "xc3028-v24.fw";
956 printk(KERN_INFO
"Setting firmware parameters for xc2028\n");
957 v4l2_device_call_all(&dev
->v4l2_dev
, 0, tuner
, s_config
,
964 struct v4l2_priv_tun_config xc5000_cfg
;
965 struct xc5000_config ctl
= {
966 .i2c_address
= dev
->tuner_addr
,
968 .radio_input
= XC5000_RADIO_FM1_MONO
,
971 xc5000_cfg
.tuner
= TUNER_XC5000
;
972 xc5000_cfg
.priv
= &ctl
;
974 v4l2_device_call_all(&dev
->v4l2_dev
, 0, tuner
, s_config
,
979 printk(KERN_INFO
"Unknown tuner type. Tuner is not configured.\n");
984 static int fill_board_specific_data(struct tm6000_core
*dev
)
988 dev
->dev_type
= tm6000_boards
[dev
->model
].type
;
989 dev
->tuner_type
= tm6000_boards
[dev
->model
].tuner_type
;
990 dev
->tuner_addr
= tm6000_boards
[dev
->model
].tuner_addr
;
992 dev
->gpio
= tm6000_boards
[dev
->model
].gpio
;
994 dev
->ir_codes
= tm6000_boards
[dev
->model
].ir_codes
;
996 dev
->demod_addr
= tm6000_boards
[dev
->model
].demod_addr
;
998 dev
->caps
= tm6000_boards
[dev
->model
].caps
;
1000 dev
->vinput
[0] = tm6000_boards
[dev
->model
].vinput
[0];
1001 dev
->vinput
[1] = tm6000_boards
[dev
->model
].vinput
[1];
1002 dev
->vinput
[2] = tm6000_boards
[dev
->model
].vinput
[2];
1003 dev
->rinput
= tm6000_boards
[dev
->model
].rinput
;
1005 /* setup per-model quirks */
1006 switch (dev
->model
) {
1007 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
:
1008 case TM6010_BOARD_HAUPPAUGE_900H
:
1009 dev
->quirks
|= TM6000_QUIRK_NO_USB_DELAY
;
1016 /* initialize hardware */
1017 rc
= tm6000_init(dev
);
1021 return v4l2_device_register(&dev
->udev
->dev
, &dev
->v4l2_dev
);
1025 static void use_alternative_detection_method(struct tm6000_core
*dev
)
1029 if (!dev
->eedata_size
)
1032 for (i
= 0; i
< ARRAY_SIZE(tm6000_boards
); i
++) {
1033 if (!tm6000_boards
[i
].eename_size
)
1035 if (dev
->eedata_size
< tm6000_boards
[i
].eename_pos
+
1036 tm6000_boards
[i
].eename_size
)
1039 if (!memcmp(&dev
->eedata
[tm6000_boards
[i
].eename_pos
],
1040 tm6000_boards
[i
].eename
,
1041 tm6000_boards
[i
].eename_size
)) {
1047 printk(KERN_INFO
"Device has eeprom but is currently unknown\n");
1053 printk(KERN_INFO
"Device identified via eeprom as %s (type = %d)\n",
1054 tm6000_boards
[model
].name
, model
);
1057 #if defined(CONFIG_MODULES) && defined(MODULE)
1058 static void request_module_async(struct work_struct
*work
)
1060 struct tm6000_core
*dev
= container_of(work
, struct tm6000_core
,
1063 request_module("tm6000-alsa");
1065 if (dev
->caps
.has_dvb
)
1066 request_module("tm6000-dvb");
1069 static void request_modules(struct tm6000_core
*dev
)
1071 INIT_WORK(&dev
->request_module_wk
, request_module_async
);
1072 schedule_work(&dev
->request_module_wk
);
1075 static void flush_request_modules(struct tm6000_core
*dev
)
1077 flush_work(&dev
->request_module_wk
);
1080 #define request_modules(dev)
1081 #define flush_request_modules(dev)
1082 #endif /* CONFIG_MODULES */
1084 static int tm6000_init_dev(struct tm6000_core
*dev
)
1086 struct v4l2_frequency f
;
1089 mutex_init(&dev
->lock
);
1090 mutex_lock(&dev
->lock
);
1092 if (!is_generic(dev
->model
)) {
1093 rc
= fill_board_specific_data(dev
);
1097 /* register i2c bus */
1098 rc
= tm6000_i2c_register(dev
);
1102 /* register i2c bus */
1103 rc
= tm6000_i2c_register(dev
);
1107 use_alternative_detection_method(dev
);
1109 rc
= fill_board_specific_data(dev
);
1114 /* Default values for STD and resolutions */
1117 dev
->norm
= V4L2_STD_NTSC_M
;
1119 /* Configure tuner */
1120 tm6000_config_tuner(dev
);
1122 /* Set video standard */
1123 v4l2_device_call_all(&dev
->v4l2_dev
, 0, core
, s_std
, dev
->norm
);
1125 /* Set tuner frequency - also loads firmware on xc2028/xc3028 */
1127 f
.type
= V4L2_TUNER_ANALOG_TV
;
1128 f
.frequency
= 3092; /* 193.25 MHz */
1129 dev
->freq
= f
.frequency
;
1130 v4l2_device_call_all(&dev
->v4l2_dev
, 0, tuner
, s_frequency
, &f
);
1132 if (dev
->caps
.has_tda9874
)
1133 v4l2_i2c_new_subdev(&dev
->v4l2_dev
, &dev
->i2c_adap
,
1134 "tvaudio", I2C_ADDR_TDA9874
, NULL
);
1136 /* register and initialize V4L2 */
1137 rc
= tm6000_v4l2_register(dev
);
1141 tm6000_add_into_devlist(dev
);
1142 tm6000_init_extension(dev
);
1144 tm6000_ir_init(dev
);
1146 request_modules(dev
);
1148 mutex_unlock(&dev
->lock
);
1152 mutex_unlock(&dev
->lock
);
1156 /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
1157 #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
1159 static void get_max_endpoint(struct usb_device
*udev
,
1160 struct usb_host_interface
*alt
,
1162 struct usb_host_endpoint
*curr_e
,
1163 struct tm6000_endpoint
*tm_ep
)
1165 u16 tmp
= le16_to_cpu(curr_e
->desc
.wMaxPacketSize
);
1166 unsigned int size
= tmp
& 0x7ff;
1168 if (udev
->speed
== USB_SPEED_HIGH
)
1169 size
= size
* hb_mult(tmp
);
1171 if (size
> tm_ep
->maxsize
) {
1172 tm_ep
->endp
= curr_e
;
1173 tm_ep
->maxsize
= size
;
1174 tm_ep
->bInterfaceNumber
= alt
->desc
.bInterfaceNumber
;
1175 tm_ep
->bAlternateSetting
= alt
->desc
.bAlternateSetting
;
1177 printk(KERN_INFO
"tm6000: %s endpoint: 0x%02x (max size=%u bytes)\n",
1178 msgtype
, curr_e
->desc
.bEndpointAddress
,
1184 * tm6000_usb_probe()
1185 * checks for supported devices
1187 static int tm6000_usb_probe(struct usb_interface
*interface
,
1188 const struct usb_device_id
*id
)
1190 struct usb_device
*usbdev
;
1191 struct tm6000_core
*dev
= NULL
;
1196 usbdev
= usb_get_dev(interface_to_usbdev(interface
));
1198 /* Selects the proper interface */
1199 rc
= usb_set_interface(usbdev
, 0, 1);
1203 /* Check to see next free device and mark as used */
1204 nr
= find_first_zero_bit(&tm6000_devused
, TM6000_MAXBOARDS
);
1205 if (nr
>= TM6000_MAXBOARDS
) {
1206 printk(KERN_ERR
"tm6000: Supports only %i tm60xx boards.\n", TM6000_MAXBOARDS
);
1207 usb_put_dev(usbdev
);
1211 /* Create and initialize dev struct */
1212 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
1214 printk(KERN_ERR
"tm6000" ": out of memory!\n");
1215 usb_put_dev(usbdev
);
1218 spin_lock_init(&dev
->slock
);
1219 mutex_init(&dev
->usb_lock
);
1221 /* Increment usage count */
1222 set_bit(nr
, &tm6000_devused
);
1223 snprintf(dev
->name
, 29, "tm6000 #%d", nr
);
1225 dev
->model
= id
->driver_info
;
1226 if (card
[nr
] < ARRAY_SIZE(tm6000_boards
))
1227 dev
->model
= card
[nr
];
1232 switch (usbdev
->speed
) {
1236 case USB_SPEED_UNKNOWN
:
1237 case USB_SPEED_FULL
:
1240 case USB_SPEED_HIGH
:
1248 for (i
= 0; i
< interface
->num_altsetting
; i
++) {
1251 for (ep
= 0; ep
< interface
->altsetting
[i
].desc
.bNumEndpoints
; ep
++) {
1252 struct usb_host_endpoint
*e
;
1255 e
= &interface
->altsetting
[i
].endpoint
[ep
];
1257 dir_out
= ((e
->desc
.bEndpointAddress
&
1258 USB_ENDPOINT_DIR_MASK
) == USB_DIR_OUT
);
1260 printk(KERN_INFO
"tm6000: alt %d, interface %i, class %i\n",
1262 interface
->altsetting
[i
].desc
.bInterfaceNumber
,
1263 interface
->altsetting
[i
].desc
.bInterfaceClass
);
1265 switch (e
->desc
.bmAttributes
) {
1266 case USB_ENDPOINT_XFER_BULK
:
1268 get_max_endpoint(usbdev
,
1269 &interface
->altsetting
[i
],
1273 get_max_endpoint(usbdev
,
1274 &interface
->altsetting
[i
],
1279 case USB_ENDPOINT_XFER_ISOC
:
1281 get_max_endpoint(usbdev
,
1282 &interface
->altsetting
[i
],
1286 get_max_endpoint(usbdev
,
1287 &interface
->altsetting
[i
],
1292 case USB_ENDPOINT_XFER_INT
:
1294 get_max_endpoint(usbdev
,
1295 &interface
->altsetting
[i
],
1299 get_max_endpoint(usbdev
,
1300 &interface
->altsetting
[i
],
1310 printk(KERN_INFO
"tm6000: New video device @ %s Mbps (%04x:%04x, ifnum %d)\n",
1312 le16_to_cpu(dev
->udev
->descriptor
.idVendor
),
1313 le16_to_cpu(dev
->udev
->descriptor
.idProduct
),
1314 interface
->altsetting
->desc
.bInterfaceNumber
);
1316 /* check if the the device has the iso in endpoint at the correct place */
1317 if (!dev
->isoc_in
.endp
) {
1318 printk(KERN_ERR
"tm6000: probing error: no IN ISOC endpoint!\n");
1324 /* save our data pointer in this interface device */
1325 usb_set_intfdata(interface
, dev
);
1327 printk(KERN_INFO
"tm6000: Found %s\n", tm6000_boards
[dev
->model
].name
);
1329 rc
= tm6000_init_dev(dev
);
1336 printk(KERN_ERR
"tm6000: Error %d while registering\n", rc
);
1338 clear_bit(nr
, &tm6000_devused
);
1339 usb_put_dev(usbdev
);
1346 * tm6000_usb_disconnect()
1347 * called when the device gets diconencted
1348 * video device will be unregistered on v4l2_close in case it is still open
1350 static void tm6000_usb_disconnect(struct usb_interface
*interface
)
1352 struct tm6000_core
*dev
= usb_get_intfdata(interface
);
1353 usb_set_intfdata(interface
, NULL
);
1358 printk(KERN_INFO
"tm6000: disconnecting %s\n", dev
->name
);
1360 flush_request_modules(dev
);
1362 tm6000_ir_fini(dev
);
1364 if (dev
->gpio
.power_led
) {
1365 switch (dev
->model
) {
1366 case TM6010_BOARD_HAUPPAUGE_900H
:
1367 case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE
:
1368 case TM6010_BOARD_TWINHAN_TU501
:
1370 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
1371 dev
->gpio
.power_led
, 0x01);
1374 case TM6010_BOARD_BEHOLD_WANDER
:
1375 case TM6010_BOARD_BEHOLD_VOYAGER
:
1376 case TM6010_BOARD_BEHOLD_WANDER_LITE
:
1377 case TM6010_BOARD_BEHOLD_VOYAGER_LITE
:
1379 tm6000_set_reg(dev
, REQ_03_SET_GET_MCU_PIN
,
1380 dev
->gpio
.power_led
, 0x00);
1385 tm6000_v4l2_unregister(dev
);
1387 tm6000_i2c_unregister(dev
);
1389 v4l2_device_unregister(&dev
->v4l2_dev
);
1391 dev
->state
|= DEV_DISCONNECTED
;
1393 usb_put_dev(dev
->udev
);
1395 tm6000_close_extension(dev
);
1396 tm6000_remove_from_devlist(dev
);
1398 clear_bit(dev
->devno
, &tm6000_devused
);
1402 static struct usb_driver tm6000_usb_driver
= {
1404 .probe
= tm6000_usb_probe
,
1405 .disconnect
= tm6000_usb_disconnect
,
1406 .id_table
= tm6000_id_table
,
1409 module_usb_driver(tm6000_usb_driver
);
1411 MODULE_DESCRIPTION("Trident TVMaster TM5600/TM6000/TM6010 USB2 adapter");
1412 MODULE_AUTHOR("Mauro Carvalho Chehab");
1413 MODULE_LICENSE("GPL");