2 * $Id: cx88-cards.c,v 1.47 2004/11/03 09:04:50 kraxel Exp $
4 * device driver for Conexant 2388x based TV cards
7 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/pci.h>
27 #include <linux/delay.h>
29 #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
38 /* ------------------------------------------------------------------ */
39 /* board config info */
41 struct cx88_board cx88_boards[] = {
42 [CX88_BOARD_UNKNOWN] = {
43 .name = "UNKNOWN/GENERIC",
46 .type = CX88_VMUX_COMPOSITE1,
49 .type = CX88_VMUX_COMPOSITE2,
52 .type = CX88_VMUX_COMPOSITE3,
55 .type = CX88_VMUX_COMPOSITE4,
59 [CX88_BOARD_HAUPPAUGE] = {
60 .name = "Hauppauge WinTV 34xxx models",
63 .type = CX88_VMUX_TELEVISION,
65 .gpio0 = 0xff00, // internal decoder
67 .type = CX88_VMUX_DEBUG,
69 .gpio0 = 0xff01, // mono from tuner chip
71 .type = CX88_VMUX_COMPOSITE1,
75 .type = CX88_VMUX_SVIDEO,
85 .name = "GDI Black Gold",
88 .type = CX88_VMUX_TELEVISION,
92 [CX88_BOARD_PIXELVIEW] = {
96 .type = CX88_VMUX_TELEVISION,
98 .gpio0 = 0xff00, // internal decoder
100 .type = CX88_VMUX_COMPOSITE1,
103 .type = CX88_VMUX_SVIDEO,
111 [CX88_BOARD_ATI_WONDER_PRO] = {
112 .name = "ATI TV Wonder Pro",
114 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER,
116 .type = CX88_VMUX_TELEVISION,
120 .type = CX88_VMUX_COMPOSITE1,
124 .type = CX88_VMUX_SVIDEO,
129 [CX88_BOARD_WINFAST2000XP] = {
130 .name = "Leadtek Winfast 2000XP Expert",
132 .tda9887_conf = TDA9887_PRESENT,
134 .type = CX88_VMUX_TELEVISION,
141 .type = CX88_VMUX_COMPOSITE1,
148 .type = CX88_VMUX_SVIDEO,
163 [CX88_BOARD_AVERTV_303] = {
164 .name = "AverTV Studio 303 (M126)",
166 .tda9887_conf = TDA9887_PRESENT,
168 .type = CX88_VMUX_TELEVISION,
172 .type = CX88_VMUX_COMPOSITE1,
176 .type = CX88_VMUX_SVIDEO,
184 [CX88_BOARD_MSI_TVANYWHERE_MASTER] = {
185 // added gpio values thanks to Michal
186 // values for PAL from DScaler
187 .name = "MSI TV-@nywhere Master",
189 .tda9887_conf = TDA9887_PRESENT,
191 .type = CX88_VMUX_TELEVISION,
197 .type = CX88_VMUX_COMPOSITE1,
203 .type = CX88_VMUX_SVIDEO,
213 [CX88_BOARD_WINFAST_DV2000] = {
214 .name = "Leadtek Winfast DV2000",
216 .tda9887_conf = TDA9887_PRESENT,
218 .type = CX88_VMUX_TELEVISION,
225 [CX88_BOARD_LEADTEK_PVR2000] = {
226 .name = "Leadtek PVR 2000",
229 .type = CX88_VMUX_TELEVISION,
232 .type = CX88_VMUX_COMPOSITE1,
235 .type = CX88_VMUX_SVIDEO,
243 [CX88_BOARD_IODATA_GVVCP3PCI] = {
244 .name = "IODATA GV-VCP3/PCI",
245 .tuner_type = TUNER_ABSENT,
247 .type = CX88_VMUX_COMPOSITE1,
250 .type = CX88_VMUX_COMPOSITE2,
253 .type = CX88_VMUX_SVIDEO,
257 [CX88_BOARD_PROLINK_PLAYTVPVR] = {
258 .name = "Prolink PlayTV PVR",
260 .tda9887_conf = TDA9887_PRESENT,
262 .type = CX88_VMUX_TELEVISION,
266 .type = CX88_VMUX_COMPOSITE1,
270 .type = CX88_VMUX_SVIDEO,
279 [CX88_BOARD_ASUS_PVR_416] = {
280 .name = "ASUS PVR-416",
282 .tda9887_conf = TDA9887_PRESENT,
284 .type = CX88_VMUX_TELEVISION,
288 .type = CX88_VMUX_SVIDEO,
290 .gpio0 = 0x0000fde6, // 0x0000fda6 L,R RCA audio in?
298 [CX88_BOARD_MSI_TVANYWHERE] = {
299 .name = "MSI TV-@nywhere",
301 .tda9887_conf = TDA9887_PRESENT,
303 .type = CX88_VMUX_TELEVISION,
308 .type = CX88_VMUX_COMPOSITE1,
313 .type = CX88_VMUX_SVIDEO,
319 [CX88_BOARD_KWORLD_DVB_T] = {
320 .name = "KWorld/VStream XPert DVB-T",
321 .tuner_type = TUNER_ABSENT,
323 .type = CX88_VMUX_DVB,
326 .type = CX88_VMUX_COMPOSITE1,
329 .type = CX88_VMUX_SVIDEO,
334 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = {
335 .name = "DVICO FusionHDTV DVB-T1",
336 .tuner_type = TUNER_ABSENT, /* No analog tuner */
338 .type = CX88_VMUX_COMPOSITE1,
342 .type = CX88_VMUX_SVIDEO,
348 [CX88_BOARD_KWORLD_LTV883] = {
349 .name = "KWorld LTV883RF",
352 .type = CX88_VMUX_TELEVISION,
356 .type = CX88_VMUX_DEBUG,
358 .gpio0 = 0x07f9, // mono from tuner chip
360 .type = CX88_VMUX_COMPOSITE1,
364 .type = CX88_VMUX_SVIDEO,
373 [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD] = {
374 .name = "DViCO - FusionHDTV 3 Gold",
375 .tuner_type = TUNER_MICROTUNE_4042FI5,
377 GPIO[0] resets DT3302 DTV receiver
380 GPIO[1] mutes analog audio output connector
381 0 - enable selected source
383 GPIO[2] selects source for analog audio output connector
384 0 - analog audio input connector on tab
385 1 - analog DAC output from CX23881 chip
386 GPIO[3] selects RF input connector on tuner module
387 0 - RF connector labeled CABLE
388 1 - RF connector labeled ANT
391 .type = CX88_VMUX_TELEVISION,
395 .type = CX88_VMUX_CABLE,
399 .type = CX88_VMUX_COMPOSITE1,
403 .type = CX88_VMUX_SVIDEO,
410 .gpio0 = 0x00000f01, /* Hooked to tuner reset bit */
414 [CX88_BOARD_HAUPPAUGE_DVB_T1] = {
415 .name = "Hauppauge Nova-T DVB-T",
416 .tuner_type = TUNER_ABSENT,
418 .type = CX88_VMUX_DVB,
423 [CX88_BOARD_CONEXANT_DVB_T1] = {
424 .name = "Conexant DVB-T reference design",
425 .tuner_type = TUNER_ABSENT,
427 .type = CX88_VMUX_DVB,
432 [CX88_BOARD_PROVIDEO_PV259] = {
433 .name = "Provideo PV259",
434 .tuner_type = TUNER_PHILIPS_FQ1216ME,
436 .type = CX88_VMUX_TELEVISION,
441 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = {
442 .name = "DVICO FusionHDTV DVB-T Plus",
443 .tuner_type = TUNER_ABSENT, /* No analog tuner */
445 .type = CX88_VMUX_COMPOSITE1,
449 .type = CX88_VMUX_SVIDEO,
456 const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
458 /* ------------------------------------------------------------------ */
459 /* PCI subsystem IDs */
461 struct cx88_subid cx88_subids[] = {
465 .card = CX88_BOARD_HAUPPAUGE,
469 .card = CX88_BOARD_HAUPPAUGE,
473 .card = CX88_BOARD_GDI,
476 .subdevice = 0x0107, /* with mpeg encoder */
477 .card = CX88_BOARD_GDI,
479 .subvendor = PCI_VENDOR_ID_ATI,
481 .card = CX88_BOARD_ATI_WONDER_PRO,
485 .card = CX88_BOARD_WINFAST2000XP,
488 .subdevice = 0x6613, /* NTSC */
489 .card = CX88_BOARD_WINFAST2000XP,
493 .card = CX88_BOARD_WINFAST_DV2000,
497 .card = CX88_BOARD_LEADTEK_PVR2000,
501 .card = CX88_BOARD_LEADTEK_PVR2000,
505 .card = CX88_BOARD_AVERTV_303,
509 .card = CX88_BOARD_MSI_TVANYWHERE_MASTER,
513 .card = CX88_BOARD_IODATA_GVVCP3PCI,
516 .subdevice = 0x4823, /* with mpeg encoder */
517 .card = CX88_BOARD_ASUS_PVR_416,
521 .card = CX88_BOARD_KWORLD_DVB_T,
525 .card = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD,
529 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1,
533 .card = CX88_BOARD_HAUPPAUGE_DVB_T1,
537 .card = CX88_BOARD_CONEXANT_DVB_T1,
541 .card = CX88_BOARD_PROVIDEO_PV259,
545 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
548 const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
550 /* ----------------------------------------------------------------------- */
551 /* some leadtek specific stuff */
553 static void __devinit leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
555 /* This is just for the Winfast 2000 XP board ATM; I don't have data on
558 * Byte 0 is 1 on the NTSC board.
561 if (eeprom_data[4] != 0x7d ||
562 eeprom_data[5] != 0x10 ||
563 eeprom_data[7] != 0x66) {
564 printk(KERN_WARNING "%s: Leadtek eeprom invalid.\n",
570 core->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38;
572 printk(KERN_INFO "%s: Leadtek Winfast 2000 XP config: "
573 "tuner=%d, eeprom[0]=0x%02x\n",
574 core->name, core->tuner_type, eeprom_data[0]);
578 /* ----------------------------------------------------------------------- */
579 /* some hauppauge specific stuff */
584 } hauppauge_tuner[] __devinitdata = {
585 { TUNER_ABSENT, "" },
586 { TUNER_ABSENT, "External" },
587 { TUNER_ABSENT, "Unspecified" },
588 { TUNER_PHILIPS_PAL, "Philips FI1216" },
589 { TUNER_PHILIPS_SECAM, "Philips FI1216MF" },
590 { TUNER_PHILIPS_NTSC, "Philips FI1236" },
591 { TUNER_PHILIPS_PAL_I, "Philips FI1246" },
592 { TUNER_PHILIPS_PAL_DK,"Philips FI1256" },
593 { TUNER_PHILIPS_PAL, "Philips FI1216 MK2" },
594 { TUNER_PHILIPS_SECAM, "Philips FI1216MF MK2" },
595 { TUNER_PHILIPS_NTSC, "Philips FI1236 MK2" },
596 { TUNER_PHILIPS_PAL_I, "Philips FI1246 MK2" },
597 { TUNER_PHILIPS_PAL_DK,"Philips FI1256 MK2" },
598 { TUNER_TEMIC_NTSC, "Temic 4032FY5" },
599 { TUNER_TEMIC_PAL, "Temic 4002FH5" },
600 { TUNER_TEMIC_PAL_I, "Temic 4062FY5" },
601 { TUNER_PHILIPS_PAL, "Philips FR1216 MK2" },
602 { TUNER_PHILIPS_SECAM, "Philips FR1216MF MK2" },
603 { TUNER_PHILIPS_NTSC, "Philips FR1236 MK2" },
604 { TUNER_PHILIPS_PAL_I, "Philips FR1246 MK2" },
605 { TUNER_PHILIPS_PAL_DK,"Philips FR1256 MK2" },
606 { TUNER_PHILIPS_PAL, "Philips FM1216" },
607 { TUNER_PHILIPS_SECAM, "Philips FM1216MF" },
608 { TUNER_PHILIPS_NTSC, "Philips FM1236" },
609 { TUNER_PHILIPS_PAL_I, "Philips FM1246" },
610 { TUNER_PHILIPS_PAL_DK,"Philips FM1256" },
611 { TUNER_TEMIC_4036FY5_NTSC, "Temic 4036FY5" },
612 { TUNER_ABSENT, "Samsung TCPN9082D" },
613 { TUNER_ABSENT, "Samsung TCPM9092P" },
614 { TUNER_TEMIC_4006FH5_PAL, "Temic 4006FH5" },
615 { TUNER_ABSENT, "Samsung TCPN9085D" },
616 { TUNER_ABSENT, "Samsung TCPB9085P" },
617 { TUNER_ABSENT, "Samsung TCPL9091P" },
618 { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" },
619 { TUNER_PHILIPS_FQ1216ME, "Philips FQ1216 ME" },
620 { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" },
621 { TUNER_PHILIPS_NTSC, "Philips TD1536" },
622 { TUNER_PHILIPS_NTSC, "Philips TD1536D" },
623 { TUNER_PHILIPS_NTSC, "Philips FMR1236" }, /* mono radio */
624 { TUNER_ABSENT, "Philips FI1256MP" },
625 { TUNER_ABSENT, "Samsung TCPQ9091P" },
626 { TUNER_TEMIC_4006FN5_MULTI_PAL, "Temic 4006FN5" },
627 { TUNER_TEMIC_4009FR5_PAL, "Temic 4009FR5" },
628 { TUNER_TEMIC_4046FM5, "Temic 4046FM5" },
629 { TUNER_TEMIC_4009FN5_MULTI_PAL_FM, "Temic 4009FN5" },
630 { TUNER_ABSENT, "Philips TD1536D_FH_44"},
631 { TUNER_LG_NTSC_FM, "LG TPI8NSR01F"},
632 { TUNER_LG_PAL_FM, "LG TPI8PSB01D"},
633 { TUNER_LG_PAL, "LG TPI8PSB11D"},
634 { TUNER_LG_PAL_I_FM, "LG TAPC-I001D"},
635 { TUNER_LG_PAL_I, "LG TAPC-I701D"}
638 static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
640 unsigned int blk2,tuner,radio,model;
642 if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0) {
643 printk(KERN_WARNING "%s: Hauppauge eeprom: invalid\n",
648 /* Block 2 starts after len+3 bytes header */
649 blk2 = eeprom_data[1] + 3;
651 /* decode + use some config infos */
652 model = eeprom_data[12] << 8 | eeprom_data[11];
653 tuner = eeprom_data[9];
654 radio = eeprom_data[blk2-1] & 0x01;
656 if (tuner < ARRAY_SIZE(hauppauge_tuner))
657 core->tuner_type = hauppauge_tuner[tuner].id;
661 printk(KERN_INFO "%s: hauppauge eeprom: model=%d, "
662 "tuner=%s (%d), radio=%s\n",
663 core->name, model, (tuner < ARRAY_SIZE(hauppauge_tuner)
664 ? hauppauge_tuner[tuner].name : "?"),
665 core->tuner_type, radio ? "yes" : "no");
669 static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
675 /* Make sure we support the board model */
676 model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c];
684 printk("%s: warning: unknown hauppauge model #%d\n",
689 /* Make sure we support the tuner */
693 tname = "Thomson DTT 7595";
694 core->pll_type = PLLTYPE_DTT7595;
697 tname = "Thomson DTT 7592";
698 core->pll_type = PLLTYPE_DTT7592;
701 printk("%s: error: unknown hauppauge tuner 0x%02x\n",
705 printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%s (%d)\n",
706 core->name, model, tname, tuner);
708 core->pll_addr = 0x61;
709 core->demod_addr = 0x43;
713 /* ----------------------------------------------------------------------- */
714 /* some GDI (was: Modular Technology) specific stuff */
721 [ 0x01 ] = { .id = TUNER_ABSENT,
723 [ 0x02 ] = { .id = TUNER_ABSENT,
725 [ 0x03 ] = { .id = TUNER_ABSENT,
727 [ 0x04 ] = { .id = TUNER_ABSENT,
729 [ 0x05 ] = { .id = TUNER_ABSENT,
732 [ 0x10 ] = { .id = TUNER_ABSENT,
734 .name = "TEMIC_4049" },
735 [ 0x11 ] = { .id = TUNER_TEMIC_4136FY5,
736 .name = "TEMIC_4136" },
737 [ 0x12 ] = { .id = TUNER_ABSENT,
738 .name = "TEMIC_4146" },
740 [ 0x20 ] = { .id = TUNER_PHILIPS_FQ1216ME,
742 .name = "PHILIPS_FQ1216_MK3" },
743 [ 0x21 ] = { .id = TUNER_ABSENT, .fm = 1,
744 .name = "PHILIPS_FQ1236_MK3" },
745 [ 0x22 ] = { .id = TUNER_ABSENT,
746 .name = "PHILIPS_FI1236_MK3" },
747 [ 0x23 ] = { .id = TUNER_ABSENT,
748 .name = "PHILIPS_FI1216_MK3" },
751 static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
753 char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
754 ? gdi_tuner[eeprom_data[0x0d]].name : NULL;
756 printk(KERN_INFO "%s: GDI: tuner=%s\n", core->name,
757 name ? name : "unknown");
760 core->tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
761 core->has_radio = gdi_tuner[eeprom_data[0x0d]].fm;
764 /* ----------------------------------------------------------------------- */
767 i2c_eeprom(struct i2c_client *c, unsigned char *eedata, int len)
774 if (1 != (err = i2c_master_send(c,&buf,1))) {
775 printk(KERN_INFO "cx88: Huh, no eeprom present (err=%d)?\n",
779 if (len != (err = i2c_master_recv(c,eedata,len))) {
780 printk(KERN_WARNING "cx88: i2c eeprom read error (err=%d)\n",
785 for (i = 0; i < len; i++) {
787 printk(KERN_INFO "cx88 ee: %02x:",i);
788 printk(" %02x",eedata[i]);
796 void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
800 if (0 == pci->subsystem_vendor &&
801 0 == pci->subsystem_device) {
802 printk("%s: Your board has no valid PCI Subsystem ID and thus can't\n"
803 "%s: be autodetected. Please pass card=<n> insmod option to\n"
804 "%s: workaround that. Redirect complaints to the vendor of\n"
805 "%s: the TV card. Best regards,\n"
807 core->name,core->name,core->name,core->name,core->name);
809 printk("%s: Your board isn't known (yet) to the driver. You can\n"
810 "%s: try to pick one of the existing card configs via\n"
811 "%s: card=<n> insmod option. Updating to the latest\n"
812 "%s: version might help as well.\n",
813 core->name,core->name,core->name,core->name);
815 printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
817 for (i = 0; i < cx88_bcount; i++)
818 printk("%s: card=%d -> %s\n",
819 core->name, i, cx88_boards[i].name);
822 void cx88_card_setup(struct cx88_core *core)
824 static u8 eeprom[128];
826 switch (core->board) {
827 case CX88_BOARD_HAUPPAUGE:
828 if (0 == core->i2c_rc)
829 i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
830 hauppauge_eeprom(core,eeprom+8);
833 if (0 == core->i2c_rc)
834 i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
835 gdi_eeprom(core,eeprom);
837 case CX88_BOARD_WINFAST2000XP:
838 if (0 == core->i2c_rc)
839 i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
840 leadtek_eeprom(core,eeprom);
842 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
843 /* Tuner reset is hooked to the tuner out of reset */
844 cx_set(MO_GP0_IO, 0x00000101);
845 cx_clear(MO_GP0_IO, 0x00000001);
847 cx_set(MO_GP0_IO, 0x00000101);
850 case CX88_BOARD_HAUPPAUGE_DVB_T1:
851 if (0 == core->i2c_rc)
852 i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
853 hauppauge_eeprom_dvb(core,eeprom);
855 case CX88_BOARD_CONEXANT_DVB_T1:
856 core->pll_type = PLLTYPE_DTT7579;
857 core->pll_addr = 0x60;
858 core->demod_addr = 0x43;
862 if (cx88_boards[core->board].radio.type == CX88_RADIO)
866 /* ------------------------------------------------------------------ */
868 EXPORT_SYMBOL(cx88_boards);
869 EXPORT_SYMBOL(cx88_bcount);
870 EXPORT_SYMBOL(cx88_subids);
871 EXPORT_SYMBOL(cx88_idcount);
872 EXPORT_SYMBOL(cx88_card_list);
873 EXPORT_SYMBOL(cx88_card_setup);