3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5 * Extended 3 / 2005 by Hartmut Hackmann to support various
6 * cards with the tda10046 DVB-T channel decoder
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/init.h>
24 #include <linux/list.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/delay.h>
28 #include <linux/kthread.h>
29 #include <linux/suspend.h>
31 #include "saa7134-reg.h"
33 #include <media/v4l2-common.h>
35 #include <dvb_frontend.h>
38 #include "mt352_priv.h" /* FIXME */
41 #include "tuner-xc2028.h"
50 #include "tuner-simple.h"
62 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
63 MODULE_LICENSE("GPL");
65 static unsigned int antenna_pwr;
67 module_param(antenna_pwr, int, 0444);
68 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
70 static int use_frontend;
71 module_param(use_frontend, int, 0644);
72 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
75 module_param(debug, int, 0644);
76 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
78 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
80 #define dprintk(fmt, arg...) do { if (debug) \
81 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
84 #define wprintk(fmt, arg...) \
85 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
87 /* ------------------------------------------------------------------
88 * mt352 based DVB-T cards
91 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
96 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
97 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
101 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
102 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
105 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
106 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
108 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
110 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
111 dprintk("%s %s\n", __func__, ok ? "on" : "off");
114 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
118 static int mt352_pinnacle_init(struct dvb_frontend* fe)
120 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
121 static u8 reset [] = { RESET, 0x80 };
122 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
123 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
124 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
125 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
126 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
127 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
128 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
129 struct saa7134_dev *dev= fe->dvb->priv;
131 dprintk("%s called\n", __func__);
133 mt352_write(fe, clock_config, sizeof(clock_config));
135 mt352_write(fe, reset, sizeof(reset));
136 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
137 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
138 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
139 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
141 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
142 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
143 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
148 static int mt352_aver777_init(struct dvb_frontend* fe)
150 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
151 static u8 reset [] = { RESET, 0x80 };
152 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
153 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
154 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
156 mt352_write(fe, clock_config, sizeof(clock_config));
158 mt352_write(fe, reset, sizeof(reset));
159 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
160 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
161 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
166 static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
168 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
169 static u8 reset [] = { RESET, 0x80 };
170 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
171 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
172 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
174 mt352_write(fe, clock_config, sizeof(clock_config));
176 mt352_write(fe, reset, sizeof(reset));
177 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
178 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
179 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
183 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
184 struct dvb_frontend_parameters* params)
186 u8 off[] = { 0x00, 0xf1};
187 u8 on[] = { 0x00, 0x71};
188 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
190 struct saa7134_dev *dev = fe->dvb->priv;
191 struct v4l2_frequency f;
193 /* set frequency (mt2050) */
195 f.type = V4L2_TUNER_DIGITAL_TV;
196 f.frequency = params->frequency / 1000 * 16 / 1000;
197 if (fe->ops.i2c_gate_ctrl)
198 fe->ops.i2c_gate_ctrl(fe, 1);
199 i2c_transfer(&dev->i2c_adap, &msg, 1);
200 saa_call_all(dev, tuner, s_frequency, &f);
202 if (fe->ops.i2c_gate_ctrl)
203 fe->ops.i2c_gate_ctrl(fe, 1);
204 i2c_transfer(&dev->i2c_adap, &msg, 1);
206 pinnacle_antenna_pwr(dev, antenna_pwr);
209 return mt352_pinnacle_init(fe);
212 static struct mt352_config pinnacle_300i = {
213 .demod_address = 0x3c >> 1,
217 .demod_init = mt352_pinnacle_init,
220 static struct mt352_config avermedia_777 = {
221 .demod_address = 0xf,
222 .demod_init = mt352_aver777_init,
225 static struct mt352_config avermedia_xc3028_mt352_dev = {
226 .demod_address = (0x1e >> 1),
228 .demod_init = mt352_avermedia_xc3028_init,
231 /* ==================================================================
232 * tda1004x based DVB-T cards, helper functions
235 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
236 const struct firmware **fw, char *name)
238 struct saa7134_dev *dev = fe->dvb->priv;
239 return request_firmware(fw, name, &dev->pci->dev);
242 /* ------------------------------------------------------------------
243 * these tuners are tu1216, td1316(a)
246 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
248 struct saa7134_dev *dev = fe->dvb->priv;
249 struct tda1004x_state *state = fe->demodulator_priv;
250 u8 addr = state->config->tuner_address;
252 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
254 int tuner_frequency = 0;
257 /* determine charge pump */
258 tuner_frequency = params->frequency + 36166000;
259 if (tuner_frequency < 87000000)
261 else if (tuner_frequency < 130000000)
263 else if (tuner_frequency < 160000000)
265 else if (tuner_frequency < 200000000)
267 else if (tuner_frequency < 290000000)
269 else if (tuner_frequency < 420000000)
271 else if (tuner_frequency < 480000000)
273 else if (tuner_frequency < 620000000)
275 else if (tuner_frequency < 830000000)
277 else if (tuner_frequency < 895000000)
283 if (params->frequency < 49000000)
285 else if (params->frequency < 161000000)
287 else if (params->frequency < 444000000)
289 else if (params->frequency < 861000000)
294 /* setup PLL filter */
295 switch (params->u.ofdm.bandwidth) {
296 case BANDWIDTH_6_MHZ:
300 case BANDWIDTH_7_MHZ:
304 case BANDWIDTH_8_MHZ:
313 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
315 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
317 /* setup tuner buffer */
318 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
319 tuner_buf[1] = tuner_frequency & 0xff;
321 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
323 if (fe->ops.i2c_gate_ctrl)
324 fe->ops.i2c_gate_ctrl(fe, 1);
325 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
326 wprintk("could not write to tuner at addr: 0x%02x\n",
334 static int philips_tu1216_init(struct dvb_frontend *fe)
336 struct saa7134_dev *dev = fe->dvb->priv;
337 struct tda1004x_state *state = fe->demodulator_priv;
338 u8 addr = state->config->tuner_address;
339 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
340 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
342 /* setup PLL configuration */
343 if (fe->ops.i2c_gate_ctrl)
344 fe->ops.i2c_gate_ctrl(fe, 1);
345 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
352 /* ------------------------------------------------------------------ */
354 static struct tda1004x_config philips_tu1216_60_config = {
355 .demod_address = 0x8,
358 .xtal_freq = TDA10046_XTAL_4M,
359 .agc_config = TDA10046_AGC_DEFAULT,
360 .if_freq = TDA10046_FREQ_3617,
361 .tuner_address = 0x60,
362 .request_firmware = philips_tda1004x_request_firmware
365 static struct tda1004x_config philips_tu1216_61_config = {
367 .demod_address = 0x8,
370 .xtal_freq = TDA10046_XTAL_4M,
371 .agc_config = TDA10046_AGC_DEFAULT,
372 .if_freq = TDA10046_FREQ_3617,
373 .tuner_address = 0x61,
374 .request_firmware = philips_tda1004x_request_firmware
377 /* ------------------------------------------------------------------ */
379 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
381 struct saa7134_dev *dev = fe->dvb->priv;
382 struct tda1004x_state *state = fe->demodulator_priv;
383 u8 addr = state->config->tuner_address;
384 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
385 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
387 /* setup PLL configuration */
388 if (fe->ops.i2c_gate_ctrl)
389 fe->ops.i2c_gate_ctrl(fe, 1);
390 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
395 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
397 return philips_tda6651_pll_set(fe, params);
400 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
402 struct saa7134_dev *dev = fe->dvb->priv;
403 struct tda1004x_state *state = fe->demodulator_priv;
404 u8 addr = state->config->tuner_address;
405 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
406 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
408 /* switch the tuner to analog mode */
409 if (fe->ops.i2c_gate_ctrl)
410 fe->ops.i2c_gate_ctrl(fe, 1);
411 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
416 /* ------------------------------------------------------------------ */
418 static int philips_europa_tuner_init(struct dvb_frontend *fe)
420 struct saa7134_dev *dev = fe->dvb->priv;
421 static u8 msg[] = { 0x00, 0x40};
422 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
425 if (philips_td1316_tuner_init(fe))
428 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
434 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
436 struct saa7134_dev *dev = fe->dvb->priv;
438 static u8 msg[] = { 0x00, 0x14 };
439 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
441 if (philips_td1316_tuner_sleep(fe))
444 /* switch the board to analog mode */
445 if (fe->ops.i2c_gate_ctrl)
446 fe->ops.i2c_gate_ctrl(fe, 1);
447 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
451 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
453 struct saa7134_dev *dev = fe->dvb->priv;
455 if (dev->original_demod_sleep)
456 dev->original_demod_sleep(fe);
457 fe->ops.i2c_gate_ctrl(fe, 1);
461 static struct tda1004x_config philips_europa_config = {
463 .demod_address = 0x8,
466 .xtal_freq = TDA10046_XTAL_4M,
467 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
468 .if_freq = TDA10046_FREQ_052,
469 .tuner_address = 0x61,
470 .request_firmware = philips_tda1004x_request_firmware
473 static struct tda1004x_config medion_cardbus = {
474 .demod_address = 0x08,
477 .xtal_freq = TDA10046_XTAL_16M,
478 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
479 .if_freq = TDA10046_FREQ_3613,
480 .tuner_address = 0x61,
481 .request_firmware = philips_tda1004x_request_firmware
484 static struct tda1004x_config technotrend_budget_t3000_config = {
485 .demod_address = 0x8,
488 .xtal_freq = TDA10046_XTAL_4M,
489 .agc_config = TDA10046_AGC_DEFAULT,
490 .if_freq = TDA10046_FREQ_3617,
491 .tuner_address = 0x63,
492 .request_firmware = philips_tda1004x_request_firmware
495 /* ------------------------------------------------------------------
496 * tda 1004x based cards with philips silicon tuner
499 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
501 struct tda1004x_state *state = fe->demodulator_priv;
503 u8 addr = state->config->i2c_gate;
504 static u8 tda8290_close[] = { 0x21, 0xc0};
505 static u8 tda8290_open[] = { 0x21, 0x80};
506 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
508 tda8290_msg.buf = tda8290_close;
510 tda8290_msg.buf = tda8290_open;
512 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
513 struct saa7134_dev *dev = fe->dvb->priv;
514 wprintk("could not access tda8290 I2C gate\n");
521 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
523 struct saa7134_dev *dev = fe->dvb->priv;
524 struct tda1004x_state *state = fe->demodulator_priv;
526 switch (state->config->antenna_switch) {
528 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
529 saa7134_set_gpio(dev, 21, 0);
531 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
532 saa7134_set_gpio(dev, 21, 1);
538 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
540 struct saa7134_dev *dev = fe->dvb->priv;
541 struct tda1004x_state *state = fe->demodulator_priv;
543 switch (state->config->antenna_switch) {
545 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
546 saa7134_set_gpio(dev, 21, 1);
548 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
549 saa7134_set_gpio(dev, 21, 0);
555 static int configure_tda827x_fe(struct saa7134_dev *dev,
556 struct tda1004x_config *cdec_conf,
557 struct tda827x_config *tuner_conf)
559 struct videobuf_dvb_frontend *fe0;
561 /* Get the first frontend */
562 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
564 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
565 if (fe0->dvb.frontend) {
566 if (cdec_conf->i2c_gate)
567 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
568 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
569 cdec_conf->tuner_address,
570 &dev->i2c_adap, tuner_conf))
573 wprintk("no tda827x tuner found at addr: %02x\n",
574 cdec_conf->tuner_address);
579 /* ------------------------------------------------------------------ */
581 static struct tda827x_config tda827x_cfg_0 = {
582 .init = philips_tda827x_tuner_init,
583 .sleep = philips_tda827x_tuner_sleep,
588 static struct tda827x_config tda827x_cfg_1 = {
589 .init = philips_tda827x_tuner_init,
590 .sleep = philips_tda827x_tuner_sleep,
595 static struct tda827x_config tda827x_cfg_2 = {
596 .init = philips_tda827x_tuner_init,
597 .sleep = philips_tda827x_tuner_sleep,
602 static struct tda827x_config tda827x_cfg_2_sw42 = {
603 .init = philips_tda827x_tuner_init,
604 .sleep = philips_tda827x_tuner_sleep,
609 /* ------------------------------------------------------------------ */
611 static struct tda1004x_config tda827x_lifeview_config = {
612 .demod_address = 0x08,
615 .xtal_freq = TDA10046_XTAL_16M,
616 .agc_config = TDA10046_AGC_TDA827X,
617 .gpio_config = TDA10046_GP11_I,
618 .if_freq = TDA10046_FREQ_045,
619 .tuner_address = 0x60,
620 .request_firmware = philips_tda1004x_request_firmware
623 static struct tda1004x_config philips_tiger_config = {
624 .demod_address = 0x08,
627 .xtal_freq = TDA10046_XTAL_16M,
628 .agc_config = TDA10046_AGC_TDA827X,
629 .gpio_config = TDA10046_GP11_I,
630 .if_freq = TDA10046_FREQ_045,
632 .tuner_address = 0x61,
634 .request_firmware = philips_tda1004x_request_firmware
637 static struct tda1004x_config cinergy_ht_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,
647 .request_firmware = philips_tda1004x_request_firmware
650 static struct tda1004x_config cinergy_ht_pci_config = {
651 .demod_address = 0x08,
654 .xtal_freq = TDA10046_XTAL_16M,
655 .agc_config = TDA10046_AGC_TDA827X,
656 .gpio_config = TDA10046_GP01_I,
657 .if_freq = TDA10046_FREQ_045,
659 .tuner_address = 0x60,
660 .request_firmware = philips_tda1004x_request_firmware
663 static struct tda1004x_config philips_tiger_s_config = {
664 .demod_address = 0x08,
667 .xtal_freq = TDA10046_XTAL_16M,
668 .agc_config = TDA10046_AGC_TDA827X,
669 .gpio_config = TDA10046_GP01_I,
670 .if_freq = TDA10046_FREQ_045,
672 .tuner_address = 0x61,
674 .request_firmware = philips_tda1004x_request_firmware
677 static struct tda1004x_config pinnacle_pctv_310i_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,
687 .request_firmware = philips_tda1004x_request_firmware
690 static struct tda1004x_config hauppauge_hvr_1110_config = {
691 .demod_address = 0x08,
694 .xtal_freq = TDA10046_XTAL_16M,
695 .agc_config = TDA10046_AGC_TDA827X,
696 .gpio_config = TDA10046_GP11_I,
697 .if_freq = TDA10046_FREQ_045,
699 .tuner_address = 0x61,
700 .request_firmware = philips_tda1004x_request_firmware
703 static struct tda1004x_config asus_p7131_dual_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,
712 .tuner_address = 0x61,
714 .request_firmware = philips_tda1004x_request_firmware
717 static struct tda1004x_config lifeview_trio_config = {
718 .demod_address = 0x09,
721 .xtal_freq = TDA10046_XTAL_16M,
722 .agc_config = TDA10046_AGC_TDA827X,
723 .gpio_config = TDA10046_GP00_I,
724 .if_freq = TDA10046_FREQ_045,
725 .tuner_address = 0x60,
726 .request_firmware = philips_tda1004x_request_firmware
729 static struct tda1004x_config tevion_dvbt220rf_config = {
730 .demod_address = 0x08,
733 .xtal_freq = TDA10046_XTAL_16M,
734 .agc_config = TDA10046_AGC_TDA827X,
735 .gpio_config = TDA10046_GP11_I,
736 .if_freq = TDA10046_FREQ_045,
737 .tuner_address = 0x60,
738 .request_firmware = philips_tda1004x_request_firmware
741 static struct tda1004x_config md8800_dvbt_config = {
742 .demod_address = 0x08,
745 .xtal_freq = TDA10046_XTAL_16M,
746 .agc_config = TDA10046_AGC_TDA827X,
747 .gpio_config = TDA10046_GP01_I,
748 .if_freq = TDA10046_FREQ_045,
750 .tuner_address = 0x60,
751 .request_firmware = philips_tda1004x_request_firmware
754 static struct tda1004x_config asus_p7131_4871_config = {
755 .demod_address = 0x08,
758 .xtal_freq = TDA10046_XTAL_16M,
759 .agc_config = TDA10046_AGC_TDA827X,
760 .gpio_config = TDA10046_GP01_I,
761 .if_freq = TDA10046_FREQ_045,
763 .tuner_address = 0x61,
765 .request_firmware = philips_tda1004x_request_firmware
768 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
769 .demod_address = 0x08,
772 .xtal_freq = TDA10046_XTAL_16M,
773 .agc_config = TDA10046_AGC_TDA827X,
774 .gpio_config = TDA10046_GP11_I,
775 .if_freq = TDA10046_FREQ_045,
777 .tuner_address = 0x61,
779 .request_firmware = philips_tda1004x_request_firmware
782 static struct tda1004x_config kworld_dvb_t_210_config = {
783 .demod_address = 0x08,
786 .xtal_freq = TDA10046_XTAL_16M,
787 .agc_config = TDA10046_AGC_TDA827X,
788 .gpio_config = TDA10046_GP11_I,
789 .if_freq = TDA10046_FREQ_045,
791 .tuner_address = 0x61,
793 .request_firmware = philips_tda1004x_request_firmware
796 static struct tda1004x_config avermedia_super_007_config = {
797 .demod_address = 0x08,
800 .xtal_freq = TDA10046_XTAL_16M,
801 .agc_config = TDA10046_AGC_TDA827X,
802 .gpio_config = TDA10046_GP01_I,
803 .if_freq = TDA10046_FREQ_045,
805 .tuner_address = 0x60,
807 .request_firmware = philips_tda1004x_request_firmware
810 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
811 .demod_address = 0x08,
814 .xtal_freq = TDA10046_XTAL_16M,
815 .agc_config = TDA10046_AGC_TDA827X,
816 .gpio_config = TDA10046_GP01_I,
817 .if_freq = TDA10046_FREQ_045,
819 .tuner_address = 0x61,
821 .request_firmware = philips_tda1004x_request_firmware
824 static struct tda1004x_config asus_tiger_3in1_config = {
825 .demod_address = 0x0b,
828 .xtal_freq = TDA10046_XTAL_16M,
829 .agc_config = TDA10046_AGC_TDA827X,
830 .gpio_config = TDA10046_GP11_I,
831 .if_freq = TDA10046_FREQ_045,
833 .tuner_address = 0x61,
835 .request_firmware = philips_tda1004x_request_firmware
838 /* ------------------------------------------------------------------
839 * special case: this card uses saa713x GPIO22 for the mode switch
842 static int ads_duo_tuner_init(struct dvb_frontend *fe)
844 struct saa7134_dev *dev = fe->dvb->priv;
845 philips_tda827x_tuner_init(fe);
846 /* route TDA8275a AGC input to the channel decoder */
847 saa7134_set_gpio(dev, 22, 1);
851 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
853 struct saa7134_dev *dev = fe->dvb->priv;
854 /* route TDA8275a AGC input to the analog IF chip*/
855 saa7134_set_gpio(dev, 22, 0);
856 philips_tda827x_tuner_sleep(fe);
860 static struct tda827x_config ads_duo_cfg = {
861 .init = ads_duo_tuner_init,
862 .sleep = ads_duo_tuner_sleep,
866 static struct tda1004x_config ads_tech_duo_config = {
867 .demod_address = 0x08,
870 .xtal_freq = TDA10046_XTAL_16M,
871 .agc_config = TDA10046_AGC_TDA827X,
872 .gpio_config = TDA10046_GP00_I,
873 .if_freq = TDA10046_FREQ_045,
874 .tuner_address = 0x61,
875 .request_firmware = philips_tda1004x_request_firmware
878 static struct zl10353_config behold_h6_config = {
879 .demod_address = 0x1e>>1,
882 .disable_i2c_gate_ctrl = 1,
885 static struct xc5000_config behold_x7_tunerconfig = {
886 .i2c_address = 0xc2>>1,
888 .radio_input = XC5000_RADIO_FM1,
891 static struct zl10353_config behold_x7_config = {
892 .demod_address = 0x1e>>1,
896 .disable_i2c_gate_ctrl = 1,
899 /* ==================================================================
900 * tda10086 based DVB-S cards, helper functions
903 static struct tda10086_config flydvbs = {
904 .demod_address = 0x0e,
907 .xtal_freq = TDA10086_XTAL_16M,
910 static struct tda10086_config sd1878_4m = {
911 .demod_address = 0x0e,
914 .xtal_freq = TDA10086_XTAL_4M,
917 /* ------------------------------------------------------------------
918 * special case: lnb supply is connected to the gated i2c
921 static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
924 struct saa7134_dev *dev = fe->dvb->priv;
925 if (fe->ops.i2c_gate_ctrl) {
926 fe->ops.i2c_gate_ctrl(fe, 1);
927 if (dev->original_set_voltage)
928 res = dev->original_set_voltage(fe, voltage);
929 fe->ops.i2c_gate_ctrl(fe, 0);
934 static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
937 struct saa7134_dev *dev = fe->dvb->priv;
938 if (fe->ops.i2c_gate_ctrl) {
939 fe->ops.i2c_gate_ctrl(fe, 1);
940 if (dev->original_set_high_voltage)
941 res = dev->original_set_high_voltage(fe, arg);
942 fe->ops.i2c_gate_ctrl(fe, 0);
947 static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
949 struct saa7134_dev *dev = fe->dvb->priv;
950 u8 wbuf[2] = { 0x1f, 00 };
952 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
953 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
955 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
957 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
958 if (voltage == SEC_VOLTAGE_18)
959 wbuf[1] = rbuf | 0x10;
961 wbuf[1] = rbuf & 0xef;
963 i2c_transfer(&dev->i2c_adap, msg, 1);
967 static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
969 struct saa7134_dev *dev = fe->dvb->priv;
970 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
974 /* ==================================================================
975 * nxt200x based ATSC cards, helper functions
978 static struct nxt200x_config avertvhda180 = {
979 .demod_address = 0x0a,
982 static struct nxt200x_config kworldatsc110 = {
983 .demod_address = 0x0a,
986 /* ------------------------------------------------------------------ */
988 static struct mt312_config avertv_a700_mt312 = {
989 .demod_address = 0x0e,
990 .voltage_inverted = 1,
993 static struct zl10036_config avertv_a700_tuner = {
994 .tuner_address = 0x60,
997 static struct mt312_config zl10313_compro_s350_config = {
998 .demod_address = 0x0e,
1001 static struct lgdt3305_config hcw_lgdt3305_config = {
1003 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1004 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1005 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1007 .spectral_inversion = 1,
1012 static struct tda10048_config hcw_tda10048_config = {
1013 .demod_address = 0x10 >> 1,
1014 .output_mode = TDA10048_SERIAL_OUTPUT,
1015 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1016 .inversion = TDA10048_INVERSION_ON,
1017 .dtv6_if_freq_khz = TDA10048_IF_3300,
1018 .dtv7_if_freq_khz = TDA10048_IF_3500,
1019 .dtv8_if_freq_khz = TDA10048_IF_4000,
1020 .clk_freq_khz = TDA10048_CLK_16000,
1021 .disable_gate_access = 1,
1024 static struct tda18271_std_map hauppauge_tda18271_std_map = {
1025 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1026 .if_lvl = 1, .rfagc_top = 0x58, },
1027 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1028 .if_lvl = 1, .rfagc_top = 0x58, },
1031 static struct tda18271_config hcw_tda18271_config = {
1032 .std_map = &hauppauge_tda18271_std_map,
1033 .gate = TDA18271_GATE_ANALOG,
1035 .output_opt = TDA18271_OUTPUT_LT_OFF,
1038 static struct tda829x_config tda829x_no_probe = {
1039 .probe_tuner = TDA829X_DONT_PROBE,
1042 static struct tda10048_config zolid_tda10048_config = {
1043 .demod_address = 0x10 >> 1,
1044 .output_mode = TDA10048_PARALLEL_OUTPUT,
1045 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1046 .inversion = TDA10048_INVERSION_ON,
1047 .dtv6_if_freq_khz = TDA10048_IF_3300,
1048 .dtv7_if_freq_khz = TDA10048_IF_3500,
1049 .dtv8_if_freq_khz = TDA10048_IF_4000,
1050 .clk_freq_khz = TDA10048_CLK_16000,
1051 .disable_gate_access = 1,
1054 static struct tda18271_config zolid_tda18271_config = {
1055 .gate = TDA18271_GATE_ANALOG,
1058 static struct tda10048_config dtv1000s_tda10048_config = {
1059 .demod_address = 0x10 >> 1,
1060 .output_mode = TDA10048_PARALLEL_OUTPUT,
1061 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1062 .inversion = TDA10048_INVERSION_ON,
1063 .dtv6_if_freq_khz = TDA10048_IF_3300,
1064 .dtv7_if_freq_khz = TDA10048_IF_3800,
1065 .dtv8_if_freq_khz = TDA10048_IF_4300,
1066 .clk_freq_khz = TDA10048_CLK_16000,
1067 .disable_gate_access = 1,
1070 static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1071 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1072 .if_lvl = 1, .rfagc_top = 0x37, },
1073 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1074 .if_lvl = 1, .rfagc_top = 0x37, },
1075 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1076 .if_lvl = 1, .rfagc_top = 0x37, },
1079 static struct tda18271_config dtv1000s_tda18271_config = {
1080 .std_map = &dtv1000s_tda18271_std_map,
1081 .gate = TDA18271_GATE_ANALOG,
1084 /* ==================================================================
1088 static int dvb_init(struct saa7134_dev *dev)
1091 int attach_xc3028 = 0;
1092 struct videobuf_dvb_frontend *fe0;
1094 /* FIXME: add support for multi-frontend */
1095 mutex_init(&dev->frontends.lock);
1096 INIT_LIST_HEAD(&dev->frontends.felist);
1098 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
1099 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1101 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1105 /* init struct videobuf_dvb */
1106 dev->ts.nr_bufs = 32;
1107 dev->ts.nr_packets = 32*4;
1108 fe0->dvb.name = dev->name;
1109 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
1110 &dev->pci->dev, &dev->slock,
1111 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1112 V4L2_FIELD_ALTERNATE,
1113 sizeof(struct saa7134_buf),
1116 switch (dev->board) {
1117 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1118 dprintk("pinnacle 300i dvb setup\n");
1119 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1121 if (fe0->dvb.frontend) {
1122 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1125 case SAA7134_BOARD_AVERMEDIA_777:
1126 case SAA7134_BOARD_AVERMEDIA_A16AR:
1127 dprintk("avertv 777 dvb setup\n");
1128 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1130 if (fe0->dvb.frontend) {
1131 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1132 &dev->i2c_adap, 0x61,
1133 TUNER_PHILIPS_TD1316);
1136 case SAA7134_BOARD_AVERMEDIA_A16D:
1137 dprintk("AverMedia A16D dvb setup\n");
1138 fe0->dvb.frontend = dvb_attach(mt352_attach,
1139 &avermedia_xc3028_mt352_dev,
1143 case SAA7134_BOARD_MD7134:
1144 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1147 if (fe0->dvb.frontend) {
1148 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1149 &dev->i2c_adap, medion_cardbus.tuner_address,
1150 TUNER_PHILIPS_FMD1216ME_MK3);
1153 case SAA7134_BOARD_PHILIPS_TOUGH:
1154 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1155 &philips_tu1216_60_config,
1157 if (fe0->dvb.frontend) {
1158 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1159 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1162 case SAA7134_BOARD_FLYDVBTDUO:
1163 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1164 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1165 &tda827x_cfg_0) < 0)
1166 goto dettach_frontend;
1168 case SAA7134_BOARD_PHILIPS_EUROPA:
1169 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1170 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
1171 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1172 &philips_europa_config,
1174 if (fe0->dvb.frontend) {
1175 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1176 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1177 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1178 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1179 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1182 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1183 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1184 &technotrend_budget_t3000_config,
1186 if (fe0->dvb.frontend) {
1187 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1188 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1189 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1190 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1191 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1194 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1195 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1196 &philips_tu1216_61_config,
1198 if (fe0->dvb.frontend) {
1199 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1200 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1203 case SAA7134_BOARD_KWORLD_DVBT_210:
1204 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1205 &tda827x_cfg_2) < 0)
1206 goto dettach_frontend;
1208 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1209 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1210 &hcw_tda10048_config,
1212 if (fe0->dvb.frontend != NULL) {
1213 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1214 &dev->i2c_adap, 0x4b,
1216 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1217 0x60, &dev->i2c_adap,
1218 &hcw_tda18271_config);
1221 case SAA7134_BOARD_PHILIPS_TIGER:
1222 if (configure_tda827x_fe(dev, &philips_tiger_config,
1223 &tda827x_cfg_0) < 0)
1224 goto dettach_frontend;
1226 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1227 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1228 &tda827x_cfg_1) < 0)
1229 goto dettach_frontend;
1231 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1232 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1233 &tda827x_cfg_1) < 0)
1234 goto dettach_frontend;
1236 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
1237 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1238 &hcw_lgdt3305_config,
1240 if (fe0->dvb.frontend) {
1241 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1242 &dev->i2c_adap, 0x4b,
1244 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1245 0x60, &dev->i2c_adap,
1246 &hcw_tda18271_config);
1249 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1250 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1251 &tda827x_cfg_0) < 0)
1252 goto dettach_frontend;
1254 case SAA7134_BOARD_FLYDVBT_LR301:
1255 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1256 &tda827x_cfg_0) < 0)
1257 goto dettach_frontend;
1259 case SAA7134_BOARD_FLYDVB_TRIO:
1260 if (!use_frontend) { /* terrestrial */
1261 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1262 &tda827x_cfg_0) < 0)
1263 goto dettach_frontend;
1264 } else { /* satellite */
1265 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1266 if (fe0->dvb.frontend) {
1267 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1268 &dev->i2c_adap, 0) == NULL) {
1269 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1270 goto dettach_frontend;
1272 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1273 0x08, 0, 0) == NULL) {
1274 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1275 goto dettach_frontend;
1280 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1281 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1282 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1283 &ads_tech_duo_config,
1285 if (fe0->dvb.frontend) {
1286 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1287 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1288 &ads_duo_cfg) == NULL) {
1289 wprintk("no tda827x tuner found at addr: %02x\n",
1290 ads_tech_duo_config.tuner_address);
1291 goto dettach_frontend;
1294 wprintk("failed to attach tda10046\n");
1296 case SAA7134_BOARD_TEVION_DVBT_220RF:
1297 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1298 &tda827x_cfg_0) < 0)
1299 goto dettach_frontend;
1301 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1302 if (!use_frontend) { /* terrestrial */
1303 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1304 &tda827x_cfg_0) < 0)
1305 goto dettach_frontend;
1306 } else { /* satellite */
1307 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1308 &flydvbs, &dev->i2c_adap);
1309 if (fe0->dvb.frontend) {
1310 struct dvb_frontend *fe = fe0->dvb.frontend;
1311 u8 dev_id = dev->eedata[2];
1313 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1315 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1316 0x60, &dev->i2c_adap, 0) == NULL) {
1317 wprintk("%s: Medion Quadro, no tda826x "
1318 "found !\n", __func__);
1319 goto dettach_frontend;
1321 if (dev_id != 0x08) {
1322 /* we need to open the i2c gate (we know it exists) */
1323 fe->ops.i2c_gate_ctrl(fe, 1);
1324 if (dvb_attach(isl6405_attach, fe,
1325 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1326 wprintk("%s: Medion Quadro, no ISL6405 "
1327 "found !\n", __func__);
1328 goto dettach_frontend;
1330 if (dev_id == 0x07) {
1331 /* fire up the 2nd section of the LNB supply since
1332 we can't do this from the other section */
1334 i2c_transfer(&dev->i2c_adap, &msg, 1);
1336 fe->ops.i2c_gate_ctrl(fe, 0);
1337 dev->original_set_voltage = fe->ops.set_voltage;
1338 fe->ops.set_voltage = md8800_set_voltage;
1339 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1340 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1342 fe->ops.set_voltage = md8800_set_voltage2;
1343 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1348 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1349 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1351 if (fe0->dvb.frontend)
1352 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1353 NULL, DVB_PLL_TDHU2);
1355 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1356 case SAA7134_BOARD_KWORLD_ATSC110:
1357 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1359 if (fe0->dvb.frontend)
1360 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1361 &dev->i2c_adap, 0x61,
1362 TUNER_PHILIPS_TUV1236D);
1364 case SAA7134_BOARD_FLYDVBS_LR300:
1365 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1367 if (fe0->dvb.frontend) {
1368 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1369 &dev->i2c_adap, 0) == NULL) {
1370 wprintk("%s: No tda826x found!\n", __func__);
1371 goto dettach_frontend;
1373 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1374 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1375 wprintk("%s: No ISL6421 found!\n", __func__);
1376 goto dettach_frontend;
1380 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1381 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1384 if (fe0->dvb.frontend) {
1385 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1386 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1388 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1389 &dev->i2c_adap, medion_cardbus.tuner_address,
1390 TUNER_PHILIPS_FMD1216ME_MK3);
1393 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1394 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1395 &philips_europa_config,
1397 if (fe0->dvb.frontend) {
1398 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1399 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1402 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1403 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1404 &tda827x_cfg_0) < 0)
1405 goto dettach_frontend;
1407 case SAA7134_BOARD_CINERGY_HT_PCI:
1408 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1409 &tda827x_cfg_0) < 0)
1410 goto dettach_frontend;
1412 case SAA7134_BOARD_PHILIPS_TIGER_S:
1413 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1414 &tda827x_cfg_2) < 0)
1415 goto dettach_frontend;
1417 case SAA7134_BOARD_ASUS_P7131_4871:
1418 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1419 &tda827x_cfg_2) < 0)
1420 goto dettach_frontend;
1422 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1423 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1424 &tda827x_cfg_2) < 0)
1425 goto dettach_frontend;
1427 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1428 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1429 &tda827x_cfg_0) < 0)
1430 goto dettach_frontend;
1432 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1433 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1434 &tda827x_cfg_2_sw42) < 0)
1435 goto dettach_frontend;
1437 case SAA7134_BOARD_PHILIPS_SNAKE:
1438 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1440 if (fe0->dvb.frontend) {
1441 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1442 &dev->i2c_adap, 0) == NULL) {
1443 wprintk("%s: No tda826x found!\n", __func__);
1444 goto dettach_frontend;
1446 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1447 &dev->i2c_adap, 0, 0) == NULL) {
1448 wprintk("%s: No lnbp21 found!\n", __func__);
1449 goto dettach_frontend;
1453 case SAA7134_BOARD_CREATIX_CTX953:
1454 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1455 &tda827x_cfg_0) < 0)
1456 goto dettach_frontend;
1458 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1459 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1460 &tda827x_cfg_2) < 0)
1461 goto dettach_frontend;
1463 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1464 dprintk("AverMedia E506R dvb setup\n");
1465 saa7134_set_gpio(dev, 25, 0);
1467 saa7134_set_gpio(dev, 25, 1);
1468 fe0->dvb.frontend = dvb_attach(mt352_attach,
1469 &avermedia_xc3028_mt352_dev,
1473 case SAA7134_BOARD_MD7134_BRIDGE_2:
1474 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1475 &sd1878_4m, &dev->i2c_adap);
1476 if (fe0->dvb.frontend) {
1477 struct dvb_frontend *fe;
1478 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1479 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1480 wprintk("%s: MD7134 DVB-S, no SD1878 "
1481 "found !\n", __func__);
1482 goto dettach_frontend;
1484 /* we need to open the i2c gate (we know it exists) */
1485 fe = fe0->dvb.frontend;
1486 fe->ops.i2c_gate_ctrl(fe, 1);
1487 if (dvb_attach(isl6405_attach, fe,
1488 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1489 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1490 "found !\n", __func__);
1491 goto dettach_frontend;
1493 fe->ops.i2c_gate_ctrl(fe, 0);
1494 dev->original_set_voltage = fe->ops.set_voltage;
1495 fe->ops.set_voltage = md8800_set_voltage;
1496 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1497 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1500 case SAA7134_BOARD_AVERMEDIA_M103:
1501 saa7134_set_gpio(dev, 25, 0);
1503 saa7134_set_gpio(dev, 25, 1);
1504 fe0->dvb.frontend = dvb_attach(mt352_attach,
1505 &avermedia_xc3028_mt352_dev,
1509 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1510 if (!use_frontend) { /* terrestrial */
1511 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1512 &tda827x_cfg_2) < 0)
1513 goto dettach_frontend;
1514 } else { /* satellite */
1515 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1516 &flydvbs, &dev->i2c_adap);
1517 if (fe0->dvb.frontend) {
1518 if (dvb_attach(tda826x_attach,
1519 fe0->dvb.frontend, 0x60,
1520 &dev->i2c_adap, 0) == NULL) {
1521 wprintk("%s: Asus Tiger 3in1, no "
1522 "tda826x found!\n", __func__);
1523 goto dettach_frontend;
1525 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1526 &dev->i2c_adap, 0, 0) == NULL) {
1527 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1528 " found!\n", __func__);
1529 goto dettach_frontend;
1534 case SAA7134_BOARD_ASUSTeK_TIGER:
1535 if (configure_tda827x_fe(dev, &philips_tiger_config,
1536 &tda827x_cfg_0) < 0)
1537 goto dettach_frontend;
1539 case SAA7134_BOARD_BEHOLD_H6:
1540 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1543 if (fe0->dvb.frontend) {
1544 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1545 &dev->i2c_adap, 0x61,
1546 TUNER_PHILIPS_FMD1216MEX_MK3);
1549 case SAA7134_BOARD_BEHOLD_X7:
1550 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1553 if (fe0->dvb.frontend) {
1554 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1555 &dev->i2c_adap, &behold_x7_tunerconfig);
1558 case SAA7134_BOARD_BEHOLD_H7:
1559 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1562 if (fe0->dvb.frontend) {
1563 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1564 &dev->i2c_adap, &behold_x7_tunerconfig);
1567 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1568 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1569 /* Zarlink ZL10313 */
1570 fe0->dvb.frontend = dvb_attach(mt312_attach,
1571 &avertv_a700_mt312, &dev->i2c_adap);
1572 if (fe0->dvb.frontend) {
1573 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1574 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1575 wprintk("%s: No zl10036 found!\n",
1580 case SAA7134_BOARD_VIDEOMATE_S350:
1581 fe0->dvb.frontend = dvb_attach(mt312_attach,
1582 &zl10313_compro_s350_config, &dev->i2c_adap);
1583 if (fe0->dvb.frontend)
1584 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1585 0x60, &dev->i2c_adap) == NULL)
1586 wprintk("%s: No zl10039 found!\n",
1590 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1591 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1592 &zolid_tda10048_config,
1594 if (fe0->dvb.frontend != NULL) {
1595 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1596 &dev->i2c_adap, 0x4b,
1598 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1599 0x60, &dev->i2c_adap,
1600 &zolid_tda18271_config);
1603 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1604 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1605 &dtv1000s_tda10048_config,
1607 if (fe0->dvb.frontend != NULL) {
1608 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1609 &dev->i2c_adap, 0x4b,
1611 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1612 0x60, &dev->i2c_adap,
1613 &dtv1000s_tda18271_config);
1617 wprintk("Huh? unknown DVB card?\n");
1621 if (attach_xc3028) {
1622 struct dvb_frontend *fe;
1623 struct xc2028_config cfg = {
1624 .i2c_adap = &dev->i2c_adap,
1628 if (!fe0->dvb.frontend)
1629 goto dettach_frontend;
1631 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1633 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1635 goto dettach_frontend;
1639 if (NULL == fe0->dvb.frontend) {
1640 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1641 goto dettach_frontend;
1643 /* define general-purpose callback pointer */
1644 fe0->dvb.frontend->callback = saa7134_tuner_callback;
1646 /* register everything else */
1647 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1648 &dev->pci->dev, adapter_nr, 0, NULL);
1650 /* this sequence is necessary to make the tda1004x load its firmware
1651 * and to enter analog mode of hybrid boards
1654 if (fe0->dvb.frontend->ops.init)
1655 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1656 if (fe0->dvb.frontend->ops.sleep)
1657 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1658 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1659 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1664 videobuf_dvb_dealloc_frontends(&dev->frontends);
1668 static int dvb_fini(struct saa7134_dev *dev)
1670 struct videobuf_dvb_frontend *fe0;
1672 /* Get the first frontend */
1673 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1677 /* FIXME: I suspect that this code is bogus, since the entry for
1678 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1679 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1681 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1682 struct v4l2_priv_tun_config tda9887_cfg;
1683 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1685 tda9887_cfg.tuner = TUNER_TDA9887;
1686 tda9887_cfg.priv = &on;
1688 /* otherwise we don't detect the tuner on next insmod */
1689 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1690 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1691 if ((dev->eedata[2] == 0x07) && use_frontend) {
1692 /* turn off the 2nd lnb supply */
1694 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1695 struct dvb_frontend *fe;
1696 fe = fe0->dvb.frontend;
1697 if (fe->ops.i2c_gate_ctrl) {
1698 fe->ops.i2c_gate_ctrl(fe, 1);
1699 i2c_transfer(&dev->i2c_adap, &msg, 1);
1700 fe->ops.i2c_gate_ctrl(fe, 0);
1704 videobuf_dvb_unregister_bus(&dev->frontends);
1708 static struct saa7134_mpeg_ops dvb_ops = {
1709 .type = SAA7134_MPEG_DVB,
1714 static int __init dvb_register(void)
1716 return saa7134_ts_register(&dvb_ops);
1719 static void __exit dvb_unregister(void)
1721 saa7134_ts_unregister(&dvb_ops);
1724 module_init(dvb_register);
1725 module_exit(dvb_unregister);
1727 /* ------------------------------------------------------------------ */