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"
51 #include "tuner-simple.h"
63 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
64 MODULE_LICENSE("GPL");
66 static unsigned int antenna_pwr;
68 module_param(antenna_pwr, int, 0444);
69 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
71 static int use_frontend;
72 module_param(use_frontend, int, 0644);
73 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
76 module_param(debug, int, 0644);
77 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
79 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
81 #define dprintk(fmt, arg...) do { if (debug) \
82 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
85 #define wprintk(fmt, arg...) \
86 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
88 /* ------------------------------------------------------------------
89 * mt352 based DVB-T cards
92 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
97 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
98 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
102 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
103 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
106 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
107 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
109 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
111 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
112 dprintk("%s %s\n", __func__, ok ? "on" : "off");
115 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
119 static int mt352_pinnacle_init(struct dvb_frontend* fe)
121 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
122 static u8 reset [] = { RESET, 0x80 };
123 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
124 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
125 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
126 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
127 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
128 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
129 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
130 struct saa7134_dev *dev= fe->dvb->priv;
132 dprintk("%s called\n", __func__);
134 mt352_write(fe, clock_config, sizeof(clock_config));
136 mt352_write(fe, reset, sizeof(reset));
137 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
138 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
139 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
140 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
142 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
143 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
144 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
149 static int mt352_aver777_init(struct dvb_frontend* fe)
151 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
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, 0xa0 };
155 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
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));
161 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
162 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
167 static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
169 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
170 static u8 reset [] = { RESET, 0x80 };
171 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
172 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
173 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
175 mt352_write(fe, clock_config, sizeof(clock_config));
177 mt352_write(fe, reset, sizeof(reset));
178 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
179 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
180 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
184 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
185 struct dvb_frontend_parameters* params)
187 u8 off[] = { 0x00, 0xf1};
188 u8 on[] = { 0x00, 0x71};
189 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
191 struct saa7134_dev *dev = fe->dvb->priv;
192 struct v4l2_frequency f;
194 /* set frequency (mt2050) */
196 f.type = V4L2_TUNER_DIGITAL_TV;
197 f.frequency = params->frequency / 1000 * 16 / 1000;
198 if (fe->ops.i2c_gate_ctrl)
199 fe->ops.i2c_gate_ctrl(fe, 1);
200 i2c_transfer(&dev->i2c_adap, &msg, 1);
201 saa_call_all(dev, tuner, s_frequency, &f);
203 if (fe->ops.i2c_gate_ctrl)
204 fe->ops.i2c_gate_ctrl(fe, 1);
205 i2c_transfer(&dev->i2c_adap, &msg, 1);
207 pinnacle_antenna_pwr(dev, antenna_pwr);
210 return mt352_pinnacle_init(fe);
213 static struct mt352_config pinnacle_300i = {
214 .demod_address = 0x3c >> 1,
218 .demod_init = mt352_pinnacle_init,
221 static struct mt352_config avermedia_777 = {
222 .demod_address = 0xf,
223 .demod_init = mt352_aver777_init,
226 static struct mt352_config avermedia_xc3028_mt352_dev = {
227 .demod_address = (0x1e >> 1),
229 .demod_init = mt352_avermedia_xc3028_init,
232 /* ==================================================================
233 * tda1004x based DVB-T cards, helper functions
236 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
237 const struct firmware **fw, char *name)
239 struct saa7134_dev *dev = fe->dvb->priv;
240 return request_firmware(fw, name, &dev->pci->dev);
243 /* ------------------------------------------------------------------
244 * these tuners are tu1216, td1316(a)
247 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
249 struct saa7134_dev *dev = fe->dvb->priv;
250 struct tda1004x_state *state = fe->demodulator_priv;
251 u8 addr = state->config->tuner_address;
253 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
255 int tuner_frequency = 0;
258 /* determine charge pump */
259 tuner_frequency = params->frequency + 36166000;
260 if (tuner_frequency < 87000000)
262 else if (tuner_frequency < 130000000)
264 else if (tuner_frequency < 160000000)
266 else if (tuner_frequency < 200000000)
268 else if (tuner_frequency < 290000000)
270 else if (tuner_frequency < 420000000)
272 else if (tuner_frequency < 480000000)
274 else if (tuner_frequency < 620000000)
276 else if (tuner_frequency < 830000000)
278 else if (tuner_frequency < 895000000)
284 if (params->frequency < 49000000)
286 else if (params->frequency < 161000000)
288 else if (params->frequency < 444000000)
290 else if (params->frequency < 861000000)
295 /* setup PLL filter */
296 switch (params->u.ofdm.bandwidth) {
297 case BANDWIDTH_6_MHZ:
301 case BANDWIDTH_7_MHZ:
305 case BANDWIDTH_8_MHZ:
314 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
316 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
318 /* setup tuner buffer */
319 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
320 tuner_buf[1] = tuner_frequency & 0xff;
322 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
324 if (fe->ops.i2c_gate_ctrl)
325 fe->ops.i2c_gate_ctrl(fe, 1);
326 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
327 wprintk("could not write to tuner at addr: 0x%02x\n",
335 static int philips_tu1216_init(struct dvb_frontend *fe)
337 struct saa7134_dev *dev = fe->dvb->priv;
338 struct tda1004x_state *state = fe->demodulator_priv;
339 u8 addr = state->config->tuner_address;
340 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
341 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
343 /* setup PLL configuration */
344 if (fe->ops.i2c_gate_ctrl)
345 fe->ops.i2c_gate_ctrl(fe, 1);
346 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
353 /* ------------------------------------------------------------------ */
355 static struct tda1004x_config philips_tu1216_60_config = {
356 .demod_address = 0x8,
359 .xtal_freq = TDA10046_XTAL_4M,
360 .agc_config = TDA10046_AGC_DEFAULT,
361 .if_freq = TDA10046_FREQ_3617,
362 .tuner_address = 0x60,
363 .request_firmware = philips_tda1004x_request_firmware
366 static struct tda1004x_config philips_tu1216_61_config = {
368 .demod_address = 0x8,
371 .xtal_freq = TDA10046_XTAL_4M,
372 .agc_config = TDA10046_AGC_DEFAULT,
373 .if_freq = TDA10046_FREQ_3617,
374 .tuner_address = 0x61,
375 .request_firmware = philips_tda1004x_request_firmware
378 /* ------------------------------------------------------------------ */
380 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
382 struct saa7134_dev *dev = fe->dvb->priv;
383 struct tda1004x_state *state = fe->demodulator_priv;
384 u8 addr = state->config->tuner_address;
385 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
386 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
388 /* setup PLL configuration */
389 if (fe->ops.i2c_gate_ctrl)
390 fe->ops.i2c_gate_ctrl(fe, 1);
391 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
396 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
398 return philips_tda6651_pll_set(fe, params);
401 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
403 struct saa7134_dev *dev = fe->dvb->priv;
404 struct tda1004x_state *state = fe->demodulator_priv;
405 u8 addr = state->config->tuner_address;
406 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
407 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
409 /* switch the tuner to analog mode */
410 if (fe->ops.i2c_gate_ctrl)
411 fe->ops.i2c_gate_ctrl(fe, 1);
412 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
417 /* ------------------------------------------------------------------ */
419 static int philips_europa_tuner_init(struct dvb_frontend *fe)
421 struct saa7134_dev *dev = fe->dvb->priv;
422 static u8 msg[] = { 0x00, 0x40};
423 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
426 if (philips_td1316_tuner_init(fe))
429 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
435 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
437 struct saa7134_dev *dev = fe->dvb->priv;
439 static u8 msg[] = { 0x00, 0x14 };
440 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
442 if (philips_td1316_tuner_sleep(fe))
445 /* switch the board to analog mode */
446 if (fe->ops.i2c_gate_ctrl)
447 fe->ops.i2c_gate_ctrl(fe, 1);
448 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
452 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
454 struct saa7134_dev *dev = fe->dvb->priv;
456 if (dev->original_demod_sleep)
457 dev->original_demod_sleep(fe);
458 fe->ops.i2c_gate_ctrl(fe, 1);
462 static struct tda1004x_config philips_europa_config = {
464 .demod_address = 0x8,
467 .xtal_freq = TDA10046_XTAL_4M,
468 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
469 .if_freq = TDA10046_FREQ_052,
470 .tuner_address = 0x61,
471 .request_firmware = philips_tda1004x_request_firmware
474 static struct tda1004x_config medion_cardbus = {
475 .demod_address = 0x08,
478 .xtal_freq = TDA10046_XTAL_16M,
479 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
480 .if_freq = TDA10046_FREQ_3613,
481 .tuner_address = 0x61,
482 .request_firmware = philips_tda1004x_request_firmware
485 /* ------------------------------------------------------------------
486 * tda 1004x based cards with philips silicon tuner
489 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
491 struct tda1004x_state *state = fe->demodulator_priv;
493 u8 addr = state->config->i2c_gate;
494 static u8 tda8290_close[] = { 0x21, 0xc0};
495 static u8 tda8290_open[] = { 0x21, 0x80};
496 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
498 tda8290_msg.buf = tda8290_close;
500 tda8290_msg.buf = tda8290_open;
502 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
503 struct saa7134_dev *dev = fe->dvb->priv;
504 wprintk("could not access tda8290 I2C gate\n");
511 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
513 struct saa7134_dev *dev = fe->dvb->priv;
514 struct tda1004x_state *state = fe->demodulator_priv;
516 switch (state->config->antenna_switch) {
518 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
519 saa7134_set_gpio(dev, 21, 0);
521 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
522 saa7134_set_gpio(dev, 21, 1);
528 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
530 struct saa7134_dev *dev = fe->dvb->priv;
531 struct tda1004x_state *state = fe->demodulator_priv;
533 switch (state->config->antenna_switch) {
535 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
536 saa7134_set_gpio(dev, 21, 1);
538 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
539 saa7134_set_gpio(dev, 21, 0);
545 static int configure_tda827x_fe(struct saa7134_dev *dev,
546 struct tda1004x_config *cdec_conf,
547 struct tda827x_config *tuner_conf)
549 struct videobuf_dvb_frontend *fe0;
551 /* Get the first frontend */
552 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
554 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
555 if (fe0->dvb.frontend) {
556 if (cdec_conf->i2c_gate)
557 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
558 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
559 cdec_conf->tuner_address,
560 &dev->i2c_adap, tuner_conf))
563 wprintk("no tda827x tuner found at addr: %02x\n",
564 cdec_conf->tuner_address);
569 /* ------------------------------------------------------------------ */
571 static struct tda827x_config tda827x_cfg_0 = {
572 .init = philips_tda827x_tuner_init,
573 .sleep = philips_tda827x_tuner_sleep,
578 static struct tda827x_config tda827x_cfg_1 = {
579 .init = philips_tda827x_tuner_init,
580 .sleep = philips_tda827x_tuner_sleep,
585 static struct tda827x_config tda827x_cfg_2 = {
586 .init = philips_tda827x_tuner_init,
587 .sleep = philips_tda827x_tuner_sleep,
592 static struct tda827x_config tda827x_cfg_2_sw42 = {
593 .init = philips_tda827x_tuner_init,
594 .sleep = philips_tda827x_tuner_sleep,
599 /* ------------------------------------------------------------------ */
601 static struct tda1004x_config tda827x_lifeview_config = {
602 .demod_address = 0x08,
605 .xtal_freq = TDA10046_XTAL_16M,
606 .agc_config = TDA10046_AGC_TDA827X,
607 .gpio_config = TDA10046_GP11_I,
608 .if_freq = TDA10046_FREQ_045,
609 .tuner_address = 0x60,
610 .request_firmware = philips_tda1004x_request_firmware
613 static struct tda1004x_config philips_tiger_config = {
614 .demod_address = 0x08,
617 .xtal_freq = TDA10046_XTAL_16M,
618 .agc_config = TDA10046_AGC_TDA827X,
619 .gpio_config = TDA10046_GP11_I,
620 .if_freq = TDA10046_FREQ_045,
622 .tuner_address = 0x61,
624 .request_firmware = philips_tda1004x_request_firmware
627 static struct tda1004x_config cinergy_ht_config = {
628 .demod_address = 0x08,
631 .xtal_freq = TDA10046_XTAL_16M,
632 .agc_config = TDA10046_AGC_TDA827X,
633 .gpio_config = TDA10046_GP01_I,
634 .if_freq = TDA10046_FREQ_045,
636 .tuner_address = 0x61,
637 .request_firmware = philips_tda1004x_request_firmware
640 static struct tda1004x_config cinergy_ht_pci_config = {
641 .demod_address = 0x08,
644 .xtal_freq = TDA10046_XTAL_16M,
645 .agc_config = TDA10046_AGC_TDA827X,
646 .gpio_config = TDA10046_GP01_I,
647 .if_freq = TDA10046_FREQ_045,
649 .tuner_address = 0x60,
650 .request_firmware = philips_tda1004x_request_firmware
653 static struct tda1004x_config philips_tiger_s_config = {
654 .demod_address = 0x08,
657 .xtal_freq = TDA10046_XTAL_16M,
658 .agc_config = TDA10046_AGC_TDA827X,
659 .gpio_config = TDA10046_GP01_I,
660 .if_freq = TDA10046_FREQ_045,
662 .tuner_address = 0x61,
664 .request_firmware = philips_tda1004x_request_firmware
667 static struct tda1004x_config pinnacle_pctv_310i_config = {
668 .demod_address = 0x08,
671 .xtal_freq = TDA10046_XTAL_16M,
672 .agc_config = TDA10046_AGC_TDA827X,
673 .gpio_config = TDA10046_GP11_I,
674 .if_freq = TDA10046_FREQ_045,
676 .tuner_address = 0x61,
677 .request_firmware = philips_tda1004x_request_firmware
680 static struct tda1004x_config hauppauge_hvr_1110_config = {
681 .demod_address = 0x08,
684 .xtal_freq = TDA10046_XTAL_16M,
685 .agc_config = TDA10046_AGC_TDA827X,
686 .gpio_config = TDA10046_GP11_I,
687 .if_freq = TDA10046_FREQ_045,
689 .tuner_address = 0x61,
690 .request_firmware = philips_tda1004x_request_firmware
693 static struct tda1004x_config asus_p7131_dual_config = {
694 .demod_address = 0x08,
697 .xtal_freq = TDA10046_XTAL_16M,
698 .agc_config = TDA10046_AGC_TDA827X,
699 .gpio_config = TDA10046_GP11_I,
700 .if_freq = TDA10046_FREQ_045,
702 .tuner_address = 0x61,
704 .request_firmware = philips_tda1004x_request_firmware
707 static struct tda1004x_config lifeview_trio_config = {
708 .demod_address = 0x09,
711 .xtal_freq = TDA10046_XTAL_16M,
712 .agc_config = TDA10046_AGC_TDA827X,
713 .gpio_config = TDA10046_GP00_I,
714 .if_freq = TDA10046_FREQ_045,
715 .tuner_address = 0x60,
716 .request_firmware = philips_tda1004x_request_firmware
719 static struct tda1004x_config tevion_dvbt220rf_config = {
720 .demod_address = 0x08,
723 .xtal_freq = TDA10046_XTAL_16M,
724 .agc_config = TDA10046_AGC_TDA827X,
725 .gpio_config = TDA10046_GP11_I,
726 .if_freq = TDA10046_FREQ_045,
727 .tuner_address = 0x60,
728 .request_firmware = philips_tda1004x_request_firmware
731 static struct tda1004x_config md8800_dvbt_config = {
732 .demod_address = 0x08,
735 .xtal_freq = TDA10046_XTAL_16M,
736 .agc_config = TDA10046_AGC_TDA827X,
737 .gpio_config = TDA10046_GP01_I,
738 .if_freq = TDA10046_FREQ_045,
740 .tuner_address = 0x60,
741 .request_firmware = philips_tda1004x_request_firmware
744 static struct tda1004x_config asus_p7131_4871_config = {
745 .demod_address = 0x08,
748 .xtal_freq = TDA10046_XTAL_16M,
749 .agc_config = TDA10046_AGC_TDA827X,
750 .gpio_config = TDA10046_GP01_I,
751 .if_freq = TDA10046_FREQ_045,
753 .tuner_address = 0x61,
755 .request_firmware = philips_tda1004x_request_firmware
758 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
759 .demod_address = 0x08,
762 .xtal_freq = TDA10046_XTAL_16M,
763 .agc_config = TDA10046_AGC_TDA827X,
764 .gpio_config = TDA10046_GP11_I,
765 .if_freq = TDA10046_FREQ_045,
767 .tuner_address = 0x61,
769 .request_firmware = philips_tda1004x_request_firmware
772 static struct tda1004x_config kworld_dvb_t_210_config = {
773 .demod_address = 0x08,
776 .xtal_freq = TDA10046_XTAL_16M,
777 .agc_config = TDA10046_AGC_TDA827X,
778 .gpio_config = TDA10046_GP11_I,
779 .if_freq = TDA10046_FREQ_045,
781 .tuner_address = 0x61,
783 .request_firmware = philips_tda1004x_request_firmware
786 static struct tda1004x_config avermedia_super_007_config = {
787 .demod_address = 0x08,
790 .xtal_freq = TDA10046_XTAL_16M,
791 .agc_config = TDA10046_AGC_TDA827X,
792 .gpio_config = TDA10046_GP01_I,
793 .if_freq = TDA10046_FREQ_045,
795 .tuner_address = 0x60,
797 .request_firmware = philips_tda1004x_request_firmware
800 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
801 .demod_address = 0x08,
804 .xtal_freq = TDA10046_XTAL_16M,
805 .agc_config = TDA10046_AGC_TDA827X,
806 .gpio_config = TDA10046_GP01_I,
807 .if_freq = TDA10046_FREQ_045,
809 .tuner_address = 0x61,
811 .request_firmware = philips_tda1004x_request_firmware
814 static struct tda1004x_config asus_tiger_3in1_config = {
815 .demod_address = 0x0b,
818 .xtal_freq = TDA10046_XTAL_16M,
819 .agc_config = TDA10046_AGC_TDA827X,
820 .gpio_config = TDA10046_GP11_I,
821 .if_freq = TDA10046_FREQ_045,
823 .tuner_address = 0x61,
825 .request_firmware = philips_tda1004x_request_firmware
828 /* ------------------------------------------------------------------
829 * special case: this card uses saa713x GPIO22 for the mode switch
832 static int ads_duo_tuner_init(struct dvb_frontend *fe)
834 struct saa7134_dev *dev = fe->dvb->priv;
835 philips_tda827x_tuner_init(fe);
836 /* route TDA8275a AGC input to the channel decoder */
837 saa7134_set_gpio(dev, 22, 1);
841 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
843 struct saa7134_dev *dev = fe->dvb->priv;
844 /* route TDA8275a AGC input to the analog IF chip*/
845 saa7134_set_gpio(dev, 22, 0);
846 philips_tda827x_tuner_sleep(fe);
850 static struct tda827x_config ads_duo_cfg = {
851 .init = ads_duo_tuner_init,
852 .sleep = ads_duo_tuner_sleep,
856 static struct tda1004x_config ads_tech_duo_config = {
857 .demod_address = 0x08,
860 .xtal_freq = TDA10046_XTAL_16M,
861 .agc_config = TDA10046_AGC_TDA827X,
862 .gpio_config = TDA10046_GP00_I,
863 .if_freq = TDA10046_FREQ_045,
864 .tuner_address = 0x61,
865 .request_firmware = philips_tda1004x_request_firmware
868 static struct zl10353_config behold_h6_config = {
869 .demod_address = 0x1e>>1,
872 .disable_i2c_gate_ctrl = 1,
875 static struct xc5000_config behold_x7_tunerconfig = {
876 .i2c_address = 0xc2>>1,
878 .radio_input = XC5000_RADIO_FM1,
881 static struct zl10353_config behold_x7_config = {
882 .demod_address = 0x1e>>1,
886 .disable_i2c_gate_ctrl = 1,
889 /* ==================================================================
890 * tda10086 based DVB-S cards, helper functions
893 static struct tda10086_config flydvbs = {
894 .demod_address = 0x0e,
897 .xtal_freq = TDA10086_XTAL_16M,
900 static struct tda10086_config sd1878_4m = {
901 .demod_address = 0x0e,
904 .xtal_freq = TDA10086_XTAL_4M,
907 /* ------------------------------------------------------------------
908 * special case: lnb supply is connected to the gated i2c
911 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
914 struct saa7134_dev *dev = fe->dvb->priv;
915 if (fe->ops.i2c_gate_ctrl) {
916 fe->ops.i2c_gate_ctrl(fe, 1);
917 if (dev->original_set_voltage)
918 res = dev->original_set_voltage(fe, voltage);
919 fe->ops.i2c_gate_ctrl(fe, 0);
924 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
927 struct saa7134_dev *dev = fe->dvb->priv;
928 if (fe->ops.i2c_gate_ctrl) {
929 fe->ops.i2c_gate_ctrl(fe, 1);
930 if (dev->original_set_high_voltage)
931 res = dev->original_set_high_voltage(fe, arg);
932 fe->ops.i2c_gate_ctrl(fe, 0);
937 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
939 struct saa7134_dev *dev = fe->dvb->priv;
940 u8 wbuf[2] = { 0x1f, 00 };
942 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
943 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
945 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
947 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
948 if (voltage == SEC_VOLTAGE_18)
949 wbuf[1] = rbuf | 0x10;
951 wbuf[1] = rbuf & 0xef;
953 i2c_transfer(&dev->i2c_adap, msg, 1);
957 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
959 struct saa7134_dev *dev = fe->dvb->priv;
960 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
964 /* ==================================================================
965 * nxt200x based ATSC cards, helper functions
968 static struct nxt200x_config avertvhda180 = {
969 .demod_address = 0x0a,
972 static struct nxt200x_config kworldatsc110 = {
973 .demod_address = 0x0a,
976 /* ------------------------------------------------------------------ */
978 static struct mt312_config avertv_a700_mt312 = {
979 .demod_address = 0x0e,
980 .voltage_inverted = 1,
983 static struct zl10036_config avertv_a700_tuner = {
984 .tuner_address = 0x60,
987 static struct mt312_config zl10313_compro_s350_config = {
988 .demod_address = 0x0e,
991 static struct lgdt3305_config hcw_lgdt3305_config = {
993 .mpeg_mode = LGDT3305_MPEG_SERIAL,
994 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
995 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
997 .spectral_inversion = 1,
1002 static struct tda10048_config hcw_tda10048_config = {
1003 .demod_address = 0x10 >> 1,
1004 .output_mode = TDA10048_SERIAL_OUTPUT,
1005 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1006 .inversion = TDA10048_INVERSION_ON,
1007 .dtv6_if_freq_khz = TDA10048_IF_3300,
1008 .dtv7_if_freq_khz = TDA10048_IF_3500,
1009 .dtv8_if_freq_khz = TDA10048_IF_4000,
1010 .clk_freq_khz = TDA10048_CLK_16000,
1011 .disable_gate_access = 1,
1014 static struct tda18271_std_map hauppauge_tda18271_std_map = {
1015 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1016 .if_lvl = 1, .rfagc_top = 0x58, },
1017 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1018 .if_lvl = 1, .rfagc_top = 0x58, },
1021 static struct tda18271_config hcw_tda18271_config = {
1022 .std_map = &hauppauge_tda18271_std_map,
1023 .gate = TDA18271_GATE_ANALOG,
1025 .output_opt = TDA18271_OUTPUT_LT_OFF,
1028 static struct tda829x_config tda829x_no_probe = {
1029 .probe_tuner = TDA829X_DONT_PROBE,
1032 static struct tda10048_config zolid_tda10048_config = {
1033 .demod_address = 0x10 >> 1,
1034 .output_mode = TDA10048_PARALLEL_OUTPUT,
1035 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1036 .inversion = TDA10048_INVERSION_ON,
1037 .dtv6_if_freq_khz = TDA10048_IF_3300,
1038 .dtv7_if_freq_khz = TDA10048_IF_3500,
1039 .dtv8_if_freq_khz = TDA10048_IF_4000,
1040 .clk_freq_khz = TDA10048_CLK_16000,
1041 .disable_gate_access = 1,
1044 static struct tda18271_config zolid_tda18271_config = {
1045 .gate = TDA18271_GATE_ANALOG,
1048 /* ==================================================================
1052 static int dvb_init(struct saa7134_dev *dev)
1055 int attach_xc3028 = 0;
1056 struct videobuf_dvb_frontend *fe0;
1058 /* FIXME: add support for multi-frontend */
1059 mutex_init(&dev->frontends.lock);
1060 INIT_LIST_HEAD(&dev->frontends.felist);
1062 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
1063 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1065 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1069 /* init struct videobuf_dvb */
1070 dev->ts.nr_bufs = 32;
1071 dev->ts.nr_packets = 32*4;
1072 fe0->dvb.name = dev->name;
1073 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
1074 &dev->pci->dev, &dev->slock,
1075 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1076 V4L2_FIELD_ALTERNATE,
1077 sizeof(struct saa7134_buf),
1080 switch (dev->board) {
1081 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1082 dprintk("pinnacle 300i dvb setup\n");
1083 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1085 if (fe0->dvb.frontend) {
1086 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1089 case SAA7134_BOARD_AVERMEDIA_777:
1090 case SAA7134_BOARD_AVERMEDIA_A16AR:
1091 dprintk("avertv 777 dvb setup\n");
1092 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1094 if (fe0->dvb.frontend) {
1095 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1096 &dev->i2c_adap, 0x61,
1097 TUNER_PHILIPS_TD1316);
1100 case SAA7134_BOARD_AVERMEDIA_A16D:
1101 dprintk("AverMedia A16D dvb setup\n");
1102 fe0->dvb.frontend = dvb_attach(mt352_attach,
1103 &avermedia_xc3028_mt352_dev,
1107 case SAA7134_BOARD_MD7134:
1108 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1111 if (fe0->dvb.frontend) {
1112 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1113 &dev->i2c_adap, medion_cardbus.tuner_address,
1114 TUNER_PHILIPS_FMD1216ME_MK3);
1117 case SAA7134_BOARD_PHILIPS_TOUGH:
1118 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1119 &philips_tu1216_60_config,
1121 if (fe0->dvb.frontend) {
1122 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1123 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1126 case SAA7134_BOARD_FLYDVBTDUO:
1127 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1128 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1129 &tda827x_cfg_0) < 0)
1130 goto dettach_frontend;
1132 case SAA7134_BOARD_PHILIPS_EUROPA:
1133 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1134 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
1135 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1136 &philips_europa_config,
1138 if (fe0->dvb.frontend) {
1139 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1140 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1141 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1142 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1143 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1146 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1147 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1148 &philips_tu1216_61_config,
1150 if (fe0->dvb.frontend) {
1151 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1152 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1155 case SAA7134_BOARD_KWORLD_DVBT_210:
1156 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1157 &tda827x_cfg_2) < 0)
1158 goto dettach_frontend;
1160 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1161 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1162 &hcw_tda10048_config,
1164 if (fe0->dvb.frontend != NULL) {
1165 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1166 &dev->i2c_adap, 0x4b,
1168 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1169 0x60, &dev->i2c_adap,
1170 &hcw_tda18271_config);
1173 case SAA7134_BOARD_PHILIPS_TIGER:
1174 if (configure_tda827x_fe(dev, &philips_tiger_config,
1175 &tda827x_cfg_0) < 0)
1176 goto dettach_frontend;
1178 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1179 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1180 &tda827x_cfg_1) < 0)
1181 goto dettach_frontend;
1183 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1184 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1185 &tda827x_cfg_1) < 0)
1186 goto dettach_frontend;
1188 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
1189 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1190 &hcw_lgdt3305_config,
1192 if (fe0->dvb.frontend) {
1193 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1194 &dev->i2c_adap, 0x4b,
1196 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1197 0x60, &dev->i2c_adap,
1198 &hcw_tda18271_config);
1201 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1202 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1203 &tda827x_cfg_0) < 0)
1204 goto dettach_frontend;
1206 case SAA7134_BOARD_FLYDVBT_LR301:
1207 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1208 &tda827x_cfg_0) < 0)
1209 goto dettach_frontend;
1211 case SAA7134_BOARD_FLYDVB_TRIO:
1212 if (!use_frontend) { /* terrestrial */
1213 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1214 &tda827x_cfg_0) < 0)
1215 goto dettach_frontend;
1216 } else { /* satellite */
1217 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1218 if (fe0->dvb.frontend) {
1219 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1220 &dev->i2c_adap, 0) == NULL) {
1221 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1222 goto dettach_frontend;
1224 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1225 0x08, 0, 0) == NULL) {
1226 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1227 goto dettach_frontend;
1232 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1233 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1234 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1235 &ads_tech_duo_config,
1237 if (fe0->dvb.frontend) {
1238 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1239 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1240 &ads_duo_cfg) == NULL) {
1241 wprintk("no tda827x tuner found at addr: %02x\n",
1242 ads_tech_duo_config.tuner_address);
1243 goto dettach_frontend;
1246 wprintk("failed to attach tda10046\n");
1248 case SAA7134_BOARD_TEVION_DVBT_220RF:
1249 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1250 &tda827x_cfg_0) < 0)
1251 goto dettach_frontend;
1253 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1254 if (!use_frontend) { /* terrestrial */
1255 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1256 &tda827x_cfg_0) < 0)
1257 goto dettach_frontend;
1258 } else { /* satellite */
1259 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1260 &flydvbs, &dev->i2c_adap);
1261 if (fe0->dvb.frontend) {
1262 struct dvb_frontend *fe = fe0->dvb.frontend;
1263 u8 dev_id = dev->eedata[2];
1265 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1267 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1268 0x60, &dev->i2c_adap, 0) == NULL) {
1269 wprintk("%s: Medion Quadro, no tda826x "
1270 "found !\n", __func__);
1271 goto dettach_frontend;
1273 if (dev_id != 0x08) {
1274 /* we need to open the i2c gate (we know it exists) */
1275 fe->ops.i2c_gate_ctrl(fe, 1);
1276 if (dvb_attach(isl6405_attach, fe,
1277 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1278 wprintk("%s: Medion Quadro, no ISL6405 "
1279 "found !\n", __func__);
1280 goto dettach_frontend;
1282 if (dev_id == 0x07) {
1283 /* fire up the 2nd section of the LNB supply since
1284 we can't do this from the other section */
1286 i2c_transfer(&dev->i2c_adap, &msg, 1);
1288 fe->ops.i2c_gate_ctrl(fe, 0);
1289 dev->original_set_voltage = fe->ops.set_voltage;
1290 fe->ops.set_voltage = md8800_set_voltage;
1291 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1292 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1294 fe->ops.set_voltage = md8800_set_voltage2;
1295 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1300 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1301 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1303 if (fe0->dvb.frontend)
1304 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1305 NULL, DVB_PLL_TDHU2);
1307 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1308 case SAA7134_BOARD_KWORLD_ATSC110:
1309 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1311 if (fe0->dvb.frontend)
1312 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1313 &dev->i2c_adap, 0x61,
1314 TUNER_PHILIPS_TUV1236D);
1316 case SAA7134_BOARD_FLYDVBS_LR300:
1317 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1319 if (fe0->dvb.frontend) {
1320 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1321 &dev->i2c_adap, 0) == NULL) {
1322 wprintk("%s: No tda826x found!\n", __func__);
1323 goto dettach_frontend;
1325 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1326 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1327 wprintk("%s: No ISL6421 found!\n", __func__);
1328 goto dettach_frontend;
1332 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1333 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1336 if (fe0->dvb.frontend) {
1337 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1338 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1340 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1341 &dev->i2c_adap, medion_cardbus.tuner_address,
1342 TUNER_PHILIPS_FMD1216ME_MK3);
1345 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1346 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1347 &philips_europa_config,
1349 if (fe0->dvb.frontend) {
1350 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1351 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1354 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1355 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1356 &tda827x_cfg_0) < 0)
1357 goto dettach_frontend;
1359 case SAA7134_BOARD_CINERGY_HT_PCI:
1360 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1361 &tda827x_cfg_0) < 0)
1362 goto dettach_frontend;
1364 case SAA7134_BOARD_PHILIPS_TIGER_S:
1365 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1366 &tda827x_cfg_2) < 0)
1367 goto dettach_frontend;
1369 case SAA7134_BOARD_ASUS_P7131_4871:
1370 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1371 &tda827x_cfg_2) < 0)
1372 goto dettach_frontend;
1374 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1375 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1376 &tda827x_cfg_2) < 0)
1377 goto dettach_frontend;
1379 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1380 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1381 &tda827x_cfg_0) < 0)
1382 goto dettach_frontend;
1384 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1385 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1386 &tda827x_cfg_2_sw42) < 0)
1387 goto dettach_frontend;
1389 case SAA7134_BOARD_PHILIPS_SNAKE:
1390 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1392 if (fe0->dvb.frontend) {
1393 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1394 &dev->i2c_adap, 0) == NULL) {
1395 wprintk("%s: No tda826x found!\n", __func__);
1396 goto dettach_frontend;
1398 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1399 &dev->i2c_adap, 0, 0) == NULL) {
1400 wprintk("%s: No lnbp21 found!\n", __func__);
1401 goto dettach_frontend;
1405 case SAA7134_BOARD_CREATIX_CTX953:
1406 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1407 &tda827x_cfg_0) < 0)
1408 goto dettach_frontend;
1410 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1411 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1412 &tda827x_cfg_2) < 0)
1413 goto dettach_frontend;
1415 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1416 dprintk("AverMedia E506R dvb setup\n");
1417 saa7134_set_gpio(dev, 25, 0);
1419 saa7134_set_gpio(dev, 25, 1);
1420 fe0->dvb.frontend = dvb_attach(mt352_attach,
1421 &avermedia_xc3028_mt352_dev,
1425 case SAA7134_BOARD_MD7134_BRIDGE_2:
1426 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1427 &sd1878_4m, &dev->i2c_adap);
1428 if (fe0->dvb.frontend) {
1429 struct dvb_frontend *fe;
1430 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1431 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1432 wprintk("%s: MD7134 DVB-S, no SD1878 "
1433 "found !\n", __func__);
1434 goto dettach_frontend;
1436 /* we need to open the i2c gate (we know it exists) */
1437 fe = fe0->dvb.frontend;
1438 fe->ops.i2c_gate_ctrl(fe, 1);
1439 if (dvb_attach(isl6405_attach, fe,
1440 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1441 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1442 "found !\n", __func__);
1443 goto dettach_frontend;
1445 fe->ops.i2c_gate_ctrl(fe, 0);
1446 dev->original_set_voltage = fe->ops.set_voltage;
1447 fe->ops.set_voltage = md8800_set_voltage;
1448 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1449 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1452 case SAA7134_BOARD_AVERMEDIA_M103:
1453 saa7134_set_gpio(dev, 25, 0);
1455 saa7134_set_gpio(dev, 25, 1);
1456 fe0->dvb.frontend = dvb_attach(mt352_attach,
1457 &avermedia_xc3028_mt352_dev,
1461 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1462 if (!use_frontend) { /* terrestrial */
1463 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1464 &tda827x_cfg_2) < 0)
1465 goto dettach_frontend;
1466 } else { /* satellite */
1467 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1468 &flydvbs, &dev->i2c_adap);
1469 if (fe0->dvb.frontend) {
1470 if (dvb_attach(tda826x_attach,
1471 fe0->dvb.frontend, 0x60,
1472 &dev->i2c_adap, 0) == NULL) {
1473 wprintk("%s: Asus Tiger 3in1, no "
1474 "tda826x found!\n", __func__);
1475 goto dettach_frontend;
1477 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1478 &dev->i2c_adap, 0, 0) == NULL) {
1479 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1480 " found!\n", __func__);
1481 goto dettach_frontend;
1486 case SAA7134_BOARD_ASUSTeK_TIGER:
1487 if (configure_tda827x_fe(dev, &philips_tiger_config,
1488 &tda827x_cfg_0) < 0)
1489 goto dettach_frontend;
1491 case SAA7134_BOARD_BEHOLD_H6:
1492 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1495 if (fe0->dvb.frontend) {
1496 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1497 &dev->i2c_adap, 0x61,
1498 TUNER_PHILIPS_FMD1216MEX_MK3);
1501 case SAA7134_BOARD_BEHOLD_X7:
1502 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1505 if (fe0->dvb.frontend) {
1506 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1507 &dev->i2c_adap, &behold_x7_tunerconfig);
1510 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1511 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1512 /* Zarlink ZL10313 */
1513 fe0->dvb.frontend = dvb_attach(mt312_attach,
1514 &avertv_a700_mt312, &dev->i2c_adap);
1515 if (fe0->dvb.frontend) {
1516 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1517 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1518 wprintk("%s: No zl10036 found!\n",
1523 case SAA7134_BOARD_VIDEOMATE_S350:
1524 fe0->dvb.frontend = dvb_attach(mt312_attach,
1525 &zl10313_compro_s350_config, &dev->i2c_adap);
1526 if (fe0->dvb.frontend)
1527 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1528 0x60, &dev->i2c_adap) == NULL)
1529 wprintk("%s: No zl10039 found!\n",
1533 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1534 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1535 &zolid_tda10048_config,
1537 if (fe0->dvb.frontend != NULL) {
1538 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1539 &dev->i2c_adap, 0x4b,
1541 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1542 0x60, &dev->i2c_adap,
1543 &zolid_tda18271_config);
1547 wprintk("Huh? unknown DVB card?\n");
1551 if (attach_xc3028) {
1552 struct dvb_frontend *fe;
1553 struct xc2028_config cfg = {
1554 .i2c_adap = &dev->i2c_adap,
1558 if (!fe0->dvb.frontend)
1559 goto dettach_frontend;
1561 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1563 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1565 goto dettach_frontend;
1569 if (NULL == fe0->dvb.frontend) {
1570 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1571 goto dettach_frontend;
1573 /* define general-purpose callback pointer */
1574 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1576 /* register everything else */
1577 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1578 &dev->pci->dev, adapter_nr, 0, NULL);
1580 /* this sequence is necessary to make the tda1004x load its firmware
1581 * and to enter analog mode of hybrid boards
1584 if (fe0->dvb.frontend->ops.init)
1585 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1586 if (fe0->dvb.frontend->ops.sleep)
1587 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1588 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1589 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1594 videobuf_dvb_dealloc_frontends(&dev->frontends);
1598 static int dvb_fini(struct saa7134_dev *dev)
1600 struct videobuf_dvb_frontend *fe0;
1602 /* Get the first frontend */
1603 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1607 /* FIXME: I suspect that this code is bogus, since the entry for
1608 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1609 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1611 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1612 struct v4l2_priv_tun_config tda9887_cfg;
1613 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1615 tda9887_cfg.tuner = TUNER_TDA9887;
1616 tda9887_cfg.priv = &on;
1618 /* otherwise we don't detect the tuner on next insmod */
1619 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1620 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1621 if ((dev->eedata[2] == 0x07) && use_frontend) {
1622 /* turn off the 2nd lnb supply */
1624 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1625 struct dvb_frontend *fe;
1626 fe = fe0->dvb.frontend;
1627 if (fe->ops.i2c_gate_ctrl) {
1628 fe->ops.i2c_gate_ctrl(fe, 1);
1629 i2c_transfer(&dev->i2c_adap, &msg, 1);
1630 fe->ops.i2c_gate_ctrl(fe, 0);
1634 videobuf_dvb_unregister_bus(&dev->frontends);
1638 static struct saa7134_mpeg_ops dvb_ops = {
1639 .type = SAA7134_MPEG_DVB,
1644 static int __init dvb_register(void)
1646 return saa7134_ts_register(&dvb_ops);
1649 static void __exit dvb_unregister(void)
1651 saa7134_ts_unregister(&dvb_ops);
1654 module_init(dvb_register);
1655 module_exit(dvb_unregister);
1657 /* ------------------------------------------------------------------ */