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 */
47 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
48 MODULE_LICENSE("GPL");
50 static unsigned int antenna_pwr = 0;
52 module_param(antenna_pwr, int, 0444);
53 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
55 static int use_frontend = 0;
56 module_param(use_frontend, int, 0644);
57 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
60 module_param(debug, int, 0644);
61 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
63 #define dprintk(fmt, arg...) do { if (debug) \
64 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
67 #define wprintk(fmt, arg...) \
68 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
70 /* ------------------------------------------------------------------
71 * mt352 based DVB-T cards
74 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
79 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
80 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
84 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
85 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
88 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
89 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
91 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
93 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
94 dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
97 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
101 static int mt352_pinnacle_init(struct dvb_frontend* fe)
103 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
104 static u8 reset [] = { RESET, 0x80 };
105 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
106 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
107 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
108 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
109 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
110 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
111 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
112 struct saa7134_dev *dev= fe->dvb->priv;
114 dprintk("%s called\n", __FUNCTION__);
116 mt352_write(fe, clock_config, sizeof(clock_config));
118 mt352_write(fe, reset, sizeof(reset));
119 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
120 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
121 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
122 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
124 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
125 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
126 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
131 static int mt352_aver777_init(struct dvb_frontend* fe)
133 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
134 static u8 reset [] = { RESET, 0x80 };
135 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
136 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
137 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
139 mt352_write(fe, clock_config, sizeof(clock_config));
141 mt352_write(fe, reset, sizeof(reset));
142 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
143 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
144 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
149 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
150 struct dvb_frontend_parameters* params)
152 u8 off[] = { 0x00, 0xf1};
153 u8 on[] = { 0x00, 0x71};
154 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
156 struct saa7134_dev *dev = fe->dvb->priv;
157 struct v4l2_frequency f;
159 /* set frequency (mt2050) */
161 f.type = V4L2_TUNER_DIGITAL_TV;
162 f.frequency = params->frequency / 1000 * 16 / 1000;
163 if (fe->ops.i2c_gate_ctrl)
164 fe->ops.i2c_gate_ctrl(fe, 1);
165 i2c_transfer(&dev->i2c_adap, &msg, 1);
166 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
168 if (fe->ops.i2c_gate_ctrl)
169 fe->ops.i2c_gate_ctrl(fe, 1);
170 i2c_transfer(&dev->i2c_adap, &msg, 1);
172 pinnacle_antenna_pwr(dev, antenna_pwr);
175 return mt352_pinnacle_init(fe);
178 static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
184 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1, params);
188 static struct mt352_config pinnacle_300i = {
189 .demod_address = 0x3c >> 1,
193 .demod_init = mt352_pinnacle_init,
196 static struct mt352_config avermedia_777 = {
197 .demod_address = 0xf,
198 .demod_init = mt352_aver777_init,
201 /* ==================================================================
202 * tda1004x based DVB-T cards, helper functions
205 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
206 const struct firmware **fw, char *name)
208 struct saa7134_dev *dev = fe->dvb->priv;
209 return request_firmware(fw, name, &dev->pci->dev);
212 /* ------------------------------------------------------------------
213 * these tuners are tu1216, td1316(a)
216 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
218 struct saa7134_dev *dev = fe->dvb->priv;
219 struct tda1004x_state *state = fe->demodulator_priv;
220 u8 addr = state->config->tuner_address;
222 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
224 int tuner_frequency = 0;
227 /* determine charge pump */
228 tuner_frequency = params->frequency + 36166000;
229 if (tuner_frequency < 87000000)
231 else if (tuner_frequency < 130000000)
233 else if (tuner_frequency < 160000000)
235 else if (tuner_frequency < 200000000)
237 else if (tuner_frequency < 290000000)
239 else if (tuner_frequency < 420000000)
241 else if (tuner_frequency < 480000000)
243 else if (tuner_frequency < 620000000)
245 else if (tuner_frequency < 830000000)
247 else if (tuner_frequency < 895000000)
253 if (params->frequency < 49000000)
255 else if (params->frequency < 161000000)
257 else if (params->frequency < 444000000)
259 else if (params->frequency < 861000000)
264 /* setup PLL filter */
265 switch (params->u.ofdm.bandwidth) {
266 case BANDWIDTH_6_MHZ:
270 case BANDWIDTH_7_MHZ:
274 case BANDWIDTH_8_MHZ:
283 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
285 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
287 /* setup tuner buffer */
288 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
289 tuner_buf[1] = tuner_frequency & 0xff;
291 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
293 if (fe->ops.i2c_gate_ctrl)
294 fe->ops.i2c_gate_ctrl(fe, 1);
295 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
296 wprintk("could not write to tuner at addr: 0x%02x\n",
304 static int philips_tu1216_init(struct dvb_frontend *fe)
306 struct saa7134_dev *dev = fe->dvb->priv;
307 struct tda1004x_state *state = fe->demodulator_priv;
308 u8 addr = state->config->tuner_address;
309 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
310 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
312 /* setup PLL configuration */
313 if (fe->ops.i2c_gate_ctrl)
314 fe->ops.i2c_gate_ctrl(fe, 1);
315 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
322 /* ------------------------------------------------------------------ */
324 static struct tda1004x_config philips_tu1216_60_config = {
325 .demod_address = 0x8,
328 .xtal_freq = TDA10046_XTAL_4M,
329 .agc_config = TDA10046_AGC_DEFAULT,
330 .if_freq = TDA10046_FREQ_3617,
331 .tuner_address = 0x60,
332 .request_firmware = philips_tda1004x_request_firmware
335 static struct tda1004x_config philips_tu1216_61_config = {
337 .demod_address = 0x8,
340 .xtal_freq = TDA10046_XTAL_4M,
341 .agc_config = TDA10046_AGC_DEFAULT,
342 .if_freq = TDA10046_FREQ_3617,
343 .tuner_address = 0x61,
344 .request_firmware = philips_tda1004x_request_firmware
347 /* ------------------------------------------------------------------ */
349 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
351 struct saa7134_dev *dev = fe->dvb->priv;
352 struct tda1004x_state *state = fe->demodulator_priv;
353 u8 addr = state->config->tuner_address;
354 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
355 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
357 /* setup PLL configuration */
358 if (fe->ops.i2c_gate_ctrl)
359 fe->ops.i2c_gate_ctrl(fe, 1);
360 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
365 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
367 return philips_tda6651_pll_set(fe, params);
370 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
372 struct saa7134_dev *dev = fe->dvb->priv;
373 struct tda1004x_state *state = fe->demodulator_priv;
374 u8 addr = state->config->tuner_address;
375 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
376 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
378 /* switch the tuner to analog mode */
379 if (fe->ops.i2c_gate_ctrl)
380 fe->ops.i2c_gate_ctrl(fe, 1);
381 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
386 /* ------------------------------------------------------------------ */
388 static int philips_europa_tuner_init(struct dvb_frontend *fe)
390 struct saa7134_dev *dev = fe->dvb->priv;
391 static u8 msg[] = { 0x00, 0x40};
392 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
395 if (philips_td1316_tuner_init(fe))
398 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
404 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
406 struct saa7134_dev *dev = fe->dvb->priv;
408 static u8 msg[] = { 0x00, 0x14 };
409 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
411 if (philips_td1316_tuner_sleep(fe))
414 /* switch the board to analog mode */
415 if (fe->ops.i2c_gate_ctrl)
416 fe->ops.i2c_gate_ctrl(fe, 1);
417 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
421 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
423 struct saa7134_dev *dev = fe->dvb->priv;
425 if (dev->original_demod_sleep)
426 dev->original_demod_sleep(fe);
427 fe->ops.i2c_gate_ctrl(fe, 1);
431 static struct tda1004x_config philips_europa_config = {
433 .demod_address = 0x8,
436 .xtal_freq = TDA10046_XTAL_4M,
437 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
438 .if_freq = TDA10046_FREQ_052,
439 .tuner_address = 0x61,
440 .request_firmware = philips_tda1004x_request_firmware
443 /* ------------------------------------------------------------------ */
445 static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
447 struct saa7134_dev *dev = fe->dvb->priv;
448 struct tda1004x_state *state = fe->demodulator_priv;
449 u8 addr = state->config->tuner_address;
450 /* this message is to set up ATC and ALC */
451 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
452 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
454 if (fe->ops.i2c_gate_ctrl)
455 fe->ops.i2c_gate_ctrl(fe, 1);
456 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
463 static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
465 struct saa7134_dev *dev = fe->dvb->priv;
466 struct tda1004x_state *state = fe->demodulator_priv;
467 u8 addr = state->config->tuner_address;
468 /* this message actually turns the tuner back to analog mode */
469 u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
470 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
472 if (fe->ops.i2c_gate_ctrl)
473 fe->ops.i2c_gate_ctrl(fe, 1);
474 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
476 fmd1216_init[2] = 0x86;
477 fmd1216_init[3] = 0x54;
478 if (fe->ops.i2c_gate_ctrl)
479 fe->ops.i2c_gate_ctrl(fe, 1);
480 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
485 static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
487 struct saa7134_dev *dev = fe->dvb->priv;
488 struct tda1004x_state *state = fe->demodulator_priv;
489 u8 addr = state->config->tuner_address;
491 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
493 int tuner_frequency = 0;
497 /* determine charge pump */
498 tuner_frequency = params->frequency + 36130000;
499 if (tuner_frequency < 87000000)
502 else if (tuner_frequency < 180000000) {
506 } else if (tuner_frequency < 195000000) {
511 } else if (tuner_frequency < 366000000) {
512 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
519 } else if (tuner_frequency < 478000000) {
520 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
528 } else if (tuner_frequency < 662000000) {
529 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
536 } else if (tuner_frequency < 840000000) {
537 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
545 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
554 /* calculate divisor */
555 /* ((36166000 + Finput) / 166666) rounded! */
556 divider = (tuner_frequency + 83333) / 166667;
558 /* setup tuner buffer */
559 tuner_buf[0] = (divider >> 8) & 0x7f;
560 tuner_buf[1] = divider & 0xff;
561 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
562 tuner_buf[3] = 0x40 | band;
564 if (fe->ops.i2c_gate_ctrl)
565 fe->ops.i2c_gate_ctrl(fe, 1);
566 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
567 wprintk("could not write to tuner at addr: 0x%02x\n",
574 static struct tda1004x_config medion_cardbus = {
575 .demod_address = 0x08,
578 .xtal_freq = TDA10046_XTAL_16M,
579 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
580 .if_freq = TDA10046_FREQ_3613,
581 .tuner_address = 0x61,
582 .request_firmware = philips_tda1004x_request_firmware
585 /* ------------------------------------------------------------------
586 * tda 1004x based cards with philips silicon tuner
589 static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
591 struct saa7134_dev *dev = fe->dvb->priv;
592 struct tda1004x_state *state = fe->demodulator_priv;
593 u8 addr = state->config->i2c_gate;
594 u8 config = state->config->tuner_config;
595 u8 GP00_CF[] = {0x20, 0x01};
596 u8 GP00_LEV[] = {0x22, 0x00};
598 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
601 dprintk("setting LNA to high gain\n");
603 dprintk("setting LNA to low gain\n");
609 case 1: /* switch is GPIO 0 of tda8290 */
612 saa7134_set_gpio(dev, 22, 0);
613 GP00_LEV[1] = high ? 0 : 1;
614 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
615 wprintk("could not access tda8290 at addr: 0x%02x\n",
621 GP00_LEV[1] = high ? 1 : 0;
622 i2c_transfer(&dev->i2c_adap, &msg, 1);
624 case 3: /* switch with GPIO of saa713x */
625 saa7134_set_gpio(dev, 22, high);
630 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
632 struct tda1004x_state *state = fe->demodulator_priv;
634 u8 addr = state->config->i2c_gate;
635 static u8 tda8290_close[] = { 0x21, 0xc0};
636 static u8 tda8290_open[] = { 0x21, 0x80};
637 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
639 tda8290_msg.buf = tda8290_close;
641 tda8290_msg.buf = tda8290_open;
643 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
644 struct saa7134_dev *dev = fe->dvb->priv;
645 wprintk("could not access tda8290 I2C gate\n");
652 /* ------------------------------------------------------------------ */
654 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
656 struct saa7134_dev *dev = fe->dvb->priv;
657 struct tda1004x_state *state = fe->demodulator_priv;
659 switch (state->config->antenna_switch) {
661 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
662 saa7134_set_gpio(dev, 21, 0);
664 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
665 saa7134_set_gpio(dev, 21, 1);
671 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
673 struct saa7134_dev *dev = fe->dvb->priv;
674 struct tda1004x_state *state = fe->demodulator_priv;
676 switch (state->config->antenna_switch) {
678 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
679 saa7134_set_gpio(dev, 21, 1);
681 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
682 saa7134_set_gpio(dev, 21, 0);
688 static struct tda827x_config tda827x_cfg = {
689 .lna_gain = philips_tda827x_lna_gain,
690 .init = philips_tda827x_tuner_init,
691 .sleep = philips_tda827x_tuner_sleep
694 static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
696 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
697 if (dev->dvb.frontend) {
698 if (tda_conf->i2c_gate)
699 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
700 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
701 &dev->i2c_adap,&tda827x_cfg) == NULL) {
702 wprintk("no tda827x tuner found at addr: %02x\n",
703 tda_conf->tuner_address);
708 /* ------------------------------------------------------------------ */
709 static struct tda1004x_config tda827x_lifeview_config = {
710 .demod_address = 0x08,
713 .xtal_freq = TDA10046_XTAL_16M,
714 .agc_config = TDA10046_AGC_TDA827X,
715 .gpio_config = TDA10046_GP11_I,
716 .if_freq = TDA10046_FREQ_045,
717 .tuner_address = 0x60,
718 .request_firmware = philips_tda1004x_request_firmware
721 static struct tda1004x_config philips_tiger_config = {
722 .demod_address = 0x08,
725 .xtal_freq = TDA10046_XTAL_16M,
726 .agc_config = TDA10046_AGC_TDA827X,
727 .gpio_config = TDA10046_GP11_I,
728 .if_freq = TDA10046_FREQ_045,
730 .tuner_address = 0x61,
733 .request_firmware = philips_tda1004x_request_firmware
736 static struct tda1004x_config cinergy_ht_config = {
737 .demod_address = 0x08,
740 .xtal_freq = TDA10046_XTAL_16M,
741 .agc_config = TDA10046_AGC_TDA827X,
742 .gpio_config = TDA10046_GP01_I,
743 .if_freq = TDA10046_FREQ_045,
745 .tuner_address = 0x61,
747 .request_firmware = philips_tda1004x_request_firmware
750 static struct tda1004x_config cinergy_ht_pci_config = {
751 .demod_address = 0x08,
754 .xtal_freq = TDA10046_XTAL_16M,
755 .agc_config = TDA10046_AGC_TDA827X,
756 .gpio_config = TDA10046_GP01_I,
757 .if_freq = TDA10046_FREQ_045,
759 .tuner_address = 0x60,
761 .request_firmware = philips_tda1004x_request_firmware
764 static struct tda1004x_config philips_tiger_s_config = {
765 .demod_address = 0x08,
768 .xtal_freq = TDA10046_XTAL_16M,
769 .agc_config = TDA10046_AGC_TDA827X,
770 .gpio_config = TDA10046_GP01_I,
771 .if_freq = TDA10046_FREQ_045,
773 .tuner_address = 0x61,
776 .request_firmware = philips_tda1004x_request_firmware
779 static struct tda1004x_config pinnacle_pctv_310i_config = {
780 .demod_address = 0x08,
783 .xtal_freq = TDA10046_XTAL_16M,
784 .agc_config = TDA10046_AGC_TDA827X,
785 .gpio_config = TDA10046_GP11_I,
786 .if_freq = TDA10046_FREQ_045,
788 .tuner_address = 0x61,
790 .request_firmware = philips_tda1004x_request_firmware
793 static struct tda1004x_config hauppauge_hvr_1110_config = {
794 .demod_address = 0x08,
797 .xtal_freq = TDA10046_XTAL_16M,
798 .agc_config = TDA10046_AGC_TDA827X,
799 .gpio_config = TDA10046_GP11_I,
800 .if_freq = TDA10046_FREQ_045,
802 .tuner_address = 0x61,
803 .request_firmware = philips_tda1004x_request_firmware
806 static struct tda1004x_config asus_p7131_dual_config = {
807 .demod_address = 0x08,
810 .xtal_freq = TDA10046_XTAL_16M,
811 .agc_config = TDA10046_AGC_TDA827X,
812 .gpio_config = TDA10046_GP11_I,
813 .if_freq = TDA10046_FREQ_045,
815 .tuner_address = 0x61,
818 .request_firmware = philips_tda1004x_request_firmware
821 static struct tda1004x_config lifeview_trio_config = {
822 .demod_address = 0x09,
825 .xtal_freq = TDA10046_XTAL_16M,
826 .agc_config = TDA10046_AGC_TDA827X,
827 .gpio_config = TDA10046_GP00_I,
828 .if_freq = TDA10046_FREQ_045,
829 .tuner_address = 0x60,
830 .request_firmware = philips_tda1004x_request_firmware
833 static struct tda1004x_config tevion_dvbt220rf_config = {
834 .demod_address = 0x08,
837 .xtal_freq = TDA10046_XTAL_16M,
838 .agc_config = TDA10046_AGC_TDA827X,
839 .gpio_config = TDA10046_GP11_I,
840 .if_freq = TDA10046_FREQ_045,
841 .tuner_address = 0x60,
842 .request_firmware = philips_tda1004x_request_firmware
845 static struct tda1004x_config md8800_dvbt_config = {
846 .demod_address = 0x08,
849 .xtal_freq = TDA10046_XTAL_16M,
850 .agc_config = TDA10046_AGC_TDA827X,
851 .gpio_config = TDA10046_GP01_I,
852 .if_freq = TDA10046_FREQ_045,
854 .tuner_address = 0x60,
856 .request_firmware = philips_tda1004x_request_firmware
859 static struct tda1004x_config asus_p7131_4871_config = {
860 .demod_address = 0x08,
863 .xtal_freq = TDA10046_XTAL_16M,
864 .agc_config = TDA10046_AGC_TDA827X,
865 .gpio_config = TDA10046_GP01_I,
866 .if_freq = TDA10046_FREQ_045,
868 .tuner_address = 0x61,
871 .request_firmware = philips_tda1004x_request_firmware
874 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
875 .demod_address = 0x08,
878 .xtal_freq = TDA10046_XTAL_16M,
879 .agc_config = TDA10046_AGC_TDA827X,
880 .gpio_config = TDA10046_GP11_I,
881 .if_freq = TDA10046_FREQ_045,
883 .tuner_address = 0x61,
886 .request_firmware = philips_tda1004x_request_firmware
888 static struct tda1004x_config kworld_dvb_t_210_config = {
889 .demod_address = 0x08,
892 .xtal_freq = TDA10046_XTAL_16M,
893 .agc_config = TDA10046_AGC_TDA827X,
894 .gpio_config = TDA10046_GP11_I,
895 .if_freq = TDA10046_FREQ_045,
897 .tuner_address = 0x61,
900 .request_firmware = philips_tda1004x_request_firmware
902 /* ------------------------------------------------------------------
903 * special case: this card uses saa713x GPIO22 for the mode switch
906 static int ads_duo_tuner_init(struct dvb_frontend *fe)
908 struct saa7134_dev *dev = fe->dvb->priv;
909 philips_tda827x_tuner_init(fe);
910 /* route TDA8275a AGC input to the channel decoder */
911 saa7134_set_gpio(dev, 22, 1);
915 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
917 struct saa7134_dev *dev = fe->dvb->priv;
918 /* route TDA8275a AGC input to the analog IF chip*/
919 saa7134_set_gpio(dev, 22, 0);
920 philips_tda827x_tuner_sleep(fe);
924 static struct tda827x_config ads_duo_cfg = {
925 .lna_gain = philips_tda827x_lna_gain,
926 .init = ads_duo_tuner_init,
927 .sleep = ads_duo_tuner_sleep
930 static struct tda1004x_config ads_tech_duo_config = {
931 .demod_address = 0x08,
934 .xtal_freq = TDA10046_XTAL_16M,
935 .agc_config = TDA10046_AGC_TDA827X,
936 .gpio_config = TDA10046_GP00_I,
937 .if_freq = TDA10046_FREQ_045,
938 .tuner_address = 0x61,
939 .request_firmware = philips_tda1004x_request_firmware
942 /* ==================================================================
943 * tda10086 based DVB-S cards, helper functions
946 static struct tda10086_config flydvbs = {
947 .demod_address = 0x0e,
951 /* ==================================================================
952 * nxt200x based ATSC cards, helper functions
955 static struct nxt200x_config avertvhda180 = {
956 .demod_address = 0x0a,
959 static struct nxt200x_config kworldatsc110 = {
960 .demod_address = 0x0a,
963 /* ==================================================================
967 static int dvb_init(struct saa7134_dev *dev)
970 /* init struct videobuf_dvb */
971 dev->ts.nr_bufs = 32;
972 dev->ts.nr_packets = 32*4;
973 dev->dvb.name = dev->name;
974 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
975 dev->pci, &dev->slock,
976 V4L2_BUF_TYPE_VIDEO_CAPTURE,
977 V4L2_FIELD_ALTERNATE,
978 sizeof(struct saa7134_buf),
981 switch (dev->board) {
982 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
983 dprintk("pinnacle 300i dvb setup\n");
984 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
986 if (dev->dvb.frontend) {
987 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
990 case SAA7134_BOARD_AVERMEDIA_777:
991 case SAA7134_BOARD_AVERMEDIA_A16AR:
992 dprintk("avertv 777 dvb setup\n");
993 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
995 if (dev->dvb.frontend) {
996 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
999 case SAA7134_BOARD_MD7134:
1000 dev->dvb.frontend = dvb_attach(tda10046_attach,
1003 if (dev->dvb.frontend) {
1004 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1005 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1006 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1009 case SAA7134_BOARD_PHILIPS_TOUGH:
1010 dev->dvb.frontend = dvb_attach(tda10046_attach,
1011 &philips_tu1216_60_config,
1013 if (dev->dvb.frontend) {
1014 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1015 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1018 case SAA7134_BOARD_FLYDVBTDUO:
1019 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1020 configure_tda827x_fe(dev, &tda827x_lifeview_config);
1022 case SAA7134_BOARD_PHILIPS_EUROPA:
1023 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1024 dev->dvb.frontend = dvb_attach(tda10046_attach,
1025 &philips_europa_config,
1027 if (dev->dvb.frontend) {
1028 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1029 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1030 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1031 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1032 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1035 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1036 dev->dvb.frontend = dvb_attach(tda10046_attach,
1037 &philips_tu1216_61_config,
1039 if (dev->dvb.frontend) {
1040 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1041 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1044 case SAA7134_BOARD_KWORLD_DVBT_210:
1045 configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
1047 case SAA7134_BOARD_PHILIPS_TIGER:
1048 configure_tda827x_fe(dev, &philips_tiger_config);
1050 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1051 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
1053 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1054 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
1056 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1057 configure_tda827x_fe(dev, &asus_p7131_dual_config);
1059 case SAA7134_BOARD_FLYDVBT_LR301:
1060 configure_tda827x_fe(dev, &tda827x_lifeview_config);
1062 case SAA7134_BOARD_FLYDVB_TRIO:
1063 if(! use_frontend) { //terrestrial
1064 configure_tda827x_fe(dev, &lifeview_trio_config);
1065 } else { //satellite
1066 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1067 if (dev->dvb.frontend) {
1068 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1069 &dev->i2c_adap, 0) == NULL) {
1070 wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
1072 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1073 0x08, 0, 0) == NULL) {
1074 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
1079 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1080 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1081 dev->dvb.frontend = dvb_attach(tda10046_attach,
1082 &ads_tech_duo_config,
1084 if (dev->dvb.frontend) {
1085 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
1086 ads_tech_duo_config.tuner_address,
1087 &dev->i2c_adap,&ads_duo_cfg) == NULL) {
1088 wprintk("no tda827x tuner found at addr: %02x\n",
1089 ads_tech_duo_config.tuner_address);
1093 case SAA7134_BOARD_TEVION_DVBT_220RF:
1094 configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
1096 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1097 configure_tda827x_fe(dev, &md8800_dvbt_config);
1099 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1100 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1102 if (dev->dvb.frontend) {
1103 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1104 NULL, &dvb_pll_tdhu2);
1107 case SAA7134_BOARD_KWORLD_ATSC110:
1108 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1110 if (dev->dvb.frontend) {
1111 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1112 NULL, &dvb_pll_tuv1236d);
1115 case SAA7134_BOARD_FLYDVBS_LR300:
1116 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1118 if (dev->dvb.frontend) {
1119 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1120 &dev->i2c_adap, 0) == NULL) {
1121 wprintk("%s: No tda826x found!\n", __FUNCTION__);
1123 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1124 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1125 wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
1129 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1130 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1132 if (dev->dvb.frontend) {
1133 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1134 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1135 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1136 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1137 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1140 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1141 dev->dvb.frontend = dvb_attach(tda10046_attach,
1142 &philips_europa_config,
1144 if (dev->dvb.frontend) {
1145 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1146 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1149 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1150 configure_tda827x_fe(dev, &cinergy_ht_config);
1152 case SAA7134_BOARD_CINERGY_HT_PCI:
1153 configure_tda827x_fe(dev, &cinergy_ht_pci_config);
1155 case SAA7134_BOARD_PHILIPS_TIGER_S:
1156 configure_tda827x_fe(dev, &philips_tiger_s_config);
1158 case SAA7134_BOARD_ASUS_P7131_4871:
1159 configure_tda827x_fe(dev, &asus_p7131_4871_config);
1161 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1162 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
1165 wprintk("Huh? unknown DVB card?\n");
1169 if (NULL == dev->dvb.frontend) {
1170 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1174 /* register everything else */
1175 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1177 /* this sequence is necessary to make the tda1004x load its firmware
1178 * and to enter analog mode of hybrid boards
1181 if (dev->dvb.frontend->ops.init)
1182 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1183 if (dev->dvb.frontend->ops.sleep)
1184 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
1185 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1186 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1191 static int dvb_fini(struct saa7134_dev *dev)
1193 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1195 switch (dev->board) {
1196 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1197 /* otherwise we don't detect the tuner on next insmod */
1198 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1201 videobuf_dvb_unregister(&dev->dvb);
1205 static struct saa7134_mpeg_ops dvb_ops = {
1206 .type = SAA7134_MPEG_DVB,
1211 static int __init dvb_register(void)
1213 return saa7134_ts_register(&dvb_ops);
1216 static void __exit dvb_unregister(void)
1218 saa7134_ts_unregister(&dvb_ops);
1221 module_init(dvb_register);
1222 module_exit(dvb_unregister);
1224 /* ------------------------------------------------------------------ */