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"
52 MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
53 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
54 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
55 MODULE_LICENSE("GPL");
57 static unsigned int debug;
58 module_param(debug, int, 0644);
59 MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
61 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
63 #define dprintk(level,fmt, arg...) if (debug >= level) \
64 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
66 /* ------------------------------------------------------------------ */
68 static int dvb_buf_setup(struct videobuf_queue *q,
69 unsigned int *count, unsigned int *size)
71 struct cx8802_dev *dev = q->priv_data;
73 dev->ts_packet_size = 188 * 4;
74 dev->ts_packet_count = 32;
76 *size = dev->ts_packet_size * dev->ts_packet_count;
81 static int dvb_buf_prepare(struct videobuf_queue *q,
82 struct videobuf_buffer *vb, enum v4l2_field field)
84 struct cx8802_dev *dev = q->priv_data;
85 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
88 static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
90 struct cx8802_dev *dev = q->priv_data;
91 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
94 static void dvb_buf_release(struct videobuf_queue *q,
95 struct videobuf_buffer *vb)
97 cx88_free_buffer(q, (struct cx88_buffer*)vb);
100 static struct videobuf_queue_ops dvb_qops = {
101 .buf_setup = dvb_buf_setup,
102 .buf_prepare = dvb_buf_prepare,
103 .buf_queue = dvb_buf_queue,
104 .buf_release = dvb_buf_release,
107 /* ------------------------------------------------------------------ */
109 static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
111 struct cx8802_dev *dev= fe->dvb->priv;
112 struct cx8802_driver *drv = NULL;
115 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
118 ret = drv->request_acquire(drv);
120 ret = drv->request_release(drv);
126 /* ------------------------------------------------------------------ */
128 static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
130 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
131 static u8 reset [] = { RESET, 0x80 };
132 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
133 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
134 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
135 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
137 mt352_write(fe, clock_config, sizeof(clock_config));
139 mt352_write(fe, reset, sizeof(reset));
140 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
142 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
143 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
144 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
148 static int dvico_dual_demod_init(struct dvb_frontend *fe)
150 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
151 static u8 reset [] = { RESET, 0x80 };
152 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
153 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
154 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
155 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
157 mt352_write(fe, clock_config, sizeof(clock_config));
159 mt352_write(fe, reset, sizeof(reset));
160 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
162 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
163 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
164 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
169 static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
171 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
172 static u8 reset [] = { 0x50, 0x80 };
173 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
174 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
175 0x00, 0xFF, 0x00, 0x40, 0x40 };
176 static u8 dntv_extra[] = { 0xB5, 0x7A };
177 static u8 capt_range_cfg[] = { 0x75, 0x32 };
179 mt352_write(fe, clock_config, sizeof(clock_config));
181 mt352_write(fe, reset, sizeof(reset));
182 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
184 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
186 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
187 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
192 static struct mt352_config dvico_fusionhdtv = {
193 .demod_address = 0x0f,
194 .demod_init = dvico_fusionhdtv_demod_init,
197 static struct mt352_config dntv_live_dvbt_config = {
198 .demod_address = 0x0f,
199 .demod_init = dntv_live_dvbt_demod_init,
202 static struct mt352_config dvico_fusionhdtv_dual = {
203 .demod_address = 0x0f,
204 .demod_init = dvico_dual_demod_init,
207 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
208 static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
210 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
211 static u8 reset [] = { 0x50, 0x80 };
212 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
213 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
214 0x00, 0xFF, 0x00, 0x40, 0x40 };
215 static u8 dntv_extra[] = { 0xB5, 0x7A };
216 static u8 capt_range_cfg[] = { 0x75, 0x32 };
218 mt352_write(fe, clock_config, sizeof(clock_config));
220 mt352_write(fe, reset, sizeof(reset));
221 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
223 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
225 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
226 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
231 static struct mt352_config dntv_live_dvbt_pro_config = {
232 .demod_address = 0x0f,
234 .demod_init = dntv_live_dvbt_pro_demod_init,
238 static struct zl10353_config dvico_fusionhdtv_hybrid = {
239 .demod_address = 0x0f,
243 static struct zl10353_config dvico_fusionhdtv_xc3028 = {
244 .demod_address = 0x0f,
249 static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
250 .demod_address = 0x0f,
253 .demod_init = dvico_fusionhdtv_demod_init,
256 static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
257 .demod_address = 0x0f,
260 static struct cx22702_config connexant_refboard_config = {
261 .demod_address = 0x43,
262 .output_mode = CX22702_SERIAL_OUTPUT,
265 static struct cx22702_config hauppauge_hvr_config = {
266 .demod_address = 0x63,
267 .output_mode = CX22702_SERIAL_OUTPUT,
270 static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
272 struct cx8802_dev *dev= fe->dvb->priv;
273 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
277 static struct or51132_config pchdtv_hd3000 = {
278 .demod_address = 0x15,
279 .set_ts_params = or51132_set_ts_param,
282 static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
284 struct cx8802_dev *dev= fe->dvb->priv;
285 struct cx88_core *core = dev->core;
287 dprintk(1, "%s: index = %d\n", __func__, index);
289 cx_clear(MO_GP0_IO, 8);
291 cx_set(MO_GP0_IO, 8);
295 static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
297 struct cx8802_dev *dev= fe->dvb->priv;
299 dev->ts_gen_cntrl |= 0x04;
301 dev->ts_gen_cntrl &= ~0x04;
305 static struct lgdt330x_config fusionhdtv_3_gold = {
306 .demod_address = 0x0e,
307 .demod_chip = LGDT3302,
308 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
309 .set_ts_params = lgdt330x_set_ts_param,
312 static struct lgdt330x_config fusionhdtv_5_gold = {
313 .demod_address = 0x0e,
314 .demod_chip = LGDT3303,
315 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
316 .set_ts_params = lgdt330x_set_ts_param,
319 static struct lgdt330x_config pchdtv_hd5500 = {
320 .demod_address = 0x59,
321 .demod_chip = LGDT3303,
322 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
323 .set_ts_params = lgdt330x_set_ts_param,
326 static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
328 struct cx8802_dev *dev= fe->dvb->priv;
329 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
333 static struct nxt200x_config ati_hdtvwonder = {
334 .demod_address = 0x0a,
335 .set_ts_params = nxt200x_set_ts_param,
338 static int cx24123_set_ts_param(struct dvb_frontend* fe,
341 struct cx8802_dev *dev= fe->dvb->priv;
342 dev->ts_gen_cntrl = 0x02;
346 static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
347 fe_sec_voltage_t voltage)
349 struct cx8802_dev *dev= fe->dvb->priv;
350 struct cx88_core *core = dev->core;
352 if (voltage == SEC_VOLTAGE_OFF)
353 cx_write(MO_GP0_IO, 0x000006fb);
355 cx_write(MO_GP0_IO, 0x000006f9);
357 if (core->prev_set_voltage)
358 return core->prev_set_voltage(fe, voltage);
362 static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
363 fe_sec_voltage_t voltage)
365 struct cx8802_dev *dev= fe->dvb->priv;
366 struct cx88_core *core = dev->core;
368 if (voltage == SEC_VOLTAGE_OFF) {
369 dprintk(1,"LNB Voltage OFF\n");
370 cx_write(MO_GP0_IO, 0x0000efff);
373 if (core->prev_set_voltage)
374 return core->prev_set_voltage(fe, voltage);
378 static int cx88_pci_nano_callback(void *ptr, int command, int arg)
380 struct cx88_core *core = ptr;
383 case XC2028_TUNER_RESET:
384 /* Send the tuner in then out of reset */
385 dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __func__, arg);
387 switch (core->boardnr) {
388 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
389 /* GPIO-4 xc3028 tuner */
391 cx_set(MO_GP0_IO, 0x00001000);
392 cx_clear(MO_GP0_IO, 0x00000010);
394 cx_set(MO_GP0_IO, 0x00000010);
400 case XC2028_RESET_CLK:
401 dprintk(1, "%s: XC2028_RESET_CLK %d\n", __func__, arg);
404 dprintk(1, "%s: unknown command %d, arg %d\n", __func__,
412 static struct cx24123_config geniatech_dvbs_config = {
413 .demod_address = 0x55,
414 .set_ts_params = cx24123_set_ts_param,
417 static struct cx24123_config hauppauge_novas_config = {
418 .demod_address = 0x55,
419 .set_ts_params = cx24123_set_ts_param,
422 static struct cx24123_config kworld_dvbs_100_config = {
423 .demod_address = 0x15,
424 .set_ts_params = cx24123_set_ts_param,
428 static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
429 .demod_address = 0x32 >> 1,
430 .output_mode = S5H1409_PARALLEL_OUTPUT,
431 .gpio = S5H1409_GPIO_ON,
433 .inversion = S5H1409_INVERSION_OFF,
434 .status_mode = S5H1409_DEMODLOCKING,
435 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
438 static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
439 .demod_address = 0x32 >> 1,
440 .output_mode = S5H1409_SERIAL_OUTPUT,
441 .gpio = S5H1409_GPIO_OFF,
442 .inversion = S5H1409_INVERSION_OFF,
443 .status_mode = S5H1409_DEMODLOCKING,
444 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
447 static struct s5h1409_config kworld_atsc_120_config = {
448 .demod_address = 0x32 >> 1,
449 .output_mode = S5H1409_SERIAL_OUTPUT,
450 .gpio = S5H1409_GPIO_OFF,
451 .inversion = S5H1409_INVERSION_OFF,
452 .status_mode = S5H1409_DEMODLOCKING,
453 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
456 static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
459 .tuner_callback = cx88_tuner_callback,
462 static struct zl10353_config cx88_geniatech_x8000_mt = {
463 .demod_address = (0x1e >> 1),
467 static struct s5h1411_config dvico_fusionhdtv7_config = {
468 .output_mode = S5H1411_SERIAL_OUTPUT,
469 .gpio = S5H1411_GPIO_ON,
470 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
471 .qam_if = S5H1411_IF_44000,
472 .vsb_if = S5H1411_IF_44000,
473 .inversion = S5H1411_INVERSION_OFF,
474 .status_mode = S5H1411_DEMODLOCKING
477 static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
478 .i2c_address = 0xc2 >> 1,
480 .tuner_callback = cx88_tuner_callback,
483 static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
485 struct dvb_frontend *fe;
486 struct xc2028_ctrl ctl;
487 struct xc2028_config cfg = {
488 .i2c_adap = &dev->core->i2c_adap,
491 .callback = cx88_tuner_callback,
494 if (!dev->dvb.frontend) {
495 printk(KERN_ERR "%s/2: dvb frontend not attached. "
496 "Can't attach xc3028\n",
502 * Some xc3028 devices may be hidden by an I2C gate. This is known
503 * to happen with some s5h1409-based devices.
504 * Now that I2C gate is open, sets up xc3028 configuration
506 cx88_setup_xc3028(dev->core, &ctl);
508 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
510 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
512 dvb_frontend_detach(dev->dvb.frontend);
513 dvb_unregister_frontend(dev->dvb.frontend);
514 dev->dvb.frontend = NULL;
518 printk(KERN_INFO "%s/2: xc3028 attached\n",
524 static int dvb_register(struct cx8802_dev *dev)
526 /* init struct videobuf_dvb */
527 dev->dvb.name = dev->core->name;
528 dev->ts_gen_cntrl = 0x0c;
531 switch (dev->core->boardnr) {
532 case CX88_BOARD_HAUPPAUGE_DVB_T1:
533 dev->dvb.frontend = dvb_attach(cx22702_attach,
534 &connexant_refboard_config,
535 &dev->core->i2c_adap);
536 if (dev->dvb.frontend != NULL) {
537 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
538 &dev->core->i2c_adap,
539 DVB_PLL_THOMSON_DTT759X);
542 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
543 case CX88_BOARD_CONEXANT_DVB_T1:
544 case CX88_BOARD_KWORLD_DVB_T_CX22702:
545 case CX88_BOARD_WINFAST_DTV1000:
546 dev->dvb.frontend = dvb_attach(cx22702_attach,
547 &connexant_refboard_config,
548 &dev->core->i2c_adap);
549 if (dev->dvb.frontend != NULL) {
550 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
551 &dev->core->i2c_adap,
552 DVB_PLL_THOMSON_DTT7579);
555 case CX88_BOARD_WINFAST_DTV2000H:
556 case CX88_BOARD_HAUPPAUGE_HVR1100:
557 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
558 case CX88_BOARD_HAUPPAUGE_HVR1300:
559 case CX88_BOARD_HAUPPAUGE_HVR3000:
560 dev->dvb.frontend = dvb_attach(cx22702_attach,
561 &hauppauge_hvr_config,
562 &dev->core->i2c_adap);
563 if (dev->dvb.frontend != NULL) {
564 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
565 &dev->core->i2c_adap, 0x61,
566 TUNER_PHILIPS_FMD1216ME_MK3);
569 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
570 dev->dvb.frontend = dvb_attach(mt352_attach,
572 &dev->core->i2c_adap);
573 if (dev->dvb.frontend != NULL) {
574 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
575 NULL, DVB_PLL_THOMSON_DTT7579);
578 /* ZL10353 replaces MT352 on later cards */
579 dev->dvb.frontend = dvb_attach(zl10353_attach,
580 &dvico_fusionhdtv_plus_v1_1,
581 &dev->core->i2c_adap);
582 if (dev->dvb.frontend != NULL) {
583 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
584 NULL, DVB_PLL_THOMSON_DTT7579);
587 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
588 /* The tin box says DEE1601, but it seems to be DTT7579
589 * compatible, with a slightly different MT352 AGC gain. */
590 dev->dvb.frontend = dvb_attach(mt352_attach,
591 &dvico_fusionhdtv_dual,
592 &dev->core->i2c_adap);
593 if (dev->dvb.frontend != NULL) {
594 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
595 NULL, DVB_PLL_THOMSON_DTT7579);
598 /* ZL10353 replaces MT352 on later cards */
599 dev->dvb.frontend = dvb_attach(zl10353_attach,
600 &dvico_fusionhdtv_plus_v1_1,
601 &dev->core->i2c_adap);
602 if (dev->dvb.frontend != NULL) {
603 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
604 NULL, DVB_PLL_THOMSON_DTT7579);
607 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
608 dev->dvb.frontend = dvb_attach(mt352_attach,
610 &dev->core->i2c_adap);
611 if (dev->dvb.frontend != NULL) {
612 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
613 NULL, DVB_PLL_LG_Z201);
616 case CX88_BOARD_KWORLD_DVB_T:
617 case CX88_BOARD_DNTV_LIVE_DVB_T:
618 case CX88_BOARD_ADSTECH_DVB_T_PCI:
619 dev->dvb.frontend = dvb_attach(mt352_attach,
620 &dntv_live_dvbt_config,
621 &dev->core->i2c_adap);
622 if (dev->dvb.frontend != NULL) {
623 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
624 NULL, DVB_PLL_UNKNOWN_1);
627 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
628 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
629 /* MT352 is on a secondary I2C bus made from some GPIO lines */
630 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
632 if (dev->dvb.frontend != NULL) {
633 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
634 &dev->core->i2c_adap, 0x61,
635 TUNER_PHILIPS_FMD1216ME_MK3);
638 printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name);
641 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
642 dev->dvb.frontend = dvb_attach(zl10353_attach,
643 &dvico_fusionhdtv_hybrid,
644 &dev->core->i2c_adap);
645 if (dev->dvb.frontend != NULL) {
646 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
647 &dev->core->i2c_adap, 0x61,
648 TUNER_THOMSON_FE6600);
651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
652 dev->dvb.frontend = dvb_attach(zl10353_attach,
653 &dvico_fusionhdtv_xc3028,
654 &dev->core->i2c_adap);
655 if (dev->dvb.frontend == NULL)
656 dev->dvb.frontend = dvb_attach(mt352_attach,
657 &dvico_fusionhdtv_mt352_xc3028,
658 &dev->core->i2c_adap);
660 * On this board, the demod provides the I2C bus pullup.
661 * We must not permit gate_ctrl to be performed, or
662 * the xc3028 cannot communicate on the bus.
664 if (dev->dvb.frontend)
665 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL;
666 if (attach_xc3028(0x61, dev) < 0)
669 case CX88_BOARD_PCHDTV_HD3000:
670 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
671 &dev->core->i2c_adap);
672 if (dev->dvb.frontend != NULL) {
673 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
674 &dev->core->i2c_adap, 0x61,
675 TUNER_THOMSON_DTT761X);
678 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
679 dev->ts_gen_cntrl = 0x08;
681 /* Do a hardware reset of chip before using it. */
682 struct cx88_core *core = dev->core;
684 cx_clear(MO_GP0_IO, 1);
686 cx_set(MO_GP0_IO, 1);
689 /* Select RF connector callback */
690 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
691 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
693 &dev->core->i2c_adap);
694 if (dev->dvb.frontend != NULL) {
695 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
696 &dev->core->i2c_adap, 0x61,
697 TUNER_MICROTUNE_4042FI5);
701 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
702 dev->ts_gen_cntrl = 0x08;
704 /* Do a hardware reset of chip before using it. */
705 struct cx88_core *core = dev->core;
707 cx_clear(MO_GP0_IO, 1);
709 cx_set(MO_GP0_IO, 9);
711 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
713 &dev->core->i2c_adap);
714 if (dev->dvb.frontend != NULL) {
715 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
716 &dev->core->i2c_adap, 0x61,
717 TUNER_THOMSON_DTT761X);
721 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
722 dev->ts_gen_cntrl = 0x08;
724 /* Do a hardware reset of chip before using it. */
725 struct cx88_core *core = dev->core;
727 cx_clear(MO_GP0_IO, 1);
729 cx_set(MO_GP0_IO, 1);
731 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
733 &dev->core->i2c_adap);
734 if (dev->dvb.frontend != NULL) {
735 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
736 &dev->core->i2c_adap, 0x61,
737 TUNER_LG_TDVS_H06XF);
738 dvb_attach(tda9887_attach, dev->dvb.frontend,
739 &dev->core->i2c_adap, 0x43);
743 case CX88_BOARD_PCHDTV_HD5500:
744 dev->ts_gen_cntrl = 0x08;
746 /* Do a hardware reset of chip before using it. */
747 struct cx88_core *core = dev->core;
749 cx_clear(MO_GP0_IO, 1);
751 cx_set(MO_GP0_IO, 1);
753 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
755 &dev->core->i2c_adap);
756 if (dev->dvb.frontend != NULL) {
757 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
758 &dev->core->i2c_adap, 0x61,
759 TUNER_LG_TDVS_H06XF);
760 dvb_attach(tda9887_attach, dev->dvb.frontend,
761 &dev->core->i2c_adap, 0x43);
765 case CX88_BOARD_ATI_HDTVWONDER:
766 dev->dvb.frontend = dvb_attach(nxt200x_attach,
768 &dev->core->i2c_adap);
769 if (dev->dvb.frontend != NULL) {
770 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
771 &dev->core->i2c_adap, 0x61,
772 TUNER_PHILIPS_TUV1236D);
775 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
776 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
777 dev->dvb.frontend = dvb_attach(cx24123_attach,
778 &hauppauge_novas_config,
779 &dev->core->i2c_adap);
780 if (dev->dvb.frontend) {
781 dvb_attach(isl6421_attach, dev->dvb.frontend,
782 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
785 case CX88_BOARD_KWORLD_DVBS_100:
786 dev->dvb.frontend = dvb_attach(cx24123_attach,
787 &kworld_dvbs_100_config,
788 &dev->core->i2c_adap);
789 if (dev->dvb.frontend) {
790 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
791 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
794 case CX88_BOARD_GENIATECH_DVBS:
795 dev->dvb.frontend = dvb_attach(cx24123_attach,
796 &geniatech_dvbs_config,
797 &dev->core->i2c_adap);
798 if (dev->dvb.frontend) {
799 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
800 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
803 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
804 dev->dvb.frontend = dvb_attach(s5h1409_attach,
805 &pinnacle_pctv_hd_800i_config,
806 &dev->core->i2c_adap);
807 if (dev->dvb.frontend != NULL) {
808 /* tuner_config.video_dev must point to
811 pinnacle_pctv_hd_800i_tuner_config.priv =
812 dev->core->i2c_adap.algo_data;
813 dvb_attach(xc5000_attach, dev->dvb.frontend,
814 &dev->core->i2c_adap,
815 &pinnacle_pctv_hd_800i_tuner_config);
818 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
819 dev->dvb.frontend = dvb_attach(s5h1409_attach,
820 &dvico_hdtv5_pci_nano_config,
821 &dev->core->i2c_adap);
822 if (dev->dvb.frontend != NULL) {
823 struct dvb_frontend *fe;
824 struct xc2028_config cfg = {
825 .i2c_adap = &dev->core->i2c_adap,
827 .callback = cx88_pci_nano_callback,
829 static struct xc2028_ctrl ctl = {
830 .fname = "xc3028-v27.fw",
832 .scode_table = XC3028_FE_OREN538,
835 fe = dvb_attach(xc2028_attach,
836 dev->dvb.frontend, &cfg);
837 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
838 fe->ops.tuner_ops.set_config(fe, &ctl);
841 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
842 dev->dvb.frontend = dvb_attach(zl10353_attach,
843 &cx88_geniatech_x8000_mt,
844 &dev->core->i2c_adap);
845 if (attach_xc3028(0x61, dev) < 0)
848 case CX88_BOARD_GENIATECH_X8000_MT:
849 dev->ts_gen_cntrl = 0x00;
851 dev->dvb.frontend = dvb_attach(zl10353_attach,
852 &cx88_geniatech_x8000_mt,
853 &dev->core->i2c_adap);
854 if (attach_xc3028(0x61, dev) < 0)
857 case CX88_BOARD_KWORLD_ATSC_120:
858 dev->dvb.frontend = dvb_attach(s5h1409_attach,
859 &kworld_atsc_120_config,
860 &dev->core->i2c_adap);
861 if (attach_xc3028(0x61, dev) < 0)
864 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
865 dev->dvb.frontend = dvb_attach(s5h1411_attach,
866 &dvico_fusionhdtv7_config,
867 &dev->core->i2c_adap);
868 if (dev->dvb.frontend != NULL) {
869 /* tuner_config.video_dev must point to
872 dvico_fusionhdtv7_tuner_config.priv =
873 dev->core->i2c_adap.algo_data;
874 dvb_attach(xc5000_attach, dev->dvb.frontend,
875 &dev->core->i2c_adap,
876 &dvico_fusionhdtv7_tuner_config);
880 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
884 if (NULL == dev->dvb.frontend) {
886 "%s/2: frontend initialization failed\n",
891 /* Ensure all frontends negotiate bus access */
892 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
894 /* Put the analog decoder in standby to keep it quiet */
895 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
897 /* register everything */
898 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
899 &dev->pci->dev, adapter_nr);
902 /* ----------------------------------------------------------- */
904 /* CX8802 MPEG -> mini driver - We have been given the hardware */
905 static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
907 struct cx88_core *core = drv->core;
909 dprintk( 1, "%s\n", __func__);
911 switch (core->boardnr) {
912 case CX88_BOARD_HAUPPAUGE_HVR1300:
913 /* We arrive here with either the cx23416 or the cx22702
914 * on the bus. Take the bus from the cx23416 and enable the
917 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
918 cx_clear(MO_GP0_IO, 0x00000004);
927 /* CX8802 MPEG -> mini driver - We no longer have the hardware */
928 static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
930 struct cx88_core *core = drv->core;
932 dprintk( 1, "%s\n", __func__);
934 switch (core->boardnr) {
935 case CX88_BOARD_HAUPPAUGE_HVR1300:
936 /* Do Nothing, leave the cx22702 on the bus. */
944 static int cx8802_dvb_probe(struct cx8802_driver *drv)
946 struct cx88_core *core = drv->core;
947 struct cx8802_dev *dev = drv->core->dvbdev;
950 dprintk( 1, "%s\n", __func__);
951 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
958 if (!(core->board.mpeg & CX88_MPEG_DVB))
961 /* If vp3054 isn't enabled, a stub will just return 0 */
962 err = vp3054_i2c_probe(dev);
967 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
968 videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops,
969 &dev->pci->dev, &dev->slock,
970 V4L2_BUF_TYPE_VIDEO_CAPTURE,
972 sizeof(struct cx88_buffer),
974 err = dvb_register(dev);
976 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
983 static int cx8802_dvb_remove(struct cx8802_driver *drv)
985 struct cx8802_dev *dev = drv->core->dvbdev;
988 if (dev->dvb.frontend)
989 videobuf_dvb_unregister(&dev->dvb);
991 vp3054_i2c_remove(dev);
996 static struct cx8802_driver cx8802_dvb_driver = {
997 .type_id = CX88_MPEG_DVB,
998 .hw_access = CX8802_DRVCTL_SHARED,
999 .probe = cx8802_dvb_probe,
1000 .remove = cx8802_dvb_remove,
1001 .advise_acquire = cx8802_dvb_advise_acquire,
1002 .advise_release = cx8802_dvb_advise_release,
1005 static int dvb_init(void)
1007 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
1008 (CX88_VERSION_CODE >> 16) & 0xff,
1009 (CX88_VERSION_CODE >> 8) & 0xff,
1010 CX88_VERSION_CODE & 0xff);
1012 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1013 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1015 return cx8802_register_driver(&cx8802_dvb_driver);
1018 static void dvb_fini(void)
1020 cx8802_unregister_driver(&cx8802_dvb_driver);
1023 module_init(dvb_init);
1024 module_exit(dvb_fini);
1029 * compile-command: "make DVB=1"