3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5 * Extended 3 / 2005 by Hartmut Hackmann to support various
6 * cards with the tda10046 DVB-T channel decoder
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/init.h>
24 #include <linux/list.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/slab.h>
28 #include <linux/delay.h>
29 #include <linux/kthread.h>
30 #include <linux/suspend.h>
32 #include "saa7134-reg.h"
34 #include <media/v4l2-common.h>
36 #include <dvb_frontend.h>
39 #include "mt352_priv.h" /* FIXME */
42 #include "tuner-xc2028.h"
50 #include "tuner-simple.h"
60 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
61 MODULE_LICENSE("GPL");
63 static unsigned int antenna_pwr;
65 module_param(antenna_pwr, int, 0444);
66 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
68 static int use_frontend;
69 module_param(use_frontend, int, 0644);
70 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
73 module_param(debug, int, 0644);
74 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
76 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
78 #define dprintk(fmt, arg...) do { if (debug) \
79 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
82 #define wprintk(fmt, arg...) \
83 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
85 /* ------------------------------------------------------------------
86 * mt352 based DVB-T cards
89 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
94 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
95 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
99 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
100 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
103 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
104 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
106 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
108 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
109 dprintk("%s %s\n", __func__, ok ? "on" : "off");
112 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
116 static int mt352_pinnacle_init(struct dvb_frontend* fe)
118 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
119 static u8 reset [] = { RESET, 0x80 };
120 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
121 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
122 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
123 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
124 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
125 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
126 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
127 struct saa7134_dev *dev= fe->dvb->priv;
129 dprintk("%s called\n", __func__);
131 mt352_write(fe, clock_config, sizeof(clock_config));
133 mt352_write(fe, reset, sizeof(reset));
134 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
135 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
136 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
137 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
139 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
140 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
141 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
146 static int mt352_aver777_init(struct dvb_frontend* fe)
148 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
149 static u8 reset [] = { RESET, 0x80 };
150 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
151 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
152 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
154 mt352_write(fe, clock_config, sizeof(clock_config));
156 mt352_write(fe, reset, sizeof(reset));
157 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
158 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
159 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
164 static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
166 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
167 static u8 reset [] = { RESET, 0x80 };
168 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
169 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
170 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
172 mt352_write(fe, clock_config, sizeof(clock_config));
174 mt352_write(fe, reset, sizeof(reset));
175 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
176 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
177 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
181 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
182 struct dvb_frontend_parameters* params)
184 u8 off[] = { 0x00, 0xf1};
185 u8 on[] = { 0x00, 0x71};
186 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
188 struct saa7134_dev *dev = fe->dvb->priv;
189 struct v4l2_frequency f;
191 /* set frequency (mt2050) */
193 f.type = V4L2_TUNER_DIGITAL_TV;
194 f.frequency = params->frequency / 1000 * 16 / 1000;
195 if (fe->ops.i2c_gate_ctrl)
196 fe->ops.i2c_gate_ctrl(fe, 1);
197 i2c_transfer(&dev->i2c_adap, &msg, 1);
198 saa_call_all(dev, tuner, s_frequency, &f);
200 if (fe->ops.i2c_gate_ctrl)
201 fe->ops.i2c_gate_ctrl(fe, 1);
202 i2c_transfer(&dev->i2c_adap, &msg, 1);
204 pinnacle_antenna_pwr(dev, antenna_pwr);
207 return mt352_pinnacle_init(fe);
210 static struct mt352_config pinnacle_300i = {
211 .demod_address = 0x3c >> 1,
215 .demod_init = mt352_pinnacle_init,
218 static struct mt352_config avermedia_777 = {
219 .demod_address = 0xf,
220 .demod_init = mt352_aver777_init,
223 static struct mt352_config avermedia_xc3028_mt352_dev = {
224 .demod_address = (0x1e >> 1),
226 .demod_init = mt352_avermedia_xc3028_init,
229 /* ==================================================================
230 * tda1004x based DVB-T cards, helper functions
233 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
234 const struct firmware **fw, char *name)
236 struct saa7134_dev *dev = fe->dvb->priv;
237 return request_firmware(fw, name, &dev->pci->dev);
240 /* ------------------------------------------------------------------
241 * these tuners are tu1216, td1316(a)
244 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
246 struct saa7134_dev *dev = fe->dvb->priv;
247 struct tda1004x_state *state = fe->demodulator_priv;
248 u8 addr = state->config->tuner_address;
250 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
252 int tuner_frequency = 0;
255 /* determine charge pump */
256 tuner_frequency = params->frequency + 36166000;
257 if (tuner_frequency < 87000000)
259 else if (tuner_frequency < 130000000)
261 else if (tuner_frequency < 160000000)
263 else if (tuner_frequency < 200000000)
265 else if (tuner_frequency < 290000000)
267 else if (tuner_frequency < 420000000)
269 else if (tuner_frequency < 480000000)
271 else if (tuner_frequency < 620000000)
273 else if (tuner_frequency < 830000000)
275 else if (tuner_frequency < 895000000)
281 if (params->frequency < 49000000)
283 else if (params->frequency < 161000000)
285 else if (params->frequency < 444000000)
287 else if (params->frequency < 861000000)
292 /* setup PLL filter */
293 switch (params->u.ofdm.bandwidth) {
294 case BANDWIDTH_6_MHZ:
298 case BANDWIDTH_7_MHZ:
302 case BANDWIDTH_8_MHZ:
311 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
313 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
315 /* setup tuner buffer */
316 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
317 tuner_buf[1] = tuner_frequency & 0xff;
319 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
321 if (fe->ops.i2c_gate_ctrl)
322 fe->ops.i2c_gate_ctrl(fe, 1);
323 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
324 wprintk("could not write to tuner at addr: 0x%02x\n",
332 static int philips_tu1216_init(struct dvb_frontend *fe)
334 struct saa7134_dev *dev = fe->dvb->priv;
335 struct tda1004x_state *state = fe->demodulator_priv;
336 u8 addr = state->config->tuner_address;
337 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
338 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
340 /* setup PLL configuration */
341 if (fe->ops.i2c_gate_ctrl)
342 fe->ops.i2c_gate_ctrl(fe, 1);
343 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
350 /* ------------------------------------------------------------------ */
352 static struct tda1004x_config philips_tu1216_60_config = {
353 .demod_address = 0x8,
356 .xtal_freq = TDA10046_XTAL_4M,
357 .agc_config = TDA10046_AGC_DEFAULT,
358 .if_freq = TDA10046_FREQ_3617,
359 .tuner_address = 0x60,
360 .request_firmware = philips_tda1004x_request_firmware
363 static struct tda1004x_config philips_tu1216_61_config = {
365 .demod_address = 0x8,
368 .xtal_freq = TDA10046_XTAL_4M,
369 .agc_config = TDA10046_AGC_DEFAULT,
370 .if_freq = TDA10046_FREQ_3617,
371 .tuner_address = 0x61,
372 .request_firmware = philips_tda1004x_request_firmware
375 /* ------------------------------------------------------------------ */
377 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
379 struct saa7134_dev *dev = fe->dvb->priv;
380 struct tda1004x_state *state = fe->demodulator_priv;
381 u8 addr = state->config->tuner_address;
382 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
383 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
385 /* setup PLL configuration */
386 if (fe->ops.i2c_gate_ctrl)
387 fe->ops.i2c_gate_ctrl(fe, 1);
388 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
393 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
395 return philips_tda6651_pll_set(fe, params);
398 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
400 struct saa7134_dev *dev = fe->dvb->priv;
401 struct tda1004x_state *state = fe->demodulator_priv;
402 u8 addr = state->config->tuner_address;
403 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
404 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
406 /* switch the tuner to analog mode */
407 if (fe->ops.i2c_gate_ctrl)
408 fe->ops.i2c_gate_ctrl(fe, 1);
409 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
414 /* ------------------------------------------------------------------ */
416 static int philips_europa_tuner_init(struct dvb_frontend *fe)
418 struct saa7134_dev *dev = fe->dvb->priv;
419 static u8 msg[] = { 0x00, 0x40};
420 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
423 if (philips_td1316_tuner_init(fe))
426 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
432 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
434 struct saa7134_dev *dev = fe->dvb->priv;
436 static u8 msg[] = { 0x00, 0x14 };
437 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
439 if (philips_td1316_tuner_sleep(fe))
442 /* switch the board to analog mode */
443 if (fe->ops.i2c_gate_ctrl)
444 fe->ops.i2c_gate_ctrl(fe, 1);
445 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
449 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
451 struct saa7134_dev *dev = fe->dvb->priv;
453 if (dev->original_demod_sleep)
454 dev->original_demod_sleep(fe);
455 fe->ops.i2c_gate_ctrl(fe, 1);
459 static struct tda1004x_config philips_europa_config = {
461 .demod_address = 0x8,
464 .xtal_freq = TDA10046_XTAL_4M,
465 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
466 .if_freq = TDA10046_FREQ_052,
467 .tuner_address = 0x61,
468 .request_firmware = philips_tda1004x_request_firmware
471 static struct tda1004x_config medion_cardbus = {
472 .demod_address = 0x08,
475 .xtal_freq = TDA10046_XTAL_16M,
476 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
477 .if_freq = TDA10046_FREQ_3613,
478 .tuner_address = 0x61,
479 .request_firmware = philips_tda1004x_request_firmware
482 /* ------------------------------------------------------------------
483 * tda 1004x based cards with philips silicon tuner
486 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
488 struct tda1004x_state *state = fe->demodulator_priv;
490 u8 addr = state->config->i2c_gate;
491 static u8 tda8290_close[] = { 0x21, 0xc0};
492 static u8 tda8290_open[] = { 0x21, 0x80};
493 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
495 tda8290_msg.buf = tda8290_close;
497 tda8290_msg.buf = tda8290_open;
499 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
500 struct saa7134_dev *dev = fe->dvb->priv;
501 wprintk("could not access tda8290 I2C gate\n");
508 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
510 struct saa7134_dev *dev = fe->dvb->priv;
511 struct tda1004x_state *state = fe->demodulator_priv;
513 switch (state->config->antenna_switch) {
515 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
516 saa7134_set_gpio(dev, 21, 0);
518 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
519 saa7134_set_gpio(dev, 21, 1);
525 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
527 struct saa7134_dev *dev = fe->dvb->priv;
528 struct tda1004x_state *state = fe->demodulator_priv;
530 switch (state->config->antenna_switch) {
532 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
533 saa7134_set_gpio(dev, 21, 1);
535 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
536 saa7134_set_gpio(dev, 21, 0);
542 static int configure_tda827x_fe(struct saa7134_dev *dev,
543 struct tda1004x_config *cdec_conf,
544 struct tda827x_config *tuner_conf)
546 struct videobuf_dvb_frontend *fe0;
548 /* Get the first frontend */
549 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
551 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
552 if (fe0->dvb.frontend) {
553 if (cdec_conf->i2c_gate)
554 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
555 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
556 cdec_conf->tuner_address,
557 &dev->i2c_adap, tuner_conf))
560 wprintk("no tda827x tuner found at addr: %02x\n",
561 cdec_conf->tuner_address);
566 /* ------------------------------------------------------------------ */
568 static struct tda827x_config tda827x_cfg_0 = {
569 .init = philips_tda827x_tuner_init,
570 .sleep = philips_tda827x_tuner_sleep,
575 static struct tda827x_config tda827x_cfg_1 = {
576 .init = philips_tda827x_tuner_init,
577 .sleep = philips_tda827x_tuner_sleep,
582 static struct tda827x_config tda827x_cfg_2 = {
583 .init = philips_tda827x_tuner_init,
584 .sleep = philips_tda827x_tuner_sleep,
589 static struct tda827x_config tda827x_cfg_2_sw42 = {
590 .init = philips_tda827x_tuner_init,
591 .sleep = philips_tda827x_tuner_sleep,
596 /* ------------------------------------------------------------------ */
598 static struct tda1004x_config tda827x_lifeview_config = {
599 .demod_address = 0x08,
602 .xtal_freq = TDA10046_XTAL_16M,
603 .agc_config = TDA10046_AGC_TDA827X,
604 .gpio_config = TDA10046_GP11_I,
605 .if_freq = TDA10046_FREQ_045,
606 .tuner_address = 0x60,
607 .request_firmware = philips_tda1004x_request_firmware
610 static struct tda1004x_config philips_tiger_config = {
611 .demod_address = 0x08,
614 .xtal_freq = TDA10046_XTAL_16M,
615 .agc_config = TDA10046_AGC_TDA827X,
616 .gpio_config = TDA10046_GP11_I,
617 .if_freq = TDA10046_FREQ_045,
619 .tuner_address = 0x61,
621 .request_firmware = philips_tda1004x_request_firmware
624 static struct tda1004x_config cinergy_ht_config = {
625 .demod_address = 0x08,
628 .xtal_freq = TDA10046_XTAL_16M,
629 .agc_config = TDA10046_AGC_TDA827X,
630 .gpio_config = TDA10046_GP01_I,
631 .if_freq = TDA10046_FREQ_045,
633 .tuner_address = 0x61,
634 .request_firmware = philips_tda1004x_request_firmware
637 static struct tda1004x_config cinergy_ht_pci_config = {
638 .demod_address = 0x08,
641 .xtal_freq = TDA10046_XTAL_16M,
642 .agc_config = TDA10046_AGC_TDA827X,
643 .gpio_config = TDA10046_GP01_I,
644 .if_freq = TDA10046_FREQ_045,
646 .tuner_address = 0x60,
647 .request_firmware = philips_tda1004x_request_firmware
650 static struct tda1004x_config philips_tiger_s_config = {
651 .demod_address = 0x08,
654 .xtal_freq = TDA10046_XTAL_16M,
655 .agc_config = TDA10046_AGC_TDA827X,
656 .gpio_config = TDA10046_GP01_I,
657 .if_freq = TDA10046_FREQ_045,
659 .tuner_address = 0x61,
661 .request_firmware = philips_tda1004x_request_firmware
664 static struct tda1004x_config pinnacle_pctv_310i_config = {
665 .demod_address = 0x08,
668 .xtal_freq = TDA10046_XTAL_16M,
669 .agc_config = TDA10046_AGC_TDA827X,
670 .gpio_config = TDA10046_GP11_I,
671 .if_freq = TDA10046_FREQ_045,
673 .tuner_address = 0x61,
674 .request_firmware = philips_tda1004x_request_firmware
677 static struct tda1004x_config hauppauge_hvr_1110_config = {
678 .demod_address = 0x08,
681 .xtal_freq = TDA10046_XTAL_16M,
682 .agc_config = TDA10046_AGC_TDA827X,
683 .gpio_config = TDA10046_GP11_I,
684 .if_freq = TDA10046_FREQ_045,
686 .tuner_address = 0x61,
687 .request_firmware = philips_tda1004x_request_firmware
690 static struct tda1004x_config asus_p7131_dual_config = {
691 .demod_address = 0x08,
694 .xtal_freq = TDA10046_XTAL_16M,
695 .agc_config = TDA10046_AGC_TDA827X,
696 .gpio_config = TDA10046_GP11_I,
697 .if_freq = TDA10046_FREQ_045,
699 .tuner_address = 0x61,
701 .request_firmware = philips_tda1004x_request_firmware
704 static struct tda1004x_config lifeview_trio_config = {
705 .demod_address = 0x09,
708 .xtal_freq = TDA10046_XTAL_16M,
709 .agc_config = TDA10046_AGC_TDA827X,
710 .gpio_config = TDA10046_GP00_I,
711 .if_freq = TDA10046_FREQ_045,
712 .tuner_address = 0x60,
713 .request_firmware = philips_tda1004x_request_firmware
716 static struct tda1004x_config tevion_dvbt220rf_config = {
717 .demod_address = 0x08,
720 .xtal_freq = TDA10046_XTAL_16M,
721 .agc_config = TDA10046_AGC_TDA827X,
722 .gpio_config = TDA10046_GP11_I,
723 .if_freq = TDA10046_FREQ_045,
724 .tuner_address = 0x60,
725 .request_firmware = philips_tda1004x_request_firmware
728 static struct tda1004x_config md8800_dvbt_config = {
729 .demod_address = 0x08,
732 .xtal_freq = TDA10046_XTAL_16M,
733 .agc_config = TDA10046_AGC_TDA827X,
734 .gpio_config = TDA10046_GP01_I,
735 .if_freq = TDA10046_FREQ_045,
737 .tuner_address = 0x60,
738 .request_firmware = philips_tda1004x_request_firmware
741 static struct tda1004x_config asus_p7131_4871_config = {
742 .demod_address = 0x08,
745 .xtal_freq = TDA10046_XTAL_16M,
746 .agc_config = TDA10046_AGC_TDA827X,
747 .gpio_config = TDA10046_GP01_I,
748 .if_freq = TDA10046_FREQ_045,
750 .tuner_address = 0x61,
752 .request_firmware = philips_tda1004x_request_firmware
755 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
756 .demod_address = 0x08,
759 .xtal_freq = TDA10046_XTAL_16M,
760 .agc_config = TDA10046_AGC_TDA827X,
761 .gpio_config = TDA10046_GP11_I,
762 .if_freq = TDA10046_FREQ_045,
764 .tuner_address = 0x61,
766 .request_firmware = philips_tda1004x_request_firmware
769 static struct tda1004x_config kworld_dvb_t_210_config = {
770 .demod_address = 0x08,
773 .xtal_freq = TDA10046_XTAL_16M,
774 .agc_config = TDA10046_AGC_TDA827X,
775 .gpio_config = TDA10046_GP11_I,
776 .if_freq = TDA10046_FREQ_045,
778 .tuner_address = 0x61,
780 .request_firmware = philips_tda1004x_request_firmware
783 static struct tda1004x_config avermedia_super_007_config = {
784 .demod_address = 0x08,
787 .xtal_freq = TDA10046_XTAL_16M,
788 .agc_config = TDA10046_AGC_TDA827X,
789 .gpio_config = TDA10046_GP01_I,
790 .if_freq = TDA10046_FREQ_045,
792 .tuner_address = 0x60,
794 .request_firmware = philips_tda1004x_request_firmware
797 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
798 .demod_address = 0x08,
801 .xtal_freq = TDA10046_XTAL_16M,
802 .agc_config = TDA10046_AGC_TDA827X,
803 .gpio_config = TDA10046_GP01_I,
804 .if_freq = TDA10046_FREQ_045,
806 .tuner_address = 0x61,
808 .request_firmware = philips_tda1004x_request_firmware
811 static struct tda1004x_config asus_tiger_3in1_config = {
812 .demod_address = 0x0b,
815 .xtal_freq = TDA10046_XTAL_16M,
816 .agc_config = TDA10046_AGC_TDA827X,
817 .gpio_config = TDA10046_GP11_I,
818 .if_freq = TDA10046_FREQ_045,
820 .tuner_address = 0x61,
822 .request_firmware = philips_tda1004x_request_firmware
825 /* ------------------------------------------------------------------
826 * special case: this card uses saa713x GPIO22 for the mode switch
829 static int ads_duo_tuner_init(struct dvb_frontend *fe)
831 struct saa7134_dev *dev = fe->dvb->priv;
832 philips_tda827x_tuner_init(fe);
833 /* route TDA8275a AGC input to the channel decoder */
834 saa7134_set_gpio(dev, 22, 1);
838 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
840 struct saa7134_dev *dev = fe->dvb->priv;
841 /* route TDA8275a AGC input to the analog IF chip*/
842 saa7134_set_gpio(dev, 22, 0);
843 philips_tda827x_tuner_sleep(fe);
847 static struct tda827x_config ads_duo_cfg = {
848 .init = ads_duo_tuner_init,
849 .sleep = ads_duo_tuner_sleep,
853 static struct tda1004x_config ads_tech_duo_config = {
854 .demod_address = 0x08,
857 .xtal_freq = TDA10046_XTAL_16M,
858 .agc_config = TDA10046_AGC_TDA827X,
859 .gpio_config = TDA10046_GP00_I,
860 .if_freq = TDA10046_FREQ_045,
861 .tuner_address = 0x61,
862 .request_firmware = philips_tda1004x_request_firmware
865 static struct zl10353_config behold_h6_config = {
866 .demod_address = 0x1e>>1,
869 .disable_i2c_gate_ctrl = 1,
872 /* ==================================================================
873 * tda10086 based DVB-S cards, helper functions
876 static struct tda10086_config flydvbs = {
877 .demod_address = 0x0e,
880 .xtal_freq = TDA10086_XTAL_16M,
883 static struct tda10086_config sd1878_4m = {
884 .demod_address = 0x0e,
887 .xtal_freq = TDA10086_XTAL_4M,
890 /* ------------------------------------------------------------------
891 * special case: lnb supply is connected to the gated i2c
894 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
897 struct saa7134_dev *dev = fe->dvb->priv;
898 if (fe->ops.i2c_gate_ctrl) {
899 fe->ops.i2c_gate_ctrl(fe, 1);
900 if (dev->original_set_voltage)
901 res = dev->original_set_voltage(fe, voltage);
902 fe->ops.i2c_gate_ctrl(fe, 0);
907 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
910 struct saa7134_dev *dev = fe->dvb->priv;
911 if (fe->ops.i2c_gate_ctrl) {
912 fe->ops.i2c_gate_ctrl(fe, 1);
913 if (dev->original_set_high_voltage)
914 res = dev->original_set_high_voltage(fe, arg);
915 fe->ops.i2c_gate_ctrl(fe, 0);
920 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
922 struct saa7134_dev *dev = fe->dvb->priv;
923 u8 wbuf[2] = { 0x1f, 00 };
925 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
926 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
928 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
930 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
931 if (voltage == SEC_VOLTAGE_18)
932 wbuf[1] = rbuf | 0x10;
934 wbuf[1] = rbuf & 0xef;
936 i2c_transfer(&dev->i2c_adap, msg, 1);
940 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
942 struct saa7134_dev *dev = fe->dvb->priv;
943 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
947 /* ==================================================================
948 * nxt200x based ATSC cards, helper functions
951 static struct nxt200x_config avertvhda180 = {
952 .demod_address = 0x0a,
955 static struct nxt200x_config kworldatsc110 = {
956 .demod_address = 0x0a,
959 /* ------------------------------------------------------------------ */
961 static struct mt312_config avertv_a700_mt312 = {
962 .demod_address = 0x0e,
963 .voltage_inverted = 1,
966 static struct zl10036_config avertv_a700_tuner = {
967 .tuner_address = 0x60,
970 static struct lgdt3305_config hcw_lgdt3305_config = {
972 .mpeg_mode = LGDT3305_MPEG_SERIAL,
973 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
974 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
976 .spectral_inversion = 1,
981 static struct tda18271_std_map hauppauge_tda18271_std_map = {
982 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
983 .if_lvl = 1, .rfagc_top = 0x58, },
984 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
985 .if_lvl = 1, .rfagc_top = 0x58, },
988 static struct tda18271_config hcw_tda18271_config = {
989 .std_map = &hauppauge_tda18271_std_map,
990 .gate = TDA18271_GATE_ANALOG,
994 static struct tda829x_config tda829x_no_probe = {
995 .probe_tuner = TDA829X_DONT_PROBE,
998 /* ==================================================================
1002 static int dvb_init(struct saa7134_dev *dev)
1005 int attach_xc3028 = 0;
1006 struct videobuf_dvb_frontend *fe0;
1008 /* FIXME: add support for multi-frontend */
1009 mutex_init(&dev->frontends.lock);
1010 INIT_LIST_HEAD(&dev->frontends.felist);
1012 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
1013 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1015 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1019 /* init struct videobuf_dvb */
1020 dev->ts.nr_bufs = 32;
1021 dev->ts.nr_packets = 32*4;
1022 fe0->dvb.name = dev->name;
1023 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
1024 &dev->pci->dev, &dev->slock,
1025 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1026 V4L2_FIELD_ALTERNATE,
1027 sizeof(struct saa7134_buf),
1030 switch (dev->board) {
1031 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1032 dprintk("pinnacle 300i dvb setup\n");
1033 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1035 if (fe0->dvb.frontend) {
1036 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1039 case SAA7134_BOARD_AVERMEDIA_777:
1040 case SAA7134_BOARD_AVERMEDIA_A16AR:
1041 dprintk("avertv 777 dvb setup\n");
1042 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1044 if (fe0->dvb.frontend) {
1045 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1046 &dev->i2c_adap, 0x61,
1047 TUNER_PHILIPS_TD1316);
1050 case SAA7134_BOARD_AVERMEDIA_A16D:
1051 dprintk("AverMedia A16D dvb setup\n");
1052 fe0->dvb.frontend = dvb_attach(mt352_attach,
1053 &avermedia_xc3028_mt352_dev,
1057 case SAA7134_BOARD_MD7134:
1058 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1061 if (fe0->dvb.frontend) {
1062 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1063 &dev->i2c_adap, medion_cardbus.tuner_address,
1064 TUNER_PHILIPS_FMD1216ME_MK3);
1067 case SAA7134_BOARD_PHILIPS_TOUGH:
1068 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1069 &philips_tu1216_60_config,
1071 if (fe0->dvb.frontend) {
1072 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1073 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1076 case SAA7134_BOARD_FLYDVBTDUO:
1077 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1078 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1079 &tda827x_cfg_0) < 0)
1080 goto dettach_frontend;
1082 case SAA7134_BOARD_PHILIPS_EUROPA:
1083 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1084 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1085 &philips_europa_config,
1087 if (fe0->dvb.frontend) {
1088 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1089 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1090 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1091 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1092 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1095 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1096 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1097 &philips_tu1216_61_config,
1099 if (fe0->dvb.frontend) {
1100 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1101 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1104 case SAA7134_BOARD_KWORLD_DVBT_210:
1105 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1106 &tda827x_cfg_2) < 0)
1107 goto dettach_frontend;
1109 case SAA7134_BOARD_PHILIPS_TIGER:
1110 if (configure_tda827x_fe(dev, &philips_tiger_config,
1111 &tda827x_cfg_0) < 0)
1112 goto dettach_frontend;
1114 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1115 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1116 &tda827x_cfg_1) < 0)
1117 goto dettach_frontend;
1119 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1120 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1121 &tda827x_cfg_1) < 0)
1122 goto dettach_frontend;
1124 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1125 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1126 &hcw_lgdt3305_config,
1128 if (fe0->dvb.frontend) {
1129 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1130 &dev->i2c_adap, 0x4b,
1132 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1133 0x60, &dev->i2c_adap,
1134 &hcw_tda18271_config);
1137 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1138 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1139 &tda827x_cfg_0) < 0)
1140 goto dettach_frontend;
1142 case SAA7134_BOARD_FLYDVBT_LR301:
1143 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1144 &tda827x_cfg_0) < 0)
1145 goto dettach_frontend;
1147 case SAA7134_BOARD_FLYDVB_TRIO:
1148 if (!use_frontend) { /* terrestrial */
1149 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1150 &tda827x_cfg_0) < 0)
1151 goto dettach_frontend;
1152 } else { /* satellite */
1153 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1154 if (fe0->dvb.frontend) {
1155 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1156 &dev->i2c_adap, 0) == NULL) {
1157 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1158 goto dettach_frontend;
1160 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1161 0x08, 0, 0) == NULL) {
1162 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1163 goto dettach_frontend;
1168 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1169 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1170 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1171 &ads_tech_duo_config,
1173 if (fe0->dvb.frontend) {
1174 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1175 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1176 &ads_duo_cfg) == NULL) {
1177 wprintk("no tda827x tuner found at addr: %02x\n",
1178 ads_tech_duo_config.tuner_address);
1179 goto dettach_frontend;
1182 wprintk("failed to attach tda10046\n");
1184 case SAA7134_BOARD_TEVION_DVBT_220RF:
1185 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1186 &tda827x_cfg_0) < 0)
1187 goto dettach_frontend;
1189 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1190 if (!use_frontend) { /* terrestrial */
1191 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1192 &tda827x_cfg_0) < 0)
1193 goto dettach_frontend;
1194 } else { /* satellite */
1195 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1196 &flydvbs, &dev->i2c_adap);
1197 if (fe0->dvb.frontend) {
1198 struct dvb_frontend *fe = fe0->dvb.frontend;
1199 u8 dev_id = dev->eedata[2];
1201 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1203 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1204 0x60, &dev->i2c_adap, 0) == NULL) {
1205 wprintk("%s: Medion Quadro, no tda826x "
1206 "found !\n", __func__);
1207 goto dettach_frontend;
1209 if (dev_id != 0x08) {
1210 /* we need to open the i2c gate (we know it exists) */
1211 fe->ops.i2c_gate_ctrl(fe, 1);
1212 if (dvb_attach(isl6405_attach, fe,
1213 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1214 wprintk("%s: Medion Quadro, no ISL6405 "
1215 "found !\n", __func__);
1216 goto dettach_frontend;
1218 if (dev_id == 0x07) {
1219 /* fire up the 2nd section of the LNB supply since
1220 we can't do this from the other section */
1222 i2c_transfer(&dev->i2c_adap, &msg, 1);
1224 fe->ops.i2c_gate_ctrl(fe, 0);
1225 dev->original_set_voltage = fe->ops.set_voltage;
1226 fe->ops.set_voltage = md8800_set_voltage;
1227 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1228 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1230 fe->ops.set_voltage = md8800_set_voltage2;
1231 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1236 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1237 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1239 if (fe0->dvb.frontend)
1240 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1241 NULL, DVB_PLL_TDHU2);
1243 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1244 case SAA7134_BOARD_KWORLD_ATSC110:
1245 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1247 if (fe0->dvb.frontend)
1248 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1249 &dev->i2c_adap, 0x61,
1250 TUNER_PHILIPS_TUV1236D);
1252 case SAA7134_BOARD_FLYDVBS_LR300:
1253 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1255 if (fe0->dvb.frontend) {
1256 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1257 &dev->i2c_adap, 0) == NULL) {
1258 wprintk("%s: No tda826x found!\n", __func__);
1259 goto dettach_frontend;
1261 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1262 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1263 wprintk("%s: No ISL6421 found!\n", __func__);
1264 goto dettach_frontend;
1268 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1269 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1272 if (fe0->dvb.frontend) {
1273 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1274 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1276 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1277 &dev->i2c_adap, medion_cardbus.tuner_address,
1278 TUNER_PHILIPS_FMD1216ME_MK3);
1281 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1282 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1283 &philips_europa_config,
1285 if (fe0->dvb.frontend) {
1286 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1287 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1290 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1291 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1292 &tda827x_cfg_0) < 0)
1293 goto dettach_frontend;
1295 case SAA7134_BOARD_CINERGY_HT_PCI:
1296 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1297 &tda827x_cfg_0) < 0)
1298 goto dettach_frontend;
1300 case SAA7134_BOARD_PHILIPS_TIGER_S:
1301 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1302 &tda827x_cfg_2) < 0)
1303 goto dettach_frontend;
1305 case SAA7134_BOARD_ASUS_P7131_4871:
1306 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1307 &tda827x_cfg_2) < 0)
1308 goto dettach_frontend;
1310 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1311 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1312 &tda827x_cfg_2) < 0)
1313 goto dettach_frontend;
1315 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1316 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1317 &tda827x_cfg_0) < 0)
1318 goto dettach_frontend;
1320 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1321 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1322 &tda827x_cfg_2_sw42) < 0)
1323 goto dettach_frontend;
1325 case SAA7134_BOARD_PHILIPS_SNAKE:
1326 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1328 if (fe0->dvb.frontend) {
1329 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1330 &dev->i2c_adap, 0) == NULL) {
1331 wprintk("%s: No tda826x found!\n", __func__);
1332 goto dettach_frontend;
1334 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1335 &dev->i2c_adap, 0, 0) == NULL) {
1336 wprintk("%s: No lnbp21 found!\n", __func__);
1337 goto dettach_frontend;
1341 case SAA7134_BOARD_CREATIX_CTX953:
1342 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1343 &tda827x_cfg_0) < 0)
1344 goto dettach_frontend;
1346 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1347 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1348 &tda827x_cfg_2) < 0)
1349 goto dettach_frontend;
1351 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1352 dprintk("AverMedia E506R dvb setup\n");
1353 saa7134_set_gpio(dev, 25, 0);
1355 saa7134_set_gpio(dev, 25, 1);
1356 fe0->dvb.frontend = dvb_attach(mt352_attach,
1357 &avermedia_xc3028_mt352_dev,
1361 case SAA7134_BOARD_MD7134_BRIDGE_2:
1362 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1363 &sd1878_4m, &dev->i2c_adap);
1364 if (fe0->dvb.frontend) {
1365 struct dvb_frontend *fe;
1366 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1367 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1368 wprintk("%s: MD7134 DVB-S, no SD1878 "
1369 "found !\n", __func__);
1370 goto dettach_frontend;
1372 /* we need to open the i2c gate (we know it exists) */
1373 fe = fe0->dvb.frontend;
1374 fe->ops.i2c_gate_ctrl(fe, 1);
1375 if (dvb_attach(isl6405_attach, fe,
1376 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1377 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1378 "found !\n", __func__);
1379 goto dettach_frontend;
1381 fe->ops.i2c_gate_ctrl(fe, 0);
1382 dev->original_set_voltage = fe->ops.set_voltage;
1383 fe->ops.set_voltage = md8800_set_voltage;
1384 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1385 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1388 case SAA7134_BOARD_AVERMEDIA_M103:
1389 saa7134_set_gpio(dev, 25, 0);
1391 saa7134_set_gpio(dev, 25, 1);
1392 fe0->dvb.frontend = dvb_attach(mt352_attach,
1393 &avermedia_xc3028_mt352_dev,
1397 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1398 if (!use_frontend) { /* terrestrial */
1399 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1400 &tda827x_cfg_2) < 0)
1401 goto dettach_frontend;
1402 } else { /* satellite */
1403 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1404 &flydvbs, &dev->i2c_adap);
1405 if (fe0->dvb.frontend) {
1406 if (dvb_attach(tda826x_attach,
1407 fe0->dvb.frontend, 0x60,
1408 &dev->i2c_adap, 0) == NULL) {
1409 wprintk("%s: Asus Tiger 3in1, no "
1410 "tda826x found!\n", __func__);
1411 goto dettach_frontend;
1413 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1414 &dev->i2c_adap, 0, 0) == NULL) {
1415 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1416 " found!\n", __func__);
1417 goto dettach_frontend;
1422 case SAA7134_BOARD_ASUSTeK_TIGER:
1423 if (configure_tda827x_fe(dev, &philips_tiger_config,
1424 &tda827x_cfg_0) < 0)
1425 goto dettach_frontend;
1427 case SAA7134_BOARD_BEHOLD_H6:
1428 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1431 if (fe0->dvb.frontend) {
1432 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1433 &dev->i2c_adap, 0x61,
1434 TUNER_PHILIPS_FMD1216ME_MK3);
1437 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1438 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1439 /* Zarlink ZL10313 */
1440 fe0->dvb.frontend = dvb_attach(mt312_attach,
1441 &avertv_a700_mt312, &dev->i2c_adap);
1442 if (fe0->dvb.frontend) {
1443 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1444 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1445 wprintk("%s: No zl10036 found!\n",
1451 wprintk("Huh? unknown DVB card?\n");
1455 if (attach_xc3028) {
1456 struct dvb_frontend *fe;
1457 struct xc2028_config cfg = {
1458 .i2c_adap = &dev->i2c_adap,
1462 if (!fe0->dvb.frontend)
1463 goto dettach_frontend;
1465 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1467 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1469 goto dettach_frontend;
1473 if (NULL == fe0->dvb.frontend) {
1474 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1475 goto dettach_frontend;
1477 /* define general-purpose callback pointer */
1478 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1480 /* register everything else */
1481 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1482 &dev->pci->dev, adapter_nr, 0);
1484 /* this sequence is necessary to make the tda1004x load its firmware
1485 * and to enter analog mode of hybrid boards
1488 if (fe0->dvb.frontend->ops.init)
1489 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1490 if (fe0->dvb.frontend->ops.sleep)
1491 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1492 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1493 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1498 videobuf_dvb_dealloc_frontends(&dev->frontends);
1502 static int dvb_fini(struct saa7134_dev *dev)
1504 struct videobuf_dvb_frontend *fe0;
1506 /* Get the first frontend */
1507 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1511 /* FIXME: I suspect that this code is bogus, since the entry for
1512 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1513 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1515 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1516 struct v4l2_priv_tun_config tda9887_cfg;
1517 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1519 tda9887_cfg.tuner = TUNER_TDA9887;
1520 tda9887_cfg.priv = &on;
1522 /* otherwise we don't detect the tuner on next insmod */
1523 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1524 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1525 if ((dev->eedata[2] == 0x07) && use_frontend) {
1526 /* turn off the 2nd lnb supply */
1528 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1529 struct dvb_frontend *fe;
1530 fe = fe0->dvb.frontend;
1531 if (fe->ops.i2c_gate_ctrl) {
1532 fe->ops.i2c_gate_ctrl(fe, 1);
1533 i2c_transfer(&dev->i2c_adap, &msg, 1);
1534 fe->ops.i2c_gate_ctrl(fe, 0);
1538 videobuf_dvb_unregister_bus(&dev->frontends);
1542 static struct saa7134_mpeg_ops dvb_ops = {
1543 .type = SAA7134_MPEG_DVB,
1548 static int __init dvb_register(void)
1550 return saa7134_ts_register(&dvb_ops);
1553 static void __exit dvb_unregister(void)
1555 saa7134_ts_unregister(&dvb_ops);
1558 module_init(dvb_register);
1559 module_exit(dvb_unregister);
1561 /* ------------------------------------------------------------------ */