2 em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
5 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
6 Markus Rechberger <mrechberger@gmail.com>
7 Mauro Carvalho Chehab <mchehab@infradead.org>
8 Sascha Sommer <saschasommer@freenet.de>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <linux/init.h>
26 #include <linux/module.h>
27 #include <linux/delay.h>
28 #include <linux/i2c.h>
29 #include <linux/usb.h>
30 #include <media/tuner.h>
31 #include <media/msp3400.h>
32 #include <media/saa7115.h>
33 #include <media/tvp5150.h>
34 #include <media/tveeprom.h>
35 #include <media/audiochip.h>
36 #include <media/v4l2-common.h>
39 #include "tuner-xc2028.h"
41 static int tuner
= -1;
42 module_param(tuner
, int, 0444);
43 MODULE_PARM_DESC(tuner
, "tuner type");
45 static unsigned int disable_ir
;
46 module_param(disable_ir
, int, 0444);
47 MODULE_PARM_DESC(disable_ir
, "disable infrared remote support");
49 struct em28xx_hash_table
{
55 /* Boards supported by driver */
57 #define EM2800_BOARD_UNKNOWN 0
58 #define EM2820_BOARD_UNKNOWN 1
59 #define EM2820_BOARD_TERRATEC_CINERGY_250 2
60 #define EM2820_BOARD_PINNACLE_USB_2 3
61 #define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4
62 #define EM2820_BOARD_MSI_VOX_USB_2 5
63 #define EM2800_BOARD_TERRATEC_CINERGY_200 6
64 #define EM2800_BOARD_LEADTEK_WINFAST_USBII 7
65 #define EM2800_BOARD_KWORLD_USB2800 8
66 #define EM2820_BOARD_PINNACLE_DVC_90 9
67 #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10
68 #define EM2880_BOARD_TERRATEC_HYBRID_XS 11
69 #define EM2820_BOARD_KWORLD_PVRTV2800RF 12
70 #define EM2880_BOARD_TERRATEC_PRODIGY_XS 13
71 #define EM2820_BOARD_PROLINK_PLAYTV_USB2 14
72 #define EM2800_BOARD_VGEAR_POCKETTV 15
73 #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 16
75 struct em28xx_board em28xx_boards
[] = {
76 [EM2800_BOARD_UNKNOWN
] = {
77 .name
= "Unknown EM2800 video grabber",
80 .tda9887_conf
= TDA9887_PRESENT
,
81 .decoder
= EM28XX_SAA7113
,
83 .type
= EM28XX_VMUX_COMPOSITE1
,
84 .vmux
= SAA7115_COMPOSITE0
,
87 .type
= EM28XX_VMUX_SVIDEO
,
88 .vmux
= SAA7115_SVIDEO3
,
92 [EM2820_BOARD_UNKNOWN
] = {
93 .name
= "Unknown EM2750/28xx video grabber",
95 .tuner_type
= TUNER_ABSENT
,
97 [EM2820_BOARD_KWORLD_PVRTV2800RF
] = {
98 .name
= "Kworld PVR TV 2800 RF",
101 .tuner_type
= TUNER_TEMIC_PAL
,
102 .tda9887_conf
= TDA9887_PRESENT
,
103 .decoder
= EM28XX_SAA7113
,
105 .type
= EM28XX_VMUX_COMPOSITE1
,
106 .vmux
= SAA7115_COMPOSITE0
,
109 .type
= EM28XX_VMUX_SVIDEO
,
110 .vmux
= SAA7115_SVIDEO3
,
114 [EM2820_BOARD_TERRATEC_CINERGY_250
] = {
115 .name
= "Terratec Cinergy 250 USB",
117 .tuner_type
= TUNER_LG_PAL_NEW_TAPC
,
118 .tda9887_conf
= TDA9887_PRESENT
,
119 .decoder
= EM28XX_SAA7113
,
121 .type
= EM28XX_VMUX_TELEVISION
,
122 .vmux
= SAA7115_COMPOSITE2
,
125 .type
= EM28XX_VMUX_COMPOSITE1
,
126 .vmux
= SAA7115_COMPOSITE0
,
129 .type
= EM28XX_VMUX_SVIDEO
,
130 .vmux
= SAA7115_SVIDEO3
,
134 [EM2820_BOARD_PINNACLE_USB_2
] = {
135 .name
= "Pinnacle PCTV USB 2",
137 .tuner_type
= TUNER_LG_PAL_NEW_TAPC
,
138 .tda9887_conf
= TDA9887_PRESENT
,
139 .decoder
= EM28XX_SAA7113
,
141 .type
= EM28XX_VMUX_TELEVISION
,
142 .vmux
= SAA7115_COMPOSITE2
,
145 .type
= EM28XX_VMUX_COMPOSITE1
,
146 .vmux
= SAA7115_COMPOSITE0
,
149 .type
= EM28XX_VMUX_SVIDEO
,
150 .vmux
= SAA7115_SVIDEO3
,
154 [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2
] = {
155 .name
= "Hauppauge WinTV USB 2",
157 .tuner_type
= TUNER_PHILIPS_FM1236_MK3
,
158 .tda9887_conf
= TDA9887_PRESENT
|
159 TDA9887_PORT1_ACTIVE
|
160 TDA9887_PORT2_ACTIVE
,
161 .decoder
= EM28XX_TVP5150
,
163 /*FIXME: S-Video not tested */
165 .type
= EM28XX_VMUX_TELEVISION
,
166 .vmux
= TVP5150_COMPOSITE0
,
167 .amux
= MSP_INPUT_DEFAULT
,
169 .type
= EM28XX_VMUX_SVIDEO
,
170 .vmux
= TVP5150_SVIDEO
,
171 .amux
= MSP_INPUT(MSP_IN_SCART1
, MSP_IN_TUNER1
,
172 MSP_DSP_IN_SCART
, MSP_DSP_IN_SCART
),
175 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900
] = {
176 .name
= "Hauppauge WinTV HVR 900",
178 .tda9887_conf
= TDA9887_PRESENT
,
179 .tuner_type
= TUNER_XC2028
,
181 .decoder
= EM28XX_TVP5150
,
183 .type
= EM28XX_VMUX_TELEVISION
,
184 .vmux
= TVP5150_COMPOSITE0
,
187 .type
= EM28XX_VMUX_COMPOSITE1
,
188 .vmux
= TVP5150_COMPOSITE1
,
191 .type
= EM28XX_VMUX_SVIDEO
,
192 .vmux
= TVP5150_SVIDEO
,
196 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950
] = {
197 .name
= "Hauppauge WinTV HVR 950",
199 .tda9887_conf
= TDA9887_PRESENT
,
200 .tuner_type
= TUNER_XC2028
,
203 .decoder
= EM28XX_TVP5150
,
205 .type
= EM28XX_VMUX_TELEVISION
,
206 .vmux
= TVP5150_COMPOSITE0
,
209 .type
= EM28XX_VMUX_COMPOSITE1
,
210 .vmux
= TVP5150_COMPOSITE1
,
213 .type
= EM28XX_VMUX_SVIDEO
,
214 .vmux
= TVP5150_SVIDEO
,
219 .analog_gpio
= 0x003d2d,
221 [EM2880_BOARD_TERRATEC_HYBRID_XS
] = {
222 .name
= "Terratec Hybrid XS",
224 .tda9887_conf
= TDA9887_PRESENT
,
225 .tuner_type
= TUNER_XC2028
,
226 .decoder
= EM28XX_TVP5150
,
228 .type
= EM28XX_VMUX_TELEVISION
,
229 .vmux
= TVP5150_COMPOSITE0
,
232 .type
= EM28XX_VMUX_COMPOSITE1
,
233 .vmux
= TVP5150_COMPOSITE1
,
236 .type
= EM28XX_VMUX_SVIDEO
,
237 .vmux
= TVP5150_SVIDEO
,
241 /* maybe there's a reason behind it why Terratec sells the Hybrid XS
242 as Prodigy XS with a different PID, let's keep it separated for now
243 maybe we'll need it lateron */
244 [EM2880_BOARD_TERRATEC_PRODIGY_XS
] = {
245 .name
= "Terratec Prodigy XS",
247 .tda9887_conf
= TDA9887_PRESENT
,
248 .tuner_type
= TUNER_XC2028
,
249 .decoder
= EM28XX_TVP5150
,
251 .type
= EM28XX_VMUX_TELEVISION
,
252 .vmux
= TVP5150_COMPOSITE0
,
255 .type
= EM28XX_VMUX_COMPOSITE1
,
256 .vmux
= TVP5150_COMPOSITE1
,
259 .type
= EM28XX_VMUX_SVIDEO
,
260 .vmux
= TVP5150_SVIDEO
,
264 [EM2820_BOARD_MSI_VOX_USB_2
] = {
265 .name
= "MSI VOX USB 2.0",
267 .tuner_type
= TUNER_LG_PAL_NEW_TAPC
,
268 .tda9887_conf
= TDA9887_PRESENT
|
269 TDA9887_PORT1_ACTIVE
|
270 TDA9887_PORT2_ACTIVE
,
271 .max_range_640_480
= 1,
273 .decoder
= EM28XX_SAA7114
,
275 .type
= EM28XX_VMUX_TELEVISION
,
276 .vmux
= SAA7115_COMPOSITE4
,
279 .type
= EM28XX_VMUX_COMPOSITE1
,
280 .vmux
= SAA7115_COMPOSITE0
,
283 .type
= EM28XX_VMUX_SVIDEO
,
284 .vmux
= SAA7115_SVIDEO3
,
288 [EM2800_BOARD_TERRATEC_CINERGY_200
] = {
289 .name
= "Terratec Cinergy 200 USB",
292 .tuner_type
= TUNER_LG_PAL_NEW_TAPC
,
293 .tda9887_conf
= TDA9887_PRESENT
,
294 .decoder
= EM28XX_SAA7113
,
296 .type
= EM28XX_VMUX_TELEVISION
,
297 .vmux
= SAA7115_COMPOSITE2
,
300 .type
= EM28XX_VMUX_COMPOSITE1
,
301 .vmux
= SAA7115_COMPOSITE0
,
304 .type
= EM28XX_VMUX_SVIDEO
,
305 .vmux
= SAA7115_SVIDEO3
,
309 [EM2800_BOARD_LEADTEK_WINFAST_USBII
] = {
310 .name
= "Leadtek Winfast USB II",
313 .tuner_type
= TUNER_LG_PAL_NEW_TAPC
,
314 .tda9887_conf
= TDA9887_PRESENT
,
315 .decoder
= EM28XX_SAA7113
,
317 .type
= EM28XX_VMUX_TELEVISION
,
318 .vmux
= SAA7115_COMPOSITE2
,
321 .type
= EM28XX_VMUX_COMPOSITE1
,
322 .vmux
= SAA7115_COMPOSITE0
,
325 .type
= EM28XX_VMUX_SVIDEO
,
326 .vmux
= SAA7115_SVIDEO3
,
330 [EM2800_BOARD_KWORLD_USB2800
] = {
331 .name
= "Kworld USB2800",
334 .tuner_type
= TUNER_PHILIPS_ATSC
,
335 .tda9887_conf
= TDA9887_PRESENT
,
336 .decoder
= EM28XX_SAA7113
,
338 .type
= EM28XX_VMUX_TELEVISION
,
339 .vmux
= SAA7115_COMPOSITE2
,
342 .type
= EM28XX_VMUX_COMPOSITE1
,
343 .vmux
= SAA7115_COMPOSITE0
,
346 .type
= EM28XX_VMUX_SVIDEO
,
347 .vmux
= SAA7115_SVIDEO3
,
351 [EM2820_BOARD_PINNACLE_DVC_90
] = {
352 .name
= "Pinnacle Dazzle DVC 90/DVC 100",
354 .tuner_type
= TUNER_ABSENT
,
355 .decoder
= EM28XX_SAA7113
,
357 .type
= EM28XX_VMUX_COMPOSITE1
,
358 .vmux
= SAA7115_COMPOSITE0
,
361 .type
= EM28XX_VMUX_SVIDEO
,
362 .vmux
= SAA7115_SVIDEO3
,
366 [EM2800_BOARD_VGEAR_POCKETTV
] = {
367 .name
= "V-Gear PocketTV",
370 .tuner_type
= TUNER_LG_PAL_NEW_TAPC
,
371 .tda9887_conf
= TDA9887_PRESENT
,
372 .decoder
= EM28XX_SAA7113
,
374 .type
= EM28XX_VMUX_TELEVISION
,
375 .vmux
= SAA7115_COMPOSITE2
,
378 .type
= EM28XX_VMUX_COMPOSITE1
,
379 .vmux
= SAA7115_COMPOSITE0
,
382 .type
= EM28XX_VMUX_SVIDEO
,
383 .vmux
= SAA7115_SVIDEO3
,
387 [EM2820_BOARD_PROLINK_PLAYTV_USB2
] = {
388 .name
= "Pixelview Prolink PlayTV USB 2.0",
390 .tda9887_conf
= TDA9887_PRESENT
,
391 .tuner_type
= TUNER_YMEC_TVF_5533MF
,
392 .decoder
= EM28XX_SAA7113
,
394 .type
= EM28XX_VMUX_TELEVISION
,
395 .vmux
= SAA7115_COMPOSITE2
,
396 <<<<<<< HEAD
:drivers
/media
/video
/em28xx
/em28xx
-cards
.c
399 .amux
= EM28XX_AMUX_LINE_IN
,
400 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/em28xx
/em28xx
-cards
.c
402 .type
= EM28XX_VMUX_COMPOSITE1
,
403 .vmux
= SAA7115_COMPOSITE0
,
404 <<<<<<< HEAD
:drivers
/media
/video
/em28xx
/em28xx
-cards
.c
407 .amux
= EM28XX_AMUX_LINE_IN
,
408 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/em28xx
/em28xx
-cards
.c
410 .type
= EM28XX_VMUX_SVIDEO
,
411 .vmux
= SAA7115_SVIDEO3
,
412 <<<<<<< HEAD
:drivers
/media
/video
/em28xx
/em28xx
-cards
.c
415 .amux
= EM28XX_AMUX_LINE_IN
,
416 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/em28xx
/em28xx
-cards
.c
420 const unsigned int em28xx_bcount
= ARRAY_SIZE(em28xx_boards
);
422 /* table of devices that work with this driver */
423 struct usb_device_id em28xx_id_table
[] = {
424 { USB_DEVICE(0xeb1a, 0x2750),
425 .driver_info
= EM2820_BOARD_UNKNOWN
},
426 { USB_DEVICE(0xeb1a, 0x2800),
427 .driver_info
= EM2800_BOARD_UNKNOWN
},
428 { USB_DEVICE(0xeb1a, 0x2820),
429 .driver_info
= EM2820_BOARD_UNKNOWN
},
430 { USB_DEVICE(0xeb1a, 0x2821),
431 .driver_info
= EM2820_BOARD_UNKNOWN
},
432 { USB_DEVICE(0xeb1a, 0x2860),
433 .driver_info
= EM2820_BOARD_UNKNOWN
},
434 { USB_DEVICE(0xeb1a, 0x2861),
435 .driver_info
= EM2820_BOARD_UNKNOWN
},
436 { USB_DEVICE(0xeb1a, 0x2870),
437 .driver_info
= EM2820_BOARD_UNKNOWN
},
438 { USB_DEVICE(0xeb1a, 0x2881),
439 .driver_info
= EM2820_BOARD_UNKNOWN
},
440 { USB_DEVICE(0xeb1a, 0x2883),
441 .driver_info
= EM2820_BOARD_UNKNOWN
},
442 { USB_DEVICE(0x0ccd, 0x0036),
443 .driver_info
= EM2820_BOARD_TERRATEC_CINERGY_250
},
444 { USB_DEVICE(0x2304, 0x0208),
445 .driver_info
= EM2820_BOARD_PINNACLE_USB_2
},
446 { USB_DEVICE(0x2040, 0x4200),
447 .driver_info
= EM2820_BOARD_HAUPPAUGE_WINTV_USB_2
},
448 { USB_DEVICE(0x2040, 0x4201),
449 .driver_info
= EM2820_BOARD_HAUPPAUGE_WINTV_USB_2
},
450 { USB_DEVICE(0x2304, 0x0207),
451 .driver_info
= EM2820_BOARD_PINNACLE_DVC_90
},
452 { USB_DEVICE(0x2304, 0x021a),
453 .driver_info
= EM2820_BOARD_PINNACLE_DVC_90
},
454 { USB_DEVICE(0x2040, 0x6500),
455 .driver_info
= EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900
},
456 <<<<<<< HEAD
:drivers
/media
/video
/em28xx
/em28xx
-cards
.c
458 { USB_DEVICE(0x2040, 0x6502),
459 .driver_info
= EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900
},
460 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/em28xx
/em28xx
-cards
.c
461 { USB_DEVICE(0x2040, 0x6513),
462 .driver_info
= EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950
},
463 { USB_DEVICE(0x0ccd, 0x0042),
464 .driver_info
= EM2880_BOARD_TERRATEC_HYBRID_XS
},
465 { USB_DEVICE(0x0ccd, 0x0047),
466 .driver_info
= EM2880_BOARD_TERRATEC_PRODIGY_XS
},
469 MODULE_DEVICE_TABLE(usb
, em28xx_id_table
);
471 /* EEPROM hash table for devices with generic USB IDs */
472 static struct em28xx_hash_table em28xx_eeprom_hash
[] = {
473 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
474 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2
, TUNER_YMEC_TVF_5533MF
},
477 /* I2C devicelist hash table for devices with generic USB IDs */
478 static struct em28xx_hash_table em28xx_i2c_hash
[] = {
479 {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200
, TUNER_LG_PAL_NEW_TAPC
},
480 {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV
, TUNER_LG_PAL_NEW_TAPC
},
483 /* Since em28xx_pre_card_setup() requires a proper dev->model,
484 * this won't work for boards with generic PCI IDs
486 void em28xx_pre_card_setup(struct em28xx
*dev
)
488 /* request some modules */
489 switch (dev
->model
) {
490 case EM2880_BOARD_TERRATEC_PRODIGY_XS
:
491 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900
:
492 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950
:
493 case EM2880_BOARD_TERRATEC_HYBRID_XS
:
494 em28xx_write_regs(dev
, XCLK_REG
, "\x27", 1);
495 em28xx_write_regs(dev
, I2C_CLK_REG
, "\x40", 1);
496 em28xx_write_regs(dev
, 0x08, "\xff", 1);
497 em28xx_write_regs(dev
, 0x04, "\x00", 1);
499 em28xx_write_regs(dev
, 0x04, "\x08", 1);
501 em28xx_write_regs(dev
, 0x08, "\xff", 1);
503 em28xx_write_regs(dev
, 0x08, "\x2d", 1);
505 em28xx_write_regs(dev
, 0x08, "\x3d", 1);
510 static int em28xx_tuner_callback(void *ptr
, int command
, int arg
)
513 struct em28xx
*dev
= ptr
;
515 if (dev
->tuner_type
!= TUNER_XC2028
)
519 case XC2028_TUNER_RESET
:
521 /* GPIO and initialization codes for analog TV and radio
522 This code should be complemented for DTV, since reset
526 dev
->em28xx_write_regs_req(dev
, 0x00, 0x48, "\x00", 1);
527 dev
->em28xx_write_regs_req(dev
, 0x00, 0x12, "\x67", 1);
529 if (dev
->analog_gpio
) {
530 char gpio0
= dev
->analog_gpio
& 0xff;
531 char gpio1
= (dev
->analog_gpio
>> 8) & 0xff;
532 char gpio4
= dev
->analog_gpio
>> 24;
535 dev
->em28xx_write_regs(dev
, 0x04, &gpio4
, 1);
540 dev
->em28xx_write_regs(dev
, 0x08, &gpio0
, 1);
542 dev
->em28xx_write_regs(dev
, 0x08, &gpio1
, 1);
552 static void em28xx_config_tuner(struct em28xx
*dev
)
554 struct v4l2_priv_tun_config xc2028_cfg
;
555 struct xc2028_ctrl ctl
;
556 struct tuner_setup tun_setup
;
557 struct v4l2_frequency f
;
559 if (dev
->tuner_type
== TUNER_ABSENT
)
562 tun_setup
.mode_mask
= T_ANALOG_TV
| T_RADIO
;
563 tun_setup
.type
= dev
->tuner_type
;
564 tun_setup
.addr
= dev
->tuner_addr
;
565 tun_setup
.tuner_callback
= em28xx_tuner_callback
;
567 em28xx_i2c_call_clients(dev
, TUNER_SET_TYPE_ADDR
, &tun_setup
);
569 if (dev
->tuner_type
== TUNER_XC2028
) {
570 memset(&ctl
, 0, sizeof(ctl
));
572 ctl
.fname
= XC2028_DEFAULT_FIRMWARE
;
574 ctl
.mts
= em28xx_boards
[dev
->model
].mts_firmware
;
576 xc2028_cfg
.tuner
= TUNER_XC2028
;
577 xc2028_cfg
.priv
= &ctl
;
579 em28xx_i2c_call_clients(dev
, TUNER_SET_CONFIG
, &xc2028_cfg
);
582 /* configure tuner */
584 f
.type
= V4L2_TUNER_ANALOG_TV
;
585 f
.frequency
= 9076; /* just a magic number */
586 dev
->ctl_freq
= f
.frequency
;
587 em28xx_i2c_call_clients(dev
, VIDIOC_S_FREQUENCY
, &f
);
590 static int em28xx_hint_board(struct em28xx
*dev
)
594 /* HINT method: EEPROM
596 * This method works only for boards with eeprom.
597 * Uses a hash of all eeprom bytes. The hash should be
598 * unique for a vendor/tuner pair.
599 * There are a high chance that tuners for different
600 * video standards produce different hashes.
602 for (i
= 0; i
< ARRAY_SIZE(em28xx_eeprom_hash
); i
++) {
603 if (dev
->hash
== em28xx_eeprom_hash
[i
].hash
) {
604 dev
->model
= em28xx_eeprom_hash
[i
].model
;
605 dev
->tuner_type
= em28xx_eeprom_hash
[i
].tuner
;
607 em28xx_errdev("Your board has no unique USB ID.\n");
608 em28xx_errdev("A hint were successfully done, "
609 "based on eeprom hash.\n");
610 em28xx_errdev("This method is not 100%% failproof.\n");
611 em28xx_errdev("If the board were missdetected, "
612 "please email this log to:\n");
613 em28xx_errdev("\tV4L Mailing List "
614 " <video4linux-list@redhat.com>\n");
615 em28xx_errdev("Board detected as %s\n",
616 em28xx_boards
[dev
->model
].name
);
622 /* HINT method: I2C attached devices
624 * This method works for all boards.
625 * Uses a hash of i2c scanned devices.
626 * Devices with the same i2c attached chips will
627 * be considered equal.
628 * This method is less precise than the eeprom one.
631 /* user did not request i2c scanning => do it now */
633 em28xx_do_i2c_scan(dev
);
635 for (i
= 0; i
< ARRAY_SIZE(em28xx_i2c_hash
); i
++) {
636 if (dev
->i2c_hash
== em28xx_i2c_hash
[i
].hash
) {
637 dev
->model
= em28xx_i2c_hash
[i
].model
;
638 dev
->tuner_type
= em28xx_i2c_hash
[i
].tuner
;
639 em28xx_errdev("Your board has no unique USB ID.\n");
640 em28xx_errdev("A hint were successfully done, "
641 "based on i2c devicelist hash.\n");
642 em28xx_errdev("This method is not 100%% failproof.\n");
643 em28xx_errdev("If the board were missdetected, "
644 "please email this log to:\n");
645 em28xx_errdev("\tV4L Mailing List "
646 " <video4linux-list@redhat.com>\n");
647 em28xx_errdev("Board detected as %s\n",
648 em28xx_boards
[dev
->model
].name
);
654 em28xx_errdev("Your board has no unique USB ID and thus need a "
655 "hint to be detected.\n");
656 em28xx_errdev("You may try to use card=<n> insmod option to "
657 "workaround that.\n");
658 em28xx_errdev("Please send an email with this log to:\n");
659 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
660 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev
->hash
);
661 em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev
->i2c_hash
);
663 em28xx_errdev("Here is a list of valid choices for the card=<n>"
664 " insmod option:\n");
665 for (i
= 0; i
< em28xx_bcount
; i
++) {
666 em28xx_errdev(" card=%d -> %s\n",
667 i
, em28xx_boards
[i
].name
);
673 static void em28xx_set_model(struct em28xx
*dev
)
675 dev
->is_em2800
= em28xx_boards
[dev
->model
].is_em2800
;
676 dev
->has_msp34xx
= em28xx_boards
[dev
->model
].has_msp34xx
;
677 dev
->tda9887_conf
= em28xx_boards
[dev
->model
].tda9887_conf
;
678 dev
->decoder
= em28xx_boards
[dev
->model
].decoder
;
679 dev
->video_inputs
= em28xx_boards
[dev
->model
].vchannels
;
680 dev
->analog_gpio
= em28xx_boards
[dev
->model
].analog_gpio
;
681 dev
->has_12mhz_i2s
= em28xx_boards
[dev
->model
].has_12mhz_i2s
;
682 dev
->max_range_640_480
= em28xx_boards
[dev
->model
].max_range_640_480
;
685 /* ----------------------------------------------------------------------- */
686 void em28xx_set_ir(struct em28xx
*dev
, struct IR_i2c
*ir
)
693 /* detect & configure */
694 switch (dev
->model
) {
695 case (EM2800_BOARD_UNKNOWN
):
697 case (EM2820_BOARD_UNKNOWN
):
699 case (EM2800_BOARD_TERRATEC_CINERGY_200
):
700 case (EM2820_BOARD_TERRATEC_CINERGY_250
):
701 ir
->ir_codes
= ir_codes_em_terratec
;
702 ir
->get_key
= em28xx_get_key_terratec
;
703 snprintf(ir
->c
.name
, sizeof(ir
->c
.name
),
704 "i2c IR (EM28XX Terratec)");
706 case (EM2820_BOARD_PINNACLE_USB_2
):
707 ir
->ir_codes
= ir_codes_pinnacle_grey
;
708 ir
->get_key
= em28xx_get_key_pinnacle_usb_grey
;
709 snprintf(ir
->c
.name
, sizeof(ir
->c
.name
),
710 "i2c IR (EM28XX Pinnacle PCTV)");
712 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2
):
713 ir
->ir_codes
= ir_codes_hauppauge_new
;
714 ir
->get_key
= em28xx_get_key_em_haup
;
715 snprintf(ir
->c
.name
, sizeof(ir
->c
.name
),
716 "i2c IR (EM2840 Hauppauge)");
718 case (EM2820_BOARD_MSI_VOX_USB_2
):
720 case (EM2800_BOARD_LEADTEK_WINFAST_USBII
):
722 case (EM2800_BOARD_KWORLD_USB2800
):
727 void em28xx_card_setup(struct em28xx
*dev
)
729 em28xx_set_model(dev
);
731 dev
->tuner_type
= em28xx_boards
[dev
->model
].tuner_type
;
733 /* request some modules */
734 switch (dev
->model
) {
735 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2
:
736 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900
:
737 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950
:
740 #ifdef CONFIG_MODULES
741 request_module("tveeprom");
743 /* Call first TVeeprom */
745 dev
->i2c_client
.addr
= 0xa0 >> 1;
746 tveeprom_hauppauge_analog(&dev
->i2c_client
, &tv
, dev
->eedata
);
748 dev
->tuner_type
= tv
.tuner_type
;
750 if (tv
.audio_processor
== AUDIO_CHIP_MSP34XX
) {
751 dev
->i2s_speed
= 2048000;
752 dev
->has_msp34xx
= 1;
754 #ifdef CONFIG_MODULES
756 request_module("ir-kbd-i2c");
760 case EM2820_BOARD_KWORLD_PVRTV2800RF
:
761 /* GPIO enables sound on KWORLD PVR TV 2800RF */
762 em28xx_write_regs_req(dev
, 0x00, 0x08, "\xf9", 1);
764 case EM2820_BOARD_UNKNOWN
:
765 case EM2800_BOARD_UNKNOWN
:
766 if (!em28xx_hint_board(dev
))
767 em28xx_set_model(dev
);
770 /* Allow override tuner type by a module parameter */
772 dev
->tuner_type
= tuner
;
774 #ifdef CONFIG_MODULES
775 /* request some modules */
776 if (dev
->has_msp34xx
)
777 request_module("msp3400");
778 if (dev
->decoder
== EM28XX_SAA7113
|| dev
->decoder
== EM28XX_SAA7114
)
779 request_module("saa7115");
780 if (dev
->decoder
== EM28XX_TVP5150
)
781 request_module("tvp5150");
782 if (dev
->tuner_type
!= TUNER_ABSENT
)
783 request_module("tuner");
786 em28xx_config_tuner(dev
);