2 * Driver for the Conexant CX23885 PCIe bridge
4 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.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; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * 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>
25 #include <linux/delay.h>
26 #include <media/cx25840.h>
29 #include "tuner-xc2028.h"
31 /* ------------------------------------------------------------------ */
32 /* board config info */
34 struct cx23885_board cx23885_boards[] = {
35 [CX23885_BOARD_UNKNOWN] = {
36 .name = "UNKNOWN/GENERIC",
37 /* Ensure safe default for unknown boards */
40 .type = CX23885_VMUX_COMPOSITE1,
43 .type = CX23885_VMUX_COMPOSITE2,
46 .type = CX23885_VMUX_COMPOSITE3,
49 .type = CX23885_VMUX_COMPOSITE4,
53 [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = {
54 .name = "Hauppauge WinTV-HVR1800lp",
55 .portc = CX23885_MPEG_DVB,
57 .type = CX23885_VMUX_TELEVISION,
61 .type = CX23885_VMUX_DEBUG,
65 .type = CX23885_VMUX_COMPOSITE1,
69 .type = CX23885_VMUX_SVIDEO,
74 [CX23885_BOARD_HAUPPAUGE_HVR1800] = {
75 .name = "Hauppauge WinTV-HVR1800",
76 .porta = CX23885_ANALOG_VIDEO,
77 .portb = CX23885_MPEG_ENCODER,
78 .portc = CX23885_MPEG_DVB,
79 .tuner_type = TUNER_PHILIPS_TDA8290,
80 .tuner_addr = 0x42, /* 0x84 >> 1 */
82 .type = CX23885_VMUX_TELEVISION,
83 .vmux = CX25840_VIN7_CH3 |
88 .type = CX23885_VMUX_COMPOSITE1,
89 .vmux = CX25840_VIN7_CH3 |
94 .type = CX23885_VMUX_SVIDEO,
95 .vmux = CX25840_VIN7_CH3 |
102 [CX23885_BOARD_HAUPPAUGE_HVR1250] = {
103 .name = "Hauppauge WinTV-HVR1250",
104 .portc = CX23885_MPEG_DVB,
106 .type = CX23885_VMUX_TELEVISION,
110 .type = CX23885_VMUX_DEBUG,
114 .type = CX23885_VMUX_COMPOSITE1,
118 .type = CX23885_VMUX_SVIDEO,
123 [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = {
124 .name = "DViCO FusionHDTV5 Express",
125 .portb = CX23885_MPEG_DVB,
127 [CX23885_BOARD_HAUPPAUGE_HVR1500Q] = {
128 .name = "Hauppauge WinTV-HVR1500Q",
129 .portc = CX23885_MPEG_DVB,
131 [CX23885_BOARD_HAUPPAUGE_HVR1500] = {
132 .name = "Hauppauge WinTV-HVR1500",
133 .portc = CX23885_MPEG_DVB,
135 [CX23885_BOARD_HAUPPAUGE_HVR1200] = {
136 .name = "Hauppauge WinTV-HVR1200",
137 .portc = CX23885_MPEG_DVB,
139 [CX23885_BOARD_HAUPPAUGE_HVR1700] = {
140 .name = "Hauppauge WinTV-HVR1700",
141 .portc = CX23885_MPEG_DVB,
143 [CX23885_BOARD_HAUPPAUGE_HVR1400] = {
144 .name = "Hauppauge WinTV-HVR1400",
145 .portc = CX23885_MPEG_DVB,
147 [CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP] = {
148 .name = "DViCO FusionHDTV7 Dual Express",
149 .portb = CX23885_MPEG_DVB,
150 .portc = CX23885_MPEG_DVB,
152 [CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP] = {
153 .name = "DViCO FusionHDTV DVB-T Dual Express",
154 .portb = CX23885_MPEG_DVB,
155 .portc = CX23885_MPEG_DVB,
157 [CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H] = {
158 .name = "Leadtek Winfast PxDVR3200 H",
159 .portc = CX23885_MPEG_DVB,
161 [CX23885_BOARD_COMPRO_VIDEOMATE_E650F] = {
162 .name = "Compro VideoMate E650F",
163 .portc = CX23885_MPEG_DVB,
165 [CX23885_BOARD_TBS_6920] = {
166 .name = "TurboSight TBS 6920",
167 .portb = CX23885_MPEG_DVB,
170 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
172 /* ------------------------------------------------------------------ */
173 /* PCI subsystem IDs */
175 struct cx23885_subid cx23885_subids[] = {
179 .card = CX23885_BOARD_UNKNOWN,
183 .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
187 .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
191 .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
195 .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
199 .card = CX23885_BOARD_HAUPPAUGE_HVR1250,
203 .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP,
207 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
211 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
215 .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
219 .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
223 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
227 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
231 .card = CX23885_BOARD_HAUPPAUGE_HVR1700,
235 .card = CX23885_BOARD_HAUPPAUGE_HVR1400,
239 .card = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP,
243 .card = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP,
247 .card = CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H,
251 .card = CX23885_BOARD_COMPRO_VIDEOMATE_E650F,
255 .card = CX23885_BOARD_TBS_6920,
258 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
260 void cx23885_card_list(struct cx23885_dev *dev)
264 if (0 == dev->pci->subsystem_vendor &&
265 0 == dev->pci->subsystem_device) {
267 "%s: Board has no valid PCIe Subsystem ID and can't\n"
268 "%s: be autodetected. Pass card=<n> insmod option\n"
269 "%s: to workaround that. Redirect complaints to the\n"
270 "%s: vendor of the TV card. Best regards,\n"
272 dev->name, dev->name, dev->name, dev->name, dev->name);
275 "%s: Your board isn't known (yet) to the driver.\n"
276 "%s: Try to pick one of the existing card configs via\n"
277 "%s: card=<n> insmod option. Updating to the latest\n"
278 "%s: version might help as well.\n",
279 dev->name, dev->name, dev->name, dev->name);
281 printk(KERN_INFO "%s: Here is a list of valid choices for the card=<n> insmod option:\n",
283 for (i = 0; i < cx23885_bcount; i++)
284 printk(KERN_INFO "%s: card=%d -> %s\n",
285 dev->name, i, cx23885_boards[i].name);
288 static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
292 tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
295 /* Make sure we support the board model */
298 /* WinTV-HVR1200 (PCIe, Retail, full height)
299 * DVB-T and basic analog */
301 /* WinTV-HVR1200 (PCIe, OEM, half height)
302 * DVB-T and basic analog */
304 /* WinTV-HVR1200 (PCIe, OEM, half height)
305 * DVB-T and basic analog */
307 /* WinTV-HVR1200 (PCIe, OEM, full height)
308 * DVB-T and basic analog */
310 /* WinTV-HVR1200 (PCIe, OEM, half height)
311 * DVB-T and basic analog */
313 /* WinTV-HVR1200 (PCIe, OEM, full height)
314 * DVB-T and basic analog */
316 /* WinTV-HVR1200 (PCIe, OEM, full height)
317 * DVB-T and basic analog */
319 /* WinTV-HVR1200 (PCIe, OEM, half height)
320 * DVB-T and basic analog */
322 /* WinTV-HVR1200 (PCIe, OEM, full height)
323 * DVB-T and basic analog */
325 /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual
326 channel ATSC and MPEG2 HW Encoder */
328 /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC
331 /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC
334 /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM
337 /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM
340 /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM,
341 Dual channel ATSC and MPEG2 HW Encoder */
343 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM,
344 Dual channel ATSC and MPEG2 HW Encoder */
346 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM,
347 Dual channel ATSC and MPEG2 HW Encoder */
349 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM,
350 Dual channel ATSC and MPEG2 HW Encoder */
352 /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM,
353 Dual channel ATSC and MPEG2 HW Encoder */
355 /* WinTV-HVR1250 (PCIe, Retail, IR, full height,
356 ATSC and Basic analog */
358 /* WinTV-HVR1250 (PCIe, Retail, IR, half height,
359 ATSC and Basic analog */
361 /* WinTV-HVR1250 (PCIe, OEM, No IR, half height,
362 ATSC and Basic analog */
364 /* WinTV-HVR1250 (PCIe, OEM, No IR, full height,
365 ATSC and Basic analog */
367 /* WinTV-HVR1250 (PCIe, OEM, No IR, half height,
368 ATSC and Basic analog */
370 /* WinTV-HVR1400 (Express Card, Retail, IR,
371 * DVB-T and Basic analog */
373 /* WinTV-HVR1700 (PCIe, OEM, No IR, half height)
374 * DVB-T and MPEG2 HW Encoder */
376 /* WinTV-HVR1700 (PCIe, OEM, No IR, full height)
377 * DVB-T and MPEG2 HW Encoder */
380 printk(KERN_WARNING "%s: warning: unknown hauppauge model #%d\n",
381 dev->name, tv.model);
385 printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
386 dev->name, tv.model);
389 int cx23885_tuner_callback(void *priv, int component, int command, int arg)
391 struct cx23885_tsport *port = priv;
392 struct cx23885_dev *dev = port->dev;
395 if (command == XC2028_RESET_CLK)
399 printk(KERN_ERR "%s(): Unknown command 0x%x.\n",
404 switch (dev->board) {
405 case CX23885_BOARD_HAUPPAUGE_HVR1400:
406 case CX23885_BOARD_HAUPPAUGE_HVR1500:
407 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
408 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
409 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
410 /* Tuner Reset Command */
413 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
414 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
415 /* Two identical tuners on two different i2c buses,
416 * we need to reset the correct gpio. */
419 else if (port->nr == 1)
425 /* Drive the tuner into reset and back out */
426 cx_clear(GP0_IO, bitmask);
428 cx_set(GP0_IO, bitmask);
434 void cx23885_gpio_setup(struct cx23885_dev *dev)
436 switch (dev->board) {
437 case CX23885_BOARD_HAUPPAUGE_HVR1250:
438 /* GPIO-0 cx24227 demodulator reset */
439 cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
441 case CX23885_BOARD_HAUPPAUGE_HVR1500:
442 /* GPIO-0 cx24227 demodulator */
443 /* GPIO-2 xc3028 tuner */
445 /* Put the parts into reset */
446 cx_set(GP0_IO, 0x00050000);
447 cx_clear(GP0_IO, 0x00000005);
450 /* Bring the parts out of reset */
451 cx_set(GP0_IO, 0x00050005);
453 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
454 /* GPIO-0 cx24227 demodulator reset */
455 /* GPIO-2 xc5000 tuner reset */
456 cx_set(GP0_IO, 0x00050005); /* Bring the part out of reset */
458 case CX23885_BOARD_HAUPPAUGE_HVR1800:
461 /* GPIO-2 8295A Reset */
462 /* GPIO-3-10 cx23417 data0-7 */
463 /* GPIO-11-14 cx23417 addr0-3 */
464 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
468 /* EIO15 Zilog Reset */
469 /* EIO14 S5H1409/CX24227 Reset */
471 /* Force the TDA8295A into reset and back */
472 cx_set(GP0_IO, 0x00040004);
474 cx_clear(GP0_IO, 0x00000004);
476 cx_set(GP0_IO, 0x00040004);
479 case CX23885_BOARD_HAUPPAUGE_HVR1200:
480 /* GPIO-0 tda10048 demodulator reset */
481 /* GPIO-2 tda18271 tuner reset */
483 /* Put the parts into reset and back */
484 cx_set(GP0_IO, 0x00050000);
486 cx_clear(GP0_IO, 0x00000005);
488 cx_set(GP0_IO, 0x00050005);
490 case CX23885_BOARD_HAUPPAUGE_HVR1700:
491 /* GPIO-0 TDA10048 demodulator reset */
492 /* GPIO-2 TDA8295A Reset */
493 /* GPIO-3-10 cx23417 data0-7 */
494 /* GPIO-11-14 cx23417 addr0-3 */
495 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
497 /* The following GPIO's are on the interna AVCore (cx25840) */
499 /* GPIO-20 IR_TX 416/DVBT Select */
500 /* GPIO-21 IIS DAT */
501 /* GPIO-22 IIS WCLK */
502 /* GPIO-23 IIS BCLK */
504 /* Put the parts into reset and back */
505 cx_set(GP0_IO, 0x00050000);
507 cx_clear(GP0_IO, 0x00000005);
509 cx_set(GP0_IO, 0x00050005);
511 case CX23885_BOARD_HAUPPAUGE_HVR1400:
512 /* GPIO-0 Dibcom7000p demodulator reset */
513 /* GPIO-2 xc3028L tuner reset */
516 /* Put the parts into reset and back */
517 cx_set(GP0_IO, 0x00050000);
519 cx_clear(GP0_IO, 0x00000005);
521 cx_set(GP0_IO, 0x00050005);
523 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
524 /* GPIO-0 xc5000 tuner reset i2c bus 0 */
525 /* GPIO-1 s5h1409 demod reset i2c bus 0 */
526 /* GPIO-2 xc5000 tuner reset i2c bus 1 */
527 /* GPIO-3 s5h1409 demod reset i2c bus 0 */
529 /* Put the parts into reset and back */
530 cx_set(GP0_IO, 0x000f0000);
532 cx_clear(GP0_IO, 0x0000000f);
534 cx_set(GP0_IO, 0x000f000f);
536 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
537 /* GPIO-0 portb xc3028 reset */
538 /* GPIO-1 portb zl10353 reset */
539 /* GPIO-2 portc xc3028 reset */
540 /* GPIO-3 portc zl10353 reset */
542 /* Put the parts into reset and back */
543 cx_set(GP0_IO, 0x000f0000);
545 cx_clear(GP0_IO, 0x0000000f);
547 cx_set(GP0_IO, 0x000f000f);
549 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
550 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
551 /* GPIO-2 xc3028 tuner reset */
553 /* The following GPIO's are on the internal AVCore (cx25840) */
554 /* GPIO-? zl10353 demod reset */
556 /* Put the parts into reset and back */
557 cx_set(GP0_IO, 0x00040000);
559 cx_clear(GP0_IO, 0x00000004);
561 cx_set(GP0_IO, 0x00040004);
563 case CX23885_BOARD_TBS_6920:
564 cx_write(MC417_CTL, 0x00000036);
565 cx_write(MC417_OEN, 0x00001000);
566 cx_write(MC417_RWD, 0x00001800);
571 int cx23885_ir_init(struct cx23885_dev *dev)
573 switch (dev->board) {
574 case CX23885_BOARD_HAUPPAUGE_HVR1250:
575 case CX23885_BOARD_HAUPPAUGE_HVR1500:
576 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
577 case CX23885_BOARD_HAUPPAUGE_HVR1800:
578 case CX23885_BOARD_HAUPPAUGE_HVR1200:
579 case CX23885_BOARD_HAUPPAUGE_HVR1400:
580 /* FIXME: Implement me */
582 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
583 request_module("ir-kbd-i2c");
590 void cx23885_card_setup(struct cx23885_dev *dev)
592 struct cx23885_tsport *ts1 = &dev->ts1;
593 struct cx23885_tsport *ts2 = &dev->ts2;
595 static u8 eeprom[256];
597 if (dev->i2c_bus[0].i2c_rc == 0) {
598 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
599 tveeprom_read(&dev->i2c_bus[0].i2c_client,
600 eeprom, sizeof(eeprom));
603 switch (dev->board) {
604 case CX23885_BOARD_HAUPPAUGE_HVR1250:
605 case CX23885_BOARD_HAUPPAUGE_HVR1500:
606 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
607 case CX23885_BOARD_HAUPPAUGE_HVR1400:
608 if (dev->i2c_bus[0].i2c_rc == 0)
609 hauppauge_eeprom(dev, eeprom+0x80);
611 case CX23885_BOARD_HAUPPAUGE_HVR1800:
612 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
613 case CX23885_BOARD_HAUPPAUGE_HVR1200:
614 case CX23885_BOARD_HAUPPAUGE_HVR1700:
615 if (dev->i2c_bus[0].i2c_rc == 0)
616 hauppauge_eeprom(dev, eeprom+0xc0);
620 switch (dev->board) {
621 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
622 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
623 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
624 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
625 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
626 /* break omitted intentionally */
627 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
628 ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
629 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
630 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
632 case CX23885_BOARD_HAUPPAUGE_HVR1800:
633 /* Defaults for VID B - Analog encoder */
634 /* DREQ_POL, SMODE, PUNC_CLK, MCLK_POL Serial bus + punc clk */
635 ts1->gen_ctrl_val = 0x10e;
636 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
637 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
639 /* APB_TSVALERR_POL (active low)*/
640 ts1->vld_misc_val = 0x2000;
641 ts1->hw_sop_ctrl_val = (0x47 << 16 | 188 << 4 | 0xc);
643 /* Defaults for VID C */
644 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
645 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
646 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
648 case CX23885_BOARD_TBS_6920:
649 ts1->gen_ctrl_val = 0x5; /* Parallel */
650 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
651 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
653 case CX23885_BOARD_HAUPPAUGE_HVR1250:
654 case CX23885_BOARD_HAUPPAUGE_HVR1500:
655 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
656 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
657 case CX23885_BOARD_HAUPPAUGE_HVR1200:
658 case CX23885_BOARD_HAUPPAUGE_HVR1700:
659 case CX23885_BOARD_HAUPPAUGE_HVR1400:
660 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
661 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
663 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
664 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
665 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
668 /* Certain boards support analog, or require the avcore to be
669 * loaded, ensure this happens.
671 switch (dev->board) {
672 case CX23885_BOARD_HAUPPAUGE_HVR1800:
673 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
674 case CX23885_BOARD_HAUPPAUGE_HVR1700:
675 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
676 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
677 request_module("cx25840");
682 /* ------------------------------------------------------------------ */