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"
65 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
66 MODULE_LICENSE("GPL");
68 static unsigned int antenna_pwr;
70 module_param(antenna_pwr, int, 0444);
71 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
73 static int use_frontend;
74 module_param(use_frontend, int, 0644);
75 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
78 module_param(debug, int, 0644);
79 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
81 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
83 #define dprintk(fmt, arg...) do { if (debug) \
84 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
87 #define wprintk(fmt, arg...) \
88 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
90 /* ------------------------------------------------------------------
91 * mt352 based DVB-T cards
94 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
99 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
100 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
104 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
105 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
108 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
109 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
111 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
113 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
114 dprintk("%s %s\n", __func__, ok ? "on" : "off");
117 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
121 static int mt352_pinnacle_init(struct dvb_frontend* fe)
123 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
124 static u8 reset [] = { RESET, 0x80 };
125 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
126 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
127 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
128 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
129 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
130 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
131 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
132 struct saa7134_dev *dev= fe->dvb->priv;
134 dprintk("%s called\n", __func__);
136 mt352_write(fe, clock_config, sizeof(clock_config));
138 mt352_write(fe, reset, sizeof(reset));
139 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
140 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
141 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
142 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
144 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
145 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
146 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
151 static int mt352_aver777_init(struct dvb_frontend* fe)
153 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
154 static u8 reset [] = { RESET, 0x80 };
155 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
156 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
157 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
159 mt352_write(fe, clock_config, sizeof(clock_config));
161 mt352_write(fe, reset, sizeof(reset));
162 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
163 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
164 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
169 static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
171 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
172 static u8 reset [] = { RESET, 0x80 };
173 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
174 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
175 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
177 mt352_write(fe, clock_config, sizeof(clock_config));
179 mt352_write(fe, reset, sizeof(reset));
180 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
181 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
182 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
186 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend *fe)
188 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
189 u8 off[] = { 0x00, 0xf1};
190 u8 on[] = { 0x00, 0x71};
191 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
193 struct saa7134_dev *dev = fe->dvb->priv;
194 struct v4l2_frequency f;
196 /* set frequency (mt2050) */
198 f.type = V4L2_TUNER_DIGITAL_TV;
199 f.frequency = c->frequency / 1000 * 16 / 1000;
200 if (fe->ops.i2c_gate_ctrl)
201 fe->ops.i2c_gate_ctrl(fe, 1);
202 i2c_transfer(&dev->i2c_adap, &msg, 1);
203 saa_call_all(dev, tuner, s_frequency, &f);
205 if (fe->ops.i2c_gate_ctrl)
206 fe->ops.i2c_gate_ctrl(fe, 1);
207 i2c_transfer(&dev->i2c_adap, &msg, 1);
209 pinnacle_antenna_pwr(dev, antenna_pwr);
212 return mt352_pinnacle_init(fe);
215 static struct mt352_config pinnacle_300i = {
216 .demod_address = 0x3c >> 1,
220 .demod_init = mt352_pinnacle_init,
223 static struct mt352_config avermedia_777 = {
224 .demod_address = 0xf,
225 .demod_init = mt352_aver777_init,
228 static struct mt352_config avermedia_xc3028_mt352_dev = {
229 .demod_address = (0x1e >> 1),
231 .demod_init = mt352_avermedia_xc3028_init,
234 static struct tda18271_std_map mb86a20s_tda18271_std_map = {
235 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
236 .if_lvl = 7, .rfagc_top = 0x37, },
239 static struct tda18271_config kworld_tda18271_config = {
240 .std_map = &mb86a20s_tda18271_std_map,
241 .gate = TDA18271_GATE_DIGITAL,
242 .config = 3, /* Use tuner callback for AGC */
246 static const struct mb86a20s_config kworld_mb86a20s_config = {
247 .demod_address = 0x10,
250 static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
252 struct saa7134_dev *dev = fe->dvb->priv;
254 unsigned char initmsg[] = {0x45, 0x97};
255 unsigned char msg_enable[] = {0x45, 0xc1};
256 unsigned char msg_disable[] = {0x45, 0x81};
257 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
259 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
260 wprintk("could not access the I2C gate\n");
264 msg.buf = msg_enable;
266 msg.buf = msg_disable;
267 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
268 wprintk("could not access the I2C gate\n");
275 /* ==================================================================
276 * tda1004x based DVB-T cards, helper functions
279 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
280 const struct firmware **fw, char *name)
282 struct saa7134_dev *dev = fe->dvb->priv;
283 return request_firmware(fw, name, &dev->pci->dev);
286 /* ------------------------------------------------------------------
287 * these tuners are tu1216, td1316(a)
290 static int philips_tda6651_pll_set(struct dvb_frontend *fe)
292 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
293 struct saa7134_dev *dev = fe->dvb->priv;
294 struct tda1004x_state *state = fe->demodulator_priv;
295 u8 addr = state->config->tuner_address;
297 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
299 int tuner_frequency = 0;
302 /* determine charge pump */
303 tuner_frequency = c->frequency + 36166000;
304 if (tuner_frequency < 87000000)
306 else if (tuner_frequency < 130000000)
308 else if (tuner_frequency < 160000000)
310 else if (tuner_frequency < 200000000)
312 else if (tuner_frequency < 290000000)
314 else if (tuner_frequency < 420000000)
316 else if (tuner_frequency < 480000000)
318 else if (tuner_frequency < 620000000)
320 else if (tuner_frequency < 830000000)
322 else if (tuner_frequency < 895000000)
328 if (c->frequency < 49000000)
330 else if (c->frequency < 161000000)
332 else if (c->frequency < 444000000)
334 else if (c->frequency < 861000000)
339 /* setup PLL filter */
340 switch (c->bandwidth_hz) {
358 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
360 tuner_frequency = (((c->frequency / 1000) * 6) + 217496) / 1000;
362 /* setup tuner buffer */
363 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
364 tuner_buf[1] = tuner_frequency & 0xff;
366 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
368 if (fe->ops.i2c_gate_ctrl)
369 fe->ops.i2c_gate_ctrl(fe, 1);
370 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
371 wprintk("could not write to tuner at addr: 0x%02x\n",
379 static int philips_tu1216_init(struct dvb_frontend *fe)
381 struct saa7134_dev *dev = fe->dvb->priv;
382 struct tda1004x_state *state = fe->demodulator_priv;
383 u8 addr = state->config->tuner_address;
384 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
385 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
387 /* setup PLL configuration */
388 if (fe->ops.i2c_gate_ctrl)
389 fe->ops.i2c_gate_ctrl(fe, 1);
390 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
397 /* ------------------------------------------------------------------ */
399 static struct tda1004x_config philips_tu1216_60_config = {
400 .demod_address = 0x8,
403 .xtal_freq = TDA10046_XTAL_4M,
404 .agc_config = TDA10046_AGC_DEFAULT,
405 .if_freq = TDA10046_FREQ_3617,
406 .tuner_address = 0x60,
407 .request_firmware = philips_tda1004x_request_firmware
410 static struct tda1004x_config philips_tu1216_61_config = {
412 .demod_address = 0x8,
415 .xtal_freq = TDA10046_XTAL_4M,
416 .agc_config = TDA10046_AGC_DEFAULT,
417 .if_freq = TDA10046_FREQ_3617,
418 .tuner_address = 0x61,
419 .request_firmware = philips_tda1004x_request_firmware
422 /* ------------------------------------------------------------------ */
424 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
426 struct saa7134_dev *dev = fe->dvb->priv;
427 struct tda1004x_state *state = fe->demodulator_priv;
428 u8 addr = state->config->tuner_address;
429 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
430 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
432 /* setup PLL configuration */
433 if (fe->ops.i2c_gate_ctrl)
434 fe->ops.i2c_gate_ctrl(fe, 1);
435 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
440 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe)
442 return philips_tda6651_pll_set(fe);
445 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
447 struct saa7134_dev *dev = fe->dvb->priv;
448 struct tda1004x_state *state = fe->demodulator_priv;
449 u8 addr = state->config->tuner_address;
450 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
451 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
453 /* switch the tuner to analog mode */
454 if (fe->ops.i2c_gate_ctrl)
455 fe->ops.i2c_gate_ctrl(fe, 1);
456 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
461 /* ------------------------------------------------------------------ */
463 static int philips_europa_tuner_init(struct dvb_frontend *fe)
465 struct saa7134_dev *dev = fe->dvb->priv;
466 static u8 msg[] = { 0x00, 0x40};
467 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
470 if (philips_td1316_tuner_init(fe))
473 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
479 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
481 struct saa7134_dev *dev = fe->dvb->priv;
483 static u8 msg[] = { 0x00, 0x14 };
484 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
486 if (philips_td1316_tuner_sleep(fe))
489 /* switch the board to analog mode */
490 if (fe->ops.i2c_gate_ctrl)
491 fe->ops.i2c_gate_ctrl(fe, 1);
492 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
496 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
498 struct saa7134_dev *dev = fe->dvb->priv;
500 if (dev->original_demod_sleep)
501 dev->original_demod_sleep(fe);
502 fe->ops.i2c_gate_ctrl(fe, 1);
506 static struct tda1004x_config philips_europa_config = {
508 .demod_address = 0x8,
511 .xtal_freq = TDA10046_XTAL_4M,
512 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
513 .if_freq = TDA10046_FREQ_052,
514 .tuner_address = 0x61,
515 .request_firmware = philips_tda1004x_request_firmware
518 static struct tda1004x_config medion_cardbus = {
519 .demod_address = 0x08,
522 .xtal_freq = TDA10046_XTAL_16M,
523 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
524 .if_freq = TDA10046_FREQ_3613,
525 .tuner_address = 0x61,
526 .request_firmware = philips_tda1004x_request_firmware
529 static struct tda1004x_config technotrend_budget_t3000_config = {
530 .demod_address = 0x8,
533 .xtal_freq = TDA10046_XTAL_4M,
534 .agc_config = TDA10046_AGC_DEFAULT,
535 .if_freq = TDA10046_FREQ_3617,
536 .tuner_address = 0x63,
537 .request_firmware = philips_tda1004x_request_firmware
540 /* ------------------------------------------------------------------
541 * tda 1004x based cards with philips silicon tuner
544 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
546 struct tda1004x_state *state = fe->demodulator_priv;
548 u8 addr = state->config->i2c_gate;
549 static u8 tda8290_close[] = { 0x21, 0xc0};
550 static u8 tda8290_open[] = { 0x21, 0x80};
551 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
553 tda8290_msg.buf = tda8290_close;
555 tda8290_msg.buf = tda8290_open;
557 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
558 struct saa7134_dev *dev = fe->dvb->priv;
559 wprintk("could not access tda8290 I2C gate\n");
566 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
568 struct saa7134_dev *dev = fe->dvb->priv;
569 struct tda1004x_state *state = fe->demodulator_priv;
571 switch (state->config->antenna_switch) {
573 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
574 saa7134_set_gpio(dev, 21, 0);
576 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
577 saa7134_set_gpio(dev, 21, 1);
583 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
585 struct saa7134_dev *dev = fe->dvb->priv;
586 struct tda1004x_state *state = fe->demodulator_priv;
588 switch (state->config->antenna_switch) {
590 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
591 saa7134_set_gpio(dev, 21, 1);
593 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
594 saa7134_set_gpio(dev, 21, 0);
600 static int configure_tda827x_fe(struct saa7134_dev *dev,
601 struct tda1004x_config *cdec_conf,
602 struct tda827x_config *tuner_conf)
604 struct videobuf_dvb_frontend *fe0;
606 /* Get the first frontend */
607 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
609 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
610 if (fe0->dvb.frontend) {
611 if (cdec_conf->i2c_gate)
612 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
613 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
614 cdec_conf->tuner_address,
615 &dev->i2c_adap, tuner_conf))
618 wprintk("no tda827x tuner found at addr: %02x\n",
619 cdec_conf->tuner_address);
624 /* ------------------------------------------------------------------ */
626 static struct tda827x_config tda827x_cfg_0 = {
627 .init = philips_tda827x_tuner_init,
628 .sleep = philips_tda827x_tuner_sleep,
633 static struct tda827x_config tda827x_cfg_1 = {
634 .init = philips_tda827x_tuner_init,
635 .sleep = philips_tda827x_tuner_sleep,
640 static struct tda827x_config tda827x_cfg_2 = {
641 .init = philips_tda827x_tuner_init,
642 .sleep = philips_tda827x_tuner_sleep,
647 static struct tda827x_config tda827x_cfg_2_sw42 = {
648 .init = philips_tda827x_tuner_init,
649 .sleep = philips_tda827x_tuner_sleep,
654 /* ------------------------------------------------------------------ */
656 static struct tda1004x_config tda827x_lifeview_config = {
657 .demod_address = 0x08,
660 .xtal_freq = TDA10046_XTAL_16M,
661 .agc_config = TDA10046_AGC_TDA827X,
662 .gpio_config = TDA10046_GP11_I,
663 .if_freq = TDA10046_FREQ_045,
664 .tuner_address = 0x60,
665 .request_firmware = philips_tda1004x_request_firmware
668 static struct tda1004x_config philips_tiger_config = {
669 .demod_address = 0x08,
672 .xtal_freq = TDA10046_XTAL_16M,
673 .agc_config = TDA10046_AGC_TDA827X,
674 .gpio_config = TDA10046_GP11_I,
675 .if_freq = TDA10046_FREQ_045,
677 .tuner_address = 0x61,
679 .request_firmware = philips_tda1004x_request_firmware
682 static struct tda1004x_config cinergy_ht_config = {
683 .demod_address = 0x08,
686 .xtal_freq = TDA10046_XTAL_16M,
687 .agc_config = TDA10046_AGC_TDA827X,
688 .gpio_config = TDA10046_GP01_I,
689 .if_freq = TDA10046_FREQ_045,
691 .tuner_address = 0x61,
692 .request_firmware = philips_tda1004x_request_firmware
695 static struct tda1004x_config cinergy_ht_pci_config = {
696 .demod_address = 0x08,
699 .xtal_freq = TDA10046_XTAL_16M,
700 .agc_config = TDA10046_AGC_TDA827X,
701 .gpio_config = TDA10046_GP01_I,
702 .if_freq = TDA10046_FREQ_045,
704 .tuner_address = 0x60,
705 .request_firmware = philips_tda1004x_request_firmware
708 static struct tda1004x_config philips_tiger_s_config = {
709 .demod_address = 0x08,
712 .xtal_freq = TDA10046_XTAL_16M,
713 .agc_config = TDA10046_AGC_TDA827X,
714 .gpio_config = TDA10046_GP01_I,
715 .if_freq = TDA10046_FREQ_045,
717 .tuner_address = 0x61,
719 .request_firmware = philips_tda1004x_request_firmware
722 static struct tda1004x_config pinnacle_pctv_310i_config = {
723 .demod_address = 0x08,
726 .xtal_freq = TDA10046_XTAL_16M,
727 .agc_config = TDA10046_AGC_TDA827X,
728 .gpio_config = TDA10046_GP11_I,
729 .if_freq = TDA10046_FREQ_045,
731 .tuner_address = 0x61,
732 .request_firmware = philips_tda1004x_request_firmware
735 static struct tda1004x_config hauppauge_hvr_1110_config = {
736 .demod_address = 0x08,
739 .xtal_freq = TDA10046_XTAL_16M,
740 .agc_config = TDA10046_AGC_TDA827X,
741 .gpio_config = TDA10046_GP11_I,
742 .if_freq = TDA10046_FREQ_045,
744 .tuner_address = 0x61,
745 .request_firmware = philips_tda1004x_request_firmware
748 static struct tda1004x_config asus_p7131_dual_config = {
749 .demod_address = 0x08,
752 .xtal_freq = TDA10046_XTAL_16M,
753 .agc_config = TDA10046_AGC_TDA827X,
754 .gpio_config = TDA10046_GP11_I,
755 .if_freq = TDA10046_FREQ_045,
757 .tuner_address = 0x61,
759 .request_firmware = philips_tda1004x_request_firmware
762 static struct tda1004x_config lifeview_trio_config = {
763 .demod_address = 0x09,
766 .xtal_freq = TDA10046_XTAL_16M,
767 .agc_config = TDA10046_AGC_TDA827X,
768 .gpio_config = TDA10046_GP00_I,
769 .if_freq = TDA10046_FREQ_045,
770 .tuner_address = 0x60,
771 .request_firmware = philips_tda1004x_request_firmware
774 static struct tda1004x_config tevion_dvbt220rf_config = {
775 .demod_address = 0x08,
778 .xtal_freq = TDA10046_XTAL_16M,
779 .agc_config = TDA10046_AGC_TDA827X,
780 .gpio_config = TDA10046_GP11_I,
781 .if_freq = TDA10046_FREQ_045,
782 .tuner_address = 0x60,
783 .request_firmware = philips_tda1004x_request_firmware
786 static struct tda1004x_config md8800_dvbt_config = {
787 .demod_address = 0x08,
790 .xtal_freq = TDA10046_XTAL_16M,
791 .agc_config = TDA10046_AGC_TDA827X,
792 .gpio_config = TDA10046_GP01_I,
793 .if_freq = TDA10046_FREQ_045,
795 .tuner_address = 0x60,
796 .request_firmware = philips_tda1004x_request_firmware
799 static struct tda1004x_config asus_p7131_4871_config = {
800 .demod_address = 0x08,
803 .xtal_freq = TDA10046_XTAL_16M,
804 .agc_config = TDA10046_AGC_TDA827X,
805 .gpio_config = TDA10046_GP01_I,
806 .if_freq = TDA10046_FREQ_045,
808 .tuner_address = 0x61,
810 .request_firmware = philips_tda1004x_request_firmware
813 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
814 .demod_address = 0x08,
817 .xtal_freq = TDA10046_XTAL_16M,
818 .agc_config = TDA10046_AGC_TDA827X,
819 .gpio_config = TDA10046_GP11_I,
820 .if_freq = TDA10046_FREQ_045,
822 .tuner_address = 0x61,
824 .request_firmware = philips_tda1004x_request_firmware
827 static struct tda1004x_config kworld_dvb_t_210_config = {
828 .demod_address = 0x08,
831 .xtal_freq = TDA10046_XTAL_16M,
832 .agc_config = TDA10046_AGC_TDA827X,
833 .gpio_config = TDA10046_GP11_I,
834 .if_freq = TDA10046_FREQ_045,
836 .tuner_address = 0x61,
838 .request_firmware = philips_tda1004x_request_firmware
841 static struct tda1004x_config avermedia_super_007_config = {
842 .demod_address = 0x08,
845 .xtal_freq = TDA10046_XTAL_16M,
846 .agc_config = TDA10046_AGC_TDA827X,
847 .gpio_config = TDA10046_GP01_I,
848 .if_freq = TDA10046_FREQ_045,
850 .tuner_address = 0x60,
852 .request_firmware = philips_tda1004x_request_firmware
855 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
856 .demod_address = 0x08,
859 .xtal_freq = TDA10046_XTAL_16M,
860 .agc_config = TDA10046_AGC_TDA827X,
861 .gpio_config = TDA10046_GP01_I,
862 .if_freq = TDA10046_FREQ_045,
864 .tuner_address = 0x61,
866 .request_firmware = philips_tda1004x_request_firmware
869 static struct tda1004x_config asus_tiger_3in1_config = {
870 .demod_address = 0x0b,
873 .xtal_freq = TDA10046_XTAL_16M,
874 .agc_config = TDA10046_AGC_TDA827X,
875 .gpio_config = TDA10046_GP11_I,
876 .if_freq = TDA10046_FREQ_045,
878 .tuner_address = 0x61,
880 .request_firmware = philips_tda1004x_request_firmware
883 /* ------------------------------------------------------------------
884 * special case: this card uses saa713x GPIO22 for the mode switch
887 static int ads_duo_tuner_init(struct dvb_frontend *fe)
889 struct saa7134_dev *dev = fe->dvb->priv;
890 philips_tda827x_tuner_init(fe);
891 /* route TDA8275a AGC input to the channel decoder */
892 saa7134_set_gpio(dev, 22, 1);
896 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
898 struct saa7134_dev *dev = fe->dvb->priv;
899 /* route TDA8275a AGC input to the analog IF chip*/
900 saa7134_set_gpio(dev, 22, 0);
901 philips_tda827x_tuner_sleep(fe);
905 static struct tda827x_config ads_duo_cfg = {
906 .init = ads_duo_tuner_init,
907 .sleep = ads_duo_tuner_sleep,
911 static struct tda1004x_config ads_tech_duo_config = {
912 .demod_address = 0x08,
915 .xtal_freq = TDA10046_XTAL_16M,
916 .agc_config = TDA10046_AGC_TDA827X,
917 .gpio_config = TDA10046_GP00_I,
918 .if_freq = TDA10046_FREQ_045,
919 .tuner_address = 0x61,
920 .request_firmware = philips_tda1004x_request_firmware
923 static struct zl10353_config behold_h6_config = {
924 .demod_address = 0x1e>>1,
927 .disable_i2c_gate_ctrl = 1,
930 static struct xc5000_config behold_x7_tunerconfig = {
931 .i2c_address = 0xc2>>1,
933 .radio_input = XC5000_RADIO_FM1,
936 static struct zl10353_config behold_x7_config = {
937 .demod_address = 0x1e>>1,
941 .disable_i2c_gate_ctrl = 1,
944 static struct zl10353_config videomate_t750_zl10353_config = {
945 .demod_address = 0x0f,
948 .disable_i2c_gate_ctrl = 1,
951 static struct qt1010_config videomate_t750_qt1010_config = {
956 /* ==================================================================
957 * tda10086 based DVB-S cards, helper functions
960 static struct tda10086_config flydvbs = {
961 .demod_address = 0x0e,
964 .xtal_freq = TDA10086_XTAL_16M,
967 static struct tda10086_config sd1878_4m = {
968 .demod_address = 0x0e,
971 .xtal_freq = TDA10086_XTAL_4M,
974 /* ------------------------------------------------------------------
975 * special case: lnb supply is connected to the gated i2c
978 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
981 struct saa7134_dev *dev = fe->dvb->priv;
982 if (fe->ops.i2c_gate_ctrl) {
983 fe->ops.i2c_gate_ctrl(fe, 1);
984 if (dev->original_set_voltage)
985 res = dev->original_set_voltage(fe, voltage);
986 fe->ops.i2c_gate_ctrl(fe, 0);
991 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
994 struct saa7134_dev *dev = fe->dvb->priv;
995 if (fe->ops.i2c_gate_ctrl) {
996 fe->ops.i2c_gate_ctrl(fe, 1);
997 if (dev->original_set_high_voltage)
998 res = dev->original_set_high_voltage(fe, arg);
999 fe->ops.i2c_gate_ctrl(fe, 0);
1004 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1006 struct saa7134_dev *dev = fe->dvb->priv;
1007 u8 wbuf[2] = { 0x1f, 00 };
1009 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
1010 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
1012 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
1014 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1015 if (voltage == SEC_VOLTAGE_18)
1016 wbuf[1] = rbuf | 0x10;
1018 wbuf[1] = rbuf & 0xef;
1020 i2c_transfer(&dev->i2c_adap, msg, 1);
1024 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1026 struct saa7134_dev *dev = fe->dvb->priv;
1027 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1031 /* ==================================================================
1032 * nxt200x based ATSC cards, helper functions
1035 static struct nxt200x_config avertvhda180 = {
1036 .demod_address = 0x0a,
1039 static struct nxt200x_config kworldatsc110 = {
1040 .demod_address = 0x0a,
1043 /* ------------------------------------------------------------------ */
1045 static struct mt312_config avertv_a700_mt312 = {
1046 .demod_address = 0x0e,
1047 .voltage_inverted = 1,
1050 static struct zl10036_config avertv_a700_tuner = {
1051 .tuner_address = 0x60,
1054 static struct mt312_config zl10313_compro_s350_config = {
1055 .demod_address = 0x0e,
1058 static struct lgdt3305_config hcw_lgdt3305_config = {
1060 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1061 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1062 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1064 .spectral_inversion = 1,
1069 static struct tda10048_config hcw_tda10048_config = {
1070 .demod_address = 0x10 >> 1,
1071 .output_mode = TDA10048_SERIAL_OUTPUT,
1072 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1073 .inversion = TDA10048_INVERSION_ON,
1074 .dtv6_if_freq_khz = TDA10048_IF_3300,
1075 .dtv7_if_freq_khz = TDA10048_IF_3500,
1076 .dtv8_if_freq_khz = TDA10048_IF_4000,
1077 .clk_freq_khz = TDA10048_CLK_16000,
1078 .disable_gate_access = 1,
1081 static struct tda18271_std_map hauppauge_tda18271_std_map = {
1082 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1083 .if_lvl = 1, .rfagc_top = 0x58, },
1084 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1085 .if_lvl = 1, .rfagc_top = 0x58, },
1088 static struct tda18271_config hcw_tda18271_config = {
1089 .std_map = &hauppauge_tda18271_std_map,
1090 .gate = TDA18271_GATE_ANALOG,
1092 .output_opt = TDA18271_OUTPUT_LT_OFF,
1095 static struct tda829x_config tda829x_no_probe = {
1096 .probe_tuner = TDA829X_DONT_PROBE,
1099 static struct tda10048_config zolid_tda10048_config = {
1100 .demod_address = 0x10 >> 1,
1101 .output_mode = TDA10048_PARALLEL_OUTPUT,
1102 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1103 .inversion = TDA10048_INVERSION_ON,
1104 .dtv6_if_freq_khz = TDA10048_IF_3300,
1105 .dtv7_if_freq_khz = TDA10048_IF_3500,
1106 .dtv8_if_freq_khz = TDA10048_IF_4000,
1107 .clk_freq_khz = TDA10048_CLK_16000,
1108 .disable_gate_access = 1,
1111 static struct tda18271_config zolid_tda18271_config = {
1112 .gate = TDA18271_GATE_ANALOG,
1115 static struct tda10048_config dtv1000s_tda10048_config = {
1116 .demod_address = 0x10 >> 1,
1117 .output_mode = TDA10048_PARALLEL_OUTPUT,
1118 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1119 .inversion = TDA10048_INVERSION_ON,
1120 .dtv6_if_freq_khz = TDA10048_IF_3300,
1121 .dtv7_if_freq_khz = TDA10048_IF_3800,
1122 .dtv8_if_freq_khz = TDA10048_IF_4300,
1123 .clk_freq_khz = TDA10048_CLK_16000,
1124 .disable_gate_access = 1,
1127 static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1128 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1129 .if_lvl = 1, .rfagc_top = 0x37, },
1130 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1131 .if_lvl = 1, .rfagc_top = 0x37, },
1132 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1133 .if_lvl = 1, .rfagc_top = 0x37, },
1136 static struct tda18271_config dtv1000s_tda18271_config = {
1137 .std_map = &dtv1000s_tda18271_std_map,
1138 .gate = TDA18271_GATE_ANALOG,
1141 static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
1142 .prod = LGS8GXX_PROD_LGS8G75,
1143 .demod_address = 0x1d,
1147 .if_clk_freq = 30400, /* 30.4 MHz */
1148 .if_freq = 4000, /* 4.00 MHz */
1152 .adc_vpp = 3, /* 2.0 Vpp */
1156 static struct tda18271_config prohdtv_pro2_tda18271_config = {
1157 .gate = TDA18271_GATE_ANALOG,
1158 .output_opt = TDA18271_OUTPUT_LT_OFF,
1161 /* ==================================================================
1165 static int dvb_init(struct saa7134_dev *dev)
1168 int attach_xc3028 = 0;
1169 struct videobuf_dvb_frontend *fe0;
1171 /* FIXME: add support for multi-frontend */
1172 mutex_init(&dev->frontends.lock);
1173 INIT_LIST_HEAD(&dev->frontends.felist);
1175 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
1176 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1178 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1182 /* init struct videobuf_dvb */
1183 dev->ts.nr_bufs = 32;
1184 dev->ts.nr_packets = 32*4;
1185 fe0->dvb.name = dev->name;
1186 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
1187 &dev->pci->dev, &dev->slock,
1188 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1189 V4L2_FIELD_ALTERNATE,
1190 sizeof(struct saa7134_buf),
1193 switch (dev->board) {
1194 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1195 dprintk("pinnacle 300i dvb setup\n");
1196 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1198 if (fe0->dvb.frontend) {
1199 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1202 case SAA7134_BOARD_AVERMEDIA_777:
1203 case SAA7134_BOARD_AVERMEDIA_A16AR:
1204 dprintk("avertv 777 dvb setup\n");
1205 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1207 if (fe0->dvb.frontend) {
1208 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1209 &dev->i2c_adap, 0x61,
1210 TUNER_PHILIPS_TD1316);
1213 case SAA7134_BOARD_AVERMEDIA_A16D:
1214 dprintk("AverMedia A16D dvb setup\n");
1215 fe0->dvb.frontend = dvb_attach(mt352_attach,
1216 &avermedia_xc3028_mt352_dev,
1220 case SAA7134_BOARD_MD7134:
1221 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1224 if (fe0->dvb.frontend) {
1225 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1226 &dev->i2c_adap, medion_cardbus.tuner_address,
1227 TUNER_PHILIPS_FMD1216ME_MK3);
1230 case SAA7134_BOARD_PHILIPS_TOUGH:
1231 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1232 &philips_tu1216_60_config,
1234 if (fe0->dvb.frontend) {
1235 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1236 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1239 case SAA7134_BOARD_FLYDVBTDUO:
1240 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1241 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1242 &tda827x_cfg_0) < 0)
1243 goto dettach_frontend;
1245 case SAA7134_BOARD_PHILIPS_EUROPA:
1246 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1247 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
1248 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1249 &philips_europa_config,
1251 if (fe0->dvb.frontend) {
1252 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1253 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1254 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1255 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1256 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1259 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1260 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1261 &technotrend_budget_t3000_config,
1263 if (fe0->dvb.frontend) {
1264 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1265 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1266 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1267 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1268 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1271 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1272 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1273 &philips_tu1216_61_config,
1275 if (fe0->dvb.frontend) {
1276 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1277 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1280 case SAA7134_BOARD_KWORLD_DVBT_210:
1281 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1282 &tda827x_cfg_2) < 0)
1283 goto dettach_frontend;
1285 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1286 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1287 &hcw_tda10048_config,
1289 if (fe0->dvb.frontend != NULL) {
1290 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1291 &dev->i2c_adap, 0x4b,
1293 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1294 0x60, &dev->i2c_adap,
1295 &hcw_tda18271_config);
1298 case SAA7134_BOARD_PHILIPS_TIGER:
1299 if (configure_tda827x_fe(dev, &philips_tiger_config,
1300 &tda827x_cfg_0) < 0)
1301 goto dettach_frontend;
1303 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1304 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1305 &tda827x_cfg_1) < 0)
1306 goto dettach_frontend;
1308 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1309 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1310 &tda827x_cfg_1) < 0)
1311 goto dettach_frontend;
1313 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
1314 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1315 &hcw_lgdt3305_config,
1317 if (fe0->dvb.frontend) {
1318 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1319 &dev->i2c_adap, 0x4b,
1321 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1322 0x60, &dev->i2c_adap,
1323 &hcw_tda18271_config);
1326 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1327 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1328 &tda827x_cfg_0) < 0)
1329 goto dettach_frontend;
1331 case SAA7134_BOARD_FLYDVBT_LR301:
1332 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1333 &tda827x_cfg_0) < 0)
1334 goto dettach_frontend;
1336 case SAA7134_BOARD_FLYDVB_TRIO:
1337 if (!use_frontend) { /* terrestrial */
1338 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1339 &tda827x_cfg_0) < 0)
1340 goto dettach_frontend;
1341 } else { /* satellite */
1342 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1343 if (fe0->dvb.frontend) {
1344 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1345 &dev->i2c_adap, 0) == NULL) {
1346 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1347 goto dettach_frontend;
1349 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1350 0x08, 0, 0) == NULL) {
1351 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1352 goto dettach_frontend;
1357 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1358 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1359 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1360 &ads_tech_duo_config,
1362 if (fe0->dvb.frontend) {
1363 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1364 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1365 &ads_duo_cfg) == NULL) {
1366 wprintk("no tda827x tuner found at addr: %02x\n",
1367 ads_tech_duo_config.tuner_address);
1368 goto dettach_frontend;
1371 wprintk("failed to attach tda10046\n");
1373 case SAA7134_BOARD_TEVION_DVBT_220RF:
1374 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1375 &tda827x_cfg_0) < 0)
1376 goto dettach_frontend;
1378 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1379 if (!use_frontend) { /* terrestrial */
1380 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1381 &tda827x_cfg_0) < 0)
1382 goto dettach_frontend;
1383 } else { /* satellite */
1384 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1385 &flydvbs, &dev->i2c_adap);
1386 if (fe0->dvb.frontend) {
1387 struct dvb_frontend *fe = fe0->dvb.frontend;
1388 u8 dev_id = dev->eedata[2];
1390 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1392 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1393 0x60, &dev->i2c_adap, 0) == NULL) {
1394 wprintk("%s: Medion Quadro, no tda826x "
1395 "found !\n", __func__);
1396 goto dettach_frontend;
1398 if (dev_id != 0x08) {
1399 /* we need to open the i2c gate (we know it exists) */
1400 fe->ops.i2c_gate_ctrl(fe, 1);
1401 if (dvb_attach(isl6405_attach, fe,
1402 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1403 wprintk("%s: Medion Quadro, no ISL6405 "
1404 "found !\n", __func__);
1405 goto dettach_frontend;
1407 if (dev_id == 0x07) {
1408 /* fire up the 2nd section of the LNB supply since
1409 we can't do this from the other section */
1411 i2c_transfer(&dev->i2c_adap, &msg, 1);
1413 fe->ops.i2c_gate_ctrl(fe, 0);
1414 dev->original_set_voltage = fe->ops.set_voltage;
1415 fe->ops.set_voltage = md8800_set_voltage;
1416 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1417 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1419 fe->ops.set_voltage = md8800_set_voltage2;
1420 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1425 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1426 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1428 if (fe0->dvb.frontend)
1429 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1430 NULL, DVB_PLL_TDHU2);
1432 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1433 case SAA7134_BOARD_KWORLD_ATSC110:
1434 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1436 if (fe0->dvb.frontend)
1437 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1438 &dev->i2c_adap, 0x61,
1439 TUNER_PHILIPS_TUV1236D);
1441 case SAA7134_BOARD_FLYDVBS_LR300:
1442 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1444 if (fe0->dvb.frontend) {
1445 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1446 &dev->i2c_adap, 0) == NULL) {
1447 wprintk("%s: No tda826x found!\n", __func__);
1448 goto dettach_frontend;
1450 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1451 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1452 wprintk("%s: No ISL6421 found!\n", __func__);
1453 goto dettach_frontend;
1457 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1458 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1461 if (fe0->dvb.frontend) {
1462 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1463 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1465 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1466 &dev->i2c_adap, medion_cardbus.tuner_address,
1467 TUNER_PHILIPS_FMD1216ME_MK3);
1470 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1471 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1472 &philips_europa_config,
1474 if (fe0->dvb.frontend) {
1475 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1476 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1479 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1480 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1481 &tda827x_cfg_0) < 0)
1482 goto dettach_frontend;
1484 case SAA7134_BOARD_CINERGY_HT_PCI:
1485 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1486 &tda827x_cfg_0) < 0)
1487 goto dettach_frontend;
1489 case SAA7134_BOARD_PHILIPS_TIGER_S:
1490 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1491 &tda827x_cfg_2) < 0)
1492 goto dettach_frontend;
1494 case SAA7134_BOARD_ASUS_P7131_4871:
1495 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1496 &tda827x_cfg_2) < 0)
1497 goto dettach_frontend;
1499 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1500 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1501 &tda827x_cfg_2) < 0)
1502 goto dettach_frontend;
1504 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1505 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1506 &tda827x_cfg_0) < 0)
1507 goto dettach_frontend;
1509 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1510 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1511 &tda827x_cfg_2_sw42) < 0)
1512 goto dettach_frontend;
1514 case SAA7134_BOARD_PHILIPS_SNAKE:
1515 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1517 if (fe0->dvb.frontend) {
1518 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1519 &dev->i2c_adap, 0) == NULL) {
1520 wprintk("%s: No tda826x found!\n", __func__);
1521 goto dettach_frontend;
1523 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1524 &dev->i2c_adap, 0, 0) == NULL) {
1525 wprintk("%s: No lnbp21 found!\n", __func__);
1526 goto dettach_frontend;
1530 case SAA7134_BOARD_CREATIX_CTX953:
1531 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1532 &tda827x_cfg_0) < 0)
1533 goto dettach_frontend;
1535 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1536 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1537 &tda827x_cfg_2) < 0)
1538 goto dettach_frontend;
1540 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1541 dprintk("AverMedia E506R dvb setup\n");
1542 saa7134_set_gpio(dev, 25, 0);
1544 saa7134_set_gpio(dev, 25, 1);
1545 fe0->dvb.frontend = dvb_attach(mt352_attach,
1546 &avermedia_xc3028_mt352_dev,
1550 case SAA7134_BOARD_MD7134_BRIDGE_2:
1551 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1552 &sd1878_4m, &dev->i2c_adap);
1553 if (fe0->dvb.frontend) {
1554 struct dvb_frontend *fe;
1555 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1556 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1557 wprintk("%s: MD7134 DVB-S, no SD1878 "
1558 "found !\n", __func__);
1559 goto dettach_frontend;
1561 /* we need to open the i2c gate (we know it exists) */
1562 fe = fe0->dvb.frontend;
1563 fe->ops.i2c_gate_ctrl(fe, 1);
1564 if (dvb_attach(isl6405_attach, fe,
1565 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1566 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1567 "found !\n", __func__);
1568 goto dettach_frontend;
1570 fe->ops.i2c_gate_ctrl(fe, 0);
1571 dev->original_set_voltage = fe->ops.set_voltage;
1572 fe->ops.set_voltage = md8800_set_voltage;
1573 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1574 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1577 case SAA7134_BOARD_AVERMEDIA_M103:
1578 saa7134_set_gpio(dev, 25, 0);
1580 saa7134_set_gpio(dev, 25, 1);
1581 fe0->dvb.frontend = dvb_attach(mt352_attach,
1582 &avermedia_xc3028_mt352_dev,
1586 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1587 if (!use_frontend) { /* terrestrial */
1588 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1589 &tda827x_cfg_2) < 0)
1590 goto dettach_frontend;
1591 } else { /* satellite */
1592 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1593 &flydvbs, &dev->i2c_adap);
1594 if (fe0->dvb.frontend) {
1595 if (dvb_attach(tda826x_attach,
1596 fe0->dvb.frontend, 0x60,
1597 &dev->i2c_adap, 0) == NULL) {
1598 wprintk("%s: Asus Tiger 3in1, no "
1599 "tda826x found!\n", __func__);
1600 goto dettach_frontend;
1602 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1603 &dev->i2c_adap, 0, 0) == NULL) {
1604 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1605 " found!\n", __func__);
1606 goto dettach_frontend;
1611 case SAA7134_BOARD_ASUSTeK_TIGER:
1612 if (configure_tda827x_fe(dev, &philips_tiger_config,
1613 &tda827x_cfg_0) < 0)
1614 goto dettach_frontend;
1616 case SAA7134_BOARD_BEHOLD_H6:
1617 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1620 if (fe0->dvb.frontend) {
1621 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1622 &dev->i2c_adap, 0x61,
1623 TUNER_PHILIPS_FMD1216MEX_MK3);
1626 case SAA7134_BOARD_BEHOLD_X7:
1627 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1630 if (fe0->dvb.frontend) {
1631 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1632 &dev->i2c_adap, &behold_x7_tunerconfig);
1635 case SAA7134_BOARD_BEHOLD_H7:
1636 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1639 if (fe0->dvb.frontend) {
1640 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1641 &dev->i2c_adap, &behold_x7_tunerconfig);
1644 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1645 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1646 /* Zarlink ZL10313 */
1647 fe0->dvb.frontend = dvb_attach(mt312_attach,
1648 &avertv_a700_mt312, &dev->i2c_adap);
1649 if (fe0->dvb.frontend) {
1650 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1651 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1652 wprintk("%s: No zl10036 found!\n",
1657 case SAA7134_BOARD_VIDEOMATE_S350:
1658 fe0->dvb.frontend = dvb_attach(mt312_attach,
1659 &zl10313_compro_s350_config, &dev->i2c_adap);
1660 if (fe0->dvb.frontend)
1661 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1662 0x60, &dev->i2c_adap) == NULL)
1663 wprintk("%s: No zl10039 found!\n",
1667 case SAA7134_BOARD_VIDEOMATE_T750:
1668 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1669 &videomate_t750_zl10353_config,
1671 if (fe0->dvb.frontend != NULL) {
1672 if (dvb_attach(qt1010_attach,
1675 &videomate_t750_qt1010_config) == NULL)
1676 wprintk("error attaching QT1010\n");
1679 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1680 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1681 &zolid_tda10048_config,
1683 if (fe0->dvb.frontend != NULL) {
1684 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1685 &dev->i2c_adap, 0x4b,
1687 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1688 0x60, &dev->i2c_adap,
1689 &zolid_tda18271_config);
1692 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1693 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1694 &dtv1000s_tda10048_config,
1696 if (fe0->dvb.frontend != NULL) {
1697 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1698 &dev->i2c_adap, 0x4b,
1700 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1701 0x60, &dev->i2c_adap,
1702 &dtv1000s_tda18271_config);
1705 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
1706 /* Switch to digital mode */
1707 saa7134_tuner_callback(dev, 0,
1708 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1709 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1710 &kworld_mb86a20s_config,
1712 if (fe0->dvb.frontend != NULL) {
1713 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1714 &dev->i2c_adap, 0x4b,
1716 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1717 0x60, &dev->i2c_adap,
1718 &kworld_tda18271_config);
1719 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
1722 /* mb86a20s need to use the I2C gateway */
1724 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
1725 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1726 &prohdtv_pro2_lgs8g75_config,
1728 if (fe0->dvb.frontend != NULL) {
1729 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1730 &dev->i2c_adap, 0x4b,
1732 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1733 0x60, &dev->i2c_adap,
1734 &prohdtv_pro2_tda18271_config);
1738 wprintk("Huh? unknown DVB card?\n");
1742 if (attach_xc3028) {
1743 struct dvb_frontend *fe;
1744 struct xc2028_config cfg = {
1745 .i2c_adap = &dev->i2c_adap,
1749 if (!fe0->dvb.frontend)
1750 goto dettach_frontend;
1752 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1754 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1756 goto dettach_frontend;
1760 if (NULL == fe0->dvb.frontend) {
1761 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1762 goto dettach_frontend;
1764 /* define general-purpose callback pointer */
1765 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1767 /* register everything else */
1768 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1769 &dev->pci->dev, adapter_nr, 0, NULL);
1771 /* this sequence is necessary to make the tda1004x load its firmware
1772 * and to enter analog mode of hybrid boards
1775 if (fe0->dvb.frontend->ops.init)
1776 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1777 if (fe0->dvb.frontend->ops.sleep)
1778 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1779 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1780 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1785 videobuf_dvb_dealloc_frontends(&dev->frontends);
1789 static int dvb_fini(struct saa7134_dev *dev)
1791 struct videobuf_dvb_frontend *fe0;
1793 /* Get the first frontend */
1794 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1798 /* FIXME: I suspect that this code is bogus, since the entry for
1799 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1800 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1802 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1803 struct v4l2_priv_tun_config tda9887_cfg;
1804 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1806 tda9887_cfg.tuner = TUNER_TDA9887;
1807 tda9887_cfg.priv = &on;
1809 /* otherwise we don't detect the tuner on next insmod */
1810 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1811 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1812 if ((dev->eedata[2] == 0x07) && use_frontend) {
1813 /* turn off the 2nd lnb supply */
1815 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1816 struct dvb_frontend *fe;
1817 fe = fe0->dvb.frontend;
1818 if (fe->ops.i2c_gate_ctrl) {
1819 fe->ops.i2c_gate_ctrl(fe, 1);
1820 i2c_transfer(&dev->i2c_adap, &msg, 1);
1821 fe->ops.i2c_gate_ctrl(fe, 0);
1825 videobuf_dvb_unregister_bus(&dev->frontends);
1829 static struct saa7134_mpeg_ops dvb_ops = {
1830 .type = SAA7134_MPEG_DVB,
1835 static int __init dvb_register(void)
1837 return saa7134_ts_register(&dvb_ops);
1840 static void __exit dvb_unregister(void)
1842 saa7134_ts_unregister(&dvb_ops);
1845 module_init(dvb_register);
1846 module_exit(dvb_unregister);
1848 /* ------------------------------------------------------------------ */