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);
613 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
614 if (fe0->dvb.frontend) {
615 if (cdec_conf->i2c_gate)
616 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
617 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
618 cdec_conf->tuner_address,
619 &dev->i2c_adap, tuner_conf))
622 wprintk("no tda827x tuner found at addr: %02x\n",
623 cdec_conf->tuner_address);
628 /* ------------------------------------------------------------------ */
630 static struct tda827x_config tda827x_cfg_0 = {
631 .init = philips_tda827x_tuner_init,
632 .sleep = philips_tda827x_tuner_sleep,
637 static struct tda827x_config tda827x_cfg_1 = {
638 .init = philips_tda827x_tuner_init,
639 .sleep = philips_tda827x_tuner_sleep,
644 static struct tda827x_config tda827x_cfg_2 = {
645 .init = philips_tda827x_tuner_init,
646 .sleep = philips_tda827x_tuner_sleep,
651 static struct tda827x_config tda827x_cfg_2_sw42 = {
652 .init = philips_tda827x_tuner_init,
653 .sleep = philips_tda827x_tuner_sleep,
658 /* ------------------------------------------------------------------ */
660 static struct tda1004x_config tda827x_lifeview_config = {
661 .demod_address = 0x08,
664 .xtal_freq = TDA10046_XTAL_16M,
665 .agc_config = TDA10046_AGC_TDA827X,
666 .gpio_config = TDA10046_GP11_I,
667 .if_freq = TDA10046_FREQ_045,
668 .tuner_address = 0x60,
669 .request_firmware = philips_tda1004x_request_firmware
672 static struct tda1004x_config philips_tiger_config = {
673 .demod_address = 0x08,
676 .xtal_freq = TDA10046_XTAL_16M,
677 .agc_config = TDA10046_AGC_TDA827X,
678 .gpio_config = TDA10046_GP11_I,
679 .if_freq = TDA10046_FREQ_045,
681 .tuner_address = 0x61,
683 .request_firmware = philips_tda1004x_request_firmware
686 static struct tda1004x_config cinergy_ht_config = {
687 .demod_address = 0x08,
690 .xtal_freq = TDA10046_XTAL_16M,
691 .agc_config = TDA10046_AGC_TDA827X,
692 .gpio_config = TDA10046_GP01_I,
693 .if_freq = TDA10046_FREQ_045,
695 .tuner_address = 0x61,
696 .request_firmware = philips_tda1004x_request_firmware
699 static struct tda1004x_config cinergy_ht_pci_config = {
700 .demod_address = 0x08,
703 .xtal_freq = TDA10046_XTAL_16M,
704 .agc_config = TDA10046_AGC_TDA827X,
705 .gpio_config = TDA10046_GP01_I,
706 .if_freq = TDA10046_FREQ_045,
708 .tuner_address = 0x60,
709 .request_firmware = philips_tda1004x_request_firmware
712 static struct tda1004x_config philips_tiger_s_config = {
713 .demod_address = 0x08,
716 .xtal_freq = TDA10046_XTAL_16M,
717 .agc_config = TDA10046_AGC_TDA827X,
718 .gpio_config = TDA10046_GP01_I,
719 .if_freq = TDA10046_FREQ_045,
721 .tuner_address = 0x61,
723 .request_firmware = philips_tda1004x_request_firmware
726 static struct tda1004x_config pinnacle_pctv_310i_config = {
727 .demod_address = 0x08,
730 .xtal_freq = TDA10046_XTAL_16M,
731 .agc_config = TDA10046_AGC_TDA827X,
732 .gpio_config = TDA10046_GP11_I,
733 .if_freq = TDA10046_FREQ_045,
735 .tuner_address = 0x61,
736 .request_firmware = philips_tda1004x_request_firmware
739 static struct tda1004x_config hauppauge_hvr_1110_config = {
740 .demod_address = 0x08,
743 .xtal_freq = TDA10046_XTAL_16M,
744 .agc_config = TDA10046_AGC_TDA827X,
745 .gpio_config = TDA10046_GP11_I,
746 .if_freq = TDA10046_FREQ_045,
748 .tuner_address = 0x61,
749 .request_firmware = philips_tda1004x_request_firmware
752 static struct tda1004x_config asus_p7131_dual_config = {
753 .demod_address = 0x08,
756 .xtal_freq = TDA10046_XTAL_16M,
757 .agc_config = TDA10046_AGC_TDA827X,
758 .gpio_config = TDA10046_GP11_I,
759 .if_freq = TDA10046_FREQ_045,
761 .tuner_address = 0x61,
763 .request_firmware = philips_tda1004x_request_firmware
766 static struct tda1004x_config lifeview_trio_config = {
767 .demod_address = 0x09,
770 .xtal_freq = TDA10046_XTAL_16M,
771 .agc_config = TDA10046_AGC_TDA827X,
772 .gpio_config = TDA10046_GP00_I,
773 .if_freq = TDA10046_FREQ_045,
774 .tuner_address = 0x60,
775 .request_firmware = philips_tda1004x_request_firmware
778 static struct tda1004x_config tevion_dvbt220rf_config = {
779 .demod_address = 0x08,
782 .xtal_freq = TDA10046_XTAL_16M,
783 .agc_config = TDA10046_AGC_TDA827X,
784 .gpio_config = TDA10046_GP11_I,
785 .if_freq = TDA10046_FREQ_045,
786 .tuner_address = 0x60,
787 .request_firmware = philips_tda1004x_request_firmware
790 static struct tda1004x_config md8800_dvbt_config = {
791 .demod_address = 0x08,
794 .xtal_freq = TDA10046_XTAL_16M,
795 .agc_config = TDA10046_AGC_TDA827X,
796 .gpio_config = TDA10046_GP01_I,
797 .if_freq = TDA10046_FREQ_045,
799 .tuner_address = 0x60,
800 .request_firmware = philips_tda1004x_request_firmware
803 static struct tda1004x_config asus_p7131_4871_config = {
804 .demod_address = 0x08,
807 .xtal_freq = TDA10046_XTAL_16M,
808 .agc_config = TDA10046_AGC_TDA827X,
809 .gpio_config = TDA10046_GP01_I,
810 .if_freq = TDA10046_FREQ_045,
812 .tuner_address = 0x61,
814 .request_firmware = philips_tda1004x_request_firmware
817 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
818 .demod_address = 0x08,
821 .xtal_freq = TDA10046_XTAL_16M,
822 .agc_config = TDA10046_AGC_TDA827X,
823 .gpio_config = TDA10046_GP11_I,
824 .if_freq = TDA10046_FREQ_045,
826 .tuner_address = 0x61,
828 .request_firmware = philips_tda1004x_request_firmware
831 static struct tda1004x_config kworld_dvb_t_210_config = {
832 .demod_address = 0x08,
835 .xtal_freq = TDA10046_XTAL_16M,
836 .agc_config = TDA10046_AGC_TDA827X,
837 .gpio_config = TDA10046_GP11_I,
838 .if_freq = TDA10046_FREQ_045,
840 .tuner_address = 0x61,
842 .request_firmware = philips_tda1004x_request_firmware
845 static struct tda1004x_config avermedia_super_007_config = {
846 .demod_address = 0x08,
849 .xtal_freq = TDA10046_XTAL_16M,
850 .agc_config = TDA10046_AGC_TDA827X,
851 .gpio_config = TDA10046_GP01_I,
852 .if_freq = TDA10046_FREQ_045,
854 .tuner_address = 0x60,
856 .request_firmware = philips_tda1004x_request_firmware
859 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
860 .demod_address = 0x08,
863 .xtal_freq = TDA10046_XTAL_16M,
864 .agc_config = TDA10046_AGC_TDA827X,
865 .gpio_config = TDA10046_GP01_I,
866 .if_freq = TDA10046_FREQ_045,
868 .tuner_address = 0x61,
870 .request_firmware = philips_tda1004x_request_firmware
873 static struct tda1004x_config asus_tiger_3in1_config = {
874 .demod_address = 0x0b,
877 .xtal_freq = TDA10046_XTAL_16M,
878 .agc_config = TDA10046_AGC_TDA827X,
879 .gpio_config = TDA10046_GP11_I,
880 .if_freq = TDA10046_FREQ_045,
882 .tuner_address = 0x61,
884 .request_firmware = philips_tda1004x_request_firmware
887 static struct tda1004x_config asus_ps3_100_config = {
888 .demod_address = 0x0b,
891 .xtal_freq = TDA10046_XTAL_16M,
892 .agc_config = TDA10046_AGC_TDA827X,
893 .gpio_config = TDA10046_GP11_I,
894 .if_freq = TDA10046_FREQ_045,
896 .tuner_address = 0x61,
898 .request_firmware = philips_tda1004x_request_firmware
901 /* ------------------------------------------------------------------
902 * special case: this card uses saa713x GPIO22 for the mode switch
905 static int ads_duo_tuner_init(struct dvb_frontend *fe)
907 struct saa7134_dev *dev = fe->dvb->priv;
908 philips_tda827x_tuner_init(fe);
909 /* route TDA8275a AGC input to the channel decoder */
910 saa7134_set_gpio(dev, 22, 1);
914 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
916 struct saa7134_dev *dev = fe->dvb->priv;
917 /* route TDA8275a AGC input to the analog IF chip*/
918 saa7134_set_gpio(dev, 22, 0);
919 philips_tda827x_tuner_sleep(fe);
923 static struct tda827x_config ads_duo_cfg = {
924 .init = ads_duo_tuner_init,
925 .sleep = ads_duo_tuner_sleep,
929 static struct tda1004x_config ads_tech_duo_config = {
930 .demod_address = 0x08,
933 .xtal_freq = TDA10046_XTAL_16M,
934 .agc_config = TDA10046_AGC_TDA827X,
935 .gpio_config = TDA10046_GP00_I,
936 .if_freq = TDA10046_FREQ_045,
937 .tuner_address = 0x61,
938 .request_firmware = philips_tda1004x_request_firmware
941 static struct zl10353_config behold_h6_config = {
942 .demod_address = 0x1e>>1,
945 .disable_i2c_gate_ctrl = 1,
948 static struct xc5000_config behold_x7_tunerconfig = {
949 .i2c_address = 0xc2>>1,
951 .radio_input = XC5000_RADIO_FM1,
954 static struct zl10353_config behold_x7_config = {
955 .demod_address = 0x1e>>1,
959 .disable_i2c_gate_ctrl = 1,
962 static struct zl10353_config videomate_t750_zl10353_config = {
963 .demod_address = 0x0f,
966 .disable_i2c_gate_ctrl = 1,
969 static struct qt1010_config videomate_t750_qt1010_config = {
974 /* ==================================================================
975 * tda10086 based DVB-S cards, helper functions
978 static struct tda10086_config flydvbs = {
979 .demod_address = 0x0e,
982 .xtal_freq = TDA10086_XTAL_16M,
985 static struct tda10086_config sd1878_4m = {
986 .demod_address = 0x0e,
989 .xtal_freq = TDA10086_XTAL_4M,
992 /* ------------------------------------------------------------------
993 * special case: lnb supply is connected to the gated i2c
996 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
999 struct saa7134_dev *dev = fe->dvb->priv;
1000 if (fe->ops.i2c_gate_ctrl) {
1001 fe->ops.i2c_gate_ctrl(fe, 1);
1002 if (dev->original_set_voltage)
1003 res = dev->original_set_voltage(fe, voltage);
1004 fe->ops.i2c_gate_ctrl(fe, 0);
1009 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
1012 struct saa7134_dev *dev = fe->dvb->priv;
1013 if (fe->ops.i2c_gate_ctrl) {
1014 fe->ops.i2c_gate_ctrl(fe, 1);
1015 if (dev->original_set_high_voltage)
1016 res = dev->original_set_high_voltage(fe, arg);
1017 fe->ops.i2c_gate_ctrl(fe, 0);
1022 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1024 struct saa7134_dev *dev = fe->dvb->priv;
1025 u8 wbuf[2] = { 0x1f, 00 };
1027 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
1028 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
1030 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
1032 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1033 if (voltage == SEC_VOLTAGE_18)
1034 wbuf[1] = rbuf | 0x10;
1036 wbuf[1] = rbuf & 0xef;
1038 i2c_transfer(&dev->i2c_adap, msg, 1);
1042 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1044 struct saa7134_dev *dev = fe->dvb->priv;
1045 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1049 /* ==================================================================
1050 * nxt200x based ATSC cards, helper functions
1053 static struct nxt200x_config avertvhda180 = {
1054 .demod_address = 0x0a,
1057 static struct nxt200x_config kworldatsc110 = {
1058 .demod_address = 0x0a,
1061 /* ------------------------------------------------------------------ */
1063 static struct mt312_config avertv_a700_mt312 = {
1064 .demod_address = 0x0e,
1065 .voltage_inverted = 1,
1068 static struct zl10036_config avertv_a700_tuner = {
1069 .tuner_address = 0x60,
1072 static struct mt312_config zl10313_compro_s350_config = {
1073 .demod_address = 0x0e,
1076 static struct lgdt3305_config hcw_lgdt3305_config = {
1078 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1079 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1080 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1082 .spectral_inversion = 1,
1087 static struct tda10048_config hcw_tda10048_config = {
1088 .demod_address = 0x10 >> 1,
1089 .output_mode = TDA10048_SERIAL_OUTPUT,
1090 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1091 .inversion = TDA10048_INVERSION_ON,
1092 .dtv6_if_freq_khz = TDA10048_IF_3300,
1093 .dtv7_if_freq_khz = TDA10048_IF_3500,
1094 .dtv8_if_freq_khz = TDA10048_IF_4000,
1095 .clk_freq_khz = TDA10048_CLK_16000,
1096 .disable_gate_access = 1,
1099 static struct tda18271_std_map hauppauge_tda18271_std_map = {
1100 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1101 .if_lvl = 1, .rfagc_top = 0x58, },
1102 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1103 .if_lvl = 1, .rfagc_top = 0x58, },
1106 static struct tda18271_config hcw_tda18271_config = {
1107 .std_map = &hauppauge_tda18271_std_map,
1108 .gate = TDA18271_GATE_ANALOG,
1110 .output_opt = TDA18271_OUTPUT_LT_OFF,
1113 static struct tda829x_config tda829x_no_probe = {
1114 .probe_tuner = TDA829X_DONT_PROBE,
1117 static struct tda10048_config zolid_tda10048_config = {
1118 .demod_address = 0x10 >> 1,
1119 .output_mode = TDA10048_PARALLEL_OUTPUT,
1120 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1121 .inversion = TDA10048_INVERSION_ON,
1122 .dtv6_if_freq_khz = TDA10048_IF_3300,
1123 .dtv7_if_freq_khz = TDA10048_IF_3500,
1124 .dtv8_if_freq_khz = TDA10048_IF_4000,
1125 .clk_freq_khz = TDA10048_CLK_16000,
1126 .disable_gate_access = 1,
1129 static struct tda18271_config zolid_tda18271_config = {
1130 .gate = TDA18271_GATE_ANALOG,
1133 static struct tda10048_config dtv1000s_tda10048_config = {
1134 .demod_address = 0x10 >> 1,
1135 .output_mode = TDA10048_PARALLEL_OUTPUT,
1136 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1137 .inversion = TDA10048_INVERSION_ON,
1138 .dtv6_if_freq_khz = TDA10048_IF_3300,
1139 .dtv7_if_freq_khz = TDA10048_IF_3800,
1140 .dtv8_if_freq_khz = TDA10048_IF_4300,
1141 .clk_freq_khz = TDA10048_CLK_16000,
1142 .disable_gate_access = 1,
1145 static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1146 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1147 .if_lvl = 1, .rfagc_top = 0x37, },
1148 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1149 .if_lvl = 1, .rfagc_top = 0x37, },
1150 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1151 .if_lvl = 1, .rfagc_top = 0x37, },
1154 static struct tda18271_config dtv1000s_tda18271_config = {
1155 .std_map = &dtv1000s_tda18271_std_map,
1156 .gate = TDA18271_GATE_ANALOG,
1159 static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
1160 .prod = LGS8GXX_PROD_LGS8G75,
1161 .demod_address = 0x1d,
1165 .if_clk_freq = 30400, /* 30.4 MHz */
1166 .if_freq = 4000, /* 4.00 MHz */
1170 .adc_vpp = 3, /* 2.0 Vpp */
1174 static struct tda18271_config prohdtv_pro2_tda18271_config = {
1175 .gate = TDA18271_GATE_ANALOG,
1176 .output_opt = TDA18271_OUTPUT_LT_OFF,
1179 static struct tda18271_std_map kworld_tda18271_std_map = {
1180 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 3,
1181 .if_lvl = 6, .rfagc_top = 0x37 },
1182 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
1183 .if_lvl = 6, .rfagc_top = 0x37 },
1186 static struct tda18271_config kworld_pc150u_tda18271_config = {
1187 .std_map = &kworld_tda18271_std_map,
1188 .gate = TDA18271_GATE_ANALOG,
1189 .output_opt = TDA18271_OUTPUT_LT_OFF,
1190 .config = 3, /* Use tuner callback for AGC */
1191 .rf_cal_on_startup = 1
1194 static struct s5h1411_config kworld_s5h1411_config = {
1195 .output_mode = S5H1411_PARALLEL_OUTPUT,
1196 .gpio = S5H1411_GPIO_OFF,
1197 .qam_if = S5H1411_IF_4000,
1198 .vsb_if = S5H1411_IF_3250,
1199 .inversion = S5H1411_INVERSION_ON,
1200 .status_mode = S5H1411_DEMODLOCKING,
1202 S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
1206 /* ==================================================================
1210 static int dvb_init(struct saa7134_dev *dev)
1213 int attach_xc3028 = 0;
1214 struct videobuf_dvb_frontend *fe0;
1216 /* FIXME: add support for multi-frontend */
1217 mutex_init(&dev->frontends.lock);
1218 INIT_LIST_HEAD(&dev->frontends.felist);
1220 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
1221 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1223 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1227 /* init struct videobuf_dvb */
1228 dev->ts.nr_bufs = 32;
1229 dev->ts.nr_packets = 32*4;
1230 fe0->dvb.name = dev->name;
1231 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
1232 &dev->pci->dev, &dev->slock,
1233 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1234 V4L2_FIELD_ALTERNATE,
1235 sizeof(struct saa7134_buf),
1238 switch (dev->board) {
1239 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1240 dprintk("pinnacle 300i dvb setup\n");
1241 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1243 if (fe0->dvb.frontend) {
1244 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1247 case SAA7134_BOARD_AVERMEDIA_777:
1248 case SAA7134_BOARD_AVERMEDIA_A16AR:
1249 dprintk("avertv 777 dvb setup\n");
1250 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1252 if (fe0->dvb.frontend) {
1253 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1254 &dev->i2c_adap, 0x61,
1255 TUNER_PHILIPS_TD1316);
1258 case SAA7134_BOARD_AVERMEDIA_A16D:
1259 dprintk("AverMedia A16D dvb setup\n");
1260 fe0->dvb.frontend = dvb_attach(mt352_attach,
1261 &avermedia_xc3028_mt352_dev,
1265 case SAA7134_BOARD_MD7134:
1266 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1269 if (fe0->dvb.frontend) {
1270 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1271 &dev->i2c_adap, medion_cardbus.tuner_address,
1272 TUNER_PHILIPS_FMD1216ME_MK3);
1275 case SAA7134_BOARD_PHILIPS_TOUGH:
1276 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1277 &philips_tu1216_60_config,
1279 if (fe0->dvb.frontend) {
1280 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1281 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1284 case SAA7134_BOARD_FLYDVBTDUO:
1285 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1286 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1287 &tda827x_cfg_0) < 0)
1288 goto detach_frontend;
1290 case SAA7134_BOARD_PHILIPS_EUROPA:
1291 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1292 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
1293 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1294 &philips_europa_config,
1296 if (fe0->dvb.frontend) {
1297 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1298 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1299 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1300 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1301 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1304 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1305 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1306 &technotrend_budget_t3000_config,
1308 if (fe0->dvb.frontend) {
1309 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1310 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1311 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1312 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1313 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1316 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1317 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1318 &philips_tu1216_61_config,
1320 if (fe0->dvb.frontend) {
1321 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1322 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1325 case SAA7134_BOARD_KWORLD_DVBT_210:
1326 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1327 &tda827x_cfg_2) < 0)
1328 goto detach_frontend;
1330 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1331 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1332 &hcw_tda10048_config,
1334 if (fe0->dvb.frontend != NULL) {
1335 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1336 &dev->i2c_adap, 0x4b,
1338 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1339 0x60, &dev->i2c_adap,
1340 &hcw_tda18271_config);
1343 case SAA7134_BOARD_PHILIPS_TIGER:
1344 if (configure_tda827x_fe(dev, &philips_tiger_config,
1345 &tda827x_cfg_0) < 0)
1346 goto detach_frontend;
1348 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1349 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1350 &tda827x_cfg_1) < 0)
1351 goto detach_frontend;
1353 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1354 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1355 &tda827x_cfg_1) < 0)
1356 goto detach_frontend;
1358 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
1359 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1360 &hcw_lgdt3305_config,
1362 if (fe0->dvb.frontend) {
1363 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1364 &dev->i2c_adap, 0x4b,
1366 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1367 0x60, &dev->i2c_adap,
1368 &hcw_tda18271_config);
1371 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1372 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1373 &tda827x_cfg_0) < 0)
1374 goto detach_frontend;
1376 case SAA7134_BOARD_FLYDVBT_LR301:
1377 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1378 &tda827x_cfg_0) < 0)
1379 goto detach_frontend;
1381 case SAA7134_BOARD_FLYDVB_TRIO:
1382 if (!use_frontend) { /* terrestrial */
1383 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1384 &tda827x_cfg_0) < 0)
1385 goto detach_frontend;
1386 } else { /* satellite */
1387 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1388 if (fe0->dvb.frontend) {
1389 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1390 &dev->i2c_adap, 0) == NULL) {
1391 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1392 goto detach_frontend;
1394 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1395 0x08, 0, 0) == NULL) {
1396 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1397 goto detach_frontend;
1402 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1403 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1404 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1405 &ads_tech_duo_config,
1407 if (fe0->dvb.frontend) {
1408 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1409 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1410 &ads_duo_cfg) == NULL) {
1411 wprintk("no tda827x tuner found at addr: %02x\n",
1412 ads_tech_duo_config.tuner_address);
1413 goto detach_frontend;
1416 wprintk("failed to attach tda10046\n");
1418 case SAA7134_BOARD_TEVION_DVBT_220RF:
1419 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1420 &tda827x_cfg_0) < 0)
1421 goto detach_frontend;
1423 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1424 if (!use_frontend) { /* terrestrial */
1425 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1426 &tda827x_cfg_0) < 0)
1427 goto detach_frontend;
1428 } else { /* satellite */
1429 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1430 &flydvbs, &dev->i2c_adap);
1431 if (fe0->dvb.frontend) {
1432 struct dvb_frontend *fe = fe0->dvb.frontend;
1433 u8 dev_id = dev->eedata[2];
1435 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1437 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1438 0x60, &dev->i2c_adap, 0) == NULL) {
1439 wprintk("%s: Medion Quadro, no tda826x "
1440 "found !\n", __func__);
1441 goto detach_frontend;
1443 if (dev_id != 0x08) {
1444 /* we need to open the i2c gate (we know it exists) */
1445 fe->ops.i2c_gate_ctrl(fe, 1);
1446 if (dvb_attach(isl6405_attach, fe,
1447 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1448 wprintk("%s: Medion Quadro, no ISL6405 "
1449 "found !\n", __func__);
1450 goto detach_frontend;
1452 if (dev_id == 0x07) {
1453 /* fire up the 2nd section of the LNB supply since
1454 we can't do this from the other section */
1456 i2c_transfer(&dev->i2c_adap, &msg, 1);
1458 fe->ops.i2c_gate_ctrl(fe, 0);
1459 dev->original_set_voltage = fe->ops.set_voltage;
1460 fe->ops.set_voltage = md8800_set_voltage;
1461 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1462 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1464 fe->ops.set_voltage = md8800_set_voltage2;
1465 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1470 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1471 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1473 if (fe0->dvb.frontend)
1474 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1475 NULL, DVB_PLL_TDHU2);
1477 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1478 case SAA7134_BOARD_KWORLD_ATSC110:
1479 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1481 if (fe0->dvb.frontend)
1482 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1483 &dev->i2c_adap, 0x61,
1484 TUNER_PHILIPS_TUV1236D);
1486 case SAA7134_BOARD_KWORLD_PC150U:
1487 saa7134_set_gpio(dev, 18, 1); /* Switch to digital mode */
1488 saa7134_tuner_callback(dev, 0,
1489 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1490 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1491 &kworld_s5h1411_config,
1493 if (fe0->dvb.frontend != NULL) {
1494 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1495 &dev->i2c_adap, 0x4b,
1497 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1498 0x60, &dev->i2c_adap,
1499 &kworld_pc150u_tda18271_config);
1502 case SAA7134_BOARD_FLYDVBS_LR300:
1503 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1505 if (fe0->dvb.frontend) {
1506 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1507 &dev->i2c_adap, 0) == NULL) {
1508 wprintk("%s: No tda826x found!\n", __func__);
1509 goto detach_frontend;
1511 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1512 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1513 wprintk("%s: No ISL6421 found!\n", __func__);
1514 goto detach_frontend;
1518 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1519 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1522 if (fe0->dvb.frontend) {
1523 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1524 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1526 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1527 &dev->i2c_adap, medion_cardbus.tuner_address,
1528 TUNER_PHILIPS_FMD1216ME_MK3);
1531 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1532 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1533 &philips_europa_config,
1535 if (fe0->dvb.frontend) {
1536 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1537 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1540 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1541 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1542 &tda827x_cfg_0) < 0)
1543 goto detach_frontend;
1545 case SAA7134_BOARD_CINERGY_HT_PCI:
1546 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1547 &tda827x_cfg_0) < 0)
1548 goto detach_frontend;
1550 case SAA7134_BOARD_PHILIPS_TIGER_S:
1551 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1552 &tda827x_cfg_2) < 0)
1553 goto detach_frontend;
1555 case SAA7134_BOARD_ASUS_P7131_4871:
1556 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1557 &tda827x_cfg_2) < 0)
1558 goto detach_frontend;
1560 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1561 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1562 &tda827x_cfg_2) < 0)
1563 goto detach_frontend;
1565 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1566 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1567 &tda827x_cfg_0) < 0)
1568 goto detach_frontend;
1570 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1571 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1572 &tda827x_cfg_2_sw42) < 0)
1573 goto detach_frontend;
1575 case SAA7134_BOARD_PHILIPS_SNAKE:
1576 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1578 if (fe0->dvb.frontend) {
1579 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1580 &dev->i2c_adap, 0) == NULL) {
1581 wprintk("%s: No tda826x found!\n", __func__);
1582 goto detach_frontend;
1584 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1585 &dev->i2c_adap, 0, 0) == NULL) {
1586 wprintk("%s: No lnbp21 found!\n", __func__);
1587 goto detach_frontend;
1591 case SAA7134_BOARD_CREATIX_CTX953:
1592 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1593 &tda827x_cfg_0) < 0)
1594 goto detach_frontend;
1596 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1597 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1598 &tda827x_cfg_2) < 0)
1599 goto detach_frontend;
1601 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1602 dprintk("AverMedia E506R dvb setup\n");
1603 saa7134_set_gpio(dev, 25, 0);
1605 saa7134_set_gpio(dev, 25, 1);
1606 fe0->dvb.frontend = dvb_attach(mt352_attach,
1607 &avermedia_xc3028_mt352_dev,
1611 case SAA7134_BOARD_MD7134_BRIDGE_2:
1612 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1613 &sd1878_4m, &dev->i2c_adap);
1614 if (fe0->dvb.frontend) {
1615 struct dvb_frontend *fe;
1616 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1617 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1618 wprintk("%s: MD7134 DVB-S, no SD1878 "
1619 "found !\n", __func__);
1620 goto detach_frontend;
1622 /* we need to open the i2c gate (we know it exists) */
1623 fe = fe0->dvb.frontend;
1624 fe->ops.i2c_gate_ctrl(fe, 1);
1625 if (dvb_attach(isl6405_attach, fe,
1626 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1627 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1628 "found !\n", __func__);
1629 goto detach_frontend;
1631 fe->ops.i2c_gate_ctrl(fe, 0);
1632 dev->original_set_voltage = fe->ops.set_voltage;
1633 fe->ops.set_voltage = md8800_set_voltage;
1634 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1635 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1638 case SAA7134_BOARD_AVERMEDIA_M103:
1639 saa7134_set_gpio(dev, 25, 0);
1641 saa7134_set_gpio(dev, 25, 1);
1642 fe0->dvb.frontend = dvb_attach(mt352_attach,
1643 &avermedia_xc3028_mt352_dev,
1647 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1648 if (!use_frontend) { /* terrestrial */
1649 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1650 &tda827x_cfg_2) < 0)
1651 goto detach_frontend;
1652 } else { /* satellite */
1653 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1654 &flydvbs, &dev->i2c_adap);
1655 if (fe0->dvb.frontend) {
1656 if (dvb_attach(tda826x_attach,
1657 fe0->dvb.frontend, 0x60,
1658 &dev->i2c_adap, 0) == NULL) {
1659 wprintk("%s: Asus Tiger 3in1, no "
1660 "tda826x found!\n", __func__);
1661 goto detach_frontend;
1663 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1664 &dev->i2c_adap, 0, 0) == NULL) {
1665 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1666 " found!\n", __func__);
1667 goto detach_frontend;
1672 case SAA7134_BOARD_ASUSTeK_PS3_100:
1673 if (!use_frontend) { /* terrestrial */
1674 if (configure_tda827x_fe(dev, &asus_ps3_100_config,
1675 &tda827x_cfg_2) < 0)
1676 goto detach_frontend;
1677 } else { /* satellite */
1678 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1679 &flydvbs, &dev->i2c_adap);
1680 if (fe0->dvb.frontend) {
1681 if (dvb_attach(tda826x_attach,
1682 fe0->dvb.frontend, 0x60,
1683 &dev->i2c_adap, 0) == NULL) {
1684 wprintk("%s: Asus My Cinema PS3-100, no "
1685 "tda826x found!\n", __func__);
1686 goto detach_frontend;
1688 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1689 &dev->i2c_adap, 0, 0) == NULL) {
1690 wprintk("%s: Asus My Cinema PS3-100, no lnbp21"
1691 " found!\n", __func__);
1692 goto detach_frontend;
1697 case SAA7134_BOARD_ASUSTeK_TIGER:
1698 if (configure_tda827x_fe(dev, &philips_tiger_config,
1699 &tda827x_cfg_0) < 0)
1700 goto detach_frontend;
1702 case SAA7134_BOARD_BEHOLD_H6:
1703 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1706 if (fe0->dvb.frontend) {
1707 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1708 &dev->i2c_adap, 0x61,
1709 TUNER_PHILIPS_FMD1216MEX_MK3);
1712 case SAA7134_BOARD_BEHOLD_X7:
1713 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1716 if (fe0->dvb.frontend) {
1717 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1718 &dev->i2c_adap, &behold_x7_tunerconfig);
1721 case SAA7134_BOARD_BEHOLD_H7:
1722 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1725 if (fe0->dvb.frontend) {
1726 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1727 &dev->i2c_adap, &behold_x7_tunerconfig);
1730 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1731 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1732 /* Zarlink ZL10313 */
1733 fe0->dvb.frontend = dvb_attach(mt312_attach,
1734 &avertv_a700_mt312, &dev->i2c_adap);
1735 if (fe0->dvb.frontend) {
1736 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1737 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1738 wprintk("%s: No zl10036 found!\n",
1743 case SAA7134_BOARD_VIDEOMATE_S350:
1744 fe0->dvb.frontend = dvb_attach(mt312_attach,
1745 &zl10313_compro_s350_config, &dev->i2c_adap);
1746 if (fe0->dvb.frontend)
1747 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1748 0x60, &dev->i2c_adap) == NULL)
1749 wprintk("%s: No zl10039 found!\n",
1753 case SAA7134_BOARD_VIDEOMATE_T750:
1754 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1755 &videomate_t750_zl10353_config,
1757 if (fe0->dvb.frontend != NULL) {
1758 if (dvb_attach(qt1010_attach,
1761 &videomate_t750_qt1010_config) == NULL)
1762 wprintk("error attaching QT1010\n");
1765 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1766 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1767 &zolid_tda10048_config,
1769 if (fe0->dvb.frontend != NULL) {
1770 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1771 &dev->i2c_adap, 0x4b,
1773 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1774 0x60, &dev->i2c_adap,
1775 &zolid_tda18271_config);
1778 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1779 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1780 &dtv1000s_tda10048_config,
1782 if (fe0->dvb.frontend != NULL) {
1783 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1784 &dev->i2c_adap, 0x4b,
1786 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1787 0x60, &dev->i2c_adap,
1788 &dtv1000s_tda18271_config);
1791 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
1792 /* Switch to digital mode */
1793 saa7134_tuner_callback(dev, 0,
1794 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1795 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1796 &kworld_mb86a20s_config,
1798 if (fe0->dvb.frontend != NULL) {
1799 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1800 &dev->i2c_adap, 0x4b,
1802 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
1803 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1804 0x60, &dev->i2c_adap,
1805 &kworld_tda18271_config);
1808 /* mb86a20s need to use the I2C gateway */
1810 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
1811 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1812 &prohdtv_pro2_lgs8g75_config,
1814 if (fe0->dvb.frontend != NULL) {
1815 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1816 &dev->i2c_adap, 0x4b,
1818 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1819 0x60, &dev->i2c_adap,
1820 &prohdtv_pro2_tda18271_config);
1824 wprintk("Huh? unknown DVB card?\n");
1828 if (attach_xc3028) {
1829 struct dvb_frontend *fe;
1830 struct xc2028_config cfg = {
1831 .i2c_adap = &dev->i2c_adap,
1835 if (!fe0->dvb.frontend)
1836 goto detach_frontend;
1838 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1840 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1842 goto detach_frontend;
1846 if (NULL == fe0->dvb.frontend) {
1847 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1848 goto detach_frontend;
1850 /* define general-purpose callback pointer */
1851 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1853 /* register everything else */
1854 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1855 &dev->pci->dev, adapter_nr, 0);
1857 /* this sequence is necessary to make the tda1004x load its firmware
1858 * and to enter analog mode of hybrid boards
1861 if (fe0->dvb.frontend->ops.init)
1862 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1863 if (fe0->dvb.frontend->ops.sleep)
1864 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1865 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1866 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1871 videobuf_dvb_dealloc_frontends(&dev->frontends);
1875 static int dvb_fini(struct saa7134_dev *dev)
1877 struct videobuf_dvb_frontend *fe0;
1879 /* Get the first frontend */
1880 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1884 /* FIXME: I suspect that this code is bogus, since the entry for
1885 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1886 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1888 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1889 struct v4l2_priv_tun_config tda9887_cfg;
1890 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1892 tda9887_cfg.tuner = TUNER_TDA9887;
1893 tda9887_cfg.priv = &on;
1895 /* otherwise we don't detect the tuner on next insmod */
1896 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1897 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1898 if ((dev->eedata[2] == 0x07) && use_frontend) {
1899 /* turn off the 2nd lnb supply */
1901 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1902 struct dvb_frontend *fe;
1903 fe = fe0->dvb.frontend;
1904 if (fe->ops.i2c_gate_ctrl) {
1905 fe->ops.i2c_gate_ctrl(fe, 1);
1906 i2c_transfer(&dev->i2c_adap, &msg, 1);
1907 fe->ops.i2c_gate_ctrl(fe, 0);
1911 videobuf_dvb_unregister_bus(&dev->frontends);
1915 static struct saa7134_mpeg_ops dvb_ops = {
1916 .type = SAA7134_MPEG_DVB,
1921 static int __init dvb_register(void)
1923 return saa7134_ts_register(&dvb_ops);
1926 static void __exit dvb_unregister(void)
1928 saa7134_ts_unregister(&dvb_ops);
1931 module_init(dvb_register);
1932 module_exit(dvb_unregister);
1934 /* ------------------------------------------------------------------ */