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/delay.h>
28 #include <linux/kthread.h>
29 #include <linux/suspend.h>
31 #include "saa7134-reg.h"
33 #include <media/v4l2-common.h>
35 #include <dvb_frontend.h>
38 #include "mt352_priv.h" /* FIXME */
41 #include "tuner-xc2028.h"
50 #include "tuner-simple.h"
66 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
67 MODULE_LICENSE("GPL");
69 static unsigned int antenna_pwr;
71 module_param(antenna_pwr, int, 0444);
72 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
74 static int use_frontend;
75 module_param(use_frontend, int, 0644);
76 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
79 module_param(debug, int, 0644);
80 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
82 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
84 #define dprintk(fmt, arg...) do { if (debug) \
85 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
88 #define wprintk(fmt, arg...) \
89 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
91 /* ------------------------------------------------------------------
92 * mt352 based DVB-T cards
95 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
100 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
101 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
105 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
106 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
109 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
110 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
112 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
114 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
115 dprintk("%s %s\n", __func__, ok ? "on" : "off");
118 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
122 static int mt352_pinnacle_init(struct dvb_frontend* fe)
124 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
125 static u8 reset [] = { RESET, 0x80 };
126 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
127 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
128 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
129 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
130 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
131 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
132 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
133 struct saa7134_dev *dev= fe->dvb->priv;
135 dprintk("%s called\n", __func__);
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));
141 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
142 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
143 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
145 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
146 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
147 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
152 static int mt352_aver777_init(struct dvb_frontend* fe)
154 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
155 static u8 reset [] = { RESET, 0x80 };
156 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
157 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
158 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
160 mt352_write(fe, clock_config, sizeof(clock_config));
162 mt352_write(fe, reset, sizeof(reset));
163 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
164 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
165 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
170 static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
172 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
173 static u8 reset [] = { RESET, 0x80 };
174 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
175 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
176 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
178 mt352_write(fe, clock_config, sizeof(clock_config));
180 mt352_write(fe, reset, sizeof(reset));
181 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
182 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
183 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
187 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend *fe)
189 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
190 u8 off[] = { 0x00, 0xf1};
191 u8 on[] = { 0x00, 0x71};
192 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
194 struct saa7134_dev *dev = fe->dvb->priv;
195 struct v4l2_frequency f;
197 /* set frequency (mt2050) */
199 f.type = V4L2_TUNER_DIGITAL_TV;
200 f.frequency = c->frequency / 1000 * 16 / 1000;
201 if (fe->ops.i2c_gate_ctrl)
202 fe->ops.i2c_gate_ctrl(fe, 1);
203 i2c_transfer(&dev->i2c_adap, &msg, 1);
204 saa_call_all(dev, tuner, s_frequency, &f);
206 if (fe->ops.i2c_gate_ctrl)
207 fe->ops.i2c_gate_ctrl(fe, 1);
208 i2c_transfer(&dev->i2c_adap, &msg, 1);
210 pinnacle_antenna_pwr(dev, antenna_pwr);
213 return mt352_pinnacle_init(fe);
216 static struct mt352_config pinnacle_300i = {
217 .demod_address = 0x3c >> 1,
221 .demod_init = mt352_pinnacle_init,
224 static struct mt352_config avermedia_777 = {
225 .demod_address = 0xf,
226 .demod_init = mt352_aver777_init,
229 static struct mt352_config avermedia_xc3028_mt352_dev = {
230 .demod_address = (0x1e >> 1),
232 .demod_init = mt352_avermedia_xc3028_init,
235 static struct tda18271_std_map mb86a20s_tda18271_std_map = {
236 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
237 .if_lvl = 7, .rfagc_top = 0x37, },
240 static struct tda18271_config kworld_tda18271_config = {
241 .std_map = &mb86a20s_tda18271_std_map,
242 .gate = TDA18271_GATE_DIGITAL,
243 .config = 3, /* Use tuner callback for AGC */
247 static const struct mb86a20s_config kworld_mb86a20s_config = {
248 .demod_address = 0x10,
251 static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
253 struct saa7134_dev *dev = fe->dvb->priv;
255 unsigned char initmsg[] = {0x45, 0x97};
256 unsigned char msg_enable[] = {0x45, 0xc1};
257 unsigned char msg_disable[] = {0x45, 0x81};
258 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
260 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
261 wprintk("could not access the I2C gate\n");
265 msg.buf = msg_enable;
267 msg.buf = msg_disable;
268 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
269 wprintk("could not access the I2C gate\n");
276 /* ==================================================================
277 * tda1004x based DVB-T cards, helper functions
280 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
281 const struct firmware **fw, char *name)
283 struct saa7134_dev *dev = fe->dvb->priv;
284 return request_firmware(fw, name, &dev->pci->dev);
287 /* ------------------------------------------------------------------
288 * these tuners are tu1216, td1316(a)
291 static int philips_tda6651_pll_set(struct dvb_frontend *fe)
293 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
294 struct saa7134_dev *dev = fe->dvb->priv;
295 struct tda1004x_state *state = fe->demodulator_priv;
296 u8 addr = state->config->tuner_address;
298 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
300 int tuner_frequency = 0;
303 /* determine charge pump */
304 tuner_frequency = c->frequency + 36166000;
305 if (tuner_frequency < 87000000)
307 else if (tuner_frequency < 130000000)
309 else if (tuner_frequency < 160000000)
311 else if (tuner_frequency < 200000000)
313 else if (tuner_frequency < 290000000)
315 else if (tuner_frequency < 420000000)
317 else if (tuner_frequency < 480000000)
319 else if (tuner_frequency < 620000000)
321 else if (tuner_frequency < 830000000)
323 else if (tuner_frequency < 895000000)
329 if (c->frequency < 49000000)
331 else if (c->frequency < 161000000)
333 else if (c->frequency < 444000000)
335 else if (c->frequency < 861000000)
340 /* setup PLL filter */
341 switch (c->bandwidth_hz) {
359 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
361 tuner_frequency = (((c->frequency / 1000) * 6) + 217496) / 1000;
363 /* setup tuner buffer */
364 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
365 tuner_buf[1] = tuner_frequency & 0xff;
367 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
369 if (fe->ops.i2c_gate_ctrl)
370 fe->ops.i2c_gate_ctrl(fe, 1);
371 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
372 wprintk("could not write to tuner at addr: 0x%02x\n",
380 static int philips_tu1216_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 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
386 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
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, &tuner_msg, 1) != 1)
398 /* ------------------------------------------------------------------ */
400 static struct tda1004x_config philips_tu1216_60_config = {
401 .demod_address = 0x8,
404 .xtal_freq = TDA10046_XTAL_4M,
405 .agc_config = TDA10046_AGC_DEFAULT,
406 .if_freq = TDA10046_FREQ_3617,
407 .tuner_address = 0x60,
408 .request_firmware = philips_tda1004x_request_firmware
411 static struct tda1004x_config philips_tu1216_61_config = {
413 .demod_address = 0x8,
416 .xtal_freq = TDA10046_XTAL_4M,
417 .agc_config = TDA10046_AGC_DEFAULT,
418 .if_freq = TDA10046_FREQ_3617,
419 .tuner_address = 0x61,
420 .request_firmware = philips_tda1004x_request_firmware
423 /* ------------------------------------------------------------------ */
425 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
427 struct saa7134_dev *dev = fe->dvb->priv;
428 struct tda1004x_state *state = fe->demodulator_priv;
429 u8 addr = state->config->tuner_address;
430 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
431 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
433 /* setup PLL configuration */
434 if (fe->ops.i2c_gate_ctrl)
435 fe->ops.i2c_gate_ctrl(fe, 1);
436 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
441 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe)
443 return philips_tda6651_pll_set(fe);
446 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
448 struct saa7134_dev *dev = fe->dvb->priv;
449 struct tda1004x_state *state = fe->demodulator_priv;
450 u8 addr = state->config->tuner_address;
451 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
452 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
454 /* switch the tuner to analog mode */
455 if (fe->ops.i2c_gate_ctrl)
456 fe->ops.i2c_gate_ctrl(fe, 1);
457 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
462 /* ------------------------------------------------------------------ */
464 static int philips_europa_tuner_init(struct dvb_frontend *fe)
466 struct saa7134_dev *dev = fe->dvb->priv;
467 static u8 msg[] = { 0x00, 0x40};
468 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
471 if (philips_td1316_tuner_init(fe))
474 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
480 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
482 struct saa7134_dev *dev = fe->dvb->priv;
484 static u8 msg[] = { 0x00, 0x14 };
485 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
487 if (philips_td1316_tuner_sleep(fe))
490 /* switch the board to analog mode */
491 if (fe->ops.i2c_gate_ctrl)
492 fe->ops.i2c_gate_ctrl(fe, 1);
493 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
497 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
499 struct saa7134_dev *dev = fe->dvb->priv;
501 if (dev->original_demod_sleep)
502 dev->original_demod_sleep(fe);
503 fe->ops.i2c_gate_ctrl(fe, 1);
507 static struct tda1004x_config philips_europa_config = {
509 .demod_address = 0x8,
512 .xtal_freq = TDA10046_XTAL_4M,
513 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
514 .if_freq = TDA10046_FREQ_052,
515 .tuner_address = 0x61,
516 .request_firmware = philips_tda1004x_request_firmware
519 static struct tda1004x_config medion_cardbus = {
520 .demod_address = 0x08,
523 .xtal_freq = TDA10046_XTAL_16M,
524 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
525 .if_freq = TDA10046_FREQ_3613,
526 .tuner_address = 0x61,
527 .request_firmware = philips_tda1004x_request_firmware
530 static struct tda1004x_config technotrend_budget_t3000_config = {
531 .demod_address = 0x8,
534 .xtal_freq = TDA10046_XTAL_4M,
535 .agc_config = TDA10046_AGC_DEFAULT,
536 .if_freq = TDA10046_FREQ_3617,
537 .tuner_address = 0x63,
538 .request_firmware = philips_tda1004x_request_firmware
541 /* ------------------------------------------------------------------
542 * tda 1004x based cards with philips silicon tuner
545 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
547 struct tda1004x_state *state = fe->demodulator_priv;
549 u8 addr = state->config->i2c_gate;
550 static u8 tda8290_close[] = { 0x21, 0xc0};
551 static u8 tda8290_open[] = { 0x21, 0x80};
552 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
554 tda8290_msg.buf = tda8290_close;
556 tda8290_msg.buf = tda8290_open;
558 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
559 struct saa7134_dev *dev = fe->dvb->priv;
560 wprintk("could not access tda8290 I2C gate\n");
567 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
569 struct saa7134_dev *dev = fe->dvb->priv;
570 struct tda1004x_state *state = fe->demodulator_priv;
572 switch (state->config->antenna_switch) {
574 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
575 saa7134_set_gpio(dev, 21, 0);
577 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
578 saa7134_set_gpio(dev, 21, 1);
584 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
586 struct saa7134_dev *dev = fe->dvb->priv;
587 struct tda1004x_state *state = fe->demodulator_priv;
589 switch (state->config->antenna_switch) {
591 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
592 saa7134_set_gpio(dev, 21, 1);
594 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
595 saa7134_set_gpio(dev, 21, 0);
601 static int configure_tda827x_fe(struct saa7134_dev *dev,
602 struct tda1004x_config *cdec_conf,
603 struct tda827x_config *tuner_conf)
605 struct videobuf_dvb_frontend *fe0;
607 /* Get the first frontend */
608 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
610 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
611 if (fe0->dvb.frontend) {
612 if (cdec_conf->i2c_gate)
613 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
614 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
615 cdec_conf->tuner_address,
616 &dev->i2c_adap, tuner_conf))
619 wprintk("no tda827x tuner found at addr: %02x\n",
620 cdec_conf->tuner_address);
625 /* ------------------------------------------------------------------ */
627 static struct tda827x_config tda827x_cfg_0 = {
628 .init = philips_tda827x_tuner_init,
629 .sleep = philips_tda827x_tuner_sleep,
634 static struct tda827x_config tda827x_cfg_1 = {
635 .init = philips_tda827x_tuner_init,
636 .sleep = philips_tda827x_tuner_sleep,
641 static struct tda827x_config tda827x_cfg_2 = {
642 .init = philips_tda827x_tuner_init,
643 .sleep = philips_tda827x_tuner_sleep,
648 static struct tda827x_config tda827x_cfg_2_sw42 = {
649 .init = philips_tda827x_tuner_init,
650 .sleep = philips_tda827x_tuner_sleep,
655 /* ------------------------------------------------------------------ */
657 static struct tda1004x_config tda827x_lifeview_config = {
658 .demod_address = 0x08,
661 .xtal_freq = TDA10046_XTAL_16M,
662 .agc_config = TDA10046_AGC_TDA827X,
663 .gpio_config = TDA10046_GP11_I,
664 .if_freq = TDA10046_FREQ_045,
665 .tuner_address = 0x60,
666 .request_firmware = philips_tda1004x_request_firmware
669 static struct tda1004x_config philips_tiger_config = {
670 .demod_address = 0x08,
673 .xtal_freq = TDA10046_XTAL_16M,
674 .agc_config = TDA10046_AGC_TDA827X,
675 .gpio_config = TDA10046_GP11_I,
676 .if_freq = TDA10046_FREQ_045,
678 .tuner_address = 0x61,
680 .request_firmware = philips_tda1004x_request_firmware
683 static struct tda1004x_config cinergy_ht_config = {
684 .demod_address = 0x08,
687 .xtal_freq = TDA10046_XTAL_16M,
688 .agc_config = TDA10046_AGC_TDA827X,
689 .gpio_config = TDA10046_GP01_I,
690 .if_freq = TDA10046_FREQ_045,
692 .tuner_address = 0x61,
693 .request_firmware = philips_tda1004x_request_firmware
696 static struct tda1004x_config cinergy_ht_pci_config = {
697 .demod_address = 0x08,
700 .xtal_freq = TDA10046_XTAL_16M,
701 .agc_config = TDA10046_AGC_TDA827X,
702 .gpio_config = TDA10046_GP01_I,
703 .if_freq = TDA10046_FREQ_045,
705 .tuner_address = 0x60,
706 .request_firmware = philips_tda1004x_request_firmware
709 static struct tda1004x_config philips_tiger_s_config = {
710 .demod_address = 0x08,
713 .xtal_freq = TDA10046_XTAL_16M,
714 .agc_config = TDA10046_AGC_TDA827X,
715 .gpio_config = TDA10046_GP01_I,
716 .if_freq = TDA10046_FREQ_045,
718 .tuner_address = 0x61,
720 .request_firmware = philips_tda1004x_request_firmware
723 static struct tda1004x_config pinnacle_pctv_310i_config = {
724 .demod_address = 0x08,
727 .xtal_freq = TDA10046_XTAL_16M,
728 .agc_config = TDA10046_AGC_TDA827X,
729 .gpio_config = TDA10046_GP11_I,
730 .if_freq = TDA10046_FREQ_045,
732 .tuner_address = 0x61,
733 .request_firmware = philips_tda1004x_request_firmware
736 static struct tda1004x_config hauppauge_hvr_1110_config = {
737 .demod_address = 0x08,
740 .xtal_freq = TDA10046_XTAL_16M,
741 .agc_config = TDA10046_AGC_TDA827X,
742 .gpio_config = TDA10046_GP11_I,
743 .if_freq = TDA10046_FREQ_045,
745 .tuner_address = 0x61,
746 .request_firmware = philips_tda1004x_request_firmware
749 static struct tda1004x_config asus_p7131_dual_config = {
750 .demod_address = 0x08,
753 .xtal_freq = TDA10046_XTAL_16M,
754 .agc_config = TDA10046_AGC_TDA827X,
755 .gpio_config = TDA10046_GP11_I,
756 .if_freq = TDA10046_FREQ_045,
758 .tuner_address = 0x61,
760 .request_firmware = philips_tda1004x_request_firmware
763 static struct tda1004x_config lifeview_trio_config = {
764 .demod_address = 0x09,
767 .xtal_freq = TDA10046_XTAL_16M,
768 .agc_config = TDA10046_AGC_TDA827X,
769 .gpio_config = TDA10046_GP00_I,
770 .if_freq = TDA10046_FREQ_045,
771 .tuner_address = 0x60,
772 .request_firmware = philips_tda1004x_request_firmware
775 static struct tda1004x_config tevion_dvbt220rf_config = {
776 .demod_address = 0x08,
779 .xtal_freq = TDA10046_XTAL_16M,
780 .agc_config = TDA10046_AGC_TDA827X,
781 .gpio_config = TDA10046_GP11_I,
782 .if_freq = TDA10046_FREQ_045,
783 .tuner_address = 0x60,
784 .request_firmware = philips_tda1004x_request_firmware
787 static struct tda1004x_config md8800_dvbt_config = {
788 .demod_address = 0x08,
791 .xtal_freq = TDA10046_XTAL_16M,
792 .agc_config = TDA10046_AGC_TDA827X,
793 .gpio_config = TDA10046_GP01_I,
794 .if_freq = TDA10046_FREQ_045,
796 .tuner_address = 0x60,
797 .request_firmware = philips_tda1004x_request_firmware
800 static struct tda1004x_config asus_p7131_4871_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_p7131_hybrid_lna_config = {
815 .demod_address = 0x08,
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 static struct tda1004x_config kworld_dvb_t_210_config = {
829 .demod_address = 0x08,
832 .xtal_freq = TDA10046_XTAL_16M,
833 .agc_config = TDA10046_AGC_TDA827X,
834 .gpio_config = TDA10046_GP11_I,
835 .if_freq = TDA10046_FREQ_045,
837 .tuner_address = 0x61,
839 .request_firmware = philips_tda1004x_request_firmware
842 static struct tda1004x_config avermedia_super_007_config = {
843 .demod_address = 0x08,
846 .xtal_freq = TDA10046_XTAL_16M,
847 .agc_config = TDA10046_AGC_TDA827X,
848 .gpio_config = TDA10046_GP01_I,
849 .if_freq = TDA10046_FREQ_045,
851 .tuner_address = 0x60,
853 .request_firmware = philips_tda1004x_request_firmware
856 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
857 .demod_address = 0x08,
860 .xtal_freq = TDA10046_XTAL_16M,
861 .agc_config = TDA10046_AGC_TDA827X,
862 .gpio_config = TDA10046_GP01_I,
863 .if_freq = TDA10046_FREQ_045,
865 .tuner_address = 0x61,
867 .request_firmware = philips_tda1004x_request_firmware
870 static struct tda1004x_config asus_tiger_3in1_config = {
871 .demod_address = 0x0b,
874 .xtal_freq = TDA10046_XTAL_16M,
875 .agc_config = TDA10046_AGC_TDA827X,
876 .gpio_config = TDA10046_GP11_I,
877 .if_freq = TDA10046_FREQ_045,
879 .tuner_address = 0x61,
881 .request_firmware = philips_tda1004x_request_firmware
884 static struct tda1004x_config asus_ps3_100_config = {
885 .demod_address = 0x0b,
888 .xtal_freq = TDA10046_XTAL_16M,
889 .agc_config = TDA10046_AGC_TDA827X,
890 .gpio_config = TDA10046_GP11_I,
891 .if_freq = TDA10046_FREQ_045,
893 .tuner_address = 0x61,
895 .request_firmware = philips_tda1004x_request_firmware
898 /* ------------------------------------------------------------------
899 * special case: this card uses saa713x GPIO22 for the mode switch
902 static int ads_duo_tuner_init(struct dvb_frontend *fe)
904 struct saa7134_dev *dev = fe->dvb->priv;
905 philips_tda827x_tuner_init(fe);
906 /* route TDA8275a AGC input to the channel decoder */
907 saa7134_set_gpio(dev, 22, 1);
911 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
913 struct saa7134_dev *dev = fe->dvb->priv;
914 /* route TDA8275a AGC input to the analog IF chip*/
915 saa7134_set_gpio(dev, 22, 0);
916 philips_tda827x_tuner_sleep(fe);
920 static struct tda827x_config ads_duo_cfg = {
921 .init = ads_duo_tuner_init,
922 .sleep = ads_duo_tuner_sleep,
926 static struct tda1004x_config ads_tech_duo_config = {
927 .demod_address = 0x08,
930 .xtal_freq = TDA10046_XTAL_16M,
931 .agc_config = TDA10046_AGC_TDA827X,
932 .gpio_config = TDA10046_GP00_I,
933 .if_freq = TDA10046_FREQ_045,
934 .tuner_address = 0x61,
935 .request_firmware = philips_tda1004x_request_firmware
938 static struct zl10353_config behold_h6_config = {
939 .demod_address = 0x1e>>1,
942 .disable_i2c_gate_ctrl = 1,
945 static struct xc5000_config behold_x7_tunerconfig = {
946 .i2c_address = 0xc2>>1,
948 .radio_input = XC5000_RADIO_FM1,
951 static struct zl10353_config behold_x7_config = {
952 .demod_address = 0x1e>>1,
956 .disable_i2c_gate_ctrl = 1,
959 static struct zl10353_config videomate_t750_zl10353_config = {
960 .demod_address = 0x0f,
963 .disable_i2c_gate_ctrl = 1,
966 static struct qt1010_config videomate_t750_qt1010_config = {
971 /* ==================================================================
972 * tda10086 based DVB-S cards, helper functions
975 static struct tda10086_config flydvbs = {
976 .demod_address = 0x0e,
979 .xtal_freq = TDA10086_XTAL_16M,
982 static struct tda10086_config sd1878_4m = {
983 .demod_address = 0x0e,
986 .xtal_freq = TDA10086_XTAL_4M,
989 /* ------------------------------------------------------------------
990 * special case: lnb supply is connected to the gated i2c
993 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
996 struct saa7134_dev *dev = fe->dvb->priv;
997 if (fe->ops.i2c_gate_ctrl) {
998 fe->ops.i2c_gate_ctrl(fe, 1);
999 if (dev->original_set_voltage)
1000 res = dev->original_set_voltage(fe, voltage);
1001 fe->ops.i2c_gate_ctrl(fe, 0);
1006 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
1009 struct saa7134_dev *dev = fe->dvb->priv;
1010 if (fe->ops.i2c_gate_ctrl) {
1011 fe->ops.i2c_gate_ctrl(fe, 1);
1012 if (dev->original_set_high_voltage)
1013 res = dev->original_set_high_voltage(fe, arg);
1014 fe->ops.i2c_gate_ctrl(fe, 0);
1019 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1021 struct saa7134_dev *dev = fe->dvb->priv;
1022 u8 wbuf[2] = { 0x1f, 00 };
1024 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
1025 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
1027 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
1029 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1030 if (voltage == SEC_VOLTAGE_18)
1031 wbuf[1] = rbuf | 0x10;
1033 wbuf[1] = rbuf & 0xef;
1035 i2c_transfer(&dev->i2c_adap, msg, 1);
1039 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1041 struct saa7134_dev *dev = fe->dvb->priv;
1042 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1046 /* ==================================================================
1047 * nxt200x based ATSC cards, helper functions
1050 static struct nxt200x_config avertvhda180 = {
1051 .demod_address = 0x0a,
1054 static struct nxt200x_config kworldatsc110 = {
1055 .demod_address = 0x0a,
1058 /* ------------------------------------------------------------------ */
1060 static struct mt312_config avertv_a700_mt312 = {
1061 .demod_address = 0x0e,
1062 .voltage_inverted = 1,
1065 static struct zl10036_config avertv_a700_tuner = {
1066 .tuner_address = 0x60,
1069 static struct mt312_config zl10313_compro_s350_config = {
1070 .demod_address = 0x0e,
1073 static struct lgdt3305_config hcw_lgdt3305_config = {
1075 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1076 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1077 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1079 .spectral_inversion = 1,
1084 static struct tda10048_config hcw_tda10048_config = {
1085 .demod_address = 0x10 >> 1,
1086 .output_mode = TDA10048_SERIAL_OUTPUT,
1087 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1088 .inversion = TDA10048_INVERSION_ON,
1089 .dtv6_if_freq_khz = TDA10048_IF_3300,
1090 .dtv7_if_freq_khz = TDA10048_IF_3500,
1091 .dtv8_if_freq_khz = TDA10048_IF_4000,
1092 .clk_freq_khz = TDA10048_CLK_16000,
1093 .disable_gate_access = 1,
1096 static struct tda18271_std_map hauppauge_tda18271_std_map = {
1097 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1098 .if_lvl = 1, .rfagc_top = 0x58, },
1099 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1100 .if_lvl = 1, .rfagc_top = 0x58, },
1103 static struct tda18271_config hcw_tda18271_config = {
1104 .std_map = &hauppauge_tda18271_std_map,
1105 .gate = TDA18271_GATE_ANALOG,
1107 .output_opt = TDA18271_OUTPUT_LT_OFF,
1110 static struct tda829x_config tda829x_no_probe = {
1111 .probe_tuner = TDA829X_DONT_PROBE,
1114 static struct tda10048_config zolid_tda10048_config = {
1115 .demod_address = 0x10 >> 1,
1116 .output_mode = TDA10048_PARALLEL_OUTPUT,
1117 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1118 .inversion = TDA10048_INVERSION_ON,
1119 .dtv6_if_freq_khz = TDA10048_IF_3300,
1120 .dtv7_if_freq_khz = TDA10048_IF_3500,
1121 .dtv8_if_freq_khz = TDA10048_IF_4000,
1122 .clk_freq_khz = TDA10048_CLK_16000,
1123 .disable_gate_access = 1,
1126 static struct tda18271_config zolid_tda18271_config = {
1127 .gate = TDA18271_GATE_ANALOG,
1130 static struct tda10048_config dtv1000s_tda10048_config = {
1131 .demod_address = 0x10 >> 1,
1132 .output_mode = TDA10048_PARALLEL_OUTPUT,
1133 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1134 .inversion = TDA10048_INVERSION_ON,
1135 .dtv6_if_freq_khz = TDA10048_IF_3300,
1136 .dtv7_if_freq_khz = TDA10048_IF_3800,
1137 .dtv8_if_freq_khz = TDA10048_IF_4300,
1138 .clk_freq_khz = TDA10048_CLK_16000,
1139 .disable_gate_access = 1,
1142 static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1143 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1144 .if_lvl = 1, .rfagc_top = 0x37, },
1145 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1146 .if_lvl = 1, .rfagc_top = 0x37, },
1147 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1148 .if_lvl = 1, .rfagc_top = 0x37, },
1151 static struct tda18271_config dtv1000s_tda18271_config = {
1152 .std_map = &dtv1000s_tda18271_std_map,
1153 .gate = TDA18271_GATE_ANALOG,
1156 static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
1157 .prod = LGS8GXX_PROD_LGS8G75,
1158 .demod_address = 0x1d,
1162 .if_clk_freq = 30400, /* 30.4 MHz */
1163 .if_freq = 4000, /* 4.00 MHz */
1167 .adc_vpp = 3, /* 2.0 Vpp */
1171 static struct tda18271_config prohdtv_pro2_tda18271_config = {
1172 .gate = TDA18271_GATE_ANALOG,
1173 .output_opt = TDA18271_OUTPUT_LT_OFF,
1176 static struct tda18271_std_map kworld_tda18271_std_map = {
1177 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 3,
1178 .if_lvl = 6, .rfagc_top = 0x37 },
1179 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
1180 .if_lvl = 6, .rfagc_top = 0x37 },
1183 static struct tda18271_config kworld_pc150u_tda18271_config = {
1184 .std_map = &kworld_tda18271_std_map,
1185 .gate = TDA18271_GATE_ANALOG,
1186 .output_opt = TDA18271_OUTPUT_LT_OFF,
1187 .config = 3, /* Use tuner callback for AGC */
1188 .rf_cal_on_startup = 1
1191 static struct s5h1411_config kworld_s5h1411_config = {
1192 .output_mode = S5H1411_PARALLEL_OUTPUT,
1193 .gpio = S5H1411_GPIO_OFF,
1194 .qam_if = S5H1411_IF_4000,
1195 .vsb_if = S5H1411_IF_3250,
1196 .inversion = S5H1411_INVERSION_ON,
1197 .status_mode = S5H1411_DEMODLOCKING,
1199 S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
1203 /* ==================================================================
1207 static int dvb_init(struct saa7134_dev *dev)
1210 int attach_xc3028 = 0;
1211 struct videobuf_dvb_frontend *fe0;
1213 /* FIXME: add support for multi-frontend */
1214 mutex_init(&dev->frontends.lock);
1215 INIT_LIST_HEAD(&dev->frontends.felist);
1217 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
1218 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1220 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1224 /* init struct videobuf_dvb */
1225 dev->ts.nr_bufs = 32;
1226 dev->ts.nr_packets = 32*4;
1227 fe0->dvb.name = dev->name;
1228 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
1229 &dev->pci->dev, &dev->slock,
1230 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1231 V4L2_FIELD_ALTERNATE,
1232 sizeof(struct saa7134_buf),
1235 switch (dev->board) {
1236 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1237 dprintk("pinnacle 300i dvb setup\n");
1238 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1240 if (fe0->dvb.frontend) {
1241 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1244 case SAA7134_BOARD_AVERMEDIA_777:
1245 case SAA7134_BOARD_AVERMEDIA_A16AR:
1246 dprintk("avertv 777 dvb setup\n");
1247 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1249 if (fe0->dvb.frontend) {
1250 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1251 &dev->i2c_adap, 0x61,
1252 TUNER_PHILIPS_TD1316);
1255 case SAA7134_BOARD_AVERMEDIA_A16D:
1256 dprintk("AverMedia A16D dvb setup\n");
1257 fe0->dvb.frontend = dvb_attach(mt352_attach,
1258 &avermedia_xc3028_mt352_dev,
1262 case SAA7134_BOARD_MD7134:
1263 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1266 if (fe0->dvb.frontend) {
1267 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1268 &dev->i2c_adap, medion_cardbus.tuner_address,
1269 TUNER_PHILIPS_FMD1216ME_MK3);
1272 case SAA7134_BOARD_PHILIPS_TOUGH:
1273 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1274 &philips_tu1216_60_config,
1276 if (fe0->dvb.frontend) {
1277 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1278 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1281 case SAA7134_BOARD_FLYDVBTDUO:
1282 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1283 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1284 &tda827x_cfg_0) < 0)
1285 goto detach_frontend;
1287 case SAA7134_BOARD_PHILIPS_EUROPA:
1288 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1289 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
1290 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1291 &philips_europa_config,
1293 if (fe0->dvb.frontend) {
1294 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1295 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1296 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1297 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1298 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1301 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1302 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1303 &technotrend_budget_t3000_config,
1305 if (fe0->dvb.frontend) {
1306 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1307 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1308 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1309 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1310 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1313 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1314 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1315 &philips_tu1216_61_config,
1317 if (fe0->dvb.frontend) {
1318 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1319 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1322 case SAA7134_BOARD_KWORLD_DVBT_210:
1323 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1324 &tda827x_cfg_2) < 0)
1325 goto detach_frontend;
1327 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1328 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1329 &hcw_tda10048_config,
1331 if (fe0->dvb.frontend != NULL) {
1332 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1333 &dev->i2c_adap, 0x4b,
1335 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1336 0x60, &dev->i2c_adap,
1337 &hcw_tda18271_config);
1340 case SAA7134_BOARD_PHILIPS_TIGER:
1341 if (configure_tda827x_fe(dev, &philips_tiger_config,
1342 &tda827x_cfg_0) < 0)
1343 goto detach_frontend;
1345 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1346 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1347 &tda827x_cfg_1) < 0)
1348 goto detach_frontend;
1350 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1351 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1352 &tda827x_cfg_1) < 0)
1353 goto detach_frontend;
1355 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
1356 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1357 &hcw_lgdt3305_config,
1359 if (fe0->dvb.frontend) {
1360 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1361 &dev->i2c_adap, 0x4b,
1363 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1364 0x60, &dev->i2c_adap,
1365 &hcw_tda18271_config);
1368 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1369 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1370 &tda827x_cfg_0) < 0)
1371 goto detach_frontend;
1373 case SAA7134_BOARD_FLYDVBT_LR301:
1374 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1375 &tda827x_cfg_0) < 0)
1376 goto detach_frontend;
1378 case SAA7134_BOARD_FLYDVB_TRIO:
1379 if (!use_frontend) { /* terrestrial */
1380 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1381 &tda827x_cfg_0) < 0)
1382 goto detach_frontend;
1383 } else { /* satellite */
1384 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1385 if (fe0->dvb.frontend) {
1386 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1387 &dev->i2c_adap, 0) == NULL) {
1388 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1389 goto detach_frontend;
1391 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1392 0x08, 0, 0) == NULL) {
1393 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1394 goto detach_frontend;
1399 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1400 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1401 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1402 &ads_tech_duo_config,
1404 if (fe0->dvb.frontend) {
1405 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1406 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1407 &ads_duo_cfg) == NULL) {
1408 wprintk("no tda827x tuner found at addr: %02x\n",
1409 ads_tech_duo_config.tuner_address);
1410 goto detach_frontend;
1413 wprintk("failed to attach tda10046\n");
1415 case SAA7134_BOARD_TEVION_DVBT_220RF:
1416 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1417 &tda827x_cfg_0) < 0)
1418 goto detach_frontend;
1420 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1421 if (!use_frontend) { /* terrestrial */
1422 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1423 &tda827x_cfg_0) < 0)
1424 goto detach_frontend;
1425 } else { /* satellite */
1426 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1427 &flydvbs, &dev->i2c_adap);
1428 if (fe0->dvb.frontend) {
1429 struct dvb_frontend *fe = fe0->dvb.frontend;
1430 u8 dev_id = dev->eedata[2];
1432 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1434 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1435 0x60, &dev->i2c_adap, 0) == NULL) {
1436 wprintk("%s: Medion Quadro, no tda826x "
1437 "found !\n", __func__);
1438 goto detach_frontend;
1440 if (dev_id != 0x08) {
1441 /* we need to open the i2c gate (we know it exists) */
1442 fe->ops.i2c_gate_ctrl(fe, 1);
1443 if (dvb_attach(isl6405_attach, fe,
1444 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1445 wprintk("%s: Medion Quadro, no ISL6405 "
1446 "found !\n", __func__);
1447 goto detach_frontend;
1449 if (dev_id == 0x07) {
1450 /* fire up the 2nd section of the LNB supply since
1451 we can't do this from the other section */
1453 i2c_transfer(&dev->i2c_adap, &msg, 1);
1455 fe->ops.i2c_gate_ctrl(fe, 0);
1456 dev->original_set_voltage = fe->ops.set_voltage;
1457 fe->ops.set_voltage = md8800_set_voltage;
1458 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1459 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1461 fe->ops.set_voltage = md8800_set_voltage2;
1462 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1467 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1468 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1470 if (fe0->dvb.frontend)
1471 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1472 NULL, DVB_PLL_TDHU2);
1474 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1475 case SAA7134_BOARD_KWORLD_ATSC110:
1476 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1478 if (fe0->dvb.frontend)
1479 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1480 &dev->i2c_adap, 0x61,
1481 TUNER_PHILIPS_TUV1236D);
1483 case SAA7134_BOARD_KWORLD_PC150U:
1484 saa7134_set_gpio(dev, 18, 1); /* Switch to digital mode */
1485 saa7134_tuner_callback(dev, 0,
1486 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1487 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1488 &kworld_s5h1411_config,
1490 if (fe0->dvb.frontend != NULL) {
1491 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1492 &dev->i2c_adap, 0x4b,
1494 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1495 0x60, &dev->i2c_adap,
1496 &kworld_pc150u_tda18271_config);
1499 case SAA7134_BOARD_FLYDVBS_LR300:
1500 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1502 if (fe0->dvb.frontend) {
1503 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1504 &dev->i2c_adap, 0) == NULL) {
1505 wprintk("%s: No tda826x found!\n", __func__);
1506 goto detach_frontend;
1508 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1509 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1510 wprintk("%s: No ISL6421 found!\n", __func__);
1511 goto detach_frontend;
1515 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1516 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1519 if (fe0->dvb.frontend) {
1520 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1521 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1523 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1524 &dev->i2c_adap, medion_cardbus.tuner_address,
1525 TUNER_PHILIPS_FMD1216ME_MK3);
1528 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1529 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1530 &philips_europa_config,
1532 if (fe0->dvb.frontend) {
1533 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1534 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1537 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1538 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1539 &tda827x_cfg_0) < 0)
1540 goto detach_frontend;
1542 case SAA7134_BOARD_CINERGY_HT_PCI:
1543 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1544 &tda827x_cfg_0) < 0)
1545 goto detach_frontend;
1547 case SAA7134_BOARD_PHILIPS_TIGER_S:
1548 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1549 &tda827x_cfg_2) < 0)
1550 goto detach_frontend;
1552 case SAA7134_BOARD_ASUS_P7131_4871:
1553 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1554 &tda827x_cfg_2) < 0)
1555 goto detach_frontend;
1557 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1558 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1559 &tda827x_cfg_2) < 0)
1560 goto detach_frontend;
1562 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1563 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1564 &tda827x_cfg_0) < 0)
1565 goto detach_frontend;
1567 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1568 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1569 &tda827x_cfg_2_sw42) < 0)
1570 goto detach_frontend;
1572 case SAA7134_BOARD_PHILIPS_SNAKE:
1573 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1575 if (fe0->dvb.frontend) {
1576 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1577 &dev->i2c_adap, 0) == NULL) {
1578 wprintk("%s: No tda826x found!\n", __func__);
1579 goto detach_frontend;
1581 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1582 &dev->i2c_adap, 0, 0) == NULL) {
1583 wprintk("%s: No lnbp21 found!\n", __func__);
1584 goto detach_frontend;
1588 case SAA7134_BOARD_CREATIX_CTX953:
1589 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1590 &tda827x_cfg_0) < 0)
1591 goto detach_frontend;
1593 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1594 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1595 &tda827x_cfg_2) < 0)
1596 goto detach_frontend;
1598 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1599 dprintk("AverMedia E506R dvb setup\n");
1600 saa7134_set_gpio(dev, 25, 0);
1602 saa7134_set_gpio(dev, 25, 1);
1603 fe0->dvb.frontend = dvb_attach(mt352_attach,
1604 &avermedia_xc3028_mt352_dev,
1608 case SAA7134_BOARD_MD7134_BRIDGE_2:
1609 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1610 &sd1878_4m, &dev->i2c_adap);
1611 if (fe0->dvb.frontend) {
1612 struct dvb_frontend *fe;
1613 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1614 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1615 wprintk("%s: MD7134 DVB-S, no SD1878 "
1616 "found !\n", __func__);
1617 goto detach_frontend;
1619 /* we need to open the i2c gate (we know it exists) */
1620 fe = fe0->dvb.frontend;
1621 fe->ops.i2c_gate_ctrl(fe, 1);
1622 if (dvb_attach(isl6405_attach, fe,
1623 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1624 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1625 "found !\n", __func__);
1626 goto detach_frontend;
1628 fe->ops.i2c_gate_ctrl(fe, 0);
1629 dev->original_set_voltage = fe->ops.set_voltage;
1630 fe->ops.set_voltage = md8800_set_voltage;
1631 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1632 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1635 case SAA7134_BOARD_AVERMEDIA_M103:
1636 saa7134_set_gpio(dev, 25, 0);
1638 saa7134_set_gpio(dev, 25, 1);
1639 fe0->dvb.frontend = dvb_attach(mt352_attach,
1640 &avermedia_xc3028_mt352_dev,
1644 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1645 if (!use_frontend) { /* terrestrial */
1646 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1647 &tda827x_cfg_2) < 0)
1648 goto detach_frontend;
1649 } else { /* satellite */
1650 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1651 &flydvbs, &dev->i2c_adap);
1652 if (fe0->dvb.frontend) {
1653 if (dvb_attach(tda826x_attach,
1654 fe0->dvb.frontend, 0x60,
1655 &dev->i2c_adap, 0) == NULL) {
1656 wprintk("%s: Asus Tiger 3in1, no "
1657 "tda826x found!\n", __func__);
1658 goto detach_frontend;
1660 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1661 &dev->i2c_adap, 0, 0) == NULL) {
1662 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1663 " found!\n", __func__);
1664 goto detach_frontend;
1669 case SAA7134_BOARD_ASUSTeK_PS3_100:
1670 if (!use_frontend) { /* terrestrial */
1671 if (configure_tda827x_fe(dev, &asus_ps3_100_config,
1672 &tda827x_cfg_2) < 0)
1673 goto detach_frontend;
1674 } else { /* satellite */
1675 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1676 &flydvbs, &dev->i2c_adap);
1677 if (fe0->dvb.frontend) {
1678 if (dvb_attach(tda826x_attach,
1679 fe0->dvb.frontend, 0x60,
1680 &dev->i2c_adap, 0) == NULL) {
1681 wprintk("%s: Asus My Cinema PS3-100, no "
1682 "tda826x found!\n", __func__);
1683 goto detach_frontend;
1685 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1686 &dev->i2c_adap, 0, 0) == NULL) {
1687 wprintk("%s: Asus My Cinema PS3-100, no lnbp21"
1688 " found!\n", __func__);
1689 goto detach_frontend;
1694 case SAA7134_BOARD_ASUSTeK_TIGER:
1695 if (configure_tda827x_fe(dev, &philips_tiger_config,
1696 &tda827x_cfg_0) < 0)
1697 goto detach_frontend;
1699 case SAA7134_BOARD_BEHOLD_H6:
1700 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1703 if (fe0->dvb.frontend) {
1704 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1705 &dev->i2c_adap, 0x61,
1706 TUNER_PHILIPS_FMD1216MEX_MK3);
1709 case SAA7134_BOARD_BEHOLD_X7:
1710 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1713 if (fe0->dvb.frontend) {
1714 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1715 &dev->i2c_adap, &behold_x7_tunerconfig);
1718 case SAA7134_BOARD_BEHOLD_H7:
1719 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1722 if (fe0->dvb.frontend) {
1723 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1724 &dev->i2c_adap, &behold_x7_tunerconfig);
1727 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1728 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1729 /* Zarlink ZL10313 */
1730 fe0->dvb.frontend = dvb_attach(mt312_attach,
1731 &avertv_a700_mt312, &dev->i2c_adap);
1732 if (fe0->dvb.frontend) {
1733 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1734 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1735 wprintk("%s: No zl10036 found!\n",
1740 case SAA7134_BOARD_VIDEOMATE_S350:
1741 fe0->dvb.frontend = dvb_attach(mt312_attach,
1742 &zl10313_compro_s350_config, &dev->i2c_adap);
1743 if (fe0->dvb.frontend)
1744 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1745 0x60, &dev->i2c_adap) == NULL)
1746 wprintk("%s: No zl10039 found!\n",
1750 case SAA7134_BOARD_VIDEOMATE_T750:
1751 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1752 &videomate_t750_zl10353_config,
1754 if (fe0->dvb.frontend != NULL) {
1755 if (dvb_attach(qt1010_attach,
1758 &videomate_t750_qt1010_config) == NULL)
1759 wprintk("error attaching QT1010\n");
1762 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1763 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1764 &zolid_tda10048_config,
1766 if (fe0->dvb.frontend != NULL) {
1767 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1768 &dev->i2c_adap, 0x4b,
1770 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1771 0x60, &dev->i2c_adap,
1772 &zolid_tda18271_config);
1775 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1776 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1777 &dtv1000s_tda10048_config,
1779 if (fe0->dvb.frontend != NULL) {
1780 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1781 &dev->i2c_adap, 0x4b,
1783 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1784 0x60, &dev->i2c_adap,
1785 &dtv1000s_tda18271_config);
1788 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
1789 /* Switch to digital mode */
1790 saa7134_tuner_callback(dev, 0,
1791 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1792 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1793 &kworld_mb86a20s_config,
1795 if (fe0->dvb.frontend != NULL) {
1796 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1797 &dev->i2c_adap, 0x4b,
1799 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1800 0x60, &dev->i2c_adap,
1801 &kworld_tda18271_config);
1802 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
1805 /* mb86a20s need to use the I2C gateway */
1807 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
1808 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1809 &prohdtv_pro2_lgs8g75_config,
1811 if (fe0->dvb.frontend != NULL) {
1812 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1813 &dev->i2c_adap, 0x4b,
1815 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1816 0x60, &dev->i2c_adap,
1817 &prohdtv_pro2_tda18271_config);
1821 wprintk("Huh? unknown DVB card?\n");
1825 if (attach_xc3028) {
1826 struct dvb_frontend *fe;
1827 struct xc2028_config cfg = {
1828 .i2c_adap = &dev->i2c_adap,
1832 if (!fe0->dvb.frontend)
1833 goto detach_frontend;
1835 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1837 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1839 goto detach_frontend;
1843 if (NULL == fe0->dvb.frontend) {
1844 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1845 goto detach_frontend;
1847 /* define general-purpose callback pointer */
1848 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1850 /* register everything else */
1851 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1852 &dev->pci->dev, adapter_nr, 0, NULL);
1854 /* this sequence is necessary to make the tda1004x load its firmware
1855 * and to enter analog mode of hybrid boards
1858 if (fe0->dvb.frontend->ops.init)
1859 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1860 if (fe0->dvb.frontend->ops.sleep)
1861 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1862 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1863 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1868 videobuf_dvb_dealloc_frontends(&dev->frontends);
1872 static int dvb_fini(struct saa7134_dev *dev)
1874 struct videobuf_dvb_frontend *fe0;
1876 /* Get the first frontend */
1877 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1881 /* FIXME: I suspect that this code is bogus, since the entry for
1882 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1883 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1885 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1886 struct v4l2_priv_tun_config tda9887_cfg;
1887 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1889 tda9887_cfg.tuner = TUNER_TDA9887;
1890 tda9887_cfg.priv = &on;
1892 /* otherwise we don't detect the tuner on next insmod */
1893 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1894 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1895 if ((dev->eedata[2] == 0x07) && use_frontend) {
1896 /* turn off the 2nd lnb supply */
1898 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1899 struct dvb_frontend *fe;
1900 fe = fe0->dvb.frontend;
1901 if (fe->ops.i2c_gate_ctrl) {
1902 fe->ops.i2c_gate_ctrl(fe, 1);
1903 i2c_transfer(&dev->i2c_adap, &msg, 1);
1904 fe->ops.i2c_gate_ctrl(fe, 0);
1908 videobuf_dvb_unregister_bus(&dev->frontends);
1912 static struct saa7134_mpeg_ops dvb_ops = {
1913 .type = SAA7134_MPEG_DVB,
1918 static int __init dvb_register(void)
1920 return saa7134_ts_register(&dvb_ops);
1923 static void __exit dvb_unregister(void)
1925 saa7134_ts_unregister(&dvb_ops);
1928 module_init(dvb_register);
1929 module_exit(dvb_unregister);
1931 /* ------------------------------------------------------------------ */