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"
52 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
53 MODULE_LICENSE("GPL");
55 static unsigned int antenna_pwr;
57 module_param(antenna_pwr, int, 0444);
58 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
60 static int use_frontend;
61 module_param(use_frontend, int, 0644);
62 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
65 module_param(debug, int, 0644);
66 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
68 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
70 #define dprintk(fmt, arg...) do { if (debug) \
71 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
74 #define wprintk(fmt, arg...) \
75 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
77 /* ------------------------------------------------------------------
78 * mt352 based DVB-T cards
81 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
86 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
87 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
91 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
92 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
95 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
96 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
98 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
100 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
101 dprintk("%s %s\n", __func__, ok ? "on" : "off");
104 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
108 static int mt352_pinnacle_init(struct dvb_frontend* fe)
110 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
111 static u8 reset [] = { RESET, 0x80 };
112 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
113 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
114 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
115 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
116 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
117 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
118 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
119 struct saa7134_dev *dev= fe->dvb->priv;
121 dprintk("%s called\n", __func__);
123 mt352_write(fe, clock_config, sizeof(clock_config));
125 mt352_write(fe, reset, sizeof(reset));
126 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
127 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
128 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
129 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
131 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
132 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
133 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
138 static int mt352_aver777_init(struct dvb_frontend* fe)
140 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
141 static u8 reset [] = { RESET, 0x80 };
142 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
143 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
144 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
146 mt352_write(fe, clock_config, sizeof(clock_config));
148 mt352_write(fe, reset, sizeof(reset));
149 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
150 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
151 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
156 static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
158 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
159 static u8 reset [] = { RESET, 0x80 };
160 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
161 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
162 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
164 mt352_write(fe, clock_config, sizeof(clock_config));
166 mt352_write(fe, reset, sizeof(reset));
167 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
168 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
169 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
173 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
174 struct dvb_frontend_parameters* params)
176 u8 off[] = { 0x00, 0xf1};
177 u8 on[] = { 0x00, 0x71};
178 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
180 struct saa7134_dev *dev = fe->dvb->priv;
181 struct v4l2_frequency f;
183 /* set frequency (mt2050) */
185 f.type = V4L2_TUNER_DIGITAL_TV;
186 f.frequency = params->frequency / 1000 * 16 / 1000;
187 if (fe->ops.i2c_gate_ctrl)
188 fe->ops.i2c_gate_ctrl(fe, 1);
189 i2c_transfer(&dev->i2c_adap, &msg, 1);
190 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
192 if (fe->ops.i2c_gate_ctrl)
193 fe->ops.i2c_gate_ctrl(fe, 1);
194 i2c_transfer(&dev->i2c_adap, &msg, 1);
196 pinnacle_antenna_pwr(dev, antenna_pwr);
199 return mt352_pinnacle_init(fe);
202 static struct mt352_config pinnacle_300i = {
203 .demod_address = 0x3c >> 1,
207 .demod_init = mt352_pinnacle_init,
210 static struct mt352_config avermedia_777 = {
211 .demod_address = 0xf,
212 .demod_init = mt352_aver777_init,
215 static struct mt352_config avermedia_xc3028_mt352_dev = {
216 .demod_address = (0x1e >> 1),
218 .demod_init = mt352_avermedia_xc3028_init,
221 /* ==================================================================
222 * tda1004x based DVB-T cards, helper functions
225 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
226 const struct firmware **fw, char *name)
228 struct saa7134_dev *dev = fe->dvb->priv;
229 return request_firmware(fw, name, &dev->pci->dev);
232 /* ------------------------------------------------------------------
233 * these tuners are tu1216, td1316(a)
236 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
238 struct saa7134_dev *dev = fe->dvb->priv;
239 struct tda1004x_state *state = fe->demodulator_priv;
240 u8 addr = state->config->tuner_address;
242 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
244 int tuner_frequency = 0;
247 /* determine charge pump */
248 tuner_frequency = params->frequency + 36166000;
249 if (tuner_frequency < 87000000)
251 else if (tuner_frequency < 130000000)
253 else if (tuner_frequency < 160000000)
255 else if (tuner_frequency < 200000000)
257 else if (tuner_frequency < 290000000)
259 else if (tuner_frequency < 420000000)
261 else if (tuner_frequency < 480000000)
263 else if (tuner_frequency < 620000000)
265 else if (tuner_frequency < 830000000)
267 else if (tuner_frequency < 895000000)
273 if (params->frequency < 49000000)
275 else if (params->frequency < 161000000)
277 else if (params->frequency < 444000000)
279 else if (params->frequency < 861000000)
284 /* setup PLL filter */
285 switch (params->u.ofdm.bandwidth) {
286 case BANDWIDTH_6_MHZ:
290 case BANDWIDTH_7_MHZ:
294 case BANDWIDTH_8_MHZ:
303 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
305 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
307 /* setup tuner buffer */
308 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
309 tuner_buf[1] = tuner_frequency & 0xff;
311 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
313 if (fe->ops.i2c_gate_ctrl)
314 fe->ops.i2c_gate_ctrl(fe, 1);
315 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
316 wprintk("could not write to tuner at addr: 0x%02x\n",
324 static int philips_tu1216_init(struct dvb_frontend *fe)
326 struct saa7134_dev *dev = fe->dvb->priv;
327 struct tda1004x_state *state = fe->demodulator_priv;
328 u8 addr = state->config->tuner_address;
329 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
330 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
332 /* setup PLL configuration */
333 if (fe->ops.i2c_gate_ctrl)
334 fe->ops.i2c_gate_ctrl(fe, 1);
335 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
342 /* ------------------------------------------------------------------ */
344 static struct tda1004x_config philips_tu1216_60_config = {
345 .demod_address = 0x8,
348 .xtal_freq = TDA10046_XTAL_4M,
349 .agc_config = TDA10046_AGC_DEFAULT,
350 .if_freq = TDA10046_FREQ_3617,
351 .tuner_address = 0x60,
352 .request_firmware = philips_tda1004x_request_firmware
355 static struct tda1004x_config philips_tu1216_61_config = {
357 .demod_address = 0x8,
360 .xtal_freq = TDA10046_XTAL_4M,
361 .agc_config = TDA10046_AGC_DEFAULT,
362 .if_freq = TDA10046_FREQ_3617,
363 .tuner_address = 0x61,
364 .request_firmware = philips_tda1004x_request_firmware
367 /* ------------------------------------------------------------------ */
369 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
371 struct saa7134_dev *dev = fe->dvb->priv;
372 struct tda1004x_state *state = fe->demodulator_priv;
373 u8 addr = state->config->tuner_address;
374 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
375 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
377 /* setup PLL configuration */
378 if (fe->ops.i2c_gate_ctrl)
379 fe->ops.i2c_gate_ctrl(fe, 1);
380 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
385 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
387 return philips_tda6651_pll_set(fe, params);
390 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
392 struct saa7134_dev *dev = fe->dvb->priv;
393 struct tda1004x_state *state = fe->demodulator_priv;
394 u8 addr = state->config->tuner_address;
395 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
396 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
398 /* switch the tuner to analog mode */
399 if (fe->ops.i2c_gate_ctrl)
400 fe->ops.i2c_gate_ctrl(fe, 1);
401 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
406 /* ------------------------------------------------------------------ */
408 static int philips_europa_tuner_init(struct dvb_frontend *fe)
410 struct saa7134_dev *dev = fe->dvb->priv;
411 static u8 msg[] = { 0x00, 0x40};
412 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
415 if (philips_td1316_tuner_init(fe))
418 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
424 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
426 struct saa7134_dev *dev = fe->dvb->priv;
428 static u8 msg[] = { 0x00, 0x14 };
429 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
431 if (philips_td1316_tuner_sleep(fe))
434 /* switch the board to analog mode */
435 if (fe->ops.i2c_gate_ctrl)
436 fe->ops.i2c_gate_ctrl(fe, 1);
437 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
441 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
443 struct saa7134_dev *dev = fe->dvb->priv;
445 if (dev->original_demod_sleep)
446 dev->original_demod_sleep(fe);
447 fe->ops.i2c_gate_ctrl(fe, 1);
451 static struct tda1004x_config philips_europa_config = {
453 .demod_address = 0x8,
456 .xtal_freq = TDA10046_XTAL_4M,
457 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
458 .if_freq = TDA10046_FREQ_052,
459 .tuner_address = 0x61,
460 .request_firmware = philips_tda1004x_request_firmware
463 static struct tda1004x_config medion_cardbus = {
464 .demod_address = 0x08,
467 .xtal_freq = TDA10046_XTAL_16M,
468 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
469 .if_freq = TDA10046_FREQ_3613,
470 .tuner_address = 0x61,
471 .request_firmware = philips_tda1004x_request_firmware
474 /* ------------------------------------------------------------------
475 * tda 1004x based cards with philips silicon tuner
478 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
480 struct tda1004x_state *state = fe->demodulator_priv;
482 u8 addr = state->config->i2c_gate;
483 static u8 tda8290_close[] = { 0x21, 0xc0};
484 static u8 tda8290_open[] = { 0x21, 0x80};
485 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
487 tda8290_msg.buf = tda8290_close;
489 tda8290_msg.buf = tda8290_open;
491 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
492 struct saa7134_dev *dev = fe->dvb->priv;
493 wprintk("could not access tda8290 I2C gate\n");
500 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
502 struct saa7134_dev *dev = fe->dvb->priv;
503 struct tda1004x_state *state = fe->demodulator_priv;
505 switch (state->config->antenna_switch) {
507 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
508 saa7134_set_gpio(dev, 21, 0);
510 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
511 saa7134_set_gpio(dev, 21, 1);
517 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
519 struct saa7134_dev *dev = fe->dvb->priv;
520 struct tda1004x_state *state = fe->demodulator_priv;
522 switch (state->config->antenna_switch) {
524 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
525 saa7134_set_gpio(dev, 21, 1);
527 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
528 saa7134_set_gpio(dev, 21, 0);
534 static int configure_tda827x_fe(struct saa7134_dev *dev,
535 struct tda1004x_config *cdec_conf,
536 struct tda827x_config *tuner_conf)
538 dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
539 if (dev->dvb.frontend) {
540 if (cdec_conf->i2c_gate)
541 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
542 if (dvb_attach(tda827x_attach, dev->dvb.frontend,
543 cdec_conf->tuner_address,
544 &dev->i2c_adap, tuner_conf))
547 wprintk("no tda827x tuner found at addr: %02x\n",
548 cdec_conf->tuner_address);
553 /* ------------------------------------------------------------------ */
555 static struct tda827x_config tda827x_cfg_0 = {
556 .tuner_callback = saa7134_tuner_callback,
557 .init = philips_tda827x_tuner_init,
558 .sleep = philips_tda827x_tuner_sleep,
563 static struct tda827x_config tda827x_cfg_1 = {
564 .tuner_callback = saa7134_tuner_callback,
565 .init = philips_tda827x_tuner_init,
566 .sleep = philips_tda827x_tuner_sleep,
571 static struct tda827x_config tda827x_cfg_2 = {
572 .tuner_callback = saa7134_tuner_callback,
573 .init = philips_tda827x_tuner_init,
574 .sleep = philips_tda827x_tuner_sleep,
579 static struct tda827x_config tda827x_cfg_2_sw42 = {
580 .tuner_callback = saa7134_tuner_callback,
581 .init = philips_tda827x_tuner_init,
582 .sleep = philips_tda827x_tuner_sleep,
587 /* ------------------------------------------------------------------ */
589 static struct tda1004x_config tda827x_lifeview_config = {
590 .demod_address = 0x08,
593 .xtal_freq = TDA10046_XTAL_16M,
594 .agc_config = TDA10046_AGC_TDA827X,
595 .gpio_config = TDA10046_GP11_I,
596 .if_freq = TDA10046_FREQ_045,
597 .tuner_address = 0x60,
598 .request_firmware = philips_tda1004x_request_firmware
601 static struct tda1004x_config philips_tiger_config = {
602 .demod_address = 0x08,
605 .xtal_freq = TDA10046_XTAL_16M,
606 .agc_config = TDA10046_AGC_TDA827X,
607 .gpio_config = TDA10046_GP11_I,
608 .if_freq = TDA10046_FREQ_045,
610 .tuner_address = 0x61,
612 .request_firmware = philips_tda1004x_request_firmware
615 static struct tda1004x_config cinergy_ht_config = {
616 .demod_address = 0x08,
619 .xtal_freq = TDA10046_XTAL_16M,
620 .agc_config = TDA10046_AGC_TDA827X,
621 .gpio_config = TDA10046_GP01_I,
622 .if_freq = TDA10046_FREQ_045,
624 .tuner_address = 0x61,
625 .request_firmware = philips_tda1004x_request_firmware
628 static struct tda1004x_config cinergy_ht_pci_config = {
629 .demod_address = 0x08,
632 .xtal_freq = TDA10046_XTAL_16M,
633 .agc_config = TDA10046_AGC_TDA827X,
634 .gpio_config = TDA10046_GP01_I,
635 .if_freq = TDA10046_FREQ_045,
637 .tuner_address = 0x60,
638 .request_firmware = philips_tda1004x_request_firmware
641 static struct tda1004x_config philips_tiger_s_config = {
642 .demod_address = 0x08,
645 .xtal_freq = TDA10046_XTAL_16M,
646 .agc_config = TDA10046_AGC_TDA827X,
647 .gpio_config = TDA10046_GP01_I,
648 .if_freq = TDA10046_FREQ_045,
650 .tuner_address = 0x61,
652 .request_firmware = philips_tda1004x_request_firmware
655 static struct tda1004x_config pinnacle_pctv_310i_config = {
656 .demod_address = 0x08,
659 .xtal_freq = TDA10046_XTAL_16M,
660 .agc_config = TDA10046_AGC_TDA827X,
661 .gpio_config = TDA10046_GP11_I,
662 .if_freq = TDA10046_FREQ_045,
664 .tuner_address = 0x61,
665 .request_firmware = philips_tda1004x_request_firmware
668 static struct tda1004x_config hauppauge_hvr_1110_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,
678 .request_firmware = philips_tda1004x_request_firmware
681 static struct tda1004x_config asus_p7131_dual_config = {
682 .demod_address = 0x08,
685 .xtal_freq = TDA10046_XTAL_16M,
686 .agc_config = TDA10046_AGC_TDA827X,
687 .gpio_config = TDA10046_GP11_I,
688 .if_freq = TDA10046_FREQ_045,
690 .tuner_address = 0x61,
692 .request_firmware = philips_tda1004x_request_firmware
695 static struct tda1004x_config lifeview_trio_config = {
696 .demod_address = 0x09,
699 .xtal_freq = TDA10046_XTAL_16M,
700 .agc_config = TDA10046_AGC_TDA827X,
701 .gpio_config = TDA10046_GP00_I,
702 .if_freq = TDA10046_FREQ_045,
703 .tuner_address = 0x60,
704 .request_firmware = philips_tda1004x_request_firmware
707 static struct tda1004x_config tevion_dvbt220rf_config = {
708 .demod_address = 0x08,
711 .xtal_freq = TDA10046_XTAL_16M,
712 .agc_config = TDA10046_AGC_TDA827X,
713 .gpio_config = TDA10046_GP11_I,
714 .if_freq = TDA10046_FREQ_045,
715 .tuner_address = 0x60,
716 .request_firmware = philips_tda1004x_request_firmware
719 static struct tda1004x_config md8800_dvbt_config = {
720 .demod_address = 0x08,
723 .xtal_freq = TDA10046_XTAL_16M,
724 .agc_config = TDA10046_AGC_TDA827X,
725 .gpio_config = TDA10046_GP01_I,
726 .if_freq = TDA10046_FREQ_045,
728 .tuner_address = 0x60,
729 .request_firmware = philips_tda1004x_request_firmware
732 static struct tda1004x_config asus_p7131_4871_config = {
733 .demod_address = 0x08,
736 .xtal_freq = TDA10046_XTAL_16M,
737 .agc_config = TDA10046_AGC_TDA827X,
738 .gpio_config = TDA10046_GP01_I,
739 .if_freq = TDA10046_FREQ_045,
741 .tuner_address = 0x61,
743 .request_firmware = philips_tda1004x_request_firmware
746 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
747 .demod_address = 0x08,
750 .xtal_freq = TDA10046_XTAL_16M,
751 .agc_config = TDA10046_AGC_TDA827X,
752 .gpio_config = TDA10046_GP11_I,
753 .if_freq = TDA10046_FREQ_045,
755 .tuner_address = 0x61,
757 .request_firmware = philips_tda1004x_request_firmware
760 static struct tda1004x_config kworld_dvb_t_210_config = {
761 .demod_address = 0x08,
764 .xtal_freq = TDA10046_XTAL_16M,
765 .agc_config = TDA10046_AGC_TDA827X,
766 .gpio_config = TDA10046_GP11_I,
767 .if_freq = TDA10046_FREQ_045,
769 .tuner_address = 0x61,
771 .request_firmware = philips_tda1004x_request_firmware
774 static struct tda1004x_config avermedia_super_007_config = {
775 .demod_address = 0x08,
778 .xtal_freq = TDA10046_XTAL_16M,
779 .agc_config = TDA10046_AGC_TDA827X,
780 .gpio_config = TDA10046_GP01_I,
781 .if_freq = TDA10046_FREQ_045,
783 .tuner_address = 0x60,
785 .request_firmware = philips_tda1004x_request_firmware
788 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
789 .demod_address = 0x08,
792 .xtal_freq = TDA10046_XTAL_16M,
793 .agc_config = TDA10046_AGC_TDA827X,
794 .gpio_config = TDA10046_GP01_I,
795 .if_freq = TDA10046_FREQ_045,
797 .tuner_address = 0x61,
799 .request_firmware = philips_tda1004x_request_firmware
802 static struct tda1004x_config asus_tiger_3in1_config = {
803 .demod_address = 0x0b,
806 .xtal_freq = TDA10046_XTAL_16M,
807 .agc_config = TDA10046_AGC_TDA827X,
808 .gpio_config = TDA10046_GP11_I,
809 .if_freq = TDA10046_FREQ_045,
811 .tuner_address = 0x61,
813 .request_firmware = philips_tda1004x_request_firmware
816 /* ------------------------------------------------------------------
817 * special case: this card uses saa713x GPIO22 for the mode switch
820 static int ads_duo_tuner_init(struct dvb_frontend *fe)
822 struct saa7134_dev *dev = fe->dvb->priv;
823 philips_tda827x_tuner_init(fe);
824 /* route TDA8275a AGC input to the channel decoder */
825 saa7134_set_gpio(dev, 22, 1);
829 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
831 struct saa7134_dev *dev = fe->dvb->priv;
832 /* route TDA8275a AGC input to the analog IF chip*/
833 saa7134_set_gpio(dev, 22, 0);
834 philips_tda827x_tuner_sleep(fe);
838 static struct tda827x_config ads_duo_cfg = {
839 .tuner_callback = saa7134_tuner_callback,
840 .init = ads_duo_tuner_init,
841 .sleep = ads_duo_tuner_sleep,
845 static struct tda1004x_config ads_tech_duo_config = {
846 .demod_address = 0x08,
849 .xtal_freq = TDA10046_XTAL_16M,
850 .agc_config = TDA10046_AGC_TDA827X,
851 .gpio_config = TDA10046_GP00_I,
852 .if_freq = TDA10046_FREQ_045,
853 .tuner_address = 0x61,
854 .request_firmware = philips_tda1004x_request_firmware
857 /* ==================================================================
858 * tda10086 based DVB-S cards, helper functions
861 static struct tda10086_config flydvbs = {
862 .demod_address = 0x0e,
865 .xtal_freq = TDA10086_XTAL_16M,
868 static struct tda10086_config sd1878_4m = {
869 .demod_address = 0x0e,
872 .xtal_freq = TDA10086_XTAL_4M,
875 /* ------------------------------------------------------------------
876 * special case: lnb supply is connected to the gated i2c
879 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
882 struct saa7134_dev *dev = fe->dvb->priv;
883 if (fe->ops.i2c_gate_ctrl) {
884 fe->ops.i2c_gate_ctrl(fe, 1);
885 if (dev->original_set_voltage)
886 res = dev->original_set_voltage(fe, voltage);
887 fe->ops.i2c_gate_ctrl(fe, 0);
892 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
895 struct saa7134_dev *dev = fe->dvb->priv;
896 if (fe->ops.i2c_gate_ctrl) {
897 fe->ops.i2c_gate_ctrl(fe, 1);
898 if (dev->original_set_high_voltage)
899 res = dev->original_set_high_voltage(fe, arg);
900 fe->ops.i2c_gate_ctrl(fe, 0);
905 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
907 struct saa7134_dev *dev = fe->dvb->priv;
908 u8 wbuf[2] = { 0x1f, 00 };
910 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
911 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
913 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
915 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
916 if (voltage == SEC_VOLTAGE_18)
917 wbuf[1] = rbuf | 0x10;
919 wbuf[1] = rbuf & 0xef;
921 i2c_transfer(&dev->i2c_adap, msg, 1);
925 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
927 struct saa7134_dev *dev = fe->dvb->priv;
928 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
932 /* ==================================================================
933 * nxt200x based ATSC cards, helper functions
936 static struct nxt200x_config avertvhda180 = {
937 .demod_address = 0x0a,
940 static struct nxt200x_config kworldatsc110 = {
941 .demod_address = 0x0a,
944 /* ==================================================================
948 static int dvb_init(struct saa7134_dev *dev)
951 int attach_xc3028 = 0;
953 /* init struct videobuf_dvb */
954 dev->ts.nr_bufs = 32;
955 dev->ts.nr_packets = 32*4;
956 dev->dvb.name = dev->name;
957 videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops,
958 &dev->pci->dev, &dev->slock,
959 V4L2_BUF_TYPE_VIDEO_CAPTURE,
960 V4L2_FIELD_ALTERNATE,
961 sizeof(struct saa7134_buf),
964 switch (dev->board) {
965 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
966 dprintk("pinnacle 300i dvb setup\n");
967 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
969 if (dev->dvb.frontend) {
970 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
973 case SAA7134_BOARD_AVERMEDIA_777:
974 case SAA7134_BOARD_AVERMEDIA_A16AR:
975 dprintk("avertv 777 dvb setup\n");
976 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
978 if (dev->dvb.frontend) {
979 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
980 &dev->i2c_adap, 0x61,
981 TUNER_PHILIPS_TD1316);
984 case SAA7134_BOARD_AVERMEDIA_A16D:
985 dprintk("AverMedia A16D dvb setup\n");
986 dev->dvb.frontend = dvb_attach(mt352_attach,
987 &avermedia_xc3028_mt352_dev,
991 case SAA7134_BOARD_MD7134:
992 dev->dvb.frontend = dvb_attach(tda10046_attach,
995 if (dev->dvb.frontend) {
996 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
997 &dev->i2c_adap, medion_cardbus.tuner_address,
998 TUNER_PHILIPS_FMD1216ME_MK3);
1001 case SAA7134_BOARD_PHILIPS_TOUGH:
1002 dev->dvb.frontend = dvb_attach(tda10046_attach,
1003 &philips_tu1216_60_config,
1005 if (dev->dvb.frontend) {
1006 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1007 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1010 case SAA7134_BOARD_FLYDVBTDUO:
1011 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1012 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1013 &tda827x_cfg_0) < 0)
1014 goto dettach_frontend;
1016 case SAA7134_BOARD_PHILIPS_EUROPA:
1017 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1018 dev->dvb.frontend = dvb_attach(tda10046_attach,
1019 &philips_europa_config,
1021 if (dev->dvb.frontend) {
1022 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1023 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1024 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1025 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1026 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1029 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1030 dev->dvb.frontend = dvb_attach(tda10046_attach,
1031 &philips_tu1216_61_config,
1033 if (dev->dvb.frontend) {
1034 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1035 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1038 case SAA7134_BOARD_KWORLD_DVBT_210:
1039 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1040 &tda827x_cfg_2) < 0)
1041 goto dettach_frontend;
1043 case SAA7134_BOARD_PHILIPS_TIGER:
1044 if (configure_tda827x_fe(dev, &philips_tiger_config,
1045 &tda827x_cfg_0) < 0)
1046 goto dettach_frontend;
1048 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1049 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1050 &tda827x_cfg_1) < 0)
1051 goto dettach_frontend;
1053 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1054 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1055 &tda827x_cfg_1) < 0)
1056 goto dettach_frontend;
1058 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1059 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1060 &tda827x_cfg_0) < 0)
1061 goto dettach_frontend;
1063 case SAA7134_BOARD_FLYDVBT_LR301:
1064 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1065 &tda827x_cfg_0) < 0)
1066 goto dettach_frontend;
1068 case SAA7134_BOARD_FLYDVB_TRIO:
1069 if (!use_frontend) { /* terrestrial */
1070 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1071 &tda827x_cfg_0) < 0)
1072 goto dettach_frontend;
1073 } else { /* satellite */
1074 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1075 if (dev->dvb.frontend) {
1076 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1077 &dev->i2c_adap, 0) == NULL) {
1078 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1079 goto dettach_frontend;
1081 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1082 0x08, 0, 0) == NULL) {
1083 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1084 goto dettach_frontend;
1089 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1090 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1091 dev->dvb.frontend = dvb_attach(tda10046_attach,
1092 &ads_tech_duo_config,
1094 if (dev->dvb.frontend) {
1095 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
1096 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1097 &ads_duo_cfg) == NULL) {
1098 wprintk("no tda827x tuner found at addr: %02x\n",
1099 ads_tech_duo_config.tuner_address);
1100 goto dettach_frontend;
1103 wprintk("failed to attach tda10046\n");
1105 case SAA7134_BOARD_TEVION_DVBT_220RF:
1106 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1107 &tda827x_cfg_0) < 0)
1108 goto dettach_frontend;
1110 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1111 if (!use_frontend) { /* terrestrial */
1112 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1113 &tda827x_cfg_0) < 0)
1114 goto dettach_frontend;
1115 } else { /* satellite */
1116 dev->dvb.frontend = dvb_attach(tda10086_attach,
1117 &flydvbs, &dev->i2c_adap);
1118 if (dev->dvb.frontend) {
1119 struct dvb_frontend *fe = dev->dvb.frontend;
1120 u8 dev_id = dev->eedata[2];
1122 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1124 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1125 0x60, &dev->i2c_adap, 0) == NULL) {
1126 wprintk("%s: Medion Quadro, no tda826x "
1127 "found !\n", __func__);
1128 goto dettach_frontend;
1130 if (dev_id != 0x08) {
1131 /* we need to open the i2c gate (we know it exists) */
1132 fe->ops.i2c_gate_ctrl(fe, 1);
1133 if (dvb_attach(isl6405_attach, fe,
1134 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1135 wprintk("%s: Medion Quadro, no ISL6405 "
1136 "found !\n", __func__);
1137 goto dettach_frontend;
1139 if (dev_id == 0x07) {
1140 /* fire up the 2nd section of the LNB supply since
1141 we can't do this from the other section */
1143 i2c_transfer(&dev->i2c_adap, &msg, 1);
1145 fe->ops.i2c_gate_ctrl(fe, 0);
1146 dev->original_set_voltage = fe->ops.set_voltage;
1147 fe->ops.set_voltage = md8800_set_voltage;
1148 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1149 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1151 fe->ops.set_voltage = md8800_set_voltage2;
1152 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1157 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1158 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1160 if (dev->dvb.frontend)
1161 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1162 NULL, DVB_PLL_TDHU2);
1164 case SAA7134_BOARD_KWORLD_ATSC110:
1165 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1167 if (dev->dvb.frontend)
1168 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1169 &dev->i2c_adap, 0x61,
1170 TUNER_PHILIPS_TUV1236D);
1172 case SAA7134_BOARD_FLYDVBS_LR300:
1173 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1175 if (dev->dvb.frontend) {
1176 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1177 &dev->i2c_adap, 0) == NULL) {
1178 wprintk("%s: No tda826x found!\n", __func__);
1179 goto dettach_frontend;
1181 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1182 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1183 wprintk("%s: No ISL6421 found!\n", __func__);
1184 goto dettach_frontend;
1188 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1189 dev->dvb.frontend = dvb_attach(tda10046_attach,
1192 if (dev->dvb.frontend) {
1193 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1194 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1196 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1197 &dev->i2c_adap, medion_cardbus.tuner_address,
1198 TUNER_PHILIPS_FMD1216ME_MK3);
1201 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1202 dev->dvb.frontend = dvb_attach(tda10046_attach,
1203 &philips_europa_config,
1205 if (dev->dvb.frontend) {
1206 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1207 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1210 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1211 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1212 &tda827x_cfg_0) < 0)
1213 goto dettach_frontend;
1215 case SAA7134_BOARD_CINERGY_HT_PCI:
1216 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1217 &tda827x_cfg_0) < 0)
1218 goto dettach_frontend;
1220 case SAA7134_BOARD_PHILIPS_TIGER_S:
1221 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1222 &tda827x_cfg_2) < 0)
1223 goto dettach_frontend;
1225 case SAA7134_BOARD_ASUS_P7131_4871:
1226 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1227 &tda827x_cfg_2) < 0)
1228 goto dettach_frontend;
1230 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1231 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1232 &tda827x_cfg_2) < 0)
1233 goto dettach_frontend;
1235 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1236 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1237 &tda827x_cfg_0) < 0)
1238 goto dettach_frontend;
1240 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1241 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1242 &tda827x_cfg_2_sw42) < 0)
1243 goto dettach_frontend;
1245 case SAA7134_BOARD_PHILIPS_SNAKE:
1246 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1248 if (dev->dvb.frontend) {
1249 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1250 &dev->i2c_adap, 0) == NULL) {
1251 wprintk("%s: No tda826x found!\n", __func__);
1252 goto dettach_frontend;
1254 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1255 &dev->i2c_adap, 0, 0) == NULL) {
1256 wprintk("%s: No lnbp21 found!\n", __func__);
1257 goto dettach_frontend;
1261 case SAA7134_BOARD_CREATIX_CTX953:
1262 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1263 &tda827x_cfg_0) < 0)
1264 goto dettach_frontend;
1266 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1267 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1268 &tda827x_cfg_2) < 0)
1269 goto dettach_frontend;
1271 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1272 dprintk("AverMedia E506R dvb setup\n");
1273 saa7134_set_gpio(dev, 25, 0);
1275 saa7134_set_gpio(dev, 25, 1);
1276 dev->dvb.frontend = dvb_attach(mt352_attach,
1277 &avermedia_xc3028_mt352_dev,
1281 case SAA7134_BOARD_MD7134_BRIDGE_2:
1282 dev->dvb.frontend = dvb_attach(tda10086_attach,
1283 &sd1878_4m, &dev->i2c_adap);
1284 if (dev->dvb.frontend) {
1285 struct dvb_frontend *fe;
1286 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
1287 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1288 wprintk("%s: MD7134 DVB-S, no SD1878 "
1289 "found !\n", __func__);
1290 goto dettach_frontend;
1292 /* we need to open the i2c gate (we know it exists) */
1293 fe = dev->dvb.frontend;
1294 fe->ops.i2c_gate_ctrl(fe, 1);
1295 if (dvb_attach(isl6405_attach, fe,
1296 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1297 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1298 "found !\n", __func__);
1299 goto dettach_frontend;
1301 fe->ops.i2c_gate_ctrl(fe, 0);
1302 dev->original_set_voltage = fe->ops.set_voltage;
1303 fe->ops.set_voltage = md8800_set_voltage;
1304 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1305 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1308 case SAA7134_BOARD_AVERMEDIA_M103:
1309 saa7134_set_gpio(dev, 25, 0);
1311 saa7134_set_gpio(dev, 25, 1);
1312 dev->dvb.frontend = dvb_attach(mt352_attach,
1313 &avermedia_xc3028_mt352_dev,
1317 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1318 if (!use_frontend) { /* terrestrial */
1319 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1320 &tda827x_cfg_2) < 0)
1321 goto dettach_frontend;
1322 } else { /* satellite */
1323 dev->dvb.frontend = dvb_attach(tda10086_attach,
1324 &flydvbs, &dev->i2c_adap);
1325 if (dev->dvb.frontend) {
1326 if (dvb_attach(tda826x_attach,
1327 dev->dvb.frontend, 0x60,
1328 &dev->i2c_adap, 0) == NULL) {
1329 wprintk("%s: Asus Tiger 3in1, no "
1330 "tda826x found!\n", __func__);
1331 goto dettach_frontend;
1333 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1334 &dev->i2c_adap, 0, 0) == NULL) {
1335 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1336 " found!\n", __func__);
1337 goto dettach_frontend;
1343 wprintk("Huh? unknown DVB card?\n");
1347 if (attach_xc3028) {
1348 struct dvb_frontend *fe;
1349 struct xc2028_config cfg = {
1350 .i2c_adap = &dev->i2c_adap,
1354 if (!dev->dvb.frontend)
1357 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
1359 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1361 goto dettach_frontend;
1365 if (NULL == dev->dvb.frontend) {
1366 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1370 /* register everything else */
1371 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev,
1374 /* this sequence is necessary to make the tda1004x load its firmware
1375 * and to enter analog mode of hybrid boards
1378 if (dev->dvb.frontend->ops.init)
1379 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1380 if (dev->dvb.frontend->ops.sleep)
1381 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
1382 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1383 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1388 if (dev->dvb.frontend)
1389 dvb_frontend_detach(dev->dvb.frontend);
1390 dev->dvb.frontend = NULL;
1395 static int dvb_fini(struct saa7134_dev *dev)
1397 /* FIXME: I suspect that this code is bogus, since the entry for
1398 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1399 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1401 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1402 struct v4l2_priv_tun_config tda9887_cfg;
1403 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1405 tda9887_cfg.tuner = TUNER_TDA9887;
1406 tda9887_cfg.priv = &on;
1408 /* otherwise we don't detect the tuner on next insmod */
1409 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
1410 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1411 if ((dev->eedata[2] == 0x07) && use_frontend) {
1412 /* turn off the 2nd lnb supply */
1414 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1415 struct dvb_frontend *fe;
1416 fe = dev->dvb.frontend;
1417 if (fe->ops.i2c_gate_ctrl) {
1418 fe->ops.i2c_gate_ctrl(fe, 1);
1419 i2c_transfer(&dev->i2c_adap, &msg, 1);
1420 fe->ops.i2c_gate_ctrl(fe, 0);
1424 if (dev->dvb.frontend)
1425 videobuf_dvb_unregister(&dev->dvb);
1429 static struct saa7134_mpeg_ops dvb_ops = {
1430 .type = SAA7134_MPEG_DVB,
1435 static int __init dvb_register(void)
1437 return saa7134_ts_register(&dvb_ops);
1440 static void __exit dvb_unregister(void)
1442 saa7134_ts_unregister(&dvb_ops);
1445 module_init(dvb_register);
1446 module_exit(dvb_unregister);
1448 /* ------------------------------------------------------------------ */