3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5 * Extended 3 / 2005 by Hartmut Hackmann to support various
6 * cards with the tda10046 DVB-T channel decoder
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/init.h>
24 #include <linux/list.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/slab.h>
28 #include <linux/delay.h>
29 #include <linux/kthread.h>
30 #include <linux/suspend.h>
32 #include "saa7134-reg.h"
34 #include <media/v4l2-common.h>
36 #include <dvb_frontend.h>
39 #include "mt352_priv.h" /* FIXME */
42 #include "tuner-xc2028.h"
50 #include "tuner-simple.h"
57 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
58 MODULE_LICENSE("GPL");
60 static unsigned int antenna_pwr;
62 module_param(antenna_pwr, int, 0444);
63 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
65 static int use_frontend;
66 module_param(use_frontend, int, 0644);
67 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
70 module_param(debug, int, 0644);
71 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
73 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
75 #define dprintk(fmt, arg...) do { if (debug) \
76 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
79 #define wprintk(fmt, arg...) \
80 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
82 /* ------------------------------------------------------------------
83 * mt352 based DVB-T cards
86 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
91 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
92 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
96 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
97 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
100 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
101 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
103 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
105 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
106 dprintk("%s %s\n", __func__, ok ? "on" : "off");
109 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
113 static int mt352_pinnacle_init(struct dvb_frontend* fe)
115 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
116 static u8 reset [] = { RESET, 0x80 };
117 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
118 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
119 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
120 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
121 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
122 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
123 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
124 struct saa7134_dev *dev= fe->dvb->priv;
126 dprintk("%s called\n", __func__);
128 mt352_write(fe, clock_config, sizeof(clock_config));
130 mt352_write(fe, reset, sizeof(reset));
131 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
132 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
133 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
134 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
136 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
137 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
138 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
143 static int mt352_aver777_init(struct dvb_frontend* fe)
145 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
146 static u8 reset [] = { RESET, 0x80 };
147 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
148 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
149 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
151 mt352_write(fe, clock_config, sizeof(clock_config));
153 mt352_write(fe, reset, sizeof(reset));
154 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
155 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
156 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
161 static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
163 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
164 static u8 reset [] = { RESET, 0x80 };
165 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
166 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
167 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
169 mt352_write(fe, clock_config, sizeof(clock_config));
171 mt352_write(fe, reset, sizeof(reset));
172 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
173 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
174 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
178 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
179 struct dvb_frontend_parameters* params)
181 u8 off[] = { 0x00, 0xf1};
182 u8 on[] = { 0x00, 0x71};
183 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
185 struct saa7134_dev *dev = fe->dvb->priv;
186 struct v4l2_frequency f;
188 /* set frequency (mt2050) */
190 f.type = V4L2_TUNER_DIGITAL_TV;
191 f.frequency = params->frequency / 1000 * 16 / 1000;
192 if (fe->ops.i2c_gate_ctrl)
193 fe->ops.i2c_gate_ctrl(fe, 1);
194 i2c_transfer(&dev->i2c_adap, &msg, 1);
195 saa_call_all(dev, tuner, s_frequency, &f);
197 if (fe->ops.i2c_gate_ctrl)
198 fe->ops.i2c_gate_ctrl(fe, 1);
199 i2c_transfer(&dev->i2c_adap, &msg, 1);
201 pinnacle_antenna_pwr(dev, antenna_pwr);
204 return mt352_pinnacle_init(fe);
207 static struct mt352_config pinnacle_300i = {
208 .demod_address = 0x3c >> 1,
212 .demod_init = mt352_pinnacle_init,
215 static struct mt352_config avermedia_777 = {
216 .demod_address = 0xf,
217 .demod_init = mt352_aver777_init,
220 static struct mt352_config avermedia_xc3028_mt352_dev = {
221 .demod_address = (0x1e >> 1),
223 .demod_init = mt352_avermedia_xc3028_init,
226 /* ==================================================================
227 * tda1004x based DVB-T cards, helper functions
230 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
231 const struct firmware **fw, char *name)
233 struct saa7134_dev *dev = fe->dvb->priv;
234 return request_firmware(fw, name, &dev->pci->dev);
237 /* ------------------------------------------------------------------
238 * these tuners are tu1216, td1316(a)
241 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
243 struct saa7134_dev *dev = fe->dvb->priv;
244 struct tda1004x_state *state = fe->demodulator_priv;
245 u8 addr = state->config->tuner_address;
247 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
249 int tuner_frequency = 0;
252 /* determine charge pump */
253 tuner_frequency = params->frequency + 36166000;
254 if (tuner_frequency < 87000000)
256 else if (tuner_frequency < 130000000)
258 else if (tuner_frequency < 160000000)
260 else if (tuner_frequency < 200000000)
262 else if (tuner_frequency < 290000000)
264 else if (tuner_frequency < 420000000)
266 else if (tuner_frequency < 480000000)
268 else if (tuner_frequency < 620000000)
270 else if (tuner_frequency < 830000000)
272 else if (tuner_frequency < 895000000)
278 if (params->frequency < 49000000)
280 else if (params->frequency < 161000000)
282 else if (params->frequency < 444000000)
284 else if (params->frequency < 861000000)
289 /* setup PLL filter */
290 switch (params->u.ofdm.bandwidth) {
291 case BANDWIDTH_6_MHZ:
295 case BANDWIDTH_7_MHZ:
299 case BANDWIDTH_8_MHZ:
308 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
310 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
312 /* setup tuner buffer */
313 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
314 tuner_buf[1] = tuner_frequency & 0xff;
316 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
318 if (fe->ops.i2c_gate_ctrl)
319 fe->ops.i2c_gate_ctrl(fe, 1);
320 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
321 wprintk("could not write to tuner at addr: 0x%02x\n",
329 static int philips_tu1216_init(struct dvb_frontend *fe)
331 struct saa7134_dev *dev = fe->dvb->priv;
332 struct tda1004x_state *state = fe->demodulator_priv;
333 u8 addr = state->config->tuner_address;
334 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
335 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
337 /* setup PLL configuration */
338 if (fe->ops.i2c_gate_ctrl)
339 fe->ops.i2c_gate_ctrl(fe, 1);
340 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
347 /* ------------------------------------------------------------------ */
349 static struct tda1004x_config philips_tu1216_60_config = {
350 .demod_address = 0x8,
353 .xtal_freq = TDA10046_XTAL_4M,
354 .agc_config = TDA10046_AGC_DEFAULT,
355 .if_freq = TDA10046_FREQ_3617,
356 .tuner_address = 0x60,
357 .request_firmware = philips_tda1004x_request_firmware
360 static struct tda1004x_config philips_tu1216_61_config = {
362 .demod_address = 0x8,
365 .xtal_freq = TDA10046_XTAL_4M,
366 .agc_config = TDA10046_AGC_DEFAULT,
367 .if_freq = TDA10046_FREQ_3617,
368 .tuner_address = 0x61,
369 .request_firmware = philips_tda1004x_request_firmware
372 /* ------------------------------------------------------------------ */
374 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
376 struct saa7134_dev *dev = fe->dvb->priv;
377 struct tda1004x_state *state = fe->demodulator_priv;
378 u8 addr = state->config->tuner_address;
379 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
380 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
382 /* setup PLL configuration */
383 if (fe->ops.i2c_gate_ctrl)
384 fe->ops.i2c_gate_ctrl(fe, 1);
385 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
390 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
392 return philips_tda6651_pll_set(fe, params);
395 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
397 struct saa7134_dev *dev = fe->dvb->priv;
398 struct tda1004x_state *state = fe->demodulator_priv;
399 u8 addr = state->config->tuner_address;
400 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
401 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
403 /* switch the tuner to analog mode */
404 if (fe->ops.i2c_gate_ctrl)
405 fe->ops.i2c_gate_ctrl(fe, 1);
406 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
411 /* ------------------------------------------------------------------ */
413 static int philips_europa_tuner_init(struct dvb_frontend *fe)
415 struct saa7134_dev *dev = fe->dvb->priv;
416 static u8 msg[] = { 0x00, 0x40};
417 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
420 if (philips_td1316_tuner_init(fe))
423 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
429 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
431 struct saa7134_dev *dev = fe->dvb->priv;
433 static u8 msg[] = { 0x00, 0x14 };
434 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
436 if (philips_td1316_tuner_sleep(fe))
439 /* switch the board to analog mode */
440 if (fe->ops.i2c_gate_ctrl)
441 fe->ops.i2c_gate_ctrl(fe, 1);
442 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
446 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
448 struct saa7134_dev *dev = fe->dvb->priv;
450 if (dev->original_demod_sleep)
451 dev->original_demod_sleep(fe);
452 fe->ops.i2c_gate_ctrl(fe, 1);
456 static struct tda1004x_config philips_europa_config = {
458 .demod_address = 0x8,
461 .xtal_freq = TDA10046_XTAL_4M,
462 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
463 .if_freq = TDA10046_FREQ_052,
464 .tuner_address = 0x61,
465 .request_firmware = philips_tda1004x_request_firmware
468 static struct tda1004x_config medion_cardbus = {
469 .demod_address = 0x08,
472 .xtal_freq = TDA10046_XTAL_16M,
473 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
474 .if_freq = TDA10046_FREQ_3613,
475 .tuner_address = 0x61,
476 .request_firmware = philips_tda1004x_request_firmware
479 /* ------------------------------------------------------------------
480 * tda 1004x based cards with philips silicon tuner
483 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
485 struct tda1004x_state *state = fe->demodulator_priv;
487 u8 addr = state->config->i2c_gate;
488 static u8 tda8290_close[] = { 0x21, 0xc0};
489 static u8 tda8290_open[] = { 0x21, 0x80};
490 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
492 tda8290_msg.buf = tda8290_close;
494 tda8290_msg.buf = tda8290_open;
496 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
497 struct saa7134_dev *dev = fe->dvb->priv;
498 wprintk("could not access tda8290 I2C gate\n");
505 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
507 struct saa7134_dev *dev = fe->dvb->priv;
508 struct tda1004x_state *state = fe->demodulator_priv;
510 switch (state->config->antenna_switch) {
512 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
513 saa7134_set_gpio(dev, 21, 0);
515 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
516 saa7134_set_gpio(dev, 21, 1);
522 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
524 struct saa7134_dev *dev = fe->dvb->priv;
525 struct tda1004x_state *state = fe->demodulator_priv;
527 switch (state->config->antenna_switch) {
529 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
530 saa7134_set_gpio(dev, 21, 1);
532 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
533 saa7134_set_gpio(dev, 21, 0);
539 static int configure_tda827x_fe(struct saa7134_dev *dev,
540 struct tda1004x_config *cdec_conf,
541 struct tda827x_config *tuner_conf)
543 struct videobuf_dvb_frontend *fe0;
545 /* Get the first frontend */
546 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
548 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
549 if (fe0->dvb.frontend) {
550 if (cdec_conf->i2c_gate)
551 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
552 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
553 cdec_conf->tuner_address,
554 &dev->i2c_adap, tuner_conf))
557 wprintk("no tda827x tuner found at addr: %02x\n",
558 cdec_conf->tuner_address);
563 /* ------------------------------------------------------------------ */
565 static struct tda827x_config tda827x_cfg_0 = {
566 .init = philips_tda827x_tuner_init,
567 .sleep = philips_tda827x_tuner_sleep,
572 static struct tda827x_config tda827x_cfg_1 = {
573 .init = philips_tda827x_tuner_init,
574 .sleep = philips_tda827x_tuner_sleep,
579 static struct tda827x_config tda827x_cfg_2 = {
580 .init = philips_tda827x_tuner_init,
581 .sleep = philips_tda827x_tuner_sleep,
586 static struct tda827x_config tda827x_cfg_2_sw42 = {
587 .init = philips_tda827x_tuner_init,
588 .sleep = philips_tda827x_tuner_sleep,
593 /* ------------------------------------------------------------------ */
595 static struct tda1004x_config tda827x_lifeview_config = {
596 .demod_address = 0x08,
599 .xtal_freq = TDA10046_XTAL_16M,
600 .agc_config = TDA10046_AGC_TDA827X,
601 .gpio_config = TDA10046_GP11_I,
602 .if_freq = TDA10046_FREQ_045,
603 .tuner_address = 0x60,
604 .request_firmware = philips_tda1004x_request_firmware
607 static struct tda1004x_config philips_tiger_config = {
608 .demod_address = 0x08,
611 .xtal_freq = TDA10046_XTAL_16M,
612 .agc_config = TDA10046_AGC_TDA827X,
613 .gpio_config = TDA10046_GP11_I,
614 .if_freq = TDA10046_FREQ_045,
616 .tuner_address = 0x61,
618 .request_firmware = philips_tda1004x_request_firmware
621 static struct tda1004x_config cinergy_ht_config = {
622 .demod_address = 0x08,
625 .xtal_freq = TDA10046_XTAL_16M,
626 .agc_config = TDA10046_AGC_TDA827X,
627 .gpio_config = TDA10046_GP01_I,
628 .if_freq = TDA10046_FREQ_045,
630 .tuner_address = 0x61,
631 .request_firmware = philips_tda1004x_request_firmware
634 static struct tda1004x_config cinergy_ht_pci_config = {
635 .demod_address = 0x08,
638 .xtal_freq = TDA10046_XTAL_16M,
639 .agc_config = TDA10046_AGC_TDA827X,
640 .gpio_config = TDA10046_GP01_I,
641 .if_freq = TDA10046_FREQ_045,
643 .tuner_address = 0x60,
644 .request_firmware = philips_tda1004x_request_firmware
647 static struct tda1004x_config philips_tiger_s_config = {
648 .demod_address = 0x08,
651 .xtal_freq = TDA10046_XTAL_16M,
652 .agc_config = TDA10046_AGC_TDA827X,
653 .gpio_config = TDA10046_GP01_I,
654 .if_freq = TDA10046_FREQ_045,
656 .tuner_address = 0x61,
658 .request_firmware = philips_tda1004x_request_firmware
661 static struct tda1004x_config pinnacle_pctv_310i_config = {
662 .demod_address = 0x08,
665 .xtal_freq = TDA10046_XTAL_16M,
666 .agc_config = TDA10046_AGC_TDA827X,
667 .gpio_config = TDA10046_GP11_I,
668 .if_freq = TDA10046_FREQ_045,
670 .tuner_address = 0x61,
671 .request_firmware = philips_tda1004x_request_firmware
674 static struct tda1004x_config hauppauge_hvr_1110_config = {
675 .demod_address = 0x08,
678 .xtal_freq = TDA10046_XTAL_16M,
679 .agc_config = TDA10046_AGC_TDA827X,
680 .gpio_config = TDA10046_GP11_I,
681 .if_freq = TDA10046_FREQ_045,
683 .tuner_address = 0x61,
684 .request_firmware = philips_tda1004x_request_firmware
687 static struct tda1004x_config asus_p7131_dual_config = {
688 .demod_address = 0x08,
691 .xtal_freq = TDA10046_XTAL_16M,
692 .agc_config = TDA10046_AGC_TDA827X,
693 .gpio_config = TDA10046_GP11_I,
694 .if_freq = TDA10046_FREQ_045,
696 .tuner_address = 0x61,
698 .request_firmware = philips_tda1004x_request_firmware
701 static struct tda1004x_config lifeview_trio_config = {
702 .demod_address = 0x09,
705 .xtal_freq = TDA10046_XTAL_16M,
706 .agc_config = TDA10046_AGC_TDA827X,
707 .gpio_config = TDA10046_GP00_I,
708 .if_freq = TDA10046_FREQ_045,
709 .tuner_address = 0x60,
710 .request_firmware = philips_tda1004x_request_firmware
713 static struct tda1004x_config tevion_dvbt220rf_config = {
714 .demod_address = 0x08,
717 .xtal_freq = TDA10046_XTAL_16M,
718 .agc_config = TDA10046_AGC_TDA827X,
719 .gpio_config = TDA10046_GP11_I,
720 .if_freq = TDA10046_FREQ_045,
721 .tuner_address = 0x60,
722 .request_firmware = philips_tda1004x_request_firmware
725 static struct tda1004x_config md8800_dvbt_config = {
726 .demod_address = 0x08,
729 .xtal_freq = TDA10046_XTAL_16M,
730 .agc_config = TDA10046_AGC_TDA827X,
731 .gpio_config = TDA10046_GP01_I,
732 .if_freq = TDA10046_FREQ_045,
734 .tuner_address = 0x60,
735 .request_firmware = philips_tda1004x_request_firmware
738 static struct tda1004x_config asus_p7131_4871_config = {
739 .demod_address = 0x08,
742 .xtal_freq = TDA10046_XTAL_16M,
743 .agc_config = TDA10046_AGC_TDA827X,
744 .gpio_config = TDA10046_GP01_I,
745 .if_freq = TDA10046_FREQ_045,
747 .tuner_address = 0x61,
749 .request_firmware = philips_tda1004x_request_firmware
752 static struct tda1004x_config asus_p7131_hybrid_lna_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 kworld_dvb_t_210_config = {
767 .demod_address = 0x08,
770 .xtal_freq = TDA10046_XTAL_16M,
771 .agc_config = TDA10046_AGC_TDA827X,
772 .gpio_config = TDA10046_GP11_I,
773 .if_freq = TDA10046_FREQ_045,
775 .tuner_address = 0x61,
777 .request_firmware = philips_tda1004x_request_firmware
780 static struct tda1004x_config avermedia_super_007_config = {
781 .demod_address = 0x08,
784 .xtal_freq = TDA10046_XTAL_16M,
785 .agc_config = TDA10046_AGC_TDA827X,
786 .gpio_config = TDA10046_GP01_I,
787 .if_freq = TDA10046_FREQ_045,
789 .tuner_address = 0x60,
791 .request_firmware = philips_tda1004x_request_firmware
794 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
795 .demod_address = 0x08,
798 .xtal_freq = TDA10046_XTAL_16M,
799 .agc_config = TDA10046_AGC_TDA827X,
800 .gpio_config = TDA10046_GP01_I,
801 .if_freq = TDA10046_FREQ_045,
803 .tuner_address = 0x61,
805 .request_firmware = philips_tda1004x_request_firmware
808 static struct tda1004x_config asus_tiger_3in1_config = {
809 .demod_address = 0x0b,
812 .xtal_freq = TDA10046_XTAL_16M,
813 .agc_config = TDA10046_AGC_TDA827X,
814 .gpio_config = TDA10046_GP11_I,
815 .if_freq = TDA10046_FREQ_045,
817 .tuner_address = 0x61,
819 .request_firmware = philips_tda1004x_request_firmware
822 /* ------------------------------------------------------------------
823 * special case: this card uses saa713x GPIO22 for the mode switch
826 static int ads_duo_tuner_init(struct dvb_frontend *fe)
828 struct saa7134_dev *dev = fe->dvb->priv;
829 philips_tda827x_tuner_init(fe);
830 /* route TDA8275a AGC input to the channel decoder */
831 saa7134_set_gpio(dev, 22, 1);
835 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
837 struct saa7134_dev *dev = fe->dvb->priv;
838 /* route TDA8275a AGC input to the analog IF chip*/
839 saa7134_set_gpio(dev, 22, 0);
840 philips_tda827x_tuner_sleep(fe);
844 static struct tda827x_config ads_duo_cfg = {
845 .init = ads_duo_tuner_init,
846 .sleep = ads_duo_tuner_sleep,
850 static struct tda1004x_config ads_tech_duo_config = {
851 .demod_address = 0x08,
854 .xtal_freq = TDA10046_XTAL_16M,
855 .agc_config = TDA10046_AGC_TDA827X,
856 .gpio_config = TDA10046_GP00_I,
857 .if_freq = TDA10046_FREQ_045,
858 .tuner_address = 0x61,
859 .request_firmware = philips_tda1004x_request_firmware
862 static struct zl10353_config behold_h6_config = {
863 .demod_address = 0x1e>>1,
866 .disable_i2c_gate_ctrl = 1,
869 /* ==================================================================
870 * tda10086 based DVB-S cards, helper functions
873 static struct tda10086_config flydvbs = {
874 .demod_address = 0x0e,
877 .xtal_freq = TDA10086_XTAL_16M,
880 static struct tda10086_config sd1878_4m = {
881 .demod_address = 0x0e,
884 .xtal_freq = TDA10086_XTAL_4M,
887 /* ------------------------------------------------------------------
888 * special case: lnb supply is connected to the gated i2c
891 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
894 struct saa7134_dev *dev = fe->dvb->priv;
895 if (fe->ops.i2c_gate_ctrl) {
896 fe->ops.i2c_gate_ctrl(fe, 1);
897 if (dev->original_set_voltage)
898 res = dev->original_set_voltage(fe, voltage);
899 fe->ops.i2c_gate_ctrl(fe, 0);
904 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
907 struct saa7134_dev *dev = fe->dvb->priv;
908 if (fe->ops.i2c_gate_ctrl) {
909 fe->ops.i2c_gate_ctrl(fe, 1);
910 if (dev->original_set_high_voltage)
911 res = dev->original_set_high_voltage(fe, arg);
912 fe->ops.i2c_gate_ctrl(fe, 0);
917 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
919 struct saa7134_dev *dev = fe->dvb->priv;
920 u8 wbuf[2] = { 0x1f, 00 };
922 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
923 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
925 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
927 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
928 if (voltage == SEC_VOLTAGE_18)
929 wbuf[1] = rbuf | 0x10;
931 wbuf[1] = rbuf & 0xef;
933 i2c_transfer(&dev->i2c_adap, msg, 1);
937 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
939 struct saa7134_dev *dev = fe->dvb->priv;
940 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
944 /* ==================================================================
945 * nxt200x based ATSC cards, helper functions
948 static struct nxt200x_config avertvhda180 = {
949 .demod_address = 0x0a,
952 static struct nxt200x_config kworldatsc110 = {
953 .demod_address = 0x0a,
956 /* ------------------------------------------------------------------ */
958 static struct mt312_config avertv_a700_mt312 = {
959 .demod_address = 0x0e,
960 .voltage_inverted = 1,
963 static struct zl10036_config avertv_a700_tuner = {
964 .tuner_address = 0x60,
967 /* ==================================================================
971 static int dvb_init(struct saa7134_dev *dev)
974 int attach_xc3028 = 0;
975 struct videobuf_dvb_frontend *fe0;
977 /* FIXME: add support for multi-frontend */
978 mutex_init(&dev->frontends.lock);
979 INIT_LIST_HEAD(&dev->frontends.felist);
981 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
982 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
984 printk(KERN_ERR "%s() failed to alloc\n", __func__);
988 /* init struct videobuf_dvb */
989 dev->ts.nr_bufs = 32;
990 dev->ts.nr_packets = 32*4;
991 fe0->dvb.name = dev->name;
992 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
993 &dev->pci->dev, &dev->slock,
994 V4L2_BUF_TYPE_VIDEO_CAPTURE,
995 V4L2_FIELD_ALTERNATE,
996 sizeof(struct saa7134_buf),
999 switch (dev->board) {
1000 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1001 dprintk("pinnacle 300i dvb setup\n");
1002 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1004 if (fe0->dvb.frontend) {
1005 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1008 case SAA7134_BOARD_AVERMEDIA_777:
1009 case SAA7134_BOARD_AVERMEDIA_A16AR:
1010 dprintk("avertv 777 dvb setup\n");
1011 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1013 if (fe0->dvb.frontend) {
1014 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1015 &dev->i2c_adap, 0x61,
1016 TUNER_PHILIPS_TD1316);
1019 case SAA7134_BOARD_AVERMEDIA_A16D:
1020 dprintk("AverMedia A16D dvb setup\n");
1021 fe0->dvb.frontend = dvb_attach(mt352_attach,
1022 &avermedia_xc3028_mt352_dev,
1026 case SAA7134_BOARD_MD7134:
1027 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1030 if (fe0->dvb.frontend) {
1031 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1032 &dev->i2c_adap, medion_cardbus.tuner_address,
1033 TUNER_PHILIPS_FMD1216ME_MK3);
1036 case SAA7134_BOARD_PHILIPS_TOUGH:
1037 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1038 &philips_tu1216_60_config,
1040 if (fe0->dvb.frontend) {
1041 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1042 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1045 case SAA7134_BOARD_FLYDVBTDUO:
1046 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1047 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1048 &tda827x_cfg_0) < 0)
1049 goto dettach_frontend;
1051 case SAA7134_BOARD_PHILIPS_EUROPA:
1052 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1053 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1054 &philips_europa_config,
1056 if (fe0->dvb.frontend) {
1057 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1058 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1059 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1060 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1061 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1064 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1065 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1066 &philips_tu1216_61_config,
1068 if (fe0->dvb.frontend) {
1069 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1070 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1073 case SAA7134_BOARD_KWORLD_DVBT_210:
1074 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1075 &tda827x_cfg_2) < 0)
1076 goto dettach_frontend;
1078 case SAA7134_BOARD_PHILIPS_TIGER:
1079 if (configure_tda827x_fe(dev, &philips_tiger_config,
1080 &tda827x_cfg_0) < 0)
1081 goto dettach_frontend;
1083 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1084 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1085 &tda827x_cfg_1) < 0)
1086 goto dettach_frontend;
1088 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1089 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1090 &tda827x_cfg_1) < 0)
1091 goto dettach_frontend;
1093 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1094 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1095 &tda827x_cfg_0) < 0)
1096 goto dettach_frontend;
1098 case SAA7134_BOARD_FLYDVBT_LR301:
1099 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1100 &tda827x_cfg_0) < 0)
1101 goto dettach_frontend;
1103 case SAA7134_BOARD_FLYDVB_TRIO:
1104 if (!use_frontend) { /* terrestrial */
1105 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1106 &tda827x_cfg_0) < 0)
1107 goto dettach_frontend;
1108 } else { /* satellite */
1109 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1110 if (fe0->dvb.frontend) {
1111 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1112 &dev->i2c_adap, 0) == NULL) {
1113 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1114 goto dettach_frontend;
1116 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1117 0x08, 0, 0) == NULL) {
1118 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1119 goto dettach_frontend;
1124 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1125 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1126 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1127 &ads_tech_duo_config,
1129 if (fe0->dvb.frontend) {
1130 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1131 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1132 &ads_duo_cfg) == NULL) {
1133 wprintk("no tda827x tuner found at addr: %02x\n",
1134 ads_tech_duo_config.tuner_address);
1135 goto dettach_frontend;
1138 wprintk("failed to attach tda10046\n");
1140 case SAA7134_BOARD_TEVION_DVBT_220RF:
1141 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1142 &tda827x_cfg_0) < 0)
1143 goto dettach_frontend;
1145 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1146 if (!use_frontend) { /* terrestrial */
1147 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1148 &tda827x_cfg_0) < 0)
1149 goto dettach_frontend;
1150 } else { /* satellite */
1151 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1152 &flydvbs, &dev->i2c_adap);
1153 if (fe0->dvb.frontend) {
1154 struct dvb_frontend *fe = fe0->dvb.frontend;
1155 u8 dev_id = dev->eedata[2];
1157 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1159 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1160 0x60, &dev->i2c_adap, 0) == NULL) {
1161 wprintk("%s: Medion Quadro, no tda826x "
1162 "found !\n", __func__);
1163 goto dettach_frontend;
1165 if (dev_id != 0x08) {
1166 /* we need to open the i2c gate (we know it exists) */
1167 fe->ops.i2c_gate_ctrl(fe, 1);
1168 if (dvb_attach(isl6405_attach, fe,
1169 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1170 wprintk("%s: Medion Quadro, no ISL6405 "
1171 "found !\n", __func__);
1172 goto dettach_frontend;
1174 if (dev_id == 0x07) {
1175 /* fire up the 2nd section of the LNB supply since
1176 we can't do this from the other section */
1178 i2c_transfer(&dev->i2c_adap, &msg, 1);
1180 fe->ops.i2c_gate_ctrl(fe, 0);
1181 dev->original_set_voltage = fe->ops.set_voltage;
1182 fe->ops.set_voltage = md8800_set_voltage;
1183 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1184 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1186 fe->ops.set_voltage = md8800_set_voltage2;
1187 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1192 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1193 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1195 if (fe0->dvb.frontend)
1196 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1197 NULL, DVB_PLL_TDHU2);
1199 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1200 case SAA7134_BOARD_KWORLD_ATSC110:
1201 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1203 if (fe0->dvb.frontend)
1204 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1205 &dev->i2c_adap, 0x61,
1206 TUNER_PHILIPS_TUV1236D);
1208 case SAA7134_BOARD_FLYDVBS_LR300:
1209 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1211 if (fe0->dvb.frontend) {
1212 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1213 &dev->i2c_adap, 0) == NULL) {
1214 wprintk("%s: No tda826x found!\n", __func__);
1215 goto dettach_frontend;
1217 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1218 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1219 wprintk("%s: No ISL6421 found!\n", __func__);
1220 goto dettach_frontend;
1224 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1225 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1228 if (fe0->dvb.frontend) {
1229 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1230 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1232 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1233 &dev->i2c_adap, medion_cardbus.tuner_address,
1234 TUNER_PHILIPS_FMD1216ME_MK3);
1237 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1238 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1239 &philips_europa_config,
1241 if (fe0->dvb.frontend) {
1242 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1243 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1246 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1247 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1248 &tda827x_cfg_0) < 0)
1249 goto dettach_frontend;
1251 case SAA7134_BOARD_CINERGY_HT_PCI:
1252 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1253 &tda827x_cfg_0) < 0)
1254 goto dettach_frontend;
1256 case SAA7134_BOARD_PHILIPS_TIGER_S:
1257 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1258 &tda827x_cfg_2) < 0)
1259 goto dettach_frontend;
1261 case SAA7134_BOARD_ASUS_P7131_4871:
1262 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1263 &tda827x_cfg_2) < 0)
1264 goto dettach_frontend;
1266 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1267 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1268 &tda827x_cfg_2) < 0)
1269 goto dettach_frontend;
1271 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1272 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1273 &tda827x_cfg_0) < 0)
1274 goto dettach_frontend;
1276 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1277 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1278 &tda827x_cfg_2_sw42) < 0)
1279 goto dettach_frontend;
1281 case SAA7134_BOARD_PHILIPS_SNAKE:
1282 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1284 if (fe0->dvb.frontend) {
1285 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1286 &dev->i2c_adap, 0) == NULL) {
1287 wprintk("%s: No tda826x found!\n", __func__);
1288 goto dettach_frontend;
1290 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1291 &dev->i2c_adap, 0, 0) == NULL) {
1292 wprintk("%s: No lnbp21 found!\n", __func__);
1293 goto dettach_frontend;
1297 case SAA7134_BOARD_CREATIX_CTX953:
1298 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1299 &tda827x_cfg_0) < 0)
1300 goto dettach_frontend;
1302 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1303 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1304 &tda827x_cfg_2) < 0)
1305 goto dettach_frontend;
1307 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1308 dprintk("AverMedia E506R dvb setup\n");
1309 saa7134_set_gpio(dev, 25, 0);
1311 saa7134_set_gpio(dev, 25, 1);
1312 fe0->dvb.frontend = dvb_attach(mt352_attach,
1313 &avermedia_xc3028_mt352_dev,
1317 case SAA7134_BOARD_MD7134_BRIDGE_2:
1318 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1319 &sd1878_4m, &dev->i2c_adap);
1320 if (fe0->dvb.frontend) {
1321 struct dvb_frontend *fe;
1322 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1323 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1324 wprintk("%s: MD7134 DVB-S, no SD1878 "
1325 "found !\n", __func__);
1326 goto dettach_frontend;
1328 /* we need to open the i2c gate (we know it exists) */
1329 fe = fe0->dvb.frontend;
1330 fe->ops.i2c_gate_ctrl(fe, 1);
1331 if (dvb_attach(isl6405_attach, fe,
1332 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1333 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1334 "found !\n", __func__);
1335 goto dettach_frontend;
1337 fe->ops.i2c_gate_ctrl(fe, 0);
1338 dev->original_set_voltage = fe->ops.set_voltage;
1339 fe->ops.set_voltage = md8800_set_voltage;
1340 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1341 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1344 case SAA7134_BOARD_AVERMEDIA_M103:
1345 saa7134_set_gpio(dev, 25, 0);
1347 saa7134_set_gpio(dev, 25, 1);
1348 fe0->dvb.frontend = dvb_attach(mt352_attach,
1349 &avermedia_xc3028_mt352_dev,
1353 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1354 if (!use_frontend) { /* terrestrial */
1355 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1356 &tda827x_cfg_2) < 0)
1357 goto dettach_frontend;
1358 } else { /* satellite */
1359 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1360 &flydvbs, &dev->i2c_adap);
1361 if (fe0->dvb.frontend) {
1362 if (dvb_attach(tda826x_attach,
1363 fe0->dvb.frontend, 0x60,
1364 &dev->i2c_adap, 0) == NULL) {
1365 wprintk("%s: Asus Tiger 3in1, no "
1366 "tda826x found!\n", __func__);
1367 goto dettach_frontend;
1369 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1370 &dev->i2c_adap, 0, 0) == NULL) {
1371 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1372 " found!\n", __func__);
1373 goto dettach_frontend;
1378 case SAA7134_BOARD_ASUSTeK_TIGER:
1379 if (configure_tda827x_fe(dev, &philips_tiger_config,
1380 &tda827x_cfg_0) < 0)
1381 goto dettach_frontend;
1383 case SAA7134_BOARD_BEHOLD_H6:
1384 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1387 if (fe0->dvb.frontend) {
1388 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1389 &dev->i2c_adap, 0x61,
1390 TUNER_PHILIPS_FMD1216ME_MK3);
1393 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1394 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1395 /* Zarlink ZL10313 */
1396 fe0->dvb.frontend = dvb_attach(mt312_attach,
1397 &avertv_a700_mt312, &dev->i2c_adap);
1398 if (fe0->dvb.frontend) {
1399 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1400 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1401 wprintk("%s: No zl10036 found!\n",
1407 wprintk("Huh? unknown DVB card?\n");
1411 if (attach_xc3028) {
1412 struct dvb_frontend *fe;
1413 struct xc2028_config cfg = {
1414 .i2c_adap = &dev->i2c_adap,
1418 if (!fe0->dvb.frontend)
1419 goto dettach_frontend;
1421 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1423 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1425 goto dettach_frontend;
1429 if (NULL == fe0->dvb.frontend) {
1430 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1431 goto dettach_frontend;
1433 /* define general-purpose callback pointer */
1434 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1436 /* register everything else */
1437 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1438 &dev->pci->dev, adapter_nr, 0);
1440 /* this sequence is necessary to make the tda1004x load its firmware
1441 * and to enter analog mode of hybrid boards
1444 if (fe0->dvb.frontend->ops.init)
1445 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1446 if (fe0->dvb.frontend->ops.sleep)
1447 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1448 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1449 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1454 videobuf_dvb_dealloc_frontends(&dev->frontends);
1458 static int dvb_fini(struct saa7134_dev *dev)
1460 struct videobuf_dvb_frontend *fe0;
1462 /* Get the first frontend */
1463 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1467 /* FIXME: I suspect that this code is bogus, since the entry for
1468 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1469 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1471 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1472 struct v4l2_priv_tun_config tda9887_cfg;
1473 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1475 tda9887_cfg.tuner = TUNER_TDA9887;
1476 tda9887_cfg.priv = &on;
1478 /* otherwise we don't detect the tuner on next insmod */
1479 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1480 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1481 if ((dev->eedata[2] == 0x07) && use_frontend) {
1482 /* turn off the 2nd lnb supply */
1484 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1485 struct dvb_frontend *fe;
1486 fe = fe0->dvb.frontend;
1487 if (fe->ops.i2c_gate_ctrl) {
1488 fe->ops.i2c_gate_ctrl(fe, 1);
1489 i2c_transfer(&dev->i2c_adap, &msg, 1);
1490 fe->ops.i2c_gate_ctrl(fe, 0);
1494 videobuf_dvb_unregister_bus(&dev->frontends);
1498 static struct saa7134_mpeg_ops dvb_ops = {
1499 .type = SAA7134_MPEG_DVB,
1504 static int __init dvb_register(void)
1506 return saa7134_ts_register(&dvb_ops);
1509 static void __exit dvb_unregister(void)
1511 saa7134_ts_unregister(&dvb_ops);
1514 module_init(dvb_register);
1515 module_exit(dvb_unregister);
1517 /* ------------------------------------------------------------------ */