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/v4l2-common.h>
36 #include <media/v4l2-chip-ident.h>
40 static int tuner = -1;
41 module_param(tuner, int, 0444);
42 MODULE_PARM_DESC(tuner, "tuner type");
44 static unsigned int disable_ir;
45 module_param(disable_ir, int, 0444);
46 MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
48 struct em28xx_hash_table {
54 struct em28xx_board em28xx_boards[] = {
55 [EM2800_BOARD_UNKNOWN] = {
56 .name = "Unknown EM2800 video grabber",
59 .tda9887_conf = TDA9887_PRESENT,
60 .decoder = EM28XX_SAA7113,
62 .type = EM28XX_VMUX_COMPOSITE1,
63 .vmux = SAA7115_COMPOSITE0,
66 .type = EM28XX_VMUX_SVIDEO,
67 .vmux = SAA7115_SVIDEO3,
71 [EM2820_BOARD_UNKNOWN] = {
72 .name = "Unknown EM2750/28xx video grabber",
74 .tuner_type = TUNER_ABSENT,
76 [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
77 .name = "Kworld PVR TV 2800 RF",
80 .tuner_type = TUNER_TEMIC_PAL,
81 .tda9887_conf = TDA9887_PRESENT,
82 .decoder = EM28XX_SAA7113,
84 .type = EM28XX_VMUX_COMPOSITE1,
85 .vmux = SAA7115_COMPOSITE0,
88 .type = EM28XX_VMUX_SVIDEO,
89 .vmux = SAA7115_SVIDEO3,
93 [EM2820_BOARD_TERRATEC_CINERGY_250] = {
94 .name = "Terratec Cinergy 250 USB",
96 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
97 .tda9887_conf = TDA9887_PRESENT,
98 .decoder = EM28XX_SAA7113,
100 .type = EM28XX_VMUX_TELEVISION,
101 .vmux = SAA7115_COMPOSITE2,
104 .type = EM28XX_VMUX_COMPOSITE1,
105 .vmux = SAA7115_COMPOSITE0,
108 .type = EM28XX_VMUX_SVIDEO,
109 .vmux = SAA7115_SVIDEO3,
113 [EM2820_BOARD_PINNACLE_USB_2] = {
114 .name = "Pinnacle PCTV USB 2",
116 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
117 .tda9887_conf = TDA9887_PRESENT,
118 .decoder = EM28XX_SAA7113,
120 .type = EM28XX_VMUX_TELEVISION,
121 .vmux = SAA7115_COMPOSITE2,
124 .type = EM28XX_VMUX_COMPOSITE1,
125 .vmux = SAA7115_COMPOSITE0,
128 .type = EM28XX_VMUX_SVIDEO,
129 .vmux = SAA7115_SVIDEO3,
133 [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
134 .name = "Hauppauge WinTV USB 2",
136 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
137 .tda9887_conf = TDA9887_PRESENT |
138 TDA9887_PORT1_ACTIVE|
139 TDA9887_PORT2_ACTIVE,
140 .decoder = EM28XX_TVP5150,
142 /*FIXME: S-Video not tested */
144 .type = EM28XX_VMUX_TELEVISION,
145 .vmux = TVP5150_COMPOSITE0,
146 .amux = MSP_INPUT_DEFAULT,
148 .type = EM28XX_VMUX_SVIDEO,
149 .vmux = TVP5150_SVIDEO,
150 .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
151 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
154 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
155 .name = "Hauppauge WinTV HVR 900",
157 .tda9887_conf = TDA9887_PRESENT,
158 .tuner_type = TUNER_XC2028,
161 .decoder = EM28XX_TVP5150,
163 .type = EM28XX_VMUX_TELEVISION,
164 .vmux = TVP5150_COMPOSITE0,
167 .type = EM28XX_VMUX_COMPOSITE1,
168 .vmux = TVP5150_COMPOSITE1,
171 .type = EM28XX_VMUX_SVIDEO,
172 .vmux = TVP5150_SVIDEO,
176 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
177 .name = "Hauppauge WinTV HVR 900 (R2)",
179 .tda9887_conf = TDA9887_PRESENT,
180 .tuner_type = TUNER_XC2028,
182 .decoder = EM28XX_TVP5150,
184 .type = EM28XX_VMUX_TELEVISION,
185 .vmux = TVP5150_COMPOSITE0,
188 .type = EM28XX_VMUX_COMPOSITE1,
189 .vmux = TVP5150_COMPOSITE1,
192 .type = EM28XX_VMUX_SVIDEO,
193 .vmux = TVP5150_SVIDEO,
197 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
198 .name = "Hauppauge WinTV HVR 950",
200 .tda9887_conf = TDA9887_PRESENT,
201 .tuner_type = TUNER_XC2028,
205 .decoder = EM28XX_TVP5150,
207 .type = EM28XX_VMUX_TELEVISION,
208 .vmux = TVP5150_COMPOSITE0,
211 .type = EM28XX_VMUX_COMPOSITE1,
212 .vmux = TVP5150_COMPOSITE1,
215 .type = EM28XX_VMUX_SVIDEO,
216 .vmux = TVP5150_SVIDEO,
220 [EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
221 .name = "Pinnacle PCTV HD Pro Stick",
223 .tda9887_conf = TDA9887_PRESENT,
224 .tuner_type = TUNER_XC2028,
228 .decoder = EM28XX_TVP5150,
230 .type = EM28XX_VMUX_TELEVISION,
231 .vmux = TVP5150_COMPOSITE0,
234 .type = EM28XX_VMUX_COMPOSITE1,
235 .vmux = TVP5150_COMPOSITE1,
238 .type = EM28XX_VMUX_SVIDEO,
239 .vmux = TVP5150_SVIDEO,
243 [EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
244 .name = "AMD ATI TV Wonder HD 600",
246 .tda9887_conf = TDA9887_PRESENT,
247 .tuner_type = TUNER_XC2028,
251 .decoder = EM28XX_TVP5150,
253 .type = EM28XX_VMUX_TELEVISION,
254 .vmux = TVP5150_COMPOSITE0,
257 .type = EM28XX_VMUX_COMPOSITE1,
258 .vmux = TVP5150_COMPOSITE1,
261 .type = EM28XX_VMUX_SVIDEO,
262 .vmux = TVP5150_SVIDEO,
266 [EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
267 .name = "AMD ATI TV Wonder HD 600",
269 .tda9887_conf = TDA9887_PRESENT,
270 .tuner_type = TUNER_XC2028,
274 .decoder = EM28XX_TVP5150,
276 .type = EM28XX_VMUX_TELEVISION,
277 .vmux = TVP5150_COMPOSITE0,
280 .type = EM28XX_VMUX_COMPOSITE1,
281 .vmux = TVP5150_COMPOSITE1,
284 .type = EM28XX_VMUX_SVIDEO,
285 .vmux = TVP5150_SVIDEO,
289 [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
290 .name = "Terratec Hybrid XS",
292 .tda9887_conf = TDA9887_PRESENT,
293 .tuner_type = TUNER_XC2028,
294 .decoder = EM28XX_TVP5150,
297 .type = EM28XX_VMUX_TELEVISION,
298 .vmux = TVP5150_COMPOSITE0,
301 .type = EM28XX_VMUX_COMPOSITE1,
302 .vmux = TVP5150_COMPOSITE1,
305 .type = EM28XX_VMUX_SVIDEO,
306 .vmux = TVP5150_SVIDEO,
310 /* maybe there's a reason behind it why Terratec sells the Hybrid XS
311 as Prodigy XS with a different PID, let's keep it separated for now
312 maybe we'll need it lateron */
313 [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
314 .name = "Terratec Prodigy XS",
316 .tda9887_conf = TDA9887_PRESENT,
317 .tuner_type = TUNER_XC2028,
318 .decoder = EM28XX_TVP5150,
320 .type = EM28XX_VMUX_TELEVISION,
321 .vmux = TVP5150_COMPOSITE0,
324 .type = EM28XX_VMUX_COMPOSITE1,
325 .vmux = TVP5150_COMPOSITE1,
328 .type = EM28XX_VMUX_SVIDEO,
329 .vmux = TVP5150_SVIDEO,
333 [EM2820_BOARD_MSI_VOX_USB_2] = {
334 .name = "MSI VOX USB 2.0",
336 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
337 .tda9887_conf = TDA9887_PRESENT |
338 TDA9887_PORT1_ACTIVE |
339 TDA9887_PORT2_ACTIVE,
340 .max_range_640_480 = 1,
342 .decoder = EM28XX_SAA7114,
344 .type = EM28XX_VMUX_TELEVISION,
345 .vmux = SAA7115_COMPOSITE4,
348 .type = EM28XX_VMUX_COMPOSITE1,
349 .vmux = SAA7115_COMPOSITE0,
352 .type = EM28XX_VMUX_SVIDEO,
353 .vmux = SAA7115_SVIDEO3,
357 [EM2800_BOARD_TERRATEC_CINERGY_200] = {
358 .name = "Terratec Cinergy 200 USB",
361 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
362 .tda9887_conf = TDA9887_PRESENT,
363 .decoder = EM28XX_SAA7113,
365 .type = EM28XX_VMUX_TELEVISION,
366 .vmux = SAA7115_COMPOSITE2,
369 .type = EM28XX_VMUX_COMPOSITE1,
370 .vmux = SAA7115_COMPOSITE0,
373 .type = EM28XX_VMUX_SVIDEO,
374 .vmux = SAA7115_SVIDEO3,
378 [EM2800_BOARD_GRABBEEX_USB2800] = {
379 .name = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
382 .decoder = EM28XX_SAA7113,
384 .type = EM28XX_VMUX_COMPOSITE1,
385 .vmux = SAA7115_COMPOSITE0,
388 .type = EM28XX_VMUX_SVIDEO,
389 .vmux = SAA7115_SVIDEO3,
393 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
394 .name = "Leadtek Winfast USB II",
397 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
398 .tda9887_conf = TDA9887_PRESENT,
399 .decoder = EM28XX_SAA7113,
401 .type = EM28XX_VMUX_TELEVISION,
402 .vmux = SAA7115_COMPOSITE2,
405 .type = EM28XX_VMUX_COMPOSITE1,
406 .vmux = SAA7115_COMPOSITE0,
409 .type = EM28XX_VMUX_SVIDEO,
410 .vmux = SAA7115_SVIDEO3,
414 [EM2800_BOARD_KWORLD_USB2800] = {
415 .name = "Kworld USB2800",
418 .tuner_type = TUNER_PHILIPS_FCV1236D,
419 .tda9887_conf = TDA9887_PRESENT,
420 .decoder = EM28XX_SAA7113,
422 .type = EM28XX_VMUX_TELEVISION,
423 .vmux = SAA7115_COMPOSITE2,
426 .type = EM28XX_VMUX_COMPOSITE1,
427 .vmux = SAA7115_COMPOSITE0,
430 .type = EM28XX_VMUX_SVIDEO,
431 .vmux = SAA7115_SVIDEO3,
435 [EM2820_BOARD_PINNACLE_DVC_90] = {
436 .name = "Pinnacle Dazzle DVC 90/DVC 100",
438 .tuner_type = TUNER_ABSENT,
439 .decoder = EM28XX_SAA7113,
441 .type = EM28XX_VMUX_COMPOSITE1,
442 .vmux = SAA7115_COMPOSITE0,
445 .type = EM28XX_VMUX_SVIDEO,
446 .vmux = SAA7115_SVIDEO3,
450 [EM2800_BOARD_VGEAR_POCKETTV] = {
451 .name = "V-Gear PocketTV",
454 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
455 .tda9887_conf = TDA9887_PRESENT,
456 .decoder = EM28XX_SAA7113,
458 .type = EM28XX_VMUX_TELEVISION,
459 .vmux = SAA7115_COMPOSITE2,
462 .type = EM28XX_VMUX_COMPOSITE1,
463 .vmux = SAA7115_COMPOSITE0,
466 .type = EM28XX_VMUX_SVIDEO,
467 .vmux = SAA7115_SVIDEO3,
471 [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
472 .name = "Pixelview Prolink PlayTV USB 2.0",
474 .tda9887_conf = TDA9887_PRESENT,
475 .tuner_type = TUNER_YMEC_TVF_5533MF,
476 .decoder = EM28XX_SAA7113,
478 .type = EM28XX_VMUX_TELEVISION,
479 .vmux = SAA7115_COMPOSITE2,
480 .amux = EM28XX_AMUX_LINE_IN,
482 .type = EM28XX_VMUX_COMPOSITE1,
483 .vmux = SAA7115_COMPOSITE0,
484 .amux = EM28XX_AMUX_LINE_IN,
486 .type = EM28XX_VMUX_SVIDEO,
487 .vmux = SAA7115_SVIDEO3,
488 .amux = EM28XX_AMUX_LINE_IN,
491 [EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA] = {
492 .name = "PointNix Intra-Oral Camera",
493 .has_snapshot_button = 1,
495 .tda9887_conf = TDA9887_PRESENT,
496 .tuner_type = TUNER_ABSENT,
497 .decoder = EM28XX_SAA7113,
499 .type = EM28XX_VMUX_SVIDEO,
500 .vmux = SAA7115_SVIDEO3,
505 const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
507 /* table of devices that work with this driver */
508 struct usb_device_id em28xx_id_table [] = {
509 { USB_DEVICE(0xeb1a, 0x2750),
510 .driver_info = EM2820_BOARD_UNKNOWN },
511 { USB_DEVICE(0xeb1a, 0x2800),
512 .driver_info = EM2800_BOARD_UNKNOWN },
513 { USB_DEVICE(0xeb1a, 0x2820),
514 .driver_info = EM2820_BOARD_UNKNOWN },
515 { USB_DEVICE(0xeb1a, 0x2821),
516 .driver_info = EM2820_BOARD_UNKNOWN },
517 { USB_DEVICE(0xeb1a, 0x2860),
518 .driver_info = EM2820_BOARD_UNKNOWN },
519 { USB_DEVICE(0xeb1a, 0x2861),
520 .driver_info = EM2820_BOARD_UNKNOWN },
521 { USB_DEVICE(0xeb1a, 0x2870),
522 .driver_info = EM2820_BOARD_UNKNOWN },
523 { USB_DEVICE(0xeb1a, 0x2881),
524 .driver_info = EM2820_BOARD_UNKNOWN },
525 { USB_DEVICE(0xeb1a, 0x2883),
526 .driver_info = EM2820_BOARD_UNKNOWN },
527 { USB_DEVICE(0x0ccd, 0x0036),
528 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
529 { USB_DEVICE(0x2304, 0x0208),
530 .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
531 { USB_DEVICE(0x2040, 0x4200),
532 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
533 { USB_DEVICE(0x2040, 0x4201),
534 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
535 { USB_DEVICE(0x2304, 0x0207),
536 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
537 { USB_DEVICE(0x2304, 0x021a),
538 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
539 { USB_DEVICE(0x2304, 0x0227),
540 .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
541 { USB_DEVICE(0x2040, 0x6500),
542 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
543 { USB_DEVICE(0x2040, 0x6502),
544 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
545 { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
546 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
547 { USB_DEVICE(0x2040, 0x6517), /* HP HVR-950 */
548 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
549 { USB_DEVICE(0x2040, 0x651b), /* RP HVR-950 */
550 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
551 { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
552 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
553 { USB_DEVICE(0x0ccd, 0x0042),
554 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
555 { USB_DEVICE(0x0ccd, 0x0047),
556 .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
557 { USB_DEVICE(0x0438, 0xb002),
558 .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
559 { USB_DEVICE(0xeb1a, 0x2801),
560 .driver_info = EM2800_BOARD_GRABBEEX_USB2800 },
563 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
566 * Reset sequences for analog/digital modes
569 /* Board Hauppauge WinTV HVR 900 analog */
570 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
571 {EM28XX_R08_GPIO, 0x2d, ~EM_GPIO_4, 10},
572 {0x05, 0xff, 0x10, 10},
576 /* Board Hauppauge WinTV HVR 900 digital */
577 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
578 {EM28XX_R08_GPIO, 0x2e, ~EM_GPIO_4, 10},
579 {EM2880_R04_GPO, 0x04, 0x0f, 10},
580 {EM2880_R04_GPO, 0x0c, 0x0f, 10},
584 /* Board Hauppauge WinTV HVR 900 tuner_callback */
585 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_tuner_callback[] = {
586 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10},
587 {EM28XX_R08_GPIO, 0, EM_GPIO_4, 10},
588 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10},
593 * EEPROM hash table for devices with generic USB IDs
595 static struct em28xx_hash_table em28xx_eeprom_hash [] = {
596 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
597 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
600 /* I2C devicelist hash table for devices with generic USB IDs */
601 static struct em28xx_hash_table em28xx_i2c_hash[] = {
602 {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
603 {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
604 {0x1ba50080, EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA, TUNER_ABSENT},
607 int em28xx_tuner_callback(void *ptr, int command, int arg)
610 struct em28xx *dev = ptr;
612 if (dev->tuner_type != TUNER_XC2028)
615 if (command != XC2028_TUNER_RESET)
618 if (dev->mode == EM28XX_ANALOG_MODE)
619 rc = em28xx_gpio_set(dev, dev->tun_analog_gpio);
621 rc = em28xx_gpio_set(dev, dev->tun_digital_gpio);
625 EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
627 static void em28xx_set_model(struct em28xx *dev)
629 dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
630 dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
631 dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
632 dev->decoder = em28xx_boards[dev->model].decoder;
633 dev->video_inputs = em28xx_boards[dev->model].vchannels;
634 dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
635 dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
636 dev->has_dvb = em28xx_boards[dev->model].has_dvb;
637 dev->has_snapshot_button = em28xx_boards[dev->model].has_snapshot_button;
640 /* Since em28xx_pre_card_setup() requires a proper dev->model,
641 * this won't work for boards with generic PCI IDs
643 void em28xx_pre_card_setup(struct em28xx *dev)
647 rc = em28xx_read_reg(dev, EM2880_R04_GPO);
651 dev->wait_after_write = 5;
652 rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
656 em28xx_info("chip ID is em2860\n");
659 em28xx_info("chip ID is em2882/em2883\n");
660 dev->wait_after_write = 0;
663 em28xx_info("em28xx chip ID = %d\n", rc);
666 em28xx_set_model(dev);
668 /* request some modules */
669 switch (dev->model) {
670 case EM2880_BOARD_TERRATEC_PRODIGY_XS:
671 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
672 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
673 case EM2880_BOARD_TERRATEC_HYBRID_XS:
674 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
675 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
676 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
677 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
678 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
681 /* Sets GPO/GPIO sequences for this device */
682 dev->analog_gpio = hauppauge_wintv_hvr_900_analog;
683 dev->digital_gpio = hauppauge_wintv_hvr_900_digital;
684 dev->tun_analog_gpio = hauppauge_wintv_hvr_900_tuner_callback;
685 dev->tun_digital_gpio = hauppauge_wintv_hvr_900_tuner_callback;
690 em28xx_gpio_set(dev, dev->tun_analog_gpio);
691 em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
694 em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED);
697 static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
699 memset(ctl, 0, sizeof(*ctl));
701 ctl->fname = XC2028_DEFAULT_FIRMWARE;
703 ctl->mts = em28xx_boards[dev->model].mts_firmware;
705 switch (dev->model) {
706 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
707 ctl->demod = XC3028_FE_ZARLINK456;
709 case EM2880_BOARD_TERRATEC_HYBRID_XS:
710 ctl->demod = XC3028_FE_ZARLINK456;
712 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
713 /* djh - Not sure which demod we need here */
714 ctl->demod = XC3028_FE_DEFAULT;
716 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
717 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
718 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
719 /* FIXME: Better to specify the needed IF */
720 ctl->demod = XC3028_FE_DEFAULT;
723 ctl->demod = XC3028_FE_OREN538;
727 static void em28xx_config_tuner(struct em28xx *dev)
729 struct v4l2_priv_tun_config xc2028_cfg;
730 struct tuner_setup tun_setup;
731 struct v4l2_frequency f;
733 if (dev->tuner_type == TUNER_ABSENT)
736 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
737 tun_setup.type = dev->tuner_type;
738 tun_setup.addr = dev->tuner_addr;
739 tun_setup.tuner_callback = em28xx_tuner_callback;
741 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
743 if (dev->tuner_type == TUNER_XC2028) {
744 struct xc2028_ctrl ctl;
746 em28xx_setup_xc3028(dev, &ctl);
748 xc2028_cfg.tuner = TUNER_XC2028;
749 xc2028_cfg.priv = &ctl;
751 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
754 /* configure tuner */
756 f.type = V4L2_TUNER_ANALOG_TV;
757 f.frequency = 9076; /* just a magic number */
758 dev->ctl_freq = f.frequency;
759 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
762 static int em28xx_hint_board(struct em28xx *dev)
766 /* HINT method: EEPROM
768 * This method works only for boards with eeprom.
769 * Uses a hash of all eeprom bytes. The hash should be
770 * unique for a vendor/tuner pair.
771 * There are a high chance that tuners for different
772 * video standards produce different hashes.
774 for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
775 if (dev->hash == em28xx_eeprom_hash[i].hash) {
776 dev->model = em28xx_eeprom_hash[i].model;
777 dev->tuner_type = em28xx_eeprom_hash[i].tuner;
779 em28xx_errdev("Your board has no unique USB ID.\n");
780 em28xx_errdev("A hint were successfully done, "
781 "based on eeprom hash.\n");
782 em28xx_errdev("This method is not 100%% failproof.\n");
783 em28xx_errdev("If the board were missdetected, "
784 "please email this log to:\n");
785 em28xx_errdev("\tV4L Mailing List "
786 " <video4linux-list@redhat.com>\n");
787 em28xx_errdev("Board detected as %s\n",
788 em28xx_boards[dev->model].name);
794 /* HINT method: I2C attached devices
796 * This method works for all boards.
797 * Uses a hash of i2c scanned devices.
798 * Devices with the same i2c attached chips will
799 * be considered equal.
800 * This method is less precise than the eeprom one.
803 /* user did not request i2c scanning => do it now */
805 em28xx_do_i2c_scan(dev);
807 for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
808 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
809 dev->model = em28xx_i2c_hash[i].model;
810 dev->tuner_type = em28xx_i2c_hash[i].tuner;
811 em28xx_errdev("Your board has no unique USB ID.\n");
812 em28xx_errdev("A hint were successfully done, "
813 "based on i2c devicelist hash.\n");
814 em28xx_errdev("This method is not 100%% failproof.\n");
815 em28xx_errdev("If the board were missdetected, "
816 "please email this log to:\n");
817 em28xx_errdev("\tV4L Mailing List "
818 " <video4linux-list@redhat.com>\n");
819 em28xx_errdev("Board detected as %s\n",
820 em28xx_boards[dev->model].name);
826 em28xx_errdev("Your board has no unique USB ID and thus need a "
827 "hint to be detected.\n");
828 em28xx_errdev("You may try to use card=<n> insmod option to "
829 "workaround that.\n");
830 em28xx_errdev("Please send an email with this log to:\n");
831 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
832 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
833 em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
835 em28xx_errdev("Here is a list of valid choices for the card=<n>"
836 " insmod option:\n");
837 for (i = 0; i < em28xx_bcount; i++) {
838 em28xx_errdev(" card=%d -> %s\n",
839 i, em28xx_boards[i].name);
844 /* ----------------------------------------------------------------------- */
845 void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
852 /* detect & configure */
853 switch (dev->model) {
854 case (EM2800_BOARD_UNKNOWN):
856 case (EM2820_BOARD_UNKNOWN):
858 case (EM2800_BOARD_TERRATEC_CINERGY_200):
859 case (EM2820_BOARD_TERRATEC_CINERGY_250):
860 ir->ir_codes = ir_codes_em_terratec;
861 ir->get_key = em28xx_get_key_terratec;
862 snprintf(ir->c.name, sizeof(ir->c.name),
863 "i2c IR (EM28XX Terratec)");
865 case (EM2820_BOARD_PINNACLE_USB_2):
866 ir->ir_codes = ir_codes_pinnacle_grey;
867 ir->get_key = em28xx_get_key_pinnacle_usb_grey;
868 snprintf(ir->c.name, sizeof(ir->c.name),
869 "i2c IR (EM28XX Pinnacle PCTV)");
871 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
872 ir->ir_codes = ir_codes_hauppauge_new;
873 ir->get_key = em28xx_get_key_em_haup;
874 snprintf(ir->c.name, sizeof(ir->c.name),
875 "i2c IR (EM2840 Hauppauge)");
877 case (EM2820_BOARD_MSI_VOX_USB_2):
879 case (EM2800_BOARD_LEADTEK_WINFAST_USBII):
881 case (EM2800_BOARD_KWORLD_USB2800):
883 case (EM2800_BOARD_GRABBEEX_USB2800):
888 void em28xx_card_setup(struct em28xx *dev)
890 em28xx_set_model(dev);
892 dev->tuner_type = em28xx_boards[dev->model].tuner_type;
894 /* request some modules */
895 switch (dev->model) {
896 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
897 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
898 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
899 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
902 #ifdef CONFIG_MODULES
903 request_module("tveeprom");
905 /* Call first TVeeprom */
907 dev->i2c_client.addr = 0xa0 >> 1;
908 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
910 dev->tuner_type = tv.tuner_type;
912 if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
913 dev->i2s_speed = 2048000;
914 dev->has_msp34xx = 1;
916 #ifdef CONFIG_MODULES
918 request_module("ir-kbd-i2c");
922 case EM2820_BOARD_KWORLD_PVRTV2800RF:
923 /* GPIO enables sound on KWORLD PVR TV 2800RF */
924 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
926 case EM2820_BOARD_UNKNOWN:
927 case EM2800_BOARD_UNKNOWN:
928 if (!em28xx_hint_board(dev))
929 em28xx_set_model(dev);
932 if (dev->has_snapshot_button)
933 em28xx_register_snapshot_button(dev);
935 /* Allow override tuner type by a module parameter */
937 dev->tuner_type = tuner;
939 #ifdef CONFIG_MODULES
940 /* request some modules */
941 if (dev->has_msp34xx)
942 request_module("msp3400");
943 if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
944 request_module("saa7115");
945 if (dev->decoder == EM28XX_TVP5150)
946 request_module("tvp5150");
947 if (dev->tuner_type != TUNER_ABSENT)
948 request_module("tuner");
951 em28xx_config_tuner(dev);