3 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines
6 * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
7 * (c) 2004 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/module.h>
25 #include <linux/init.h>
26 #include <linux/device.h>
28 #include <linux/kthread.h>
29 #include <linux/file.h>
30 #include <linux/suspend.h>
34 #include <media/v4l2-common.h>
37 #include "mt352_priv.h"
38 #include "cx88-vp3054-i2c.h"
48 #include "tuner-simple.h"
53 MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
54 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
55 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
56 MODULE_LICENSE("GPL");
58 static unsigned int debug;
59 module_param(debug, int, 0644);
60 MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
62 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
64 #define dprintk(level,fmt, arg...) if (debug >= level) \
65 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
67 /* ------------------------------------------------------------------ */
69 static int dvb_buf_setup(struct videobuf_queue *q,
70 unsigned int *count, unsigned int *size)
72 struct cx8802_dev *dev = q->priv_data;
74 dev->ts_packet_size = 188 * 4;
75 dev->ts_packet_count = 32;
77 *size = dev->ts_packet_size * dev->ts_packet_count;
82 static int dvb_buf_prepare(struct videobuf_queue *q,
83 struct videobuf_buffer *vb, enum v4l2_field field)
85 struct cx8802_dev *dev = q->priv_data;
86 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
89 static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
91 struct cx8802_dev *dev = q->priv_data;
92 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
95 static void dvb_buf_release(struct videobuf_queue *q,
96 struct videobuf_buffer *vb)
98 cx88_free_buffer(q, (struct cx88_buffer*)vb);
101 static struct videobuf_queue_ops dvb_qops = {
102 .buf_setup = dvb_buf_setup,
103 .buf_prepare = dvb_buf_prepare,
104 .buf_queue = dvb_buf_queue,
105 .buf_release = dvb_buf_release,
108 /* ------------------------------------------------------------------ */
110 static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
112 struct cx8802_dev *dev= fe->dvb->priv;
113 struct cx8802_driver *drv = NULL;
116 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
119 ret = drv->request_acquire(drv);
121 ret = drv->request_release(drv);
127 /* ------------------------------------------------------------------ */
129 static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
131 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
132 static u8 reset [] = { RESET, 0x80 };
133 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
134 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
135 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
136 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
138 mt352_write(fe, clock_config, sizeof(clock_config));
140 mt352_write(fe, reset, sizeof(reset));
141 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
143 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
144 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
145 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
149 static int dvico_dual_demod_init(struct dvb_frontend *fe)
151 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
152 static u8 reset [] = { RESET, 0x80 };
153 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
154 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
155 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
156 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
158 mt352_write(fe, clock_config, sizeof(clock_config));
160 mt352_write(fe, reset, sizeof(reset));
161 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
163 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
164 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
165 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
170 static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
172 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
173 static u8 reset [] = { 0x50, 0x80 };
174 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
175 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
176 0x00, 0xFF, 0x00, 0x40, 0x40 };
177 static u8 dntv_extra[] = { 0xB5, 0x7A };
178 static u8 capt_range_cfg[] = { 0x75, 0x32 };
180 mt352_write(fe, clock_config, sizeof(clock_config));
182 mt352_write(fe, reset, sizeof(reset));
183 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
185 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
187 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
188 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
193 static struct mt352_config dvico_fusionhdtv = {
194 .demod_address = 0x0f,
195 .demod_init = dvico_fusionhdtv_demod_init,
198 static struct mt352_config dntv_live_dvbt_config = {
199 .demod_address = 0x0f,
200 .demod_init = dntv_live_dvbt_demod_init,
203 static struct mt352_config dvico_fusionhdtv_dual = {
204 .demod_address = 0x0f,
205 .demod_init = dvico_dual_demod_init,
208 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
209 static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
211 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
212 static u8 reset [] = { 0x50, 0x80 };
213 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
214 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
215 0x00, 0xFF, 0x00, 0x40, 0x40 };
216 static u8 dntv_extra[] = { 0xB5, 0x7A };
217 static u8 capt_range_cfg[] = { 0x75, 0x32 };
219 mt352_write(fe, clock_config, sizeof(clock_config));
221 mt352_write(fe, reset, sizeof(reset));
222 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
224 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
226 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
227 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
232 static struct mt352_config dntv_live_dvbt_pro_config = {
233 .demod_address = 0x0f,
235 .demod_init = dntv_live_dvbt_pro_demod_init,
239 static struct zl10353_config dvico_fusionhdtv_hybrid = {
240 .demod_address = 0x0f,
244 static struct zl10353_config dvico_fusionhdtv_xc3028 = {
245 .demod_address = 0x0f,
250 static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
251 .demod_address = 0x0f,
254 .demod_init = dvico_fusionhdtv_demod_init,
257 static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
258 .demod_address = 0x0f,
261 static struct cx22702_config connexant_refboard_config = {
262 .demod_address = 0x43,
263 .output_mode = CX22702_SERIAL_OUTPUT,
266 static struct cx22702_config hauppauge_hvr_config = {
267 .demod_address = 0x63,
268 .output_mode = CX22702_SERIAL_OUTPUT,
271 static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
273 struct cx8802_dev *dev= fe->dvb->priv;
274 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
278 static struct or51132_config pchdtv_hd3000 = {
279 .demod_address = 0x15,
280 .set_ts_params = or51132_set_ts_param,
283 static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
285 struct cx8802_dev *dev= fe->dvb->priv;
286 struct cx88_core *core = dev->core;
288 dprintk(1, "%s: index = %d\n", __func__, index);
290 cx_clear(MO_GP0_IO, 8);
292 cx_set(MO_GP0_IO, 8);
296 static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
298 struct cx8802_dev *dev= fe->dvb->priv;
300 dev->ts_gen_cntrl |= 0x04;
302 dev->ts_gen_cntrl &= ~0x04;
306 static struct lgdt330x_config fusionhdtv_3_gold = {
307 .demod_address = 0x0e,
308 .demod_chip = LGDT3302,
309 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
310 .set_ts_params = lgdt330x_set_ts_param,
313 static struct lgdt330x_config fusionhdtv_5_gold = {
314 .demod_address = 0x0e,
315 .demod_chip = LGDT3303,
316 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
317 .set_ts_params = lgdt330x_set_ts_param,
320 static struct lgdt330x_config pchdtv_hd5500 = {
321 .demod_address = 0x59,
322 .demod_chip = LGDT3303,
323 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
324 .set_ts_params = lgdt330x_set_ts_param,
327 static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
329 struct cx8802_dev *dev= fe->dvb->priv;
330 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
334 static struct nxt200x_config ati_hdtvwonder = {
335 .demod_address = 0x0a,
336 .set_ts_params = nxt200x_set_ts_param,
339 static int cx24123_set_ts_param(struct dvb_frontend* fe,
342 struct cx8802_dev *dev= fe->dvb->priv;
343 dev->ts_gen_cntrl = 0x02;
347 static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
348 fe_sec_voltage_t voltage)
350 struct cx8802_dev *dev= fe->dvb->priv;
351 struct cx88_core *core = dev->core;
353 if (voltage == SEC_VOLTAGE_OFF)
354 cx_write(MO_GP0_IO, 0x000006fb);
356 cx_write(MO_GP0_IO, 0x000006f9);
358 if (core->prev_set_voltage)
359 return core->prev_set_voltage(fe, voltage);
363 static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
364 fe_sec_voltage_t voltage)
366 struct cx8802_dev *dev= fe->dvb->priv;
367 struct cx88_core *core = dev->core;
369 if (voltage == SEC_VOLTAGE_OFF) {
370 dprintk(1,"LNB Voltage OFF\n");
371 cx_write(MO_GP0_IO, 0x0000efff);
374 if (core->prev_set_voltage)
375 return core->prev_set_voltage(fe, voltage);
379 static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
380 fe_sec_voltage_t voltage)
382 struct cx8802_dev *dev= fe->dvb->priv;
383 struct cx88_core *core = dev->core;
387 printk("LNB Voltage SEC_VOLTAGE_13\n");
388 cx_write(MO_GP0_IO, 0x00006040);
391 printk("LNB Voltage SEC_VOLTAGE_18\n");
392 cx_write(MO_GP0_IO, 0x00006060);
394 case SEC_VOLTAGE_OFF:
395 printk("LNB Voltage SEC_VOLTAGE_off\n");
399 if (core->prev_set_voltage)
400 return core->prev_set_voltage(fe, voltage);
404 static int cx88_pci_nano_callback(void *ptr, int command, int arg)
406 struct cx88_core *core = ptr;
409 case XC2028_TUNER_RESET:
410 /* Send the tuner in then out of reset */
411 dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __func__, arg);
413 switch (core->boardnr) {
414 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
415 /* GPIO-4 xc3028 tuner */
417 cx_set(MO_GP0_IO, 0x00001000);
418 cx_clear(MO_GP0_IO, 0x00000010);
420 cx_set(MO_GP0_IO, 0x00000010);
426 case XC2028_RESET_CLK:
427 dprintk(1, "%s: XC2028_RESET_CLK %d\n", __func__, arg);
430 dprintk(1, "%s: unknown command %d, arg %d\n", __func__,
438 static struct cx24123_config geniatech_dvbs_config = {
439 .demod_address = 0x55,
440 .set_ts_params = cx24123_set_ts_param,
443 static struct cx24123_config hauppauge_novas_config = {
444 .demod_address = 0x55,
445 .set_ts_params = cx24123_set_ts_param,
448 static struct cx24123_config kworld_dvbs_100_config = {
449 .demod_address = 0x15,
450 .set_ts_params = cx24123_set_ts_param,
454 static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
455 .demod_address = 0x32 >> 1,
456 .output_mode = S5H1409_PARALLEL_OUTPUT,
457 .gpio = S5H1409_GPIO_ON,
459 .inversion = S5H1409_INVERSION_OFF,
460 .status_mode = S5H1409_DEMODLOCKING,
461 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
464 static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
465 .demod_address = 0x32 >> 1,
466 .output_mode = S5H1409_SERIAL_OUTPUT,
467 .gpio = S5H1409_GPIO_OFF,
468 .inversion = S5H1409_INVERSION_OFF,
469 .status_mode = S5H1409_DEMODLOCKING,
470 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
473 static struct s5h1409_config kworld_atsc_120_config = {
474 .demod_address = 0x32 >> 1,
475 .output_mode = S5H1409_SERIAL_OUTPUT,
476 .gpio = S5H1409_GPIO_OFF,
477 .inversion = S5H1409_INVERSION_OFF,
478 .status_mode = S5H1409_DEMODLOCKING,
479 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
482 static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
485 .tuner_callback = cx88_tuner_callback,
488 static struct zl10353_config cx88_geniatech_x8000_mt = {
489 .demod_address = (0x1e >> 1),
493 static struct s5h1411_config dvico_fusionhdtv7_config = {
494 .output_mode = S5H1411_SERIAL_OUTPUT,
495 .gpio = S5H1411_GPIO_ON,
496 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
497 .qam_if = S5H1411_IF_44000,
498 .vsb_if = S5H1411_IF_44000,
499 .inversion = S5H1411_INVERSION_OFF,
500 .status_mode = S5H1411_DEMODLOCKING
503 static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
504 .i2c_address = 0xc2 >> 1,
506 .tuner_callback = cx88_tuner_callback,
509 static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
511 struct dvb_frontend *fe;
512 struct xc2028_ctrl ctl;
513 struct xc2028_config cfg = {
514 .i2c_adap = &dev->core->i2c_adap,
517 .callback = cx88_tuner_callback,
520 if (!dev->dvb.frontend) {
521 printk(KERN_ERR "%s/2: dvb frontend not attached. "
522 "Can't attach xc3028\n",
528 * Some xc3028 devices may be hidden by an I2C gate. This is known
529 * to happen with some s5h1409-based devices.
530 * Now that I2C gate is open, sets up xc3028 configuration
532 cx88_setup_xc3028(dev->core, &ctl);
534 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
536 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
541 printk(KERN_INFO "%s/2: xc3028 attached\n",
547 static int cx24116_set_ts_param(struct dvb_frontend *fe,
550 struct cx8802_dev *dev = fe->dvb->priv;
551 dev->ts_gen_cntrl = 0x2;
556 static int cx24116_reset_device(struct dvb_frontend *fe)
558 struct cx8802_dev *dev = fe->dvb->priv;
559 struct cx88_core *core = dev->core;
562 cx_write(MO_SRST_IO, 0);
564 cx_write(MO_SRST_IO, 1);
570 static struct cx24116_config hauppauge_hvr4000_config = {
571 .demod_address = 0x05,
572 .set_ts_params = cx24116_set_ts_param,
573 .reset_device = cx24116_reset_device,
576 static struct cx24116_config tevii_s460_config = {
577 .demod_address = 0x55,
578 .set_ts_params = cx24116_set_ts_param,
579 .reset_device = cx24116_reset_device,
582 static int dvb_register(struct cx8802_dev *dev)
584 struct cx88_core *core = dev->core;
586 /* init struct videobuf_dvb */
587 dev->dvb.name = core->name;
588 dev->ts_gen_cntrl = 0x0c;
591 switch (core->boardnr) {
592 case CX88_BOARD_HAUPPAUGE_DVB_T1:
593 dev->dvb.frontend = dvb_attach(cx22702_attach,
594 &connexant_refboard_config,
596 if (dev->dvb.frontend != NULL) {
597 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
598 0x61, &core->i2c_adap,
599 DVB_PLL_THOMSON_DTT759X))
600 goto frontend_detach;
603 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
604 case CX88_BOARD_CONEXANT_DVB_T1:
605 case CX88_BOARD_KWORLD_DVB_T_CX22702:
606 case CX88_BOARD_WINFAST_DTV1000:
607 dev->dvb.frontend = dvb_attach(cx22702_attach,
608 &connexant_refboard_config,
610 if (dev->dvb.frontend != NULL) {
611 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
612 0x60, &core->i2c_adap,
613 DVB_PLL_THOMSON_DTT7579))
614 goto frontend_detach;
617 case CX88_BOARD_WINFAST_DTV2000H:
618 case CX88_BOARD_HAUPPAUGE_HVR1100:
619 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
620 case CX88_BOARD_HAUPPAUGE_HVR1300:
621 case CX88_BOARD_HAUPPAUGE_HVR3000:
622 dev->dvb.frontend = dvb_attach(cx22702_attach,
623 &hauppauge_hvr_config,
625 if (dev->dvb.frontend != NULL) {
626 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
627 &core->i2c_adap, 0x61,
628 TUNER_PHILIPS_FMD1216ME_MK3))
629 goto frontend_detach;
632 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
633 dev->dvb.frontend = dvb_attach(mt352_attach,
636 if (dev->dvb.frontend != NULL) {
637 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
638 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
639 goto frontend_detach;
642 /* ZL10353 replaces MT352 on later cards */
643 dev->dvb.frontend = dvb_attach(zl10353_attach,
644 &dvico_fusionhdtv_plus_v1_1,
646 if (dev->dvb.frontend != NULL) {
647 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
648 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
649 goto frontend_detach;
652 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
653 /* The tin box says DEE1601, but it seems to be DTT7579
654 * compatible, with a slightly different MT352 AGC gain. */
655 dev->dvb.frontend = dvb_attach(mt352_attach,
656 &dvico_fusionhdtv_dual,
658 if (dev->dvb.frontend != NULL) {
659 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
660 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
661 goto frontend_detach;
664 /* ZL10353 replaces MT352 on later cards */
665 dev->dvb.frontend = dvb_attach(zl10353_attach,
666 &dvico_fusionhdtv_plus_v1_1,
668 if (dev->dvb.frontend != NULL) {
669 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
670 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
671 goto frontend_detach;
674 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
675 dev->dvb.frontend = dvb_attach(mt352_attach,
678 if (dev->dvb.frontend != NULL) {
679 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
680 0x61, NULL, DVB_PLL_LG_Z201))
681 goto frontend_detach;
684 case CX88_BOARD_KWORLD_DVB_T:
685 case CX88_BOARD_DNTV_LIVE_DVB_T:
686 case CX88_BOARD_ADSTECH_DVB_T_PCI:
687 dev->dvb.frontend = dvb_attach(mt352_attach,
688 &dntv_live_dvbt_config,
690 if (dev->dvb.frontend != NULL) {
691 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
692 0x61, NULL, DVB_PLL_UNKNOWN_1))
693 goto frontend_detach;
696 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
697 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
698 /* MT352 is on a secondary I2C bus made from some GPIO lines */
699 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
701 if (dev->dvb.frontend != NULL) {
702 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
703 &core->i2c_adap, 0x61,
704 TUNER_PHILIPS_FMD1216ME_MK3))
705 goto frontend_detach;
708 printk(KERN_ERR "%s/2: built without vp3054 support\n",
712 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
713 dev->dvb.frontend = dvb_attach(zl10353_attach,
714 &dvico_fusionhdtv_hybrid,
716 if (dev->dvb.frontend != NULL) {
717 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
718 &core->i2c_adap, 0x61,
719 TUNER_THOMSON_FE6600))
720 goto frontend_detach;
723 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
724 dev->dvb.frontend = dvb_attach(zl10353_attach,
725 &dvico_fusionhdtv_xc3028,
727 if (dev->dvb.frontend == NULL)
728 dev->dvb.frontend = dvb_attach(mt352_attach,
729 &dvico_fusionhdtv_mt352_xc3028,
732 * On this board, the demod provides the I2C bus pullup.
733 * We must not permit gate_ctrl to be performed, or
734 * the xc3028 cannot communicate on the bus.
736 if (dev->dvb.frontend)
737 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL;
738 if (attach_xc3028(0x61, dev) < 0)
741 case CX88_BOARD_PCHDTV_HD3000:
742 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
744 if (dev->dvb.frontend != NULL) {
745 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
746 &core->i2c_adap, 0x61,
747 TUNER_THOMSON_DTT761X))
748 goto frontend_detach;
751 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
752 dev->ts_gen_cntrl = 0x08;
754 /* Do a hardware reset of chip before using it. */
755 cx_clear(MO_GP0_IO, 1);
757 cx_set(MO_GP0_IO, 1);
760 /* Select RF connector callback */
761 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
762 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
765 if (dev->dvb.frontend != NULL) {
766 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
767 &core->i2c_adap, 0x61,
768 TUNER_MICROTUNE_4042FI5))
769 goto frontend_detach;
772 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
773 dev->ts_gen_cntrl = 0x08;
775 /* Do a hardware reset of chip before using it. */
776 cx_clear(MO_GP0_IO, 1);
778 cx_set(MO_GP0_IO, 9);
780 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
783 if (dev->dvb.frontend != NULL) {
784 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
785 &core->i2c_adap, 0x61,
786 TUNER_THOMSON_DTT761X))
787 goto frontend_detach;
790 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
791 dev->ts_gen_cntrl = 0x08;
793 /* Do a hardware reset of chip before using it. */
794 cx_clear(MO_GP0_IO, 1);
796 cx_set(MO_GP0_IO, 1);
798 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
801 if (dev->dvb.frontend != NULL) {
802 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
803 &core->i2c_adap, 0x61,
804 TUNER_LG_TDVS_H06XF))
805 goto frontend_detach;
806 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
807 &core->i2c_adap, 0x43))
808 goto frontend_detach;
811 case CX88_BOARD_PCHDTV_HD5500:
812 dev->ts_gen_cntrl = 0x08;
814 /* Do a hardware reset of chip before using it. */
815 cx_clear(MO_GP0_IO, 1);
817 cx_set(MO_GP0_IO, 1);
819 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
822 if (dev->dvb.frontend != NULL) {
823 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
824 &core->i2c_adap, 0x61,
825 TUNER_LG_TDVS_H06XF))
826 goto frontend_detach;
827 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
828 &core->i2c_adap, 0x43))
829 goto frontend_detach;
832 case CX88_BOARD_ATI_HDTVWONDER:
833 dev->dvb.frontend = dvb_attach(nxt200x_attach,
836 if (dev->dvb.frontend != NULL) {
837 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
838 &core->i2c_adap, 0x61,
839 TUNER_PHILIPS_TUV1236D))
840 goto frontend_detach;
843 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
844 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
845 dev->dvb.frontend = dvb_attach(cx24123_attach,
846 &hauppauge_novas_config,
848 if (dev->dvb.frontend) {
849 if (!dvb_attach(isl6421_attach, dev->dvb.frontend,
850 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
851 goto frontend_detach;
854 case CX88_BOARD_KWORLD_DVBS_100:
855 dev->dvb.frontend = dvb_attach(cx24123_attach,
856 &kworld_dvbs_100_config,
858 if (dev->dvb.frontend) {
859 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
860 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
863 case CX88_BOARD_GENIATECH_DVBS:
864 dev->dvb.frontend = dvb_attach(cx24123_attach,
865 &geniatech_dvbs_config,
867 if (dev->dvb.frontend) {
868 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
869 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
872 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
873 dev->dvb.frontend = dvb_attach(s5h1409_attach,
874 &pinnacle_pctv_hd_800i_config,
876 if (dev->dvb.frontend != NULL) {
877 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
879 &pinnacle_pctv_hd_800i_tuner_config))
880 goto frontend_detach;
883 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
884 dev->dvb.frontend = dvb_attach(s5h1409_attach,
885 &dvico_hdtv5_pci_nano_config,
887 if (dev->dvb.frontend != NULL) {
888 struct dvb_frontend *fe;
889 struct xc2028_config cfg = {
890 .i2c_adap = &core->i2c_adap,
892 .callback = cx88_pci_nano_callback,
894 static struct xc2028_ctrl ctl = {
895 .fname = XC2028_DEFAULT_FIRMWARE,
897 .scode_table = XC3028_FE_OREN538,
900 fe = dvb_attach(xc2028_attach,
901 dev->dvb.frontend, &cfg);
902 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
903 fe->ops.tuner_ops.set_config(fe, &ctl);
906 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
907 dev->dvb.frontend = dvb_attach(zl10353_attach,
908 &cx88_geniatech_x8000_mt,
910 if (attach_xc3028(0x61, dev) < 0)
911 goto frontend_detach;
913 case CX88_BOARD_GENIATECH_X8000_MT:
914 dev->ts_gen_cntrl = 0x00;
916 dev->dvb.frontend = dvb_attach(zl10353_attach,
917 &cx88_geniatech_x8000_mt,
919 if (attach_xc3028(0x61, dev) < 0)
920 goto frontend_detach;
922 case CX88_BOARD_KWORLD_ATSC_120:
923 dev->dvb.frontend = dvb_attach(s5h1409_attach,
924 &kworld_atsc_120_config,
926 if (attach_xc3028(0x61, dev) < 0)
927 goto frontend_detach;
929 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
930 dev->dvb.frontend = dvb_attach(s5h1411_attach,
931 &dvico_fusionhdtv7_config,
933 if (dev->dvb.frontend != NULL) {
934 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
936 &dvico_fusionhdtv7_tuner_config))
937 goto frontend_detach;
940 case CX88_BOARD_HAUPPAUGE_HVR4000:
941 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
942 /* Support for DVB-S only, not DVB-T support */
943 dev->dvb.frontend = dvb_attach(cx24116_attach,
944 &hauppauge_hvr4000_config,
945 &dev->core->i2c_adap);
946 if (dev->dvb.frontend) {
947 dvb_attach(isl6421_attach, dev->dvb.frontend,
948 &dev->core->i2c_adap,
949 0x08, ISL6421_DCL, 0x00);
952 case CX88_BOARD_TEVII_S460:
953 dev->dvb.frontend = dvb_attach(cx24116_attach,
956 if (dev->dvb.frontend != NULL) {
957 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
958 dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
961 case CX88_BOARD_OMICOM_SS4_PCI:
962 dev->dvb.frontend = dvb_attach(cx24116_attach,
963 &hauppauge_hvr4000_config,
965 if (dev->dvb.frontend != NULL) {
966 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
967 dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
970 case CX88_BOARD_TBS_8920:
971 dev->dvb.frontend = dvb_attach(cx24116_attach,
972 &hauppauge_hvr4000_config,
974 if (dev->dvb.frontend != NULL) {
975 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
976 dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
980 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
984 if (NULL == dev->dvb.frontend) {
986 "%s/2: frontend initialization failed\n",
991 /* Ensure all frontends negotiate bus access */
992 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
994 /* Put the analog decoder in standby to keep it quiet */
995 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
997 /* register everything */
998 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
999 &dev->pci->dev, adapter_nr);
1002 if (dev->dvb.frontend) {
1003 dvb_frontend_detach(dev->dvb.frontend);
1004 dev->dvb.frontend = NULL;
1009 /* ----------------------------------------------------------- */
1011 /* CX8802 MPEG -> mini driver - We have been given the hardware */
1012 static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
1014 struct cx88_core *core = drv->core;
1016 dprintk( 1, "%s\n", __func__);
1018 switch (core->boardnr) {
1019 case CX88_BOARD_HAUPPAUGE_HVR1300:
1020 /* We arrive here with either the cx23416 or the cx22702
1021 * on the bus. Take the bus from the cx23416 and enable the
1024 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
1025 cx_clear(MO_GP0_IO, 0x00000004);
1034 /* CX8802 MPEG -> mini driver - We no longer have the hardware */
1035 static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1037 struct cx88_core *core = drv->core;
1039 dprintk( 1, "%s\n", __func__);
1041 switch (core->boardnr) {
1042 case CX88_BOARD_HAUPPAUGE_HVR1300:
1043 /* Do Nothing, leave the cx22702 on the bus. */
1051 static int cx8802_dvb_probe(struct cx8802_driver *drv)
1053 struct cx88_core *core = drv->core;
1054 struct cx8802_dev *dev = drv->core->dvbdev;
1057 dprintk( 1, "%s\n", __func__);
1058 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1065 if (!(core->board.mpeg & CX88_MPEG_DVB))
1068 /* If vp3054 isn't enabled, a stub will just return 0 */
1069 err = vp3054_i2c_probe(dev);
1074 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
1075 videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops,
1076 &dev->pci->dev, &dev->slock,
1077 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1079 sizeof(struct cx88_buffer),
1081 err = dvb_register(dev);
1083 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1090 static int cx8802_dvb_remove(struct cx8802_driver *drv)
1092 struct cx8802_dev *dev = drv->core->dvbdev;
1095 if (dev->dvb.frontend)
1096 videobuf_dvb_unregister(&dev->dvb);
1098 vp3054_i2c_remove(dev);
1103 static struct cx8802_driver cx8802_dvb_driver = {
1104 .type_id = CX88_MPEG_DVB,
1105 .hw_access = CX8802_DRVCTL_SHARED,
1106 .probe = cx8802_dvb_probe,
1107 .remove = cx8802_dvb_remove,
1108 .advise_acquire = cx8802_dvb_advise_acquire,
1109 .advise_release = cx8802_dvb_advise_release,
1112 static int dvb_init(void)
1114 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
1115 (CX88_VERSION_CODE >> 16) & 0xff,
1116 (CX88_VERSION_CODE >> 8) & 0xff,
1117 CX88_VERSION_CODE & 0xff);
1119 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1120 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1122 return cx8802_register_driver(&cx8802_dvb_driver);
1125 static void dvb_fini(void)
1127 cx8802_unregister_driver(&cx8802_dvb_driver);
1130 module_init(dvb_init);
1131 module_exit(dvb_fini);
1136 * compile-command: "make DVB=1"