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"
54 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
55 MODULE_LICENSE("GPL");
57 static unsigned int antenna_pwr;
59 module_param(antenna_pwr, int, 0444);
60 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
62 static int use_frontend;
63 module_param(use_frontend, int, 0644);
64 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
67 module_param(debug, int, 0644);
68 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
70 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
72 #define dprintk(fmt, arg...) do { if (debug) \
73 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
76 #define wprintk(fmt, arg...) \
77 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
79 /* ------------------------------------------------------------------
80 * mt352 based DVB-T cards
83 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
88 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
89 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
93 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
94 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
97 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
98 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
100 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
102 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
103 dprintk("%s %s\n", __func__, ok ? "on" : "off");
106 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
110 static int mt352_pinnacle_init(struct dvb_frontend* fe)
112 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
113 static u8 reset [] = { RESET, 0x80 };
114 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
115 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
116 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
117 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
118 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
119 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
120 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
121 struct saa7134_dev *dev= fe->dvb->priv;
123 dprintk("%s called\n", __func__);
125 mt352_write(fe, clock_config, sizeof(clock_config));
127 mt352_write(fe, reset, sizeof(reset));
128 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
129 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
130 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
131 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
133 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
134 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
135 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
140 static int mt352_aver777_init(struct dvb_frontend* fe)
142 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
143 static u8 reset [] = { RESET, 0x80 };
144 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
145 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
146 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
148 mt352_write(fe, clock_config, sizeof(clock_config));
150 mt352_write(fe, reset, sizeof(reset));
151 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
152 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
153 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
158 static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
160 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
161 static u8 reset [] = { RESET, 0x80 };
162 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
163 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
164 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
166 mt352_write(fe, clock_config, sizeof(clock_config));
168 mt352_write(fe, reset, sizeof(reset));
169 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
170 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
171 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
175 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
176 struct dvb_frontend_parameters* params)
178 u8 off[] = { 0x00, 0xf1};
179 u8 on[] = { 0x00, 0x71};
180 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
182 struct saa7134_dev *dev = fe->dvb->priv;
183 struct v4l2_frequency f;
185 /* set frequency (mt2050) */
187 f.type = V4L2_TUNER_DIGITAL_TV;
188 f.frequency = params->frequency / 1000 * 16 / 1000;
189 if (fe->ops.i2c_gate_ctrl)
190 fe->ops.i2c_gate_ctrl(fe, 1);
191 i2c_transfer(&dev->i2c_adap, &msg, 1);
192 saa_call_all(dev, tuner, s_frequency, &f);
194 if (fe->ops.i2c_gate_ctrl)
195 fe->ops.i2c_gate_ctrl(fe, 1);
196 i2c_transfer(&dev->i2c_adap, &msg, 1);
198 pinnacle_antenna_pwr(dev, antenna_pwr);
201 return mt352_pinnacle_init(fe);
204 static struct mt352_config pinnacle_300i = {
205 .demod_address = 0x3c >> 1,
209 .demod_init = mt352_pinnacle_init,
212 static struct mt352_config avermedia_777 = {
213 .demod_address = 0xf,
214 .demod_init = mt352_aver777_init,
217 static struct mt352_config avermedia_xc3028_mt352_dev = {
218 .demod_address = (0x1e >> 1),
220 .demod_init = mt352_avermedia_xc3028_init,
223 /* ==================================================================
224 * tda1004x based DVB-T cards, helper functions
227 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
228 const struct firmware **fw, char *name)
230 struct saa7134_dev *dev = fe->dvb->priv;
231 return request_firmware(fw, name, &dev->pci->dev);
234 /* ------------------------------------------------------------------
235 * these tuners are tu1216, td1316(a)
238 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
240 struct saa7134_dev *dev = fe->dvb->priv;
241 struct tda1004x_state *state = fe->demodulator_priv;
242 u8 addr = state->config->tuner_address;
244 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
246 int tuner_frequency = 0;
249 /* determine charge pump */
250 tuner_frequency = params->frequency + 36166000;
251 if (tuner_frequency < 87000000)
253 else if (tuner_frequency < 130000000)
255 else if (tuner_frequency < 160000000)
257 else if (tuner_frequency < 200000000)
259 else if (tuner_frequency < 290000000)
261 else if (tuner_frequency < 420000000)
263 else if (tuner_frequency < 480000000)
265 else if (tuner_frequency < 620000000)
267 else if (tuner_frequency < 830000000)
269 else if (tuner_frequency < 895000000)
275 if (params->frequency < 49000000)
277 else if (params->frequency < 161000000)
279 else if (params->frequency < 444000000)
281 else if (params->frequency < 861000000)
286 /* setup PLL filter */
287 switch (params->u.ofdm.bandwidth) {
288 case BANDWIDTH_6_MHZ:
292 case BANDWIDTH_7_MHZ:
296 case BANDWIDTH_8_MHZ:
305 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
307 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
309 /* setup tuner buffer */
310 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
311 tuner_buf[1] = tuner_frequency & 0xff;
313 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
315 if (fe->ops.i2c_gate_ctrl)
316 fe->ops.i2c_gate_ctrl(fe, 1);
317 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
318 wprintk("could not write to tuner at addr: 0x%02x\n",
326 static int philips_tu1216_init(struct dvb_frontend *fe)
328 struct saa7134_dev *dev = fe->dvb->priv;
329 struct tda1004x_state *state = fe->demodulator_priv;
330 u8 addr = state->config->tuner_address;
331 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
332 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
334 /* setup PLL configuration */
335 if (fe->ops.i2c_gate_ctrl)
336 fe->ops.i2c_gate_ctrl(fe, 1);
337 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
344 /* ------------------------------------------------------------------ */
346 static struct tda1004x_config philips_tu1216_60_config = {
347 .demod_address = 0x8,
350 .xtal_freq = TDA10046_XTAL_4M,
351 .agc_config = TDA10046_AGC_DEFAULT,
352 .if_freq = TDA10046_FREQ_3617,
353 .tuner_address = 0x60,
354 .request_firmware = philips_tda1004x_request_firmware
357 static struct tda1004x_config philips_tu1216_61_config = {
359 .demod_address = 0x8,
362 .xtal_freq = TDA10046_XTAL_4M,
363 .agc_config = TDA10046_AGC_DEFAULT,
364 .if_freq = TDA10046_FREQ_3617,
365 .tuner_address = 0x61,
366 .request_firmware = philips_tda1004x_request_firmware
369 /* ------------------------------------------------------------------ */
371 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
373 struct saa7134_dev *dev = fe->dvb->priv;
374 struct tda1004x_state *state = fe->demodulator_priv;
375 u8 addr = state->config->tuner_address;
376 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
377 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
379 /* setup PLL configuration */
380 if (fe->ops.i2c_gate_ctrl)
381 fe->ops.i2c_gate_ctrl(fe, 1);
382 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
387 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
389 return philips_tda6651_pll_set(fe, params);
392 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
394 struct saa7134_dev *dev = fe->dvb->priv;
395 struct tda1004x_state *state = fe->demodulator_priv;
396 u8 addr = state->config->tuner_address;
397 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
398 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
400 /* switch the tuner to analog mode */
401 if (fe->ops.i2c_gate_ctrl)
402 fe->ops.i2c_gate_ctrl(fe, 1);
403 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
408 /* ------------------------------------------------------------------ */
410 static int philips_europa_tuner_init(struct dvb_frontend *fe)
412 struct saa7134_dev *dev = fe->dvb->priv;
413 static u8 msg[] = { 0x00, 0x40};
414 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
417 if (philips_td1316_tuner_init(fe))
420 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
426 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
428 struct saa7134_dev *dev = fe->dvb->priv;
430 static u8 msg[] = { 0x00, 0x14 };
431 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
433 if (philips_td1316_tuner_sleep(fe))
436 /* switch the board to analog mode */
437 if (fe->ops.i2c_gate_ctrl)
438 fe->ops.i2c_gate_ctrl(fe, 1);
439 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
443 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
445 struct saa7134_dev *dev = fe->dvb->priv;
447 if (dev->original_demod_sleep)
448 dev->original_demod_sleep(fe);
449 fe->ops.i2c_gate_ctrl(fe, 1);
453 static struct tda1004x_config philips_europa_config = {
455 .demod_address = 0x8,
458 .xtal_freq = TDA10046_XTAL_4M,
459 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
460 .if_freq = TDA10046_FREQ_052,
461 .tuner_address = 0x61,
462 .request_firmware = philips_tda1004x_request_firmware
465 static struct tda1004x_config medion_cardbus = {
466 .demod_address = 0x08,
469 .xtal_freq = TDA10046_XTAL_16M,
470 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
471 .if_freq = TDA10046_FREQ_3613,
472 .tuner_address = 0x61,
473 .request_firmware = philips_tda1004x_request_firmware
476 /* ------------------------------------------------------------------
477 * tda 1004x based cards with philips silicon tuner
480 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
482 struct tda1004x_state *state = fe->demodulator_priv;
484 u8 addr = state->config->i2c_gate;
485 static u8 tda8290_close[] = { 0x21, 0xc0};
486 static u8 tda8290_open[] = { 0x21, 0x80};
487 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
489 tda8290_msg.buf = tda8290_close;
491 tda8290_msg.buf = tda8290_open;
493 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
494 struct saa7134_dev *dev = fe->dvb->priv;
495 wprintk("could not access tda8290 I2C gate\n");
502 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
504 struct saa7134_dev *dev = fe->dvb->priv;
505 struct tda1004x_state *state = fe->demodulator_priv;
507 switch (state->config->antenna_switch) {
509 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
510 saa7134_set_gpio(dev, 21, 0);
512 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
513 saa7134_set_gpio(dev, 21, 1);
519 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
521 struct saa7134_dev *dev = fe->dvb->priv;
522 struct tda1004x_state *state = fe->demodulator_priv;
524 switch (state->config->antenna_switch) {
526 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
527 saa7134_set_gpio(dev, 21, 1);
529 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
530 saa7134_set_gpio(dev, 21, 0);
536 static int configure_tda827x_fe(struct saa7134_dev *dev,
537 struct tda1004x_config *cdec_conf,
538 struct tda827x_config *tuner_conf)
540 struct videobuf_dvb_frontend *fe0;
542 /* Get the first frontend */
543 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
545 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
546 if (fe0->dvb.frontend) {
547 if (cdec_conf->i2c_gate)
548 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
549 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
550 cdec_conf->tuner_address,
551 &dev->i2c_adap, tuner_conf))
554 wprintk("no tda827x tuner found at addr: %02x\n",
555 cdec_conf->tuner_address);
560 /* ------------------------------------------------------------------ */
562 static struct tda827x_config tda827x_cfg_0 = {
563 .init = philips_tda827x_tuner_init,
564 .sleep = philips_tda827x_tuner_sleep,
569 static struct tda827x_config tda827x_cfg_1 = {
570 .init = philips_tda827x_tuner_init,
571 .sleep = philips_tda827x_tuner_sleep,
576 static struct tda827x_config tda827x_cfg_2 = {
577 .init = philips_tda827x_tuner_init,
578 .sleep = philips_tda827x_tuner_sleep,
583 static struct tda827x_config tda827x_cfg_2_sw42 = {
584 .init = philips_tda827x_tuner_init,
585 .sleep = philips_tda827x_tuner_sleep,
590 /* ------------------------------------------------------------------ */
592 static struct tda1004x_config tda827x_lifeview_config = {
593 .demod_address = 0x08,
596 .xtal_freq = TDA10046_XTAL_16M,
597 .agc_config = TDA10046_AGC_TDA827X,
598 .gpio_config = TDA10046_GP11_I,
599 .if_freq = TDA10046_FREQ_045,
600 .tuner_address = 0x60,
601 .request_firmware = philips_tda1004x_request_firmware
604 static struct tda1004x_config philips_tiger_config = {
605 .demod_address = 0x08,
608 .xtal_freq = TDA10046_XTAL_16M,
609 .agc_config = TDA10046_AGC_TDA827X,
610 .gpio_config = TDA10046_GP11_I,
611 .if_freq = TDA10046_FREQ_045,
613 .tuner_address = 0x61,
615 .request_firmware = philips_tda1004x_request_firmware
618 static struct tda1004x_config cinergy_ht_config = {
619 .demod_address = 0x08,
622 .xtal_freq = TDA10046_XTAL_16M,
623 .agc_config = TDA10046_AGC_TDA827X,
624 .gpio_config = TDA10046_GP01_I,
625 .if_freq = TDA10046_FREQ_045,
627 .tuner_address = 0x61,
628 .request_firmware = philips_tda1004x_request_firmware
631 static struct tda1004x_config cinergy_ht_pci_config = {
632 .demod_address = 0x08,
635 .xtal_freq = TDA10046_XTAL_16M,
636 .agc_config = TDA10046_AGC_TDA827X,
637 .gpio_config = TDA10046_GP01_I,
638 .if_freq = TDA10046_FREQ_045,
640 .tuner_address = 0x60,
641 .request_firmware = philips_tda1004x_request_firmware
644 static struct tda1004x_config philips_tiger_s_config = {
645 .demod_address = 0x08,
648 .xtal_freq = TDA10046_XTAL_16M,
649 .agc_config = TDA10046_AGC_TDA827X,
650 .gpio_config = TDA10046_GP01_I,
651 .if_freq = TDA10046_FREQ_045,
653 .tuner_address = 0x61,
655 .request_firmware = philips_tda1004x_request_firmware
658 static struct tda1004x_config pinnacle_pctv_310i_config = {
659 .demod_address = 0x08,
662 .xtal_freq = TDA10046_XTAL_16M,
663 .agc_config = TDA10046_AGC_TDA827X,
664 .gpio_config = TDA10046_GP11_I,
665 .if_freq = TDA10046_FREQ_045,
667 .tuner_address = 0x61,
668 .request_firmware = philips_tda1004x_request_firmware
671 static struct tda1004x_config hauppauge_hvr_1110_config = {
672 .demod_address = 0x08,
675 .xtal_freq = TDA10046_XTAL_16M,
676 .agc_config = TDA10046_AGC_TDA827X,
677 .gpio_config = TDA10046_GP11_I,
678 .if_freq = TDA10046_FREQ_045,
680 .tuner_address = 0x61,
681 .request_firmware = philips_tda1004x_request_firmware
684 static struct tda1004x_config asus_p7131_dual_config = {
685 .demod_address = 0x08,
688 .xtal_freq = TDA10046_XTAL_16M,
689 .agc_config = TDA10046_AGC_TDA827X,
690 .gpio_config = TDA10046_GP11_I,
691 .if_freq = TDA10046_FREQ_045,
693 .tuner_address = 0x61,
695 .request_firmware = philips_tda1004x_request_firmware
698 static struct tda1004x_config lifeview_trio_config = {
699 .demod_address = 0x09,
702 .xtal_freq = TDA10046_XTAL_16M,
703 .agc_config = TDA10046_AGC_TDA827X,
704 .gpio_config = TDA10046_GP00_I,
705 .if_freq = TDA10046_FREQ_045,
706 .tuner_address = 0x60,
707 .request_firmware = philips_tda1004x_request_firmware
710 static struct tda1004x_config tevion_dvbt220rf_config = {
711 .demod_address = 0x08,
714 .xtal_freq = TDA10046_XTAL_16M,
715 .agc_config = TDA10046_AGC_TDA827X,
716 .gpio_config = TDA10046_GP11_I,
717 .if_freq = TDA10046_FREQ_045,
718 .tuner_address = 0x60,
719 .request_firmware = philips_tda1004x_request_firmware
722 static struct tda1004x_config md8800_dvbt_config = {
723 .demod_address = 0x08,
726 .xtal_freq = TDA10046_XTAL_16M,
727 .agc_config = TDA10046_AGC_TDA827X,
728 .gpio_config = TDA10046_GP01_I,
729 .if_freq = TDA10046_FREQ_045,
731 .tuner_address = 0x60,
732 .request_firmware = philips_tda1004x_request_firmware
735 static struct tda1004x_config asus_p7131_4871_config = {
736 .demod_address = 0x08,
739 .xtal_freq = TDA10046_XTAL_16M,
740 .agc_config = TDA10046_AGC_TDA827X,
741 .gpio_config = TDA10046_GP01_I,
742 .if_freq = TDA10046_FREQ_045,
744 .tuner_address = 0x61,
746 .request_firmware = philips_tda1004x_request_firmware
749 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
750 .demod_address = 0x08,
753 .xtal_freq = TDA10046_XTAL_16M,
754 .agc_config = TDA10046_AGC_TDA827X,
755 .gpio_config = TDA10046_GP11_I,
756 .if_freq = TDA10046_FREQ_045,
758 .tuner_address = 0x61,
760 .request_firmware = philips_tda1004x_request_firmware
763 static struct tda1004x_config kworld_dvb_t_210_config = {
764 .demod_address = 0x08,
767 .xtal_freq = TDA10046_XTAL_16M,
768 .agc_config = TDA10046_AGC_TDA827X,
769 .gpio_config = TDA10046_GP11_I,
770 .if_freq = TDA10046_FREQ_045,
772 .tuner_address = 0x61,
774 .request_firmware = philips_tda1004x_request_firmware
777 static struct tda1004x_config avermedia_super_007_config = {
778 .demod_address = 0x08,
781 .xtal_freq = TDA10046_XTAL_16M,
782 .agc_config = TDA10046_AGC_TDA827X,
783 .gpio_config = TDA10046_GP01_I,
784 .if_freq = TDA10046_FREQ_045,
786 .tuner_address = 0x60,
788 .request_firmware = philips_tda1004x_request_firmware
791 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
792 .demod_address = 0x08,
795 .xtal_freq = TDA10046_XTAL_16M,
796 .agc_config = TDA10046_AGC_TDA827X,
797 .gpio_config = TDA10046_GP01_I,
798 .if_freq = TDA10046_FREQ_045,
800 .tuner_address = 0x61,
802 .request_firmware = philips_tda1004x_request_firmware
805 static struct tda1004x_config asus_tiger_3in1_config = {
806 .demod_address = 0x0b,
809 .xtal_freq = TDA10046_XTAL_16M,
810 .agc_config = TDA10046_AGC_TDA827X,
811 .gpio_config = TDA10046_GP11_I,
812 .if_freq = TDA10046_FREQ_045,
814 .tuner_address = 0x61,
816 .request_firmware = philips_tda1004x_request_firmware
819 /* ------------------------------------------------------------------
820 * special case: this card uses saa713x GPIO22 for the mode switch
823 static int ads_duo_tuner_init(struct dvb_frontend *fe)
825 struct saa7134_dev *dev = fe->dvb->priv;
826 philips_tda827x_tuner_init(fe);
827 /* route TDA8275a AGC input to the channel decoder */
828 saa7134_set_gpio(dev, 22, 1);
832 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
834 struct saa7134_dev *dev = fe->dvb->priv;
835 /* route TDA8275a AGC input to the analog IF chip*/
836 saa7134_set_gpio(dev, 22, 0);
837 philips_tda827x_tuner_sleep(fe);
841 static struct tda827x_config ads_duo_cfg = {
842 .init = ads_duo_tuner_init,
843 .sleep = ads_duo_tuner_sleep,
847 static struct tda1004x_config ads_tech_duo_config = {
848 .demod_address = 0x08,
851 .xtal_freq = TDA10046_XTAL_16M,
852 .agc_config = TDA10046_AGC_TDA827X,
853 .gpio_config = TDA10046_GP00_I,
854 .if_freq = TDA10046_FREQ_045,
855 .tuner_address = 0x61,
856 .request_firmware = philips_tda1004x_request_firmware
859 static struct zl10353_config behold_h6_config = {
860 .demod_address = 0x1e>>1,
863 .disable_i2c_gate_ctrl = 1,
866 /* ==================================================================
867 * tda10086 based DVB-S cards, helper functions
870 static struct tda10086_config flydvbs = {
871 .demod_address = 0x0e,
874 .xtal_freq = TDA10086_XTAL_16M,
877 static struct tda10086_config sd1878_4m = {
878 .demod_address = 0x0e,
881 .xtal_freq = TDA10086_XTAL_4M,
884 /* ------------------------------------------------------------------
885 * special case: lnb supply is connected to the gated i2c
888 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
891 struct saa7134_dev *dev = fe->dvb->priv;
892 if (fe->ops.i2c_gate_ctrl) {
893 fe->ops.i2c_gate_ctrl(fe, 1);
894 if (dev->original_set_voltage)
895 res = dev->original_set_voltage(fe, voltage);
896 fe->ops.i2c_gate_ctrl(fe, 0);
901 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
904 struct saa7134_dev *dev = fe->dvb->priv;
905 if (fe->ops.i2c_gate_ctrl) {
906 fe->ops.i2c_gate_ctrl(fe, 1);
907 if (dev->original_set_high_voltage)
908 res = dev->original_set_high_voltage(fe, arg);
909 fe->ops.i2c_gate_ctrl(fe, 0);
914 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
916 struct saa7134_dev *dev = fe->dvb->priv;
917 u8 wbuf[2] = { 0x1f, 00 };
919 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
920 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
922 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
924 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
925 if (voltage == SEC_VOLTAGE_18)
926 wbuf[1] = rbuf | 0x10;
928 wbuf[1] = rbuf & 0xef;
930 i2c_transfer(&dev->i2c_adap, msg, 1);
934 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
936 struct saa7134_dev *dev = fe->dvb->priv;
937 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
941 /* ==================================================================
942 * nxt200x based ATSC cards, helper functions
945 static struct nxt200x_config avertvhda180 = {
946 .demod_address = 0x0a,
949 static struct nxt200x_config kworldatsc110 = {
950 .demod_address = 0x0a,
953 /* ==================================================================
957 static int dvb_init(struct saa7134_dev *dev)
960 int attach_xc3028 = 0;
961 struct videobuf_dvb_frontend *fe0;
963 /* FIXME: add support for multi-frontend */
964 mutex_init(&dev->frontends.lock);
965 INIT_LIST_HEAD(&dev->frontends.felist);
967 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
968 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
970 printk(KERN_ERR "%s() failed to alloc\n", __func__);
974 /* init struct videobuf_dvb */
975 dev->ts.nr_bufs = 32;
976 dev->ts.nr_packets = 32*4;
977 fe0->dvb.name = dev->name;
978 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
979 &dev->pci->dev, &dev->slock,
980 V4L2_BUF_TYPE_VIDEO_CAPTURE,
981 V4L2_FIELD_ALTERNATE,
982 sizeof(struct saa7134_buf),
985 switch (dev->board) {
986 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
987 dprintk("pinnacle 300i dvb setup\n");
988 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
990 if (fe0->dvb.frontend) {
991 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
994 case SAA7134_BOARD_AVERMEDIA_777:
995 case SAA7134_BOARD_AVERMEDIA_A16AR:
996 dprintk("avertv 777 dvb setup\n");
997 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
999 if (fe0->dvb.frontend) {
1000 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1001 &dev->i2c_adap, 0x61,
1002 TUNER_PHILIPS_TD1316);
1005 case SAA7134_BOARD_AVERMEDIA_A16D:
1006 dprintk("AverMedia A16D dvb setup\n");
1007 fe0->dvb.frontend = dvb_attach(mt352_attach,
1008 &avermedia_xc3028_mt352_dev,
1012 case SAA7134_BOARD_MD7134:
1013 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1016 if (fe0->dvb.frontend) {
1017 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1018 &dev->i2c_adap, medion_cardbus.tuner_address,
1019 TUNER_PHILIPS_FMD1216ME_MK3);
1022 case SAA7134_BOARD_PHILIPS_TOUGH:
1023 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1024 &philips_tu1216_60_config,
1026 if (fe0->dvb.frontend) {
1027 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1028 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1031 case SAA7134_BOARD_FLYDVBTDUO:
1032 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1033 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1034 &tda827x_cfg_0) < 0)
1035 goto dettach_frontend;
1037 case SAA7134_BOARD_PHILIPS_EUROPA:
1038 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1039 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1040 &philips_europa_config,
1042 if (fe0->dvb.frontend) {
1043 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1044 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1045 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1046 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1047 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1050 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1051 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1052 &philips_tu1216_61_config,
1054 if (fe0->dvb.frontend) {
1055 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1056 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1059 case SAA7134_BOARD_KWORLD_DVBT_210:
1060 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1061 &tda827x_cfg_2) < 0)
1062 goto dettach_frontend;
1064 case SAA7134_BOARD_PHILIPS_TIGER:
1065 if (configure_tda827x_fe(dev, &philips_tiger_config,
1066 &tda827x_cfg_0) < 0)
1067 goto dettach_frontend;
1069 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1070 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1071 &tda827x_cfg_1) < 0)
1072 goto dettach_frontend;
1074 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1075 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1076 &tda827x_cfg_1) < 0)
1077 goto dettach_frontend;
1079 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1080 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1081 &tda827x_cfg_0) < 0)
1082 goto dettach_frontend;
1084 case SAA7134_BOARD_FLYDVBT_LR301:
1085 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1086 &tda827x_cfg_0) < 0)
1087 goto dettach_frontend;
1089 case SAA7134_BOARD_FLYDVB_TRIO:
1090 if (!use_frontend) { /* terrestrial */
1091 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1092 &tda827x_cfg_0) < 0)
1093 goto dettach_frontend;
1094 } else { /* satellite */
1095 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1096 if (fe0->dvb.frontend) {
1097 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1098 &dev->i2c_adap, 0) == NULL) {
1099 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1100 goto dettach_frontend;
1102 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1103 0x08, 0, 0) == NULL) {
1104 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1105 goto dettach_frontend;
1110 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1111 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1112 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1113 &ads_tech_duo_config,
1115 if (fe0->dvb.frontend) {
1116 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1117 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1118 &ads_duo_cfg) == NULL) {
1119 wprintk("no tda827x tuner found at addr: %02x\n",
1120 ads_tech_duo_config.tuner_address);
1121 goto dettach_frontend;
1124 wprintk("failed to attach tda10046\n");
1126 case SAA7134_BOARD_TEVION_DVBT_220RF:
1127 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1128 &tda827x_cfg_0) < 0)
1129 goto dettach_frontend;
1131 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1132 if (!use_frontend) { /* terrestrial */
1133 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1134 &tda827x_cfg_0) < 0)
1135 goto dettach_frontend;
1136 } else { /* satellite */
1137 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1138 &flydvbs, &dev->i2c_adap);
1139 if (fe0->dvb.frontend) {
1140 struct dvb_frontend *fe = fe0->dvb.frontend;
1141 u8 dev_id = dev->eedata[2];
1143 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1145 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1146 0x60, &dev->i2c_adap, 0) == NULL) {
1147 wprintk("%s: Medion Quadro, no tda826x "
1148 "found !\n", __func__);
1149 goto dettach_frontend;
1151 if (dev_id != 0x08) {
1152 /* we need to open the i2c gate (we know it exists) */
1153 fe->ops.i2c_gate_ctrl(fe, 1);
1154 if (dvb_attach(isl6405_attach, fe,
1155 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1156 wprintk("%s: Medion Quadro, no ISL6405 "
1157 "found !\n", __func__);
1158 goto dettach_frontend;
1160 if (dev_id == 0x07) {
1161 /* fire up the 2nd section of the LNB supply since
1162 we can't do this from the other section */
1164 i2c_transfer(&dev->i2c_adap, &msg, 1);
1166 fe->ops.i2c_gate_ctrl(fe, 0);
1167 dev->original_set_voltage = fe->ops.set_voltage;
1168 fe->ops.set_voltage = md8800_set_voltage;
1169 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1170 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1172 fe->ops.set_voltage = md8800_set_voltage2;
1173 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1178 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1179 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1181 if (fe0->dvb.frontend)
1182 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1183 NULL, DVB_PLL_TDHU2);
1185 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1186 case SAA7134_BOARD_KWORLD_ATSC110:
1187 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1189 if (fe0->dvb.frontend)
1190 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1191 &dev->i2c_adap, 0x61,
1192 TUNER_PHILIPS_TUV1236D);
1194 case SAA7134_BOARD_FLYDVBS_LR300:
1195 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1197 if (fe0->dvb.frontend) {
1198 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1199 &dev->i2c_adap, 0) == NULL) {
1200 wprintk("%s: No tda826x found!\n", __func__);
1201 goto dettach_frontend;
1203 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1204 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1205 wprintk("%s: No ISL6421 found!\n", __func__);
1206 goto dettach_frontend;
1210 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1211 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1214 if (fe0->dvb.frontend) {
1215 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1216 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1218 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1219 &dev->i2c_adap, medion_cardbus.tuner_address,
1220 TUNER_PHILIPS_FMD1216ME_MK3);
1223 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1224 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1225 &philips_europa_config,
1227 if (fe0->dvb.frontend) {
1228 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1229 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1232 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1233 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1234 &tda827x_cfg_0) < 0)
1235 goto dettach_frontend;
1237 case SAA7134_BOARD_CINERGY_HT_PCI:
1238 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1239 &tda827x_cfg_0) < 0)
1240 goto dettach_frontend;
1242 case SAA7134_BOARD_PHILIPS_TIGER_S:
1243 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1244 &tda827x_cfg_2) < 0)
1245 goto dettach_frontend;
1247 case SAA7134_BOARD_ASUS_P7131_4871:
1248 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1249 &tda827x_cfg_2) < 0)
1250 goto dettach_frontend;
1252 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1253 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1254 &tda827x_cfg_2) < 0)
1255 goto dettach_frontend;
1257 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1258 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1259 &tda827x_cfg_0) < 0)
1260 goto dettach_frontend;
1262 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1263 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1264 &tda827x_cfg_2_sw42) < 0)
1265 goto dettach_frontend;
1267 case SAA7134_BOARD_PHILIPS_SNAKE:
1268 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1270 if (fe0->dvb.frontend) {
1271 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1272 &dev->i2c_adap, 0) == NULL) {
1273 wprintk("%s: No tda826x found!\n", __func__);
1274 goto dettach_frontend;
1276 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1277 &dev->i2c_adap, 0, 0) == NULL) {
1278 wprintk("%s: No lnbp21 found!\n", __func__);
1279 goto dettach_frontend;
1283 case SAA7134_BOARD_CREATIX_CTX953:
1284 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1285 &tda827x_cfg_0) < 0)
1286 goto dettach_frontend;
1288 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1289 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1290 &tda827x_cfg_2) < 0)
1291 goto dettach_frontend;
1293 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1294 dprintk("AverMedia E506R dvb setup\n");
1295 saa7134_set_gpio(dev, 25, 0);
1297 saa7134_set_gpio(dev, 25, 1);
1298 fe0->dvb.frontend = dvb_attach(mt352_attach,
1299 &avermedia_xc3028_mt352_dev,
1303 case SAA7134_BOARD_MD7134_BRIDGE_2:
1304 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1305 &sd1878_4m, &dev->i2c_adap);
1306 if (fe0->dvb.frontend) {
1307 struct dvb_frontend *fe;
1308 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1309 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1310 wprintk("%s: MD7134 DVB-S, no SD1878 "
1311 "found !\n", __func__);
1312 goto dettach_frontend;
1314 /* we need to open the i2c gate (we know it exists) */
1315 fe = fe0->dvb.frontend;
1316 fe->ops.i2c_gate_ctrl(fe, 1);
1317 if (dvb_attach(isl6405_attach, fe,
1318 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1319 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1320 "found !\n", __func__);
1321 goto dettach_frontend;
1323 fe->ops.i2c_gate_ctrl(fe, 0);
1324 dev->original_set_voltage = fe->ops.set_voltage;
1325 fe->ops.set_voltage = md8800_set_voltage;
1326 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1327 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1330 case SAA7134_BOARD_AVERMEDIA_M103:
1331 saa7134_set_gpio(dev, 25, 0);
1333 saa7134_set_gpio(dev, 25, 1);
1334 fe0->dvb.frontend = dvb_attach(mt352_attach,
1335 &avermedia_xc3028_mt352_dev,
1339 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1340 if (!use_frontend) { /* terrestrial */
1341 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1342 &tda827x_cfg_2) < 0)
1343 goto dettach_frontend;
1344 } else { /* satellite */
1345 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1346 &flydvbs, &dev->i2c_adap);
1347 if (fe0->dvb.frontend) {
1348 if (dvb_attach(tda826x_attach,
1349 fe0->dvb.frontend, 0x60,
1350 &dev->i2c_adap, 0) == NULL) {
1351 wprintk("%s: Asus Tiger 3in1, no "
1352 "tda826x found!\n", __func__);
1353 goto dettach_frontend;
1355 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1356 &dev->i2c_adap, 0, 0) == NULL) {
1357 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1358 " found!\n", __func__);
1359 goto dettach_frontend;
1364 case SAA7134_BOARD_ASUSTeK_TIGER:
1365 if (configure_tda827x_fe(dev, &philips_tiger_config,
1366 &tda827x_cfg_0) < 0)
1367 goto dettach_frontend;
1369 case SAA7134_BOARD_BEHOLD_H6:
1370 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1373 if (fe0->dvb.frontend) {
1374 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1375 &dev->i2c_adap, 0x61,
1376 TUNER_PHILIPS_FMD1216ME_MK3);
1380 wprintk("Huh? unknown DVB card?\n");
1384 if (attach_xc3028) {
1385 struct dvb_frontend *fe;
1386 struct xc2028_config cfg = {
1387 .i2c_adap = &dev->i2c_adap,
1391 if (!fe0->dvb.frontend)
1392 goto dettach_frontend;
1394 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1396 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1398 goto dettach_frontend;
1402 if (NULL == fe0->dvb.frontend) {
1403 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1404 goto dettach_frontend;
1406 /* define general-purpose callback pointer */
1407 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1409 /* register everything else */
1410 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1411 &dev->pci->dev, adapter_nr, 0);
1413 /* this sequence is necessary to make the tda1004x load its firmware
1414 * and to enter analog mode of hybrid boards
1417 if (fe0->dvb.frontend->ops.init)
1418 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1419 if (fe0->dvb.frontend->ops.sleep)
1420 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1421 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1422 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1427 videobuf_dvb_dealloc_frontends(&dev->frontends);
1431 static int dvb_fini(struct saa7134_dev *dev)
1433 struct videobuf_dvb_frontend *fe0;
1435 /* Get the first frontend */
1436 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1440 /* FIXME: I suspect that this code is bogus, since the entry for
1441 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1442 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1444 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1445 struct v4l2_priv_tun_config tda9887_cfg;
1446 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1448 tda9887_cfg.tuner = TUNER_TDA9887;
1449 tda9887_cfg.priv = &on;
1451 /* otherwise we don't detect the tuner on next insmod */
1452 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1453 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1454 if ((dev->eedata[2] == 0x07) && use_frontend) {
1455 /* turn off the 2nd lnb supply */
1457 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1458 struct dvb_frontend *fe;
1459 fe = fe0->dvb.frontend;
1460 if (fe->ops.i2c_gate_ctrl) {
1461 fe->ops.i2c_gate_ctrl(fe, 1);
1462 i2c_transfer(&dev->i2c_adap, &msg, 1);
1463 fe->ops.i2c_gate_ctrl(fe, 0);
1467 videobuf_dvb_unregister_bus(&dev->frontends);
1471 static struct saa7134_mpeg_ops dvb_ops = {
1472 .type = SAA7134_MPEG_DVB,
1477 static int __init dvb_register(void)
1479 return saa7134_ts_register(&dvb_ops);
1482 static void __exit dvb_unregister(void)
1484 saa7134_ts_unregister(&dvb_ops);
1487 module_init(dvb_register);
1488 module_exit(dvb_unregister);
1490 /* ------------------------------------------------------------------ */