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 cx88_pci_nano_callback(void *ptr, int command, int arg)
381 struct cx88_core *core = ptr;
384 case XC2028_TUNER_RESET:
385 /* Send the tuner in then out of reset */
386 dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __func__, arg);
388 switch (core->boardnr) {
389 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
390 /* GPIO-4 xc3028 tuner */
392 cx_set(MO_GP0_IO, 0x00001000);
393 cx_clear(MO_GP0_IO, 0x00000010);
395 cx_set(MO_GP0_IO, 0x00000010);
401 case XC2028_RESET_CLK:
402 dprintk(1, "%s: XC2028_RESET_CLK %d\n", __func__, arg);
405 dprintk(1, "%s: unknown command %d, arg %d\n", __func__,
413 static struct cx24123_config geniatech_dvbs_config = {
414 .demod_address = 0x55,
415 .set_ts_params = cx24123_set_ts_param,
418 static struct cx24123_config hauppauge_novas_config = {
419 .demod_address = 0x55,
420 .set_ts_params = cx24123_set_ts_param,
423 static struct cx24123_config kworld_dvbs_100_config = {
424 .demod_address = 0x15,
425 .set_ts_params = cx24123_set_ts_param,
429 static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
430 .demod_address = 0x32 >> 1,
431 .output_mode = S5H1409_PARALLEL_OUTPUT,
432 .gpio = S5H1409_GPIO_ON,
434 .inversion = S5H1409_INVERSION_OFF,
435 .status_mode = S5H1409_DEMODLOCKING,
436 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
439 static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
440 .demod_address = 0x32 >> 1,
441 .output_mode = S5H1409_SERIAL_OUTPUT,
442 .gpio = S5H1409_GPIO_OFF,
443 .inversion = S5H1409_INVERSION_OFF,
444 .status_mode = S5H1409_DEMODLOCKING,
445 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
448 static struct s5h1409_config kworld_atsc_120_config = {
449 .demod_address = 0x32 >> 1,
450 .output_mode = S5H1409_SERIAL_OUTPUT,
451 .gpio = S5H1409_GPIO_OFF,
452 .inversion = S5H1409_INVERSION_OFF,
453 .status_mode = S5H1409_DEMODLOCKING,
454 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
457 static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
460 .tuner_callback = cx88_tuner_callback,
463 static struct zl10353_config cx88_geniatech_x8000_mt = {
464 .demod_address = (0x1e >> 1),
468 static struct s5h1411_config dvico_fusionhdtv7_config = {
469 .output_mode = S5H1411_SERIAL_OUTPUT,
470 .gpio = S5H1411_GPIO_ON,
471 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
472 .qam_if = S5H1411_IF_44000,
473 .vsb_if = S5H1411_IF_44000,
474 .inversion = S5H1411_INVERSION_OFF,
475 .status_mode = S5H1411_DEMODLOCKING
478 static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
479 .i2c_address = 0xc2 >> 1,
481 .tuner_callback = cx88_tuner_callback,
484 static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
486 struct dvb_frontend *fe;
487 struct xc2028_ctrl ctl;
488 struct xc2028_config cfg = {
489 .i2c_adap = &dev->core->i2c_adap,
492 .callback = cx88_tuner_callback,
495 if (!dev->dvb.frontend) {
496 printk(KERN_ERR "%s/2: dvb frontend not attached. "
497 "Can't attach xc3028\n",
503 * Some xc3028 devices may be hidden by an I2C gate. This is known
504 * to happen with some s5h1409-based devices.
505 * Now that I2C gate is open, sets up xc3028 configuration
507 cx88_setup_xc3028(dev->core, &ctl);
509 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
511 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
516 printk(KERN_INFO "%s/2: xc3028 attached\n",
522 static int cx24116_set_ts_param(struct dvb_frontend *fe,
525 struct cx8802_dev *dev = fe->dvb->priv;
526 dev->ts_gen_cntrl = 0x2;
531 static int cx24116_reset_device(struct dvb_frontend *fe)
533 struct cx8802_dev *dev = fe->dvb->priv;
534 struct cx88_core *core = dev->core;
537 cx_write(MO_SRST_IO, 0);
539 cx_write(MO_SRST_IO, 1);
545 static struct cx24116_config hauppauge_hvr4000_config = {
546 .demod_address = 0x05,
547 .set_ts_params = cx24116_set_ts_param,
548 .reset_device = cx24116_reset_device,
551 static int dvb_register(struct cx8802_dev *dev)
553 struct cx88_core *core = dev->core;
555 /* init struct videobuf_dvb */
556 dev->dvb.name = core->name;
557 dev->ts_gen_cntrl = 0x0c;
560 switch (core->boardnr) {
561 case CX88_BOARD_HAUPPAUGE_DVB_T1:
562 dev->dvb.frontend = dvb_attach(cx22702_attach,
563 &connexant_refboard_config,
565 if (dev->dvb.frontend != NULL) {
566 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
567 0x61, &core->i2c_adap,
568 DVB_PLL_THOMSON_DTT759X))
569 goto frontend_detach;
572 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
573 case CX88_BOARD_CONEXANT_DVB_T1:
574 case CX88_BOARD_KWORLD_DVB_T_CX22702:
575 case CX88_BOARD_WINFAST_DTV1000:
576 dev->dvb.frontend = dvb_attach(cx22702_attach,
577 &connexant_refboard_config,
579 if (dev->dvb.frontend != NULL) {
580 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
581 0x60, &core->i2c_adap,
582 DVB_PLL_THOMSON_DTT7579))
583 goto frontend_detach;
586 case CX88_BOARD_WINFAST_DTV2000H:
587 case CX88_BOARD_HAUPPAUGE_HVR1100:
588 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
589 case CX88_BOARD_HAUPPAUGE_HVR1300:
590 case CX88_BOARD_HAUPPAUGE_HVR3000:
591 dev->dvb.frontend = dvb_attach(cx22702_attach,
592 &hauppauge_hvr_config,
594 if (dev->dvb.frontend != NULL) {
595 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
596 &core->i2c_adap, 0x61,
597 TUNER_PHILIPS_FMD1216ME_MK3))
598 goto frontend_detach;
601 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
602 dev->dvb.frontend = dvb_attach(mt352_attach,
605 if (dev->dvb.frontend != NULL) {
606 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
607 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
608 goto frontend_detach;
611 /* ZL10353 replaces MT352 on later cards */
612 dev->dvb.frontend = dvb_attach(zl10353_attach,
613 &dvico_fusionhdtv_plus_v1_1,
615 if (dev->dvb.frontend != NULL) {
616 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
617 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
618 goto frontend_detach;
621 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
622 /* The tin box says DEE1601, but it seems to be DTT7579
623 * compatible, with a slightly different MT352 AGC gain. */
624 dev->dvb.frontend = dvb_attach(mt352_attach,
625 &dvico_fusionhdtv_dual,
627 if (dev->dvb.frontend != NULL) {
628 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
629 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
630 goto frontend_detach;
633 /* ZL10353 replaces MT352 on later cards */
634 dev->dvb.frontend = dvb_attach(zl10353_attach,
635 &dvico_fusionhdtv_plus_v1_1,
637 if (dev->dvb.frontend != NULL) {
638 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
639 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
640 goto frontend_detach;
643 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
644 dev->dvb.frontend = dvb_attach(mt352_attach,
647 if (dev->dvb.frontend != NULL) {
648 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
649 0x61, NULL, DVB_PLL_LG_Z201))
650 goto frontend_detach;
653 case CX88_BOARD_KWORLD_DVB_T:
654 case CX88_BOARD_DNTV_LIVE_DVB_T:
655 case CX88_BOARD_ADSTECH_DVB_T_PCI:
656 dev->dvb.frontend = dvb_attach(mt352_attach,
657 &dntv_live_dvbt_config,
659 if (dev->dvb.frontend != NULL) {
660 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
661 0x61, NULL, DVB_PLL_UNKNOWN_1))
662 goto frontend_detach;
665 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
666 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
667 /* MT352 is on a secondary I2C bus made from some GPIO lines */
668 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
670 if (dev->dvb.frontend != NULL) {
671 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
672 &core->i2c_adap, 0x61,
673 TUNER_PHILIPS_FMD1216ME_MK3))
674 goto frontend_detach;
677 printk(KERN_ERR "%s/2: built without vp3054 support\n",
681 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
682 dev->dvb.frontend = dvb_attach(zl10353_attach,
683 &dvico_fusionhdtv_hybrid,
685 if (dev->dvb.frontend != NULL) {
686 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
687 &core->i2c_adap, 0x61,
688 TUNER_THOMSON_FE6600))
689 goto frontend_detach;
692 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
693 dev->dvb.frontend = dvb_attach(zl10353_attach,
694 &dvico_fusionhdtv_xc3028,
696 if (dev->dvb.frontend == NULL)
697 dev->dvb.frontend = dvb_attach(mt352_attach,
698 &dvico_fusionhdtv_mt352_xc3028,
701 * On this board, the demod provides the I2C bus pullup.
702 * We must not permit gate_ctrl to be performed, or
703 * the xc3028 cannot communicate on the bus.
705 if (dev->dvb.frontend)
706 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL;
707 if (attach_xc3028(0x61, dev) < 0)
710 case CX88_BOARD_PCHDTV_HD3000:
711 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
713 if (dev->dvb.frontend != NULL) {
714 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
715 &core->i2c_adap, 0x61,
716 TUNER_THOMSON_DTT761X))
717 goto frontend_detach;
720 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
721 dev->ts_gen_cntrl = 0x08;
723 /* Do a hardware reset of chip before using it. */
724 cx_clear(MO_GP0_IO, 1);
726 cx_set(MO_GP0_IO, 1);
729 /* Select RF connector callback */
730 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
731 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
734 if (dev->dvb.frontend != NULL) {
735 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
736 &core->i2c_adap, 0x61,
737 TUNER_MICROTUNE_4042FI5))
738 goto frontend_detach;
741 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
742 dev->ts_gen_cntrl = 0x08;
744 /* Do a hardware reset of chip before using it. */
745 cx_clear(MO_GP0_IO, 1);
747 cx_set(MO_GP0_IO, 9);
749 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
752 if (dev->dvb.frontend != NULL) {
753 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
754 &core->i2c_adap, 0x61,
755 TUNER_THOMSON_DTT761X))
756 goto frontend_detach;
759 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
760 dev->ts_gen_cntrl = 0x08;
762 /* Do a hardware reset of chip before using it. */
763 cx_clear(MO_GP0_IO, 1);
765 cx_set(MO_GP0_IO, 1);
767 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
770 if (dev->dvb.frontend != NULL) {
771 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
772 &core->i2c_adap, 0x61,
773 TUNER_LG_TDVS_H06XF))
774 goto frontend_detach;
775 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
776 &core->i2c_adap, 0x43))
777 goto frontend_detach;
780 case CX88_BOARD_PCHDTV_HD5500:
781 dev->ts_gen_cntrl = 0x08;
783 /* Do a hardware reset of chip before using it. */
784 cx_clear(MO_GP0_IO, 1);
786 cx_set(MO_GP0_IO, 1);
788 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
791 if (dev->dvb.frontend != NULL) {
792 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
793 &core->i2c_adap, 0x61,
794 TUNER_LG_TDVS_H06XF))
795 goto frontend_detach;
796 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
797 &core->i2c_adap, 0x43))
798 goto frontend_detach;
801 case CX88_BOARD_ATI_HDTVWONDER:
802 dev->dvb.frontend = dvb_attach(nxt200x_attach,
805 if (dev->dvb.frontend != NULL) {
806 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
807 &core->i2c_adap, 0x61,
808 TUNER_PHILIPS_TUV1236D))
809 goto frontend_detach;
812 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
813 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
814 dev->dvb.frontend = dvb_attach(cx24123_attach,
815 &hauppauge_novas_config,
817 if (dev->dvb.frontend) {
818 if (!dvb_attach(isl6421_attach, dev->dvb.frontend,
819 &core->i2c_adap, 0x08, 0x00, 0x00))
820 goto frontend_detach;
823 case CX88_BOARD_KWORLD_DVBS_100:
824 dev->dvb.frontend = dvb_attach(cx24123_attach,
825 &kworld_dvbs_100_config,
827 if (dev->dvb.frontend) {
828 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
829 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
832 case CX88_BOARD_GENIATECH_DVBS:
833 dev->dvb.frontend = dvb_attach(cx24123_attach,
834 &geniatech_dvbs_config,
836 if (dev->dvb.frontend) {
837 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
838 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
841 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
842 dev->dvb.frontend = dvb_attach(s5h1409_attach,
843 &pinnacle_pctv_hd_800i_config,
845 if (dev->dvb.frontend != NULL) {
846 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
848 &pinnacle_pctv_hd_800i_tuner_config))
849 goto frontend_detach;
852 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
853 dev->dvb.frontend = dvb_attach(s5h1409_attach,
854 &dvico_hdtv5_pci_nano_config,
856 if (dev->dvb.frontend != NULL) {
857 struct dvb_frontend *fe;
858 struct xc2028_config cfg = {
859 .i2c_adap = &core->i2c_adap,
861 .callback = cx88_pci_nano_callback,
863 static struct xc2028_ctrl ctl = {
864 .fname = XC2028_DEFAULT_FIRMWARE,
866 .scode_table = XC3028_FE_OREN538,
869 fe = dvb_attach(xc2028_attach,
870 dev->dvb.frontend, &cfg);
871 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
872 fe->ops.tuner_ops.set_config(fe, &ctl);
875 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
876 dev->dvb.frontend = dvb_attach(zl10353_attach,
877 &cx88_geniatech_x8000_mt,
879 if (attach_xc3028(0x61, dev) < 0)
880 goto frontend_detach;
882 case CX88_BOARD_GENIATECH_X8000_MT:
883 dev->ts_gen_cntrl = 0x00;
885 dev->dvb.frontend = dvb_attach(zl10353_attach,
886 &cx88_geniatech_x8000_mt,
888 if (attach_xc3028(0x61, dev) < 0)
889 goto frontend_detach;
891 case CX88_BOARD_KWORLD_ATSC_120:
892 dev->dvb.frontend = dvb_attach(s5h1409_attach,
893 &kworld_atsc_120_config,
895 if (attach_xc3028(0x61, dev) < 0)
896 goto frontend_detach;
898 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
899 dev->dvb.frontend = dvb_attach(s5h1411_attach,
900 &dvico_fusionhdtv7_config,
902 if (dev->dvb.frontend != NULL) {
903 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
905 &dvico_fusionhdtv7_tuner_config))
906 goto frontend_detach;
909 case CX88_BOARD_HAUPPAUGE_HVR4000:
910 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
911 /* Support for DVB-S only, not DVB-T support */
912 dev->dvb.frontend = dvb_attach(cx24116_attach,
913 &hauppauge_hvr4000_config,
914 &dev->core->i2c_adap);
915 if (dev->dvb.frontend) {
916 dvb_attach(isl6421_attach, dev->dvb.frontend,
917 &dev->core->i2c_adap,
922 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
926 if (NULL == dev->dvb.frontend) {
928 "%s/2: frontend initialization failed\n",
933 /* Ensure all frontends negotiate bus access */
934 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
936 /* Put the analog decoder in standby to keep it quiet */
937 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
939 /* register everything */
940 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
941 &dev->pci->dev, adapter_nr);
944 if (dev->dvb.frontend) {
945 dvb_frontend_detach(dev->dvb.frontend);
946 dev->dvb.frontend = NULL;
951 /* ----------------------------------------------------------- */
953 /* CX8802 MPEG -> mini driver - We have been given the hardware */
954 static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
956 struct cx88_core *core = drv->core;
958 dprintk( 1, "%s\n", __func__);
960 switch (core->boardnr) {
961 case CX88_BOARD_HAUPPAUGE_HVR1300:
962 /* We arrive here with either the cx23416 or the cx22702
963 * on the bus. Take the bus from the cx23416 and enable the
966 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
967 cx_clear(MO_GP0_IO, 0x00000004);
976 /* CX8802 MPEG -> mini driver - We no longer have the hardware */
977 static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
979 struct cx88_core *core = drv->core;
981 dprintk( 1, "%s\n", __func__);
983 switch (core->boardnr) {
984 case CX88_BOARD_HAUPPAUGE_HVR1300:
985 /* Do Nothing, leave the cx22702 on the bus. */
993 static int cx8802_dvb_probe(struct cx8802_driver *drv)
995 struct cx88_core *core = drv->core;
996 struct cx8802_dev *dev = drv->core->dvbdev;
999 dprintk( 1, "%s\n", __func__);
1000 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1007 if (!(core->board.mpeg & CX88_MPEG_DVB))
1010 /* If vp3054 isn't enabled, a stub will just return 0 */
1011 err = vp3054_i2c_probe(dev);
1016 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
1017 videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops,
1018 &dev->pci->dev, &dev->slock,
1019 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1021 sizeof(struct cx88_buffer),
1023 err = dvb_register(dev);
1025 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1032 static int cx8802_dvb_remove(struct cx8802_driver *drv)
1034 struct cx8802_dev *dev = drv->core->dvbdev;
1037 if (dev->dvb.frontend)
1038 videobuf_dvb_unregister(&dev->dvb);
1040 vp3054_i2c_remove(dev);
1045 static struct cx8802_driver cx8802_dvb_driver = {
1046 .type_id = CX88_MPEG_DVB,
1047 .hw_access = CX8802_DRVCTL_SHARED,
1048 .probe = cx8802_dvb_probe,
1049 .remove = cx8802_dvb_remove,
1050 .advise_acquire = cx8802_dvb_advise_acquire,
1051 .advise_release = cx8802_dvb_advise_release,
1054 static int dvb_init(void)
1056 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
1057 (CX88_VERSION_CODE >> 16) & 0xff,
1058 (CX88_VERSION_CODE >> 8) & 0xff,
1059 CX88_VERSION_CODE & 0xff);
1061 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1062 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1064 return cx8802_register_driver(&cx8802_dvb_driver);
1067 static void dvb_fini(void)
1069 cx8802_unregister_driver(&cx8802_dvb_driver);
1072 module_init(dvb_init);
1073 module_exit(dvb_fini);
1078 * compile-command: "make DVB=1"