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>
38 #include "mt352_priv.h" /* FIXME */
48 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
49 MODULE_LICENSE("GPL");
51 static unsigned int antenna_pwr;
53 module_param(antenna_pwr, int, 0444);
54 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
56 static int use_frontend;
57 module_param(use_frontend, int, 0644);
58 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
61 module_param(debug, int, 0644);
62 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
64 #define dprintk(fmt, arg...) do { if (debug) \
65 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
68 #define wprintk(fmt, arg...) \
69 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
71 /* ------------------------------------------------------------------
72 * mt352 based DVB-T cards
75 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
80 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
81 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
85 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
86 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
89 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
90 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
92 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
94 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
95 dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
98 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
102 static int mt352_pinnacle_init(struct dvb_frontend* fe)
104 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
105 static u8 reset [] = { RESET, 0x80 };
106 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
107 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
108 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
109 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
110 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
111 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
112 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
113 struct saa7134_dev *dev= fe->dvb->priv;
115 dprintk("%s called\n", __FUNCTION__);
117 mt352_write(fe, clock_config, sizeof(clock_config));
119 mt352_write(fe, reset, sizeof(reset));
120 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
121 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
122 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
123 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
125 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
126 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
127 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
132 static int mt352_aver777_init(struct dvb_frontend* fe)
134 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
135 static u8 reset [] = { RESET, 0x80 };
136 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
137 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
138 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
140 mt352_write(fe, clock_config, sizeof(clock_config));
142 mt352_write(fe, reset, sizeof(reset));
143 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
144 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
145 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
150 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
151 struct dvb_frontend_parameters* params)
153 u8 off[] = { 0x00, 0xf1};
154 u8 on[] = { 0x00, 0x71};
155 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
157 struct saa7134_dev *dev = fe->dvb->priv;
158 struct v4l2_frequency f;
160 /* set frequency (mt2050) */
162 f.type = V4L2_TUNER_DIGITAL_TV;
163 f.frequency = params->frequency / 1000 * 16 / 1000;
164 if (fe->ops.i2c_gate_ctrl)
165 fe->ops.i2c_gate_ctrl(fe, 1);
166 i2c_transfer(&dev->i2c_adap, &msg, 1);
167 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
169 if (fe->ops.i2c_gate_ctrl)
170 fe->ops.i2c_gate_ctrl(fe, 1);
171 i2c_transfer(&dev->i2c_adap, &msg, 1);
173 pinnacle_antenna_pwr(dev, antenna_pwr);
176 return mt352_pinnacle_init(fe);
179 static struct mt352_config pinnacle_300i = {
180 .demod_address = 0x3c >> 1,
184 .demod_init = mt352_pinnacle_init,
187 static struct mt352_config avermedia_777 = {
188 .demod_address = 0xf,
189 .demod_init = mt352_aver777_init,
192 /* ==================================================================
193 * tda1004x based DVB-T cards, helper functions
196 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
197 const struct firmware **fw, char *name)
199 struct saa7134_dev *dev = fe->dvb->priv;
200 return request_firmware(fw, name, &dev->pci->dev);
203 /* ------------------------------------------------------------------
204 * these tuners are tu1216, td1316(a)
207 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
209 struct saa7134_dev *dev = fe->dvb->priv;
210 struct tda1004x_state *state = fe->demodulator_priv;
211 u8 addr = state->config->tuner_address;
213 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
215 int tuner_frequency = 0;
218 /* determine charge pump */
219 tuner_frequency = params->frequency + 36166000;
220 if (tuner_frequency < 87000000)
222 else if (tuner_frequency < 130000000)
224 else if (tuner_frequency < 160000000)
226 else if (tuner_frequency < 200000000)
228 else if (tuner_frequency < 290000000)
230 else if (tuner_frequency < 420000000)
232 else if (tuner_frequency < 480000000)
234 else if (tuner_frequency < 620000000)
236 else if (tuner_frequency < 830000000)
238 else if (tuner_frequency < 895000000)
244 if (params->frequency < 49000000)
246 else if (params->frequency < 161000000)
248 else if (params->frequency < 444000000)
250 else if (params->frequency < 861000000)
255 /* setup PLL filter */
256 switch (params->u.ofdm.bandwidth) {
257 case BANDWIDTH_6_MHZ:
261 case BANDWIDTH_7_MHZ:
265 case BANDWIDTH_8_MHZ:
274 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
276 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
278 /* setup tuner buffer */
279 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
280 tuner_buf[1] = tuner_frequency & 0xff;
282 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
284 if (fe->ops.i2c_gate_ctrl)
285 fe->ops.i2c_gate_ctrl(fe, 1);
286 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
287 wprintk("could not write to tuner at addr: 0x%02x\n",
295 static int philips_tu1216_init(struct dvb_frontend *fe)
297 struct saa7134_dev *dev = fe->dvb->priv;
298 struct tda1004x_state *state = fe->demodulator_priv;
299 u8 addr = state->config->tuner_address;
300 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
301 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
303 /* setup PLL configuration */
304 if (fe->ops.i2c_gate_ctrl)
305 fe->ops.i2c_gate_ctrl(fe, 1);
306 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
313 /* ------------------------------------------------------------------ */
315 static struct tda1004x_config philips_tu1216_60_config = {
316 .demod_address = 0x8,
319 .xtal_freq = TDA10046_XTAL_4M,
320 .agc_config = TDA10046_AGC_DEFAULT,
321 .if_freq = TDA10046_FREQ_3617,
322 .tuner_address = 0x60,
323 .request_firmware = philips_tda1004x_request_firmware
326 static struct tda1004x_config philips_tu1216_61_config = {
328 .demod_address = 0x8,
331 .xtal_freq = TDA10046_XTAL_4M,
332 .agc_config = TDA10046_AGC_DEFAULT,
333 .if_freq = TDA10046_FREQ_3617,
334 .tuner_address = 0x61,
335 .request_firmware = philips_tda1004x_request_firmware
338 /* ------------------------------------------------------------------ */
340 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
342 struct saa7134_dev *dev = fe->dvb->priv;
343 struct tda1004x_state *state = fe->demodulator_priv;
344 u8 addr = state->config->tuner_address;
345 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
346 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
348 /* setup PLL configuration */
349 if (fe->ops.i2c_gate_ctrl)
350 fe->ops.i2c_gate_ctrl(fe, 1);
351 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
356 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
358 return philips_tda6651_pll_set(fe, params);
361 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
363 struct saa7134_dev *dev = fe->dvb->priv;
364 struct tda1004x_state *state = fe->demodulator_priv;
365 u8 addr = state->config->tuner_address;
366 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
367 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
369 /* switch the tuner to analog mode */
370 if (fe->ops.i2c_gate_ctrl)
371 fe->ops.i2c_gate_ctrl(fe, 1);
372 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
377 /* ------------------------------------------------------------------ */
379 static int philips_europa_tuner_init(struct dvb_frontend *fe)
381 struct saa7134_dev *dev = fe->dvb->priv;
382 static u8 msg[] = { 0x00, 0x40};
383 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
386 if (philips_td1316_tuner_init(fe))
389 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
395 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
397 struct saa7134_dev *dev = fe->dvb->priv;
399 static u8 msg[] = { 0x00, 0x14 };
400 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
402 if (philips_td1316_tuner_sleep(fe))
405 /* switch the board to analog mode */
406 if (fe->ops.i2c_gate_ctrl)
407 fe->ops.i2c_gate_ctrl(fe, 1);
408 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
412 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
414 struct saa7134_dev *dev = fe->dvb->priv;
416 if (dev->original_demod_sleep)
417 dev->original_demod_sleep(fe);
418 fe->ops.i2c_gate_ctrl(fe, 1);
422 static struct tda1004x_config philips_europa_config = {
424 .demod_address = 0x8,
427 .xtal_freq = TDA10046_XTAL_4M,
428 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
429 .if_freq = TDA10046_FREQ_052,
430 .tuner_address = 0x61,
431 .request_firmware = philips_tda1004x_request_firmware
434 /* ------------------------------------------------------------------ */
436 static struct tda1004x_config medion_cardbus = {
437 .demod_address = 0x08,
440 .xtal_freq = TDA10046_XTAL_16M,
441 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
442 .if_freq = TDA10046_FREQ_3613,
443 .tuner_address = 0x61,
444 .request_firmware = philips_tda1004x_request_firmware
447 /* ------------------------------------------------------------------
448 * tda 1004x based cards with philips silicon tuner
451 static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
453 struct saa7134_dev *dev = fe->dvb->priv;
454 struct tda1004x_state *state = fe->demodulator_priv;
455 u8 addr = state->config->i2c_gate;
456 u8 config = state->config->tuner_config;
457 u8 GP00_CF[] = {0x20, 0x01};
458 u8 GP00_LEV[] = {0x22, 0x00};
460 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
463 dprintk("setting LNA to high gain\n");
465 dprintk("setting LNA to low gain\n");
471 case 1: /* switch is GPIO 0 of tda8290 */
474 saa7134_set_gpio(dev, 22, 0);
475 GP00_LEV[1] = high ? 0 : 1;
476 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
477 wprintk("could not access tda8290 at addr: 0x%02x\n",
483 GP00_LEV[1] = high ? 1 : 0;
484 i2c_transfer(&dev->i2c_adap, &msg, 1);
486 case 3: /* switch with GPIO of saa713x */
487 saa7134_set_gpio(dev, 22, high);
492 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
494 struct tda1004x_state *state = fe->demodulator_priv;
496 u8 addr = state->config->i2c_gate;
497 static u8 tda8290_close[] = { 0x21, 0xc0};
498 static u8 tda8290_open[] = { 0x21, 0x80};
499 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
501 tda8290_msg.buf = tda8290_close;
503 tda8290_msg.buf = tda8290_open;
505 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
506 struct saa7134_dev *dev = fe->dvb->priv;
507 wprintk("could not access tda8290 I2C gate\n");
514 /* ------------------------------------------------------------------ */
516 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
518 struct saa7134_dev *dev = fe->dvb->priv;
519 struct tda1004x_state *state = fe->demodulator_priv;
521 switch (state->config->antenna_switch) {
523 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
524 saa7134_set_gpio(dev, 21, 0);
526 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
527 saa7134_set_gpio(dev, 21, 1);
533 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
535 struct saa7134_dev *dev = fe->dvb->priv;
536 struct tda1004x_state *state = fe->demodulator_priv;
538 switch (state->config->antenna_switch) {
540 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
541 saa7134_set_gpio(dev, 21, 1);
543 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
544 saa7134_set_gpio(dev, 21, 0);
550 static struct tda827x_config tda827x_cfg = {
551 .lna_gain = philips_tda827x_lna_gain,
552 .init = philips_tda827x_tuner_init,
553 .sleep = philips_tda827x_tuner_sleep
556 static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
558 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
559 if (dev->dvb.frontend) {
560 if (tda_conf->i2c_gate)
561 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
562 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
563 &dev->i2c_adap,&tda827x_cfg) == NULL) {
564 wprintk("no tda827x tuner found at addr: %02x\n",
565 tda_conf->tuner_address);
570 /* ------------------------------------------------------------------ */
572 static struct tda1004x_config tda827x_lifeview_config = {
573 .demod_address = 0x08,
576 .xtal_freq = TDA10046_XTAL_16M,
577 .agc_config = TDA10046_AGC_TDA827X,
578 .gpio_config = TDA10046_GP11_I,
579 .if_freq = TDA10046_FREQ_045,
580 .tuner_address = 0x60,
581 .request_firmware = philips_tda1004x_request_firmware
584 static struct tda1004x_config philips_tiger_config = {
585 .demod_address = 0x08,
588 .xtal_freq = TDA10046_XTAL_16M,
589 .agc_config = TDA10046_AGC_TDA827X,
590 .gpio_config = TDA10046_GP11_I,
591 .if_freq = TDA10046_FREQ_045,
593 .tuner_address = 0x61,
596 .request_firmware = philips_tda1004x_request_firmware
599 static struct tda1004x_config cinergy_ht_config = {
600 .demod_address = 0x08,
603 .xtal_freq = TDA10046_XTAL_16M,
604 .agc_config = TDA10046_AGC_TDA827X,
605 .gpio_config = TDA10046_GP01_I,
606 .if_freq = TDA10046_FREQ_045,
608 .tuner_address = 0x61,
610 .request_firmware = philips_tda1004x_request_firmware
613 static struct tda1004x_config cinergy_ht_pci_config = {
614 .demod_address = 0x08,
617 .xtal_freq = TDA10046_XTAL_16M,
618 .agc_config = TDA10046_AGC_TDA827X,
619 .gpio_config = TDA10046_GP01_I,
620 .if_freq = TDA10046_FREQ_045,
622 .tuner_address = 0x60,
624 .request_firmware = philips_tda1004x_request_firmware
627 static struct tda1004x_config philips_tiger_s_config = {
628 .demod_address = 0x08,
631 .xtal_freq = TDA10046_XTAL_16M,
632 .agc_config = TDA10046_AGC_TDA827X,
633 .gpio_config = TDA10046_GP01_I,
634 .if_freq = TDA10046_FREQ_045,
636 .tuner_address = 0x61,
639 .request_firmware = philips_tda1004x_request_firmware
642 static struct tda1004x_config pinnacle_pctv_310i_config = {
643 .demod_address = 0x08,
646 .xtal_freq = TDA10046_XTAL_16M,
647 .agc_config = TDA10046_AGC_TDA827X,
648 .gpio_config = TDA10046_GP11_I,
649 .if_freq = TDA10046_FREQ_045,
651 .tuner_address = 0x61,
653 .request_firmware = philips_tda1004x_request_firmware
656 static struct tda1004x_config hauppauge_hvr_1110_config = {
657 .demod_address = 0x08,
660 .xtal_freq = TDA10046_XTAL_16M,
661 .agc_config = TDA10046_AGC_TDA827X,
662 .gpio_config = TDA10046_GP11_I,
663 .if_freq = TDA10046_FREQ_045,
665 .tuner_address = 0x61,
667 .request_firmware = philips_tda1004x_request_firmware
670 static struct tda1004x_config asus_p7131_dual_config = {
671 .demod_address = 0x08,
674 .xtal_freq = TDA10046_XTAL_16M,
675 .agc_config = TDA10046_AGC_TDA827X,
676 .gpio_config = TDA10046_GP11_I,
677 .if_freq = TDA10046_FREQ_045,
679 .tuner_address = 0x61,
682 .request_firmware = philips_tda1004x_request_firmware
685 static struct tda1004x_config lifeview_trio_config = {
686 .demod_address = 0x09,
689 .xtal_freq = TDA10046_XTAL_16M,
690 .agc_config = TDA10046_AGC_TDA827X,
691 .gpio_config = TDA10046_GP00_I,
692 .if_freq = TDA10046_FREQ_045,
693 .tuner_address = 0x60,
694 .request_firmware = philips_tda1004x_request_firmware
697 static struct tda1004x_config tevion_dvbt220rf_config = {
698 .demod_address = 0x08,
701 .xtal_freq = TDA10046_XTAL_16M,
702 .agc_config = TDA10046_AGC_TDA827X,
703 .gpio_config = TDA10046_GP11_I,
704 .if_freq = TDA10046_FREQ_045,
705 .tuner_address = 0x60,
706 .request_firmware = philips_tda1004x_request_firmware
709 static struct tda1004x_config md8800_dvbt_config = {
710 .demod_address = 0x08,
713 .xtal_freq = TDA10046_XTAL_16M,
714 .agc_config = TDA10046_AGC_TDA827X,
715 .gpio_config = TDA10046_GP01_I,
716 .if_freq = TDA10046_FREQ_045,
718 .tuner_address = 0x60,
720 .request_firmware = philips_tda1004x_request_firmware
723 static struct tda1004x_config asus_p7131_4871_config = {
724 .demod_address = 0x08,
727 .xtal_freq = TDA10046_XTAL_16M,
728 .agc_config = TDA10046_AGC_TDA827X,
729 .gpio_config = TDA10046_GP01_I,
730 .if_freq = TDA10046_FREQ_045,
732 .tuner_address = 0x61,
735 .request_firmware = philips_tda1004x_request_firmware
738 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
739 .demod_address = 0x08,
742 .xtal_freq = TDA10046_XTAL_16M,
743 .agc_config = TDA10046_AGC_TDA827X,
744 .gpio_config = TDA10046_GP11_I,
745 .if_freq = TDA10046_FREQ_045,
747 .tuner_address = 0x61,
750 .request_firmware = philips_tda1004x_request_firmware
753 static struct tda1004x_config kworld_dvb_t_210_config = {
754 .demod_address = 0x08,
757 .xtal_freq = TDA10046_XTAL_16M,
758 .agc_config = TDA10046_AGC_TDA827X,
759 .gpio_config = TDA10046_GP11_I,
760 .if_freq = TDA10046_FREQ_045,
762 .tuner_address = 0x61,
765 .request_firmware = philips_tda1004x_request_firmware
768 static struct tda1004x_config avermedia_super_007_config = {
769 .demod_address = 0x08,
772 .xtal_freq = TDA10046_XTAL_16M,
773 .agc_config = TDA10046_AGC_TDA827X,
774 .gpio_config = TDA10046_GP01_I,
775 .if_freq = TDA10046_FREQ_045,
777 .tuner_address = 0x60,
780 .request_firmware = philips_tda1004x_request_firmware
783 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
784 .demod_address = 0x08,
787 .xtal_freq = TDA10046_XTAL_16M,
788 .agc_config = TDA10046_AGC_TDA827X,
789 .gpio_config = TDA10046_GP01_I,
790 .if_freq = TDA10046_FREQ_045,
792 .tuner_address = 0x61,
795 .request_firmware = philips_tda1004x_request_firmware
798 /* ------------------------------------------------------------------
799 * special case: this card uses saa713x GPIO22 for the mode switch
802 static int ads_duo_tuner_init(struct dvb_frontend *fe)
804 struct saa7134_dev *dev = fe->dvb->priv;
805 philips_tda827x_tuner_init(fe);
806 /* route TDA8275a AGC input to the channel decoder */
807 saa7134_set_gpio(dev, 22, 1);
811 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
813 struct saa7134_dev *dev = fe->dvb->priv;
814 /* route TDA8275a AGC input to the analog IF chip*/
815 saa7134_set_gpio(dev, 22, 0);
816 philips_tda827x_tuner_sleep(fe);
820 static struct tda827x_config ads_duo_cfg = {
821 .lna_gain = philips_tda827x_lna_gain,
822 .init = ads_duo_tuner_init,
823 .sleep = ads_duo_tuner_sleep
826 static struct tda1004x_config ads_tech_duo_config = {
827 .demod_address = 0x08,
830 .xtal_freq = TDA10046_XTAL_16M,
831 .agc_config = TDA10046_AGC_TDA827X,
832 .gpio_config = TDA10046_GP00_I,
833 .if_freq = TDA10046_FREQ_045,
834 .tuner_address = 0x61,
835 .request_firmware = philips_tda1004x_request_firmware
838 /* ==================================================================
839 * tda10086 based DVB-S cards, helper functions
842 static struct tda10086_config flydvbs = {
843 .demod_address = 0x0e,
848 /* ==================================================================
849 * nxt200x based ATSC cards, helper functions
852 static struct nxt200x_config avertvhda180 = {
853 .demod_address = 0x0a,
856 static struct nxt200x_config kworldatsc110 = {
857 .demod_address = 0x0a,
860 /* ==================================================================
864 static int dvb_init(struct saa7134_dev *dev)
867 /* init struct videobuf_dvb */
868 dev->ts.nr_bufs = 32;
869 dev->ts.nr_packets = 32*4;
870 dev->dvb.name = dev->name;
871 videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops,
872 dev->pci, &dev->slock,
873 V4L2_BUF_TYPE_VIDEO_CAPTURE,
874 V4L2_FIELD_ALTERNATE,
875 sizeof(struct saa7134_buf),
878 switch (dev->board) {
879 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
880 dprintk("pinnacle 300i dvb setup\n");
881 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
883 if (dev->dvb.frontend) {
884 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
887 case SAA7134_BOARD_AVERMEDIA_777:
888 case SAA7134_BOARD_AVERMEDIA_A16AR:
889 dprintk("avertv 777 dvb setup\n");
890 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
892 if (dev->dvb.frontend) {
893 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
894 NULL, DVB_PLL_PHILIPS_TD1316);
897 case SAA7134_BOARD_MD7134:
898 dev->dvb.frontend = dvb_attach(tda10046_attach,
901 if (dev->dvb.frontend) {
902 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
903 &dev->i2c_adap, DVB_PLL_FMD1216ME);
906 case SAA7134_BOARD_PHILIPS_TOUGH:
907 dev->dvb.frontend = dvb_attach(tda10046_attach,
908 &philips_tu1216_60_config,
910 if (dev->dvb.frontend) {
911 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
912 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
915 case SAA7134_BOARD_FLYDVBTDUO:
916 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
917 configure_tda827x_fe(dev, &tda827x_lifeview_config);
919 case SAA7134_BOARD_PHILIPS_EUROPA:
920 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
921 dev->dvb.frontend = dvb_attach(tda10046_attach,
922 &philips_europa_config,
924 if (dev->dvb.frontend) {
925 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
926 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
927 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
928 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
929 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
932 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
933 dev->dvb.frontend = dvb_attach(tda10046_attach,
934 &philips_tu1216_61_config,
936 if (dev->dvb.frontend) {
937 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
938 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
941 case SAA7134_BOARD_KWORLD_DVBT_210:
942 configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
944 case SAA7134_BOARD_PHILIPS_TIGER:
945 configure_tda827x_fe(dev, &philips_tiger_config);
947 case SAA7134_BOARD_PINNACLE_PCTV_310i:
948 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
950 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
951 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
953 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
954 configure_tda827x_fe(dev, &asus_p7131_dual_config);
956 case SAA7134_BOARD_FLYDVBT_LR301:
957 configure_tda827x_fe(dev, &tda827x_lifeview_config);
959 case SAA7134_BOARD_FLYDVB_TRIO:
960 if(! use_frontend) { /* terrestrial */
961 configure_tda827x_fe(dev, &lifeview_trio_config);
962 } else { /* satellite */
963 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
964 if (dev->dvb.frontend) {
965 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
966 &dev->i2c_adap, 0) == NULL) {
967 wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
969 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
970 0x08, 0, 0) == NULL) {
971 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
976 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
977 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
978 dev->dvb.frontend = dvb_attach(tda10046_attach,
979 &ads_tech_duo_config,
981 if (dev->dvb.frontend) {
982 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
983 ads_tech_duo_config.tuner_address,
984 &dev->i2c_adap,&ads_duo_cfg) == NULL) {
985 wprintk("no tda827x tuner found at addr: %02x\n",
986 ads_tech_duo_config.tuner_address);
990 case SAA7134_BOARD_TEVION_DVBT_220RF:
991 configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
993 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
994 if (!use_frontend) { /* terrestrial */
995 configure_tda827x_fe(dev, &md8800_dvbt_config);
996 } else { /* satellite */
997 dev->dvb.frontend = dvb_attach(tda10086_attach,
998 &flydvbs, &dev->i2c_adap);
999 if (dev->dvb.frontend) {
1000 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1001 0x60, &dev->i2c_adap, 0) == NULL)
1002 wprintk("%s: Medion Quadro, no tda826x "
1003 "found !\n", __FUNCTION__);
1004 if (dvb_attach(isl6405_attach, dev->dvb.frontend,
1005 &dev->i2c_adap, 0x08, 0, 0) == NULL)
1006 wprintk("%s: Medion Quadro, no ISL6405 "
1007 "found !\n", __FUNCTION__);
1011 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1012 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1014 if (dev->dvb.frontend) {
1015 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1016 NULL, DVB_PLL_TDHU2);
1019 case SAA7134_BOARD_KWORLD_ATSC110:
1020 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1022 if (dev->dvb.frontend) {
1023 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1024 NULL, DVB_PLL_TUV1236D);
1027 case SAA7134_BOARD_FLYDVBS_LR300:
1028 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1030 if (dev->dvb.frontend) {
1031 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1032 &dev->i2c_adap, 0) == NULL) {
1033 wprintk("%s: No tda826x found!\n", __FUNCTION__);
1035 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1036 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1037 wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
1041 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1042 dev->dvb.frontend = dvb_attach(tda10046_attach,
1045 if (dev->dvb.frontend) {
1046 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1047 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1049 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
1050 &dev->i2c_adap, DVB_PLL_FMD1216ME);
1053 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1054 dev->dvb.frontend = dvb_attach(tda10046_attach,
1055 &philips_europa_config,
1057 if (dev->dvb.frontend) {
1058 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1059 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1062 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1063 configure_tda827x_fe(dev, &cinergy_ht_config);
1065 case SAA7134_BOARD_CINERGY_HT_PCI:
1066 configure_tda827x_fe(dev, &cinergy_ht_pci_config);
1068 case SAA7134_BOARD_PHILIPS_TIGER_S:
1069 configure_tda827x_fe(dev, &philips_tiger_s_config);
1071 case SAA7134_BOARD_ASUS_P7131_4871:
1072 configure_tda827x_fe(dev, &asus_p7131_4871_config);
1074 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1075 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
1077 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1078 configure_tda827x_fe(dev, &avermedia_super_007_config);
1080 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1081 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
1084 wprintk("Huh? unknown DVB card?\n");
1088 if (NULL == dev->dvb.frontend) {
1089 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1093 /* register everything else */
1094 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1096 /* this sequence is necessary to make the tda1004x load its firmware
1097 * and to enter analog mode of hybrid boards
1100 if (dev->dvb.frontend->ops.init)
1101 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1102 if (dev->dvb.frontend->ops.sleep)
1103 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
1104 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1105 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1110 static int dvb_fini(struct saa7134_dev *dev)
1112 /* FIXME: I suspect that this code is bogus, since the entry for
1113 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1114 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1116 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1117 struct v4l2_priv_tun_config tda9887_cfg;
1118 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1120 tda9887_cfg.tuner = TUNER_TDA9887;
1121 tda9887_cfg.priv = &on;
1123 /* otherwise we don't detect the tuner on next insmod */
1124 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
1127 videobuf_dvb_unregister(&dev->dvb);
1131 static struct saa7134_mpeg_ops dvb_ops = {
1132 .type = SAA7134_MPEG_DVB,
1137 static int __init dvb_register(void)
1139 return saa7134_ts_register(&dvb_ops);
1142 static void __exit dvb_unregister(void)
1144 saa7134_ts_unregister(&dvb_ops);
1147 module_init(dvb_register);
1148 module_exit(dvb_unregister);
1150 /* ------------------------------------------------------------------ */