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 .init = philips_tda827x_tuner_init,
557 .sleep = philips_tda827x_tuner_sleep,
562 static struct tda827x_config tda827x_cfg_1 = {
563 .init = philips_tda827x_tuner_init,
564 .sleep = philips_tda827x_tuner_sleep,
569 static struct tda827x_config tda827x_cfg_2 = {
570 .init = philips_tda827x_tuner_init,
571 .sleep = philips_tda827x_tuner_sleep,
576 static struct tda827x_config tda827x_cfg_2_sw42 = {
577 .init = philips_tda827x_tuner_init,
578 .sleep = philips_tda827x_tuner_sleep,
583 /* ------------------------------------------------------------------ */
585 static struct tda1004x_config tda827x_lifeview_config = {
586 .demod_address = 0x08,
589 .xtal_freq = TDA10046_XTAL_16M,
590 .agc_config = TDA10046_AGC_TDA827X,
591 .gpio_config = TDA10046_GP11_I,
592 .if_freq = TDA10046_FREQ_045,
593 .tuner_address = 0x60,
594 .request_firmware = philips_tda1004x_request_firmware
597 static struct tda1004x_config philips_tiger_config = {
598 .demod_address = 0x08,
601 .xtal_freq = TDA10046_XTAL_16M,
602 .agc_config = TDA10046_AGC_TDA827X,
603 .gpio_config = TDA10046_GP11_I,
604 .if_freq = TDA10046_FREQ_045,
606 .tuner_address = 0x61,
608 .request_firmware = philips_tda1004x_request_firmware
611 static struct tda1004x_config cinergy_ht_config = {
612 .demod_address = 0x08,
615 .xtal_freq = TDA10046_XTAL_16M,
616 .agc_config = TDA10046_AGC_TDA827X,
617 .gpio_config = TDA10046_GP01_I,
618 .if_freq = TDA10046_FREQ_045,
620 .tuner_address = 0x61,
621 .request_firmware = philips_tda1004x_request_firmware
624 static struct tda1004x_config cinergy_ht_pci_config = {
625 .demod_address = 0x08,
628 .xtal_freq = TDA10046_XTAL_16M,
629 .agc_config = TDA10046_AGC_TDA827X,
630 .gpio_config = TDA10046_GP01_I,
631 .if_freq = TDA10046_FREQ_045,
633 .tuner_address = 0x60,
634 .request_firmware = philips_tda1004x_request_firmware
637 static struct tda1004x_config philips_tiger_s_config = {
638 .demod_address = 0x08,
641 .xtal_freq = TDA10046_XTAL_16M,
642 .agc_config = TDA10046_AGC_TDA827X,
643 .gpio_config = TDA10046_GP01_I,
644 .if_freq = TDA10046_FREQ_045,
646 .tuner_address = 0x61,
648 .request_firmware = philips_tda1004x_request_firmware
651 static struct tda1004x_config pinnacle_pctv_310i_config = {
652 .demod_address = 0x08,
655 .xtal_freq = TDA10046_XTAL_16M,
656 .agc_config = TDA10046_AGC_TDA827X,
657 .gpio_config = TDA10046_GP11_I,
658 .if_freq = TDA10046_FREQ_045,
660 .tuner_address = 0x61,
661 .request_firmware = philips_tda1004x_request_firmware
664 static struct tda1004x_config hauppauge_hvr_1110_config = {
665 .demod_address = 0x08,
668 .xtal_freq = TDA10046_XTAL_16M,
669 .agc_config = TDA10046_AGC_TDA827X,
670 .gpio_config = TDA10046_GP11_I,
671 .if_freq = TDA10046_FREQ_045,
673 .tuner_address = 0x61,
674 .request_firmware = philips_tda1004x_request_firmware
677 static struct tda1004x_config asus_p7131_dual_config = {
678 .demod_address = 0x08,
681 .xtal_freq = TDA10046_XTAL_16M,
682 .agc_config = TDA10046_AGC_TDA827X,
683 .gpio_config = TDA10046_GP11_I,
684 .if_freq = TDA10046_FREQ_045,
686 .tuner_address = 0x61,
688 .request_firmware = philips_tda1004x_request_firmware
691 static struct tda1004x_config lifeview_trio_config = {
692 .demod_address = 0x09,
695 .xtal_freq = TDA10046_XTAL_16M,
696 .agc_config = TDA10046_AGC_TDA827X,
697 .gpio_config = TDA10046_GP00_I,
698 .if_freq = TDA10046_FREQ_045,
699 .tuner_address = 0x60,
700 .request_firmware = philips_tda1004x_request_firmware
703 static struct tda1004x_config tevion_dvbt220rf_config = {
704 .demod_address = 0x08,
707 .xtal_freq = TDA10046_XTAL_16M,
708 .agc_config = TDA10046_AGC_TDA827X,
709 .gpio_config = TDA10046_GP11_I,
710 .if_freq = TDA10046_FREQ_045,
711 .tuner_address = 0x60,
712 .request_firmware = philips_tda1004x_request_firmware
715 static struct tda1004x_config md8800_dvbt_config = {
716 .demod_address = 0x08,
719 .xtal_freq = TDA10046_XTAL_16M,
720 .agc_config = TDA10046_AGC_TDA827X,
721 .gpio_config = TDA10046_GP01_I,
722 .if_freq = TDA10046_FREQ_045,
724 .tuner_address = 0x60,
725 .request_firmware = philips_tda1004x_request_firmware
728 static struct tda1004x_config asus_p7131_4871_config = {
729 .demod_address = 0x08,
732 .xtal_freq = TDA10046_XTAL_16M,
733 .agc_config = TDA10046_AGC_TDA827X,
734 .gpio_config = TDA10046_GP01_I,
735 .if_freq = TDA10046_FREQ_045,
737 .tuner_address = 0x61,
739 .request_firmware = philips_tda1004x_request_firmware
742 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
743 .demod_address = 0x08,
746 .xtal_freq = TDA10046_XTAL_16M,
747 .agc_config = TDA10046_AGC_TDA827X,
748 .gpio_config = TDA10046_GP11_I,
749 .if_freq = TDA10046_FREQ_045,
751 .tuner_address = 0x61,
753 .request_firmware = philips_tda1004x_request_firmware
756 static struct tda1004x_config kworld_dvb_t_210_config = {
757 .demod_address = 0x08,
760 .xtal_freq = TDA10046_XTAL_16M,
761 .agc_config = TDA10046_AGC_TDA827X,
762 .gpio_config = TDA10046_GP11_I,
763 .if_freq = TDA10046_FREQ_045,
765 .tuner_address = 0x61,
767 .request_firmware = philips_tda1004x_request_firmware
770 static struct tda1004x_config avermedia_super_007_config = {
771 .demod_address = 0x08,
774 .xtal_freq = TDA10046_XTAL_16M,
775 .agc_config = TDA10046_AGC_TDA827X,
776 .gpio_config = TDA10046_GP01_I,
777 .if_freq = TDA10046_FREQ_045,
779 .tuner_address = 0x60,
781 .request_firmware = philips_tda1004x_request_firmware
784 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
785 .demod_address = 0x08,
788 .xtal_freq = TDA10046_XTAL_16M,
789 .agc_config = TDA10046_AGC_TDA827X,
790 .gpio_config = TDA10046_GP01_I,
791 .if_freq = TDA10046_FREQ_045,
793 .tuner_address = 0x61,
795 .request_firmware = philips_tda1004x_request_firmware
798 static struct tda1004x_config asus_tiger_3in1_config = {
799 .demod_address = 0x0b,
802 .xtal_freq = TDA10046_XTAL_16M,
803 .agc_config = TDA10046_AGC_TDA827X,
804 .gpio_config = TDA10046_GP11_I,
805 .if_freq = TDA10046_FREQ_045,
807 .tuner_address = 0x61,
809 .request_firmware = philips_tda1004x_request_firmware
812 /* ------------------------------------------------------------------
813 * special case: this card uses saa713x GPIO22 for the mode switch
816 static int ads_duo_tuner_init(struct dvb_frontend *fe)
818 struct saa7134_dev *dev = fe->dvb->priv;
819 philips_tda827x_tuner_init(fe);
820 /* route TDA8275a AGC input to the channel decoder */
821 saa7134_set_gpio(dev, 22, 1);
825 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
827 struct saa7134_dev *dev = fe->dvb->priv;
828 /* route TDA8275a AGC input to the analog IF chip*/
829 saa7134_set_gpio(dev, 22, 0);
830 philips_tda827x_tuner_sleep(fe);
834 static struct tda827x_config ads_duo_cfg = {
835 .init = ads_duo_tuner_init,
836 .sleep = ads_duo_tuner_sleep,
840 static struct tda1004x_config ads_tech_duo_config = {
841 .demod_address = 0x08,
844 .xtal_freq = TDA10046_XTAL_16M,
845 .agc_config = TDA10046_AGC_TDA827X,
846 .gpio_config = TDA10046_GP00_I,
847 .if_freq = TDA10046_FREQ_045,
848 .tuner_address = 0x61,
849 .request_firmware = philips_tda1004x_request_firmware
852 /* ==================================================================
853 * tda10086 based DVB-S cards, helper functions
856 static struct tda10086_config flydvbs = {
857 .demod_address = 0x0e,
860 .xtal_freq = TDA10086_XTAL_16M,
863 static struct tda10086_config sd1878_4m = {
864 .demod_address = 0x0e,
867 .xtal_freq = TDA10086_XTAL_4M,
870 /* ------------------------------------------------------------------
871 * special case: lnb supply is connected to the gated i2c
874 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
877 struct saa7134_dev *dev = fe->dvb->priv;
878 if (fe->ops.i2c_gate_ctrl) {
879 fe->ops.i2c_gate_ctrl(fe, 1);
880 if (dev->original_set_voltage)
881 res = dev->original_set_voltage(fe, voltage);
882 fe->ops.i2c_gate_ctrl(fe, 0);
887 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
890 struct saa7134_dev *dev = fe->dvb->priv;
891 if (fe->ops.i2c_gate_ctrl) {
892 fe->ops.i2c_gate_ctrl(fe, 1);
893 if (dev->original_set_high_voltage)
894 res = dev->original_set_high_voltage(fe, arg);
895 fe->ops.i2c_gate_ctrl(fe, 0);
900 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
902 struct saa7134_dev *dev = fe->dvb->priv;
903 u8 wbuf[2] = { 0x1f, 00 };
905 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
906 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
908 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
910 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
911 if (voltage == SEC_VOLTAGE_18)
912 wbuf[1] = rbuf | 0x10;
914 wbuf[1] = rbuf & 0xef;
916 i2c_transfer(&dev->i2c_adap, msg, 1);
920 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
922 struct saa7134_dev *dev = fe->dvb->priv;
923 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
927 /* ==================================================================
928 * nxt200x based ATSC cards, helper functions
931 static struct nxt200x_config avertvhda180 = {
932 .demod_address = 0x0a,
935 static struct nxt200x_config kworldatsc110 = {
936 .demod_address = 0x0a,
939 /* ==================================================================
943 static int dvb_init(struct saa7134_dev *dev)
946 int attach_xc3028 = 0;
948 /* init struct videobuf_dvb */
949 dev->ts.nr_bufs = 32;
950 dev->ts.nr_packets = 32*4;
951 dev->dvb.name = dev->name;
952 videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops,
953 &dev->pci->dev, &dev->slock,
954 V4L2_BUF_TYPE_VIDEO_CAPTURE,
955 V4L2_FIELD_ALTERNATE,
956 sizeof(struct saa7134_buf),
959 switch (dev->board) {
960 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
961 dprintk("pinnacle 300i dvb setup\n");
962 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
964 if (dev->dvb.frontend) {
965 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
968 case SAA7134_BOARD_AVERMEDIA_777:
969 case SAA7134_BOARD_AVERMEDIA_A16AR:
970 dprintk("avertv 777 dvb setup\n");
971 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
973 if (dev->dvb.frontend) {
974 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
975 &dev->i2c_adap, 0x61,
976 TUNER_PHILIPS_TD1316);
979 case SAA7134_BOARD_AVERMEDIA_A16D:
980 dprintk("AverMedia A16D dvb setup\n");
981 dev->dvb.frontend = dvb_attach(mt352_attach,
982 &avermedia_xc3028_mt352_dev,
986 case SAA7134_BOARD_MD7134:
987 dev->dvb.frontend = dvb_attach(tda10046_attach,
990 if (dev->dvb.frontend) {
991 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
992 &dev->i2c_adap, medion_cardbus.tuner_address,
993 TUNER_PHILIPS_FMD1216ME_MK3);
996 case SAA7134_BOARD_PHILIPS_TOUGH:
997 dev->dvb.frontend = dvb_attach(tda10046_attach,
998 &philips_tu1216_60_config,
1000 if (dev->dvb.frontend) {
1001 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1002 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1005 case SAA7134_BOARD_FLYDVBTDUO:
1006 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1007 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1008 &tda827x_cfg_0) < 0)
1009 goto dettach_frontend;
1011 case SAA7134_BOARD_PHILIPS_EUROPA:
1012 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1013 dev->dvb.frontend = dvb_attach(tda10046_attach,
1014 &philips_europa_config,
1016 if (dev->dvb.frontend) {
1017 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1018 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1019 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1020 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1021 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1024 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1025 dev->dvb.frontend = dvb_attach(tda10046_attach,
1026 &philips_tu1216_61_config,
1028 if (dev->dvb.frontend) {
1029 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1030 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1033 case SAA7134_BOARD_KWORLD_DVBT_210:
1034 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1035 &tda827x_cfg_2) < 0)
1036 goto dettach_frontend;
1038 case SAA7134_BOARD_PHILIPS_TIGER:
1039 if (configure_tda827x_fe(dev, &philips_tiger_config,
1040 &tda827x_cfg_0) < 0)
1041 goto dettach_frontend;
1043 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1044 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1045 &tda827x_cfg_1) < 0)
1046 goto dettach_frontend;
1048 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1049 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1050 &tda827x_cfg_1) < 0)
1051 goto dettach_frontend;
1053 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1054 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1055 &tda827x_cfg_0) < 0)
1056 goto dettach_frontend;
1058 case SAA7134_BOARD_FLYDVBT_LR301:
1059 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1060 &tda827x_cfg_0) < 0)
1061 goto dettach_frontend;
1063 case SAA7134_BOARD_FLYDVB_TRIO:
1064 if (!use_frontend) { /* terrestrial */
1065 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1066 &tda827x_cfg_0) < 0)
1067 goto dettach_frontend;
1068 } else { /* satellite */
1069 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1070 if (dev->dvb.frontend) {
1071 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1072 &dev->i2c_adap, 0) == NULL) {
1073 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1074 goto dettach_frontend;
1076 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1077 0x08, 0, 0) == NULL) {
1078 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1079 goto dettach_frontend;
1084 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1085 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1086 dev->dvb.frontend = dvb_attach(tda10046_attach,
1087 &ads_tech_duo_config,
1089 if (dev->dvb.frontend) {
1090 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
1091 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1092 &ads_duo_cfg) == NULL) {
1093 wprintk("no tda827x tuner found at addr: %02x\n",
1094 ads_tech_duo_config.tuner_address);
1095 goto dettach_frontend;
1098 wprintk("failed to attach tda10046\n");
1100 case SAA7134_BOARD_TEVION_DVBT_220RF:
1101 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1102 &tda827x_cfg_0) < 0)
1103 goto dettach_frontend;
1105 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1106 if (!use_frontend) { /* terrestrial */
1107 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1108 &tda827x_cfg_0) < 0)
1109 goto dettach_frontend;
1110 } else { /* satellite */
1111 dev->dvb.frontend = dvb_attach(tda10086_attach,
1112 &flydvbs, &dev->i2c_adap);
1113 if (dev->dvb.frontend) {
1114 struct dvb_frontend *fe = dev->dvb.frontend;
1115 u8 dev_id = dev->eedata[2];
1117 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1119 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1120 0x60, &dev->i2c_adap, 0) == NULL) {
1121 wprintk("%s: Medion Quadro, no tda826x "
1122 "found !\n", __func__);
1123 goto dettach_frontend;
1125 if (dev_id != 0x08) {
1126 /* we need to open the i2c gate (we know it exists) */
1127 fe->ops.i2c_gate_ctrl(fe, 1);
1128 if (dvb_attach(isl6405_attach, fe,
1129 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1130 wprintk("%s: Medion Quadro, no ISL6405 "
1131 "found !\n", __func__);
1132 goto dettach_frontend;
1134 if (dev_id == 0x07) {
1135 /* fire up the 2nd section of the LNB supply since
1136 we can't do this from the other section */
1138 i2c_transfer(&dev->i2c_adap, &msg, 1);
1140 fe->ops.i2c_gate_ctrl(fe, 0);
1141 dev->original_set_voltage = fe->ops.set_voltage;
1142 fe->ops.set_voltage = md8800_set_voltage;
1143 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1144 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1146 fe->ops.set_voltage = md8800_set_voltage2;
1147 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1152 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1153 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1155 if (dev->dvb.frontend)
1156 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1157 NULL, DVB_PLL_TDHU2);
1159 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1160 case SAA7134_BOARD_KWORLD_ATSC110:
1161 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1163 if (dev->dvb.frontend)
1164 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1165 &dev->i2c_adap, 0x61,
1166 TUNER_PHILIPS_TUV1236D);
1168 case SAA7134_BOARD_FLYDVBS_LR300:
1169 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1171 if (dev->dvb.frontend) {
1172 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1173 &dev->i2c_adap, 0) == NULL) {
1174 wprintk("%s: No tda826x found!\n", __func__);
1175 goto dettach_frontend;
1177 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1178 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1179 wprintk("%s: No ISL6421 found!\n", __func__);
1180 goto dettach_frontend;
1184 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1185 dev->dvb.frontend = dvb_attach(tda10046_attach,
1188 if (dev->dvb.frontend) {
1189 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1190 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1192 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1193 &dev->i2c_adap, medion_cardbus.tuner_address,
1194 TUNER_PHILIPS_FMD1216ME_MK3);
1197 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1198 dev->dvb.frontend = dvb_attach(tda10046_attach,
1199 &philips_europa_config,
1201 if (dev->dvb.frontend) {
1202 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1203 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1206 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1207 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1208 &tda827x_cfg_0) < 0)
1209 goto dettach_frontend;
1211 case SAA7134_BOARD_CINERGY_HT_PCI:
1212 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1213 &tda827x_cfg_0) < 0)
1214 goto dettach_frontend;
1216 case SAA7134_BOARD_PHILIPS_TIGER_S:
1217 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1218 &tda827x_cfg_2) < 0)
1219 goto dettach_frontend;
1221 case SAA7134_BOARD_ASUS_P7131_4871:
1222 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1223 &tda827x_cfg_2) < 0)
1224 goto dettach_frontend;
1226 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1227 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1228 &tda827x_cfg_2) < 0)
1229 goto dettach_frontend;
1231 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1232 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1233 &tda827x_cfg_0) < 0)
1234 goto dettach_frontend;
1236 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1237 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1238 &tda827x_cfg_2_sw42) < 0)
1239 goto dettach_frontend;
1241 case SAA7134_BOARD_PHILIPS_SNAKE:
1242 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1244 if (dev->dvb.frontend) {
1245 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1246 &dev->i2c_adap, 0) == NULL) {
1247 wprintk("%s: No tda826x found!\n", __func__);
1248 goto dettach_frontend;
1250 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1251 &dev->i2c_adap, 0, 0) == NULL) {
1252 wprintk("%s: No lnbp21 found!\n", __func__);
1253 goto dettach_frontend;
1257 case SAA7134_BOARD_CREATIX_CTX953:
1258 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1259 &tda827x_cfg_0) < 0)
1260 goto dettach_frontend;
1262 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1263 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1264 &tda827x_cfg_2) < 0)
1265 goto dettach_frontend;
1267 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1268 dprintk("AverMedia E506R dvb setup\n");
1269 saa7134_set_gpio(dev, 25, 0);
1271 saa7134_set_gpio(dev, 25, 1);
1272 dev->dvb.frontend = dvb_attach(mt352_attach,
1273 &avermedia_xc3028_mt352_dev,
1277 case SAA7134_BOARD_MD7134_BRIDGE_2:
1278 dev->dvb.frontend = dvb_attach(tda10086_attach,
1279 &sd1878_4m, &dev->i2c_adap);
1280 if (dev->dvb.frontend) {
1281 struct dvb_frontend *fe;
1282 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
1283 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1284 wprintk("%s: MD7134 DVB-S, no SD1878 "
1285 "found !\n", __func__);
1286 goto dettach_frontend;
1288 /* we need to open the i2c gate (we know it exists) */
1289 fe = dev->dvb.frontend;
1290 fe->ops.i2c_gate_ctrl(fe, 1);
1291 if (dvb_attach(isl6405_attach, fe,
1292 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1293 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1294 "found !\n", __func__);
1295 goto dettach_frontend;
1297 fe->ops.i2c_gate_ctrl(fe, 0);
1298 dev->original_set_voltage = fe->ops.set_voltage;
1299 fe->ops.set_voltage = md8800_set_voltage;
1300 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1301 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1304 case SAA7134_BOARD_AVERMEDIA_M103:
1305 saa7134_set_gpio(dev, 25, 0);
1307 saa7134_set_gpio(dev, 25, 1);
1308 dev->dvb.frontend = dvb_attach(mt352_attach,
1309 &avermedia_xc3028_mt352_dev,
1313 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1314 if (!use_frontend) { /* terrestrial */
1315 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1316 &tda827x_cfg_2) < 0)
1317 goto dettach_frontend;
1318 } else { /* satellite */
1319 dev->dvb.frontend = dvb_attach(tda10086_attach,
1320 &flydvbs, &dev->i2c_adap);
1321 if (dev->dvb.frontend) {
1322 if (dvb_attach(tda826x_attach,
1323 dev->dvb.frontend, 0x60,
1324 &dev->i2c_adap, 0) == NULL) {
1325 wprintk("%s: Asus Tiger 3in1, no "
1326 "tda826x found!\n", __func__);
1327 goto dettach_frontend;
1329 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1330 &dev->i2c_adap, 0, 0) == NULL) {
1331 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1332 " found!\n", __func__);
1333 goto dettach_frontend;
1338 case SAA7134_BOARD_ASUSTeK_TIGER:
1339 if (configure_tda827x_fe(dev, &philips_tiger_config,
1340 &tda827x_cfg_0) < 0)
1341 goto dettach_frontend;
1344 wprintk("Huh? unknown DVB card?\n");
1348 if (attach_xc3028) {
1349 struct dvb_frontend *fe;
1350 struct xc2028_config cfg = {
1351 .i2c_adap = &dev->i2c_adap,
1355 if (!dev->dvb.frontend)
1358 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
1360 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1362 goto dettach_frontend;
1366 if (NULL == dev->dvb.frontend) {
1367 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1370 /* define general-purpose callback pointer */
1371 dev->dvb.frontend->callback = saa7134_tuner_callback;
1373 /* register everything else */
1374 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev,
1377 /* this sequence is necessary to make the tda1004x load its firmware
1378 * and to enter analog mode of hybrid boards
1381 if (dev->dvb.frontend->ops.init)
1382 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1383 if (dev->dvb.frontend->ops.sleep)
1384 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
1385 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1386 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1391 if (dev->dvb.frontend)
1392 dvb_frontend_detach(dev->dvb.frontend);
1393 dev->dvb.frontend = NULL;
1398 static int dvb_fini(struct saa7134_dev *dev)
1400 /* FIXME: I suspect that this code is bogus, since the entry for
1401 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1402 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1404 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1405 struct v4l2_priv_tun_config tda9887_cfg;
1406 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1408 tda9887_cfg.tuner = TUNER_TDA9887;
1409 tda9887_cfg.priv = &on;
1411 /* otherwise we don't detect the tuner on next insmod */
1412 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
1413 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1414 if ((dev->eedata[2] == 0x07) && use_frontend) {
1415 /* turn off the 2nd lnb supply */
1417 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1418 struct dvb_frontend *fe;
1419 fe = dev->dvb.frontend;
1420 if (fe->ops.i2c_gate_ctrl) {
1421 fe->ops.i2c_gate_ctrl(fe, 1);
1422 i2c_transfer(&dev->i2c_adap, &msg, 1);
1423 fe->ops.i2c_gate_ctrl(fe, 0);
1427 if (dev->dvb.frontend)
1428 videobuf_dvb_unregister(&dev->dvb);
1432 static struct saa7134_mpeg_ops dvb_ops = {
1433 .type = SAA7134_MPEG_DVB,
1438 static int __init dvb_register(void)
1440 return saa7134_ts_register(&dvb_ops);
1443 static void __exit dvb_unregister(void)
1445 saa7134_ts_unregister(&dvb_ops);
1448 module_init(dvb_register);
1449 module_exit(dvb_unregister);
1451 /* ------------------------------------------------------------------ */