2 * device driver for Conexant 2388x based TV cards
5 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/init.h>
23 #include <linux/module.h>
24 #include <linux/pci.h>
28 /* ------------------------------------------------------------------ */
29 /* board config info */
31 struct cx88_board cx88_boards[] = {
32 [CX88_BOARD_UNKNOWN] = {
33 .name = "UNKNOWN/GENERIC",
36 .type = CX88_VMUX_COMPOSITE1,
39 .type = CX88_VMUX_COMPOSITE2,
42 .type = CX88_VMUX_COMPOSITE3,
45 .type = CX88_VMUX_COMPOSITE4,
49 [CX88_BOARD_HAUPPAUGE] = {
50 .name = "Hauppauge WinTV 34xxx models",
53 .type = CX88_VMUX_TELEVISION,
55 .gpio0 = 0xff00, // internal decoder
57 .type = CX88_VMUX_DEBUG,
59 .gpio0 = 0xff01, // mono from tuner chip
61 .type = CX88_VMUX_COMPOSITE1,
65 .type = CX88_VMUX_SVIDEO,
75 .name = "GDI Black Gold",
78 .type = CX88_VMUX_TELEVISION,
82 [CX88_BOARD_PIXELVIEW] = {
86 .type = CX88_VMUX_TELEVISION,
89 .type = CX88_VMUX_COMPOSITE1,
92 .type = CX88_VMUX_SVIDEO,
96 [CX88_BOARD_ATI_WONDER_PRO] = {
97 .name = "ATI TV Wonder Pro",
100 .type = CX88_VMUX_TELEVISION,
107 .type = CX88_VMUX_COMPOSITE1,
110 .type = CX88_VMUX_SVIDEO,
115 [CX88_BOARD_WINFAST2000XP] = {
116 .name = "Leadtek Winfast 2000XP Expert",
120 .type = CX88_VMUX_TELEVISION,
127 .type = CX88_VMUX_COMPOSITE1,
134 .type = CX88_VMUX_SVIDEO,
149 [CX88_BOARD_AVERTV_303] = {
150 .name = "AverTV Studio 303 (M126)",
151 .tuner_type = TUNER_PHILIPS_PAL_DK,
153 .type = CX88_VMUX_TELEVISION,
157 [CX88_BOARD_MSI_TVANYWHERE_MASTER] = {
158 //added gpio values thanks to Torsten Seeboth
159 //values for PAL from DScaler
160 .name = "MSI TV-@nywhere Master",
164 .type = CX88_VMUX_TELEVISION,
171 .type = CX88_VMUX_COMPOSITE1,
178 .type = CX88_VMUX_SVIDEO,
189 [CX88_BOARD_WINFAST_DV2000] = {
190 .name = "Leadtek Winfast DV2000",
194 .type = CX88_VMUX_TELEVISION,
201 [CX88_BOARD_LEADTEK_PVR2000] = {
202 .name = "Leadtek PVR 2000",
205 .type = CX88_VMUX_TELEVISION,
208 .type = CX88_VMUX_COMPOSITE1,
211 .type = CX88_VMUX_SVIDEO,
218 [CX88_BOARD_IODATA_GVVCP3PCI] = {
219 .name = "IODATA GV-VCP3/PCI",
220 .tuner_type = TUNER_ABSENT,
223 .type = CX88_VMUX_COMPOSITE1,
226 .type = CX88_VMUX_COMPOSITE2,
229 .type = CX88_VMUX_SVIDEO,
233 [CX88_BOARD_PROLINK_PLAYTVPVR] = {
234 .name = "Prolink PlayTV PVR",
238 .type = CX88_VMUX_TELEVISION,
242 .type = CX88_VMUX_COMPOSITE1,
246 .type = CX88_VMUX_SVIDEO,
255 [CX88_BOARD_ASUS_PVR_416] = {
256 .name = "ASUS PVR-416",
260 .type = CX88_VMUX_TELEVISION,
263 .gpio1 = 0x00000000, // possibly for mpeg data
267 .type = CX88_VMUX_SVIDEO,
269 .gpio0 = 0x0000fde6, // 0x0000fda6 L,R RCA audio in?
270 .gpio1 = 0x00000000, // possibly for mpeg data
282 [CX88_BOARD_MSI_TVANYWHERE] = {
283 .name = "MSI TV-@nywhere",
287 .type = CX88_VMUX_TELEVISION,
294 .type = CX88_VMUX_COMPOSITE1,
301 .type = CX88_VMUX_SVIDEO,
310 const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
312 /* ------------------------------------------------------------------ */
313 /* PCI subsystem IDs */
315 struct cx88_subid cx88_subids[] = {
319 .card = CX88_BOARD_HAUPPAUGE,
323 .card = CX88_BOARD_HAUPPAUGE,
327 .card = CX88_BOARD_GDI,
330 .subdevice = 0x0107, /* with mpeg encoder */
331 .card = CX88_BOARD_GDI,
333 .subvendor = PCI_VENDOR_ID_ATI,
335 .card = CX88_BOARD_ATI_WONDER_PRO,
339 .card = CX88_BOARD_WINFAST2000XP,
342 .subdevice = 0x6613, /* NTSC */
343 .card = CX88_BOARD_WINFAST2000XP,
347 .card = CX88_BOARD_WINFAST_DV2000,
351 .card = CX88_BOARD_LEADTEK_PVR2000,
355 .card = CX88_BOARD_LEADTEK_PVR2000,
359 .card = CX88_BOARD_AVERTV_303,
363 .card = CX88_BOARD_MSI_TVANYWHERE_MASTER,
367 .card = CX88_BOARD_IODATA_GVVCP3PCI,
370 .subdevice = 0x4823, /* with mpeg encoder */
371 .card = CX88_BOARD_ASUS_PVR_416,
374 const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
376 /* ----------------------------------------------------------------------- */
377 /* some leadtek specific stuff */
379 static void __devinit leadtek_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
381 /* This is just for the Winfast 2000 XP board ATM; I don't have data on
384 * Byte 0 is 1 on the NTSC board.
387 if (eeprom_data[4] != 0x7d ||
388 eeprom_data[5] != 0x10 ||
389 eeprom_data[7] != 0x66) {
390 printk(KERN_WARNING "%s Leadtek eeprom invalid.\n", dev->name);
395 dev->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38;
397 printk(KERN_INFO "%s: Leadtek Winfast 2000 XP config: "
398 "tuner=%d, eeprom[0]=0x%02x\n",
399 dev->name, dev->tuner_type, eeprom_data[0]);
403 /* ----------------------------------------------------------------------- */
404 /* some hauppauge specific stuff */
409 } hauppauge_tuner[] __devinitdata = {
410 { TUNER_ABSENT, "" },
411 { TUNER_ABSENT, "External" },
412 { TUNER_ABSENT, "Unspecified" },
413 { TUNER_PHILIPS_PAL, "Philips FI1216" },
414 { TUNER_PHILIPS_SECAM, "Philips FI1216MF" },
415 { TUNER_PHILIPS_NTSC, "Philips FI1236" },
416 { TUNER_PHILIPS_PAL_I, "Philips FI1246" },
417 { TUNER_PHILIPS_PAL_DK,"Philips FI1256" },
418 { TUNER_PHILIPS_PAL, "Philips FI1216 MK2" },
419 { TUNER_PHILIPS_SECAM, "Philips FI1216MF MK2" },
420 { TUNER_PHILIPS_NTSC, "Philips FI1236 MK2" },
421 { TUNER_PHILIPS_PAL_I, "Philips FI1246 MK2" },
422 { TUNER_PHILIPS_PAL_DK,"Philips FI1256 MK2" },
423 { TUNER_TEMIC_NTSC, "Temic 4032FY5" },
424 { TUNER_TEMIC_PAL, "Temic 4002FH5" },
425 { TUNER_TEMIC_PAL_I, "Temic 4062FY5" },
426 { TUNER_PHILIPS_PAL, "Philips FR1216 MK2" },
427 { TUNER_PHILIPS_SECAM, "Philips FR1216MF MK2" },
428 { TUNER_PHILIPS_NTSC, "Philips FR1236 MK2" },
429 { TUNER_PHILIPS_PAL_I, "Philips FR1246 MK2" },
430 { TUNER_PHILIPS_PAL_DK,"Philips FR1256 MK2" },
431 { TUNER_PHILIPS_PAL, "Philips FM1216" },
432 { TUNER_PHILIPS_SECAM, "Philips FM1216MF" },
433 { TUNER_PHILIPS_NTSC, "Philips FM1236" },
434 { TUNER_PHILIPS_PAL_I, "Philips FM1246" },
435 { TUNER_PHILIPS_PAL_DK,"Philips FM1256" },
436 { TUNER_TEMIC_4036FY5_NTSC, "Temic 4036FY5" },
437 { TUNER_ABSENT, "Samsung TCPN9082D" },
438 { TUNER_ABSENT, "Samsung TCPM9092P" },
439 { TUNER_TEMIC_4006FH5_PAL, "Temic 4006FH5" },
440 { TUNER_ABSENT, "Samsung TCPN9085D" },
441 { TUNER_ABSENT, "Samsung TCPB9085P" },
442 { TUNER_ABSENT, "Samsung TCPL9091P" },
443 { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" },
444 { TUNER_PHILIPS_FQ1216ME, "Philips FQ1216 ME" },
445 { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" },
446 { TUNER_PHILIPS_NTSC, "Philips TD1536" },
447 { TUNER_PHILIPS_NTSC, "Philips TD1536D" },
448 { TUNER_PHILIPS_NTSC, "Philips FMR1236" }, /* mono radio */
449 { TUNER_ABSENT, "Philips FI1256MP" },
450 { TUNER_ABSENT, "Samsung TCPQ9091P" },
451 { TUNER_TEMIC_4006FN5_MULTI_PAL, "Temic 4006FN5" },
452 { TUNER_TEMIC_4009FR5_PAL, "Temic 4009FR5" },
453 { TUNER_TEMIC_4046FM5, "Temic 4046FM5" },
454 { TUNER_TEMIC_4009FN5_MULTI_PAL_FM, "Temic 4009FN5" },
455 { TUNER_ABSENT, "Philips TD1536D_FH_44"},
456 { TUNER_LG_NTSC_FM, "LG TPI8NSR01F"},
457 { TUNER_LG_PAL_FM, "LG TPI8PSB01D"},
458 { TUNER_LG_PAL, "LG TPI8PSB11D"},
459 { TUNER_LG_PAL_I_FM, "LG TAPC-I001D"},
460 { TUNER_LG_PAL_I, "LG TAPC-I701D"}
463 static void __devinit hauppauge_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
465 unsigned int blk2,tuner,radio,model;
467 if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0) {
468 printk(KERN_WARNING "%s: Hauppauge eeprom: invalid\n",
473 /* Block 2 starts after len+3 bytes header */
474 blk2 = eeprom_data[1] + 3;
476 /* decode + use some config infos */
477 model = eeprom_data[12] << 8 | eeprom_data[11];
478 tuner = eeprom_data[9];
479 radio = eeprom_data[blk2-1] & 0x01;
481 if (tuner < ARRAY_SIZE(hauppauge_tuner))
482 dev->tuner_type = hauppauge_tuner[tuner].id;
486 printk(KERN_INFO "%s: hauppauge eeprom: model=%d, "
487 "tuner=%s (%d), radio=%s\n",
488 dev->name, model, hauppauge_tuner[tuner].name,
489 dev->tuner_type, radio ? "yes" : "no");
492 /* ----------------------------------------------------------------------- */
493 /* some GDI (was: Modular Technology) specific stuff */
500 [ 0x01 ] = { .id = TUNER_ABSENT,
502 [ 0x02 ] = { .id = TUNER_ABSENT,
504 [ 0x03 ] = { .id = TUNER_ABSENT,
506 [ 0x04 ] = { .id = TUNER_ABSENT,
508 [ 0x05 ] = { .id = TUNER_ABSENT,
511 [ 0x10 ] = { .id = TUNER_ABSENT,
513 .name = "TEMIC_4049" },
514 [ 0x11 ] = { .id = TUNER_TEMIC_4136FY5,
515 .name = "TEMIC_4136" },
516 [ 0x12 ] = { .id = TUNER_ABSENT,
517 .name = "TEMIC_4146" },
519 [ 0x20 ] = { .id = TUNER_PHILIPS_FQ1216ME,
521 .name = "PHILIPS_FQ1216_MK3" },
522 [ 0x21 ] = { .id = TUNER_ABSENT, .fm = 1,
523 .name = "PHILIPS_FQ1236_MK3" },
524 [ 0x22 ] = { .id = TUNER_ABSENT,
525 .name = "PHILIPS_FI1236_MK3" },
526 [ 0x23 ] = { .id = TUNER_ABSENT,
527 .name = "PHILIPS_FI1216_MK3" },
530 static void __devinit gdi_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
532 char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
533 ? gdi_tuner[eeprom_data[0x0d]].name : NULL;
535 printk(KERN_INFO "%s: GDI: tuner=%s\n", dev->name,
536 name ? name : "unknown");
539 dev->tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
540 dev->has_radio = gdi_tuner[eeprom_data[0x0d]].fm;
543 /* ----------------------------------------------------------------------- */
546 i2c_eeprom(struct i2c_client *c, unsigned char *eedata, int len)
553 if (1 != (err = i2c_master_send(c,&buf,1))) {
554 printk(KERN_INFO "cx88: Huh, no eeprom present (err=%d)?\n",
558 if (len != (err = i2c_master_recv(c,eedata,len))) {
559 printk(KERN_WARNING "cx88: i2c eeprom read error (err=%d)\n",
564 for (i = 0; i < len; i++) {
566 printk(KERN_INFO "cx88 ee: %02x:",i);
567 printk(" %02x",eedata[i]);
575 void cx88_card_list(struct cx8800_dev *dev)
579 if (0 == dev->pci->subsystem_vendor &&
580 0 == dev->pci->subsystem_device) {
581 printk("%s: Your board has no valid PCI Subsystem ID and thus can't\n"
582 "%s: be autodetected. Please pass card=<n> insmod option to\n"
583 "%s: workaround that. Redirect complaints to the vendor of\n"
584 "%s: the TV card. Best regards,\n"
586 dev->name,dev->name,dev->name,dev->name,dev->name);
588 printk("%s: Your board isn't known (yet) to the driver. You can\n"
589 "%s: try to pick one of the existing card configs via\n"
590 "%s: card=<n> insmod option. Updating to the latest\n"
591 "%s: version might help as well.\n",
592 dev->name,dev->name,dev->name,dev->name);
594 printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
596 for (i = 0; i < cx88_bcount; i++)
597 printk("%s: card=%d -> %s\n",
598 dev->name, i, cx88_boards[i].name);
601 void cx88_card_setup(struct cx8800_dev *dev)
603 static u8 eeprom[128];
605 switch (dev->board) {
606 case CX88_BOARD_HAUPPAUGE:
607 if (0 == dev->i2c_rc)
608 i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
609 hauppauge_eeprom(dev,eeprom+8);
612 if (0 == dev->i2c_rc)
613 i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
614 gdi_eeprom(dev,eeprom);
616 case CX88_BOARD_WINFAST2000XP:
617 if (0 == dev->i2c_rc)
618 i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
619 leadtek_eeprom(dev,eeprom);
621 case CX88_BOARD_ASUS_PVR_416:
627 /* ------------------------------------------------------------------ */
629 EXPORT_SYMBOL(cx88_boards);
630 EXPORT_SYMBOL(cx88_bcount);
631 EXPORT_SYMBOL(cx88_subids);
632 EXPORT_SYMBOL(cx88_idcount);
633 EXPORT_SYMBOL(cx88_card_list);
634 EXPORT_SYMBOL(cx88_card_setup);