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 */
45 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
46 MODULE_LICENSE("GPL");
48 static unsigned int antenna_pwr = 0;
50 module_param(antenna_pwr, int, 0444);
51 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
53 static int use_frontend = 0;
54 module_param(use_frontend, int, 0644);
55 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
58 module_param(debug, int, 0644);
59 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
61 #define dprintk(fmt, arg...) if (debug) \
62 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg)
64 /* ------------------------------------------------------------------
65 * mt352 based DVB-T cards
68 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
73 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
74 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
78 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
79 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
82 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
83 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
85 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
87 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
88 printk("%s: %s %s\n", dev->name, __FUNCTION__,
92 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
96 static int mt352_pinnacle_init(struct dvb_frontend* fe)
98 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
99 static u8 reset [] = { RESET, 0x80 };
100 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
101 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
102 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
103 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
104 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
105 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
106 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
107 struct saa7134_dev *dev= fe->dvb->priv;
109 printk("%s: %s called\n",dev->name,__FUNCTION__);
111 mt352_write(fe, clock_config, sizeof(clock_config));
113 mt352_write(fe, reset, sizeof(reset));
114 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
115 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
116 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
117 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
119 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
120 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
121 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
126 static int mt352_aver777_init(struct dvb_frontend* fe)
128 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
129 static u8 reset [] = { RESET, 0x80 };
130 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
131 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
132 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
134 mt352_write(fe, clock_config, sizeof(clock_config));
136 mt352_write(fe, reset, sizeof(reset));
137 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
138 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
139 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
144 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
145 struct dvb_frontend_parameters* params)
147 u8 off[] = { 0x00, 0xf1};
148 u8 on[] = { 0x00, 0x71};
149 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
151 struct saa7134_dev *dev = fe->dvb->priv;
152 struct v4l2_frequency f;
154 /* set frequency (mt2050) */
156 f.type = V4L2_TUNER_DIGITAL_TV;
157 f.frequency = params->frequency / 1000 * 16 / 1000;
158 if (fe->ops.i2c_gate_ctrl)
159 fe->ops.i2c_gate_ctrl(fe, 1);
160 i2c_transfer(&dev->i2c_adap, &msg, 1);
161 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
163 if (fe->ops.i2c_gate_ctrl)
164 fe->ops.i2c_gate_ctrl(fe, 1);
165 i2c_transfer(&dev->i2c_adap, &msg, 1);
167 pinnacle_antenna_pwr(dev, antenna_pwr);
170 return mt352_pinnacle_init(fe);
173 static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
179 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
181 params->u.ofdm.bandwidth);
185 static struct mt352_config pinnacle_300i = {
186 .demod_address = 0x3c >> 1,
190 .demod_init = mt352_pinnacle_init,
193 static struct mt352_config avermedia_777 = {
194 .demod_address = 0xf,
195 .demod_init = mt352_aver777_init,
198 /* ==================================================================
199 * tda1004x based DVB-T cards, helper functions
202 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
203 const struct firmware **fw, char *name)
205 struct saa7134_dev *dev = fe->dvb->priv;
206 return request_firmware(fw, name, &dev->pci->dev);
209 static void philips_tda1004x_set_board_name(struct dvb_frontend *fe, char *name)
213 len = sizeof(fe->ops.info.name);
214 strncpy(fe->ops.info.name, name, len);
215 fe->ops.info.name[len - 1] = 0;
218 /* ------------------------------------------------------------------
219 * these tuners are tu1216, td1316(a)
222 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
224 struct saa7134_dev *dev = fe->dvb->priv;
225 struct tda1004x_state *state = fe->demodulator_priv;
226 u8 addr = state->config->tuner_address;
228 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
230 int tuner_frequency = 0;
233 /* determine charge pump */
234 tuner_frequency = params->frequency + 36166000;
235 if (tuner_frequency < 87000000)
237 else if (tuner_frequency < 130000000)
239 else if (tuner_frequency < 160000000)
241 else if (tuner_frequency < 200000000)
243 else if (tuner_frequency < 290000000)
245 else if (tuner_frequency < 420000000)
247 else if (tuner_frequency < 480000000)
249 else if (tuner_frequency < 620000000)
251 else if (tuner_frequency < 830000000)
253 else if (tuner_frequency < 895000000)
259 if (params->frequency < 49000000)
261 else if (params->frequency < 161000000)
263 else if (params->frequency < 444000000)
265 else if (params->frequency < 861000000)
270 /* setup PLL filter */
271 switch (params->u.ofdm.bandwidth) {
272 case BANDWIDTH_6_MHZ:
276 case BANDWIDTH_7_MHZ:
280 case BANDWIDTH_8_MHZ:
289 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
291 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
293 /* setup tuner buffer */
294 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
295 tuner_buf[1] = tuner_frequency & 0xff;
297 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
299 if (fe->ops.i2c_gate_ctrl)
300 fe->ops.i2c_gate_ctrl(fe, 1);
301 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
302 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
309 static int philips_tu1216_init(struct dvb_frontend *fe)
311 struct saa7134_dev *dev = fe->dvb->priv;
312 struct tda1004x_state *state = fe->demodulator_priv;
313 u8 addr = state->config->tuner_address;
314 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
315 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
317 /* setup PLL configuration */
318 if (fe->ops.i2c_gate_ctrl)
319 fe->ops.i2c_gate_ctrl(fe, 1);
320 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
327 /* ------------------------------------------------------------------ */
329 static struct tda1004x_config philips_tu1216_60_config = {
330 .demod_address = 0x8,
333 .xtal_freq = TDA10046_XTAL_4M,
334 .agc_config = TDA10046_AGC_DEFAULT,
335 .if_freq = TDA10046_FREQ_3617,
336 .tuner_address = 0x60,
337 .request_firmware = philips_tda1004x_request_firmware
340 static struct tda1004x_config philips_tu1216_61_config = {
342 .demod_address = 0x8,
345 .xtal_freq = TDA10046_XTAL_4M,
346 .agc_config = TDA10046_AGC_DEFAULT,
347 .if_freq = TDA10046_FREQ_3617,
348 .tuner_address = 0x61,
349 .request_firmware = philips_tda1004x_request_firmware
352 /* ------------------------------------------------------------------ */
354 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
356 struct saa7134_dev *dev = fe->dvb->priv;
357 struct tda1004x_state *state = fe->demodulator_priv;
358 u8 addr = state->config->tuner_address;
359 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
360 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
362 /* setup PLL configuration */
363 if (fe->ops.i2c_gate_ctrl)
364 fe->ops.i2c_gate_ctrl(fe, 1);
365 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
370 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
372 return philips_tda6651_pll_set(fe, params);
375 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
377 struct saa7134_dev *dev = fe->dvb->priv;
378 struct tda1004x_state *state = fe->demodulator_priv;
379 u8 addr = state->config->tuner_address;
380 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
381 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
383 /* switch the tuner to analog mode */
384 if (fe->ops.i2c_gate_ctrl)
385 fe->ops.i2c_gate_ctrl(fe, 1);
386 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
391 /* ------------------------------------------------------------------ */
393 static int philips_europa_tuner_init(struct dvb_frontend *fe)
395 struct saa7134_dev *dev = fe->dvb->priv;
396 static u8 msg[] = { 0x00, 0x40};
397 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
400 if (philips_td1316_tuner_init(fe))
403 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
409 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
411 struct saa7134_dev *dev = fe->dvb->priv;
413 static u8 msg[] = { 0x00, 0x14 };
414 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
416 if (philips_td1316_tuner_sleep(fe))
419 /* switch the board to analog mode */
420 if (fe->ops.i2c_gate_ctrl)
421 fe->ops.i2c_gate_ctrl(fe, 1);
422 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
426 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
428 struct saa7134_dev *dev = fe->dvb->priv;
430 if (dev->original_demod_sleep)
431 dev->original_demod_sleep(fe);
432 fe->ops.i2c_gate_ctrl(fe, 1);
436 static struct tda1004x_config philips_europa_config = {
438 .demod_address = 0x8,
441 .xtal_freq = TDA10046_XTAL_4M,
442 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
443 .if_freq = TDA10046_FREQ_052,
444 .tuner_address = 0x61,
445 .request_firmware = philips_tda1004x_request_firmware
448 /* ------------------------------------------------------------------ */
450 static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
452 struct saa7134_dev *dev = fe->dvb->priv;
453 struct tda1004x_state *state = fe->demodulator_priv;
454 u8 addr = state->config->tuner_address;
455 /* this message is to set up ATC and ALC */
456 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
457 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
459 if (fe->ops.i2c_gate_ctrl)
460 fe->ops.i2c_gate_ctrl(fe, 1);
461 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
468 static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
470 struct saa7134_dev *dev = fe->dvb->priv;
471 struct tda1004x_state *state = fe->demodulator_priv;
472 u8 addr = state->config->tuner_address;
473 /* this message actually turns the tuner back to analog mode */
474 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
475 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
477 if (fe->ops.i2c_gate_ctrl)
478 fe->ops.i2c_gate_ctrl(fe, 1);
479 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
481 fmd1216_init[2] = 0x86;
482 fmd1216_init[3] = 0x54;
483 if (fe->ops.i2c_gate_ctrl)
484 fe->ops.i2c_gate_ctrl(fe, 1);
485 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
490 static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
492 struct saa7134_dev *dev = fe->dvb->priv;
493 struct tda1004x_state *state = fe->demodulator_priv;
494 u8 addr = state->config->tuner_address;
496 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
498 int tuner_frequency = 0;
502 /* determine charge pump */
503 tuner_frequency = params->frequency + 36130000;
504 if (tuner_frequency < 87000000)
507 else if (tuner_frequency < 180000000) {
511 } else if (tuner_frequency < 195000000) {
516 } else if (tuner_frequency < 366000000) {
517 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
524 } else if (tuner_frequency < 478000000) {
525 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
533 } else if (tuner_frequency < 662000000) {
534 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
541 } else if (tuner_frequency < 840000000) {
542 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
550 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
559 /* calculate divisor */
560 /* ((36166000 + Finput) / 166666) rounded! */
561 divider = (tuner_frequency + 83333) / 166667;
563 /* setup tuner buffer */
564 tuner_buf[0] = (divider >> 8) & 0x7f;
565 tuner_buf[1] = divider & 0xff;
566 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
567 tuner_buf[3] = 0x40 | band;
569 if (fe->ops.i2c_gate_ctrl)
570 fe->ops.i2c_gate_ctrl(fe, 1);
571 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
572 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
578 static struct tda1004x_config medion_cardbus = {
579 .demod_address = 0x08,
582 .xtal_freq = TDA10046_XTAL_16M,
583 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
584 .if_freq = TDA10046_FREQ_3613,
585 .tuner_address = 0x61,
586 .request_firmware = philips_tda1004x_request_firmware
589 /* ------------------------------------------------------------------
590 * tda 1004x based cards with philips silicon tuner
593 static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
595 struct saa7134_dev *dev = fe->dvb->priv;
596 struct tda1004x_state *state = fe->demodulator_priv;
597 u8 addr = state->config->i2c_gate;
598 u8 config = state->config->tuner_config;
599 u8 GP00_CF[] = {0x20, 0x01};
600 u8 GP00_LEV[] = {0x22, 0x00};
602 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
605 dprintk("setting LNA to high gain\n");
607 dprintk("setting LNA to low gain\n");
613 case 1: /* switch is GPIO 0 of tda8290 */
616 saa7134_set_gpio(dev, 22, 0);
617 GP00_LEV[1] = high ? 0 : 1;
618 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
619 printk("%s/dvb: could not access tda8290 at addr: 0x%02x\n",dev->name, addr << 1);
624 GP00_LEV[1] = high ? 1 : 0;
625 i2c_transfer(&dev->i2c_adap, &msg, 1);
627 case 3: /* switch with GPIO of saa713x */
628 saa7134_set_gpio(dev, 22, high);
633 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
635 struct saa7134_dev *dev = fe->dvb->priv;
636 struct tda1004x_state *state = fe->demodulator_priv;
638 u8 addr = state->config->i2c_gate;
639 static u8 tda8290_close[] = { 0x21, 0xc0};
640 static u8 tda8290_open[] = { 0x21, 0x80};
641 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
643 tda8290_msg.buf = tda8290_close;
645 tda8290_msg.buf = tda8290_open;
647 if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1) {
648 printk("%s/dvb: could not access tda8290 I2C gate\n",dev->name);
655 /* ------------------------------------------------------------------ */
657 struct tda827x_data {
667 static struct tda827x_data tda827x_dvbt[] = {
668 { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
669 { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
670 { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
671 { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
672 { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
673 { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
674 { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
675 { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
676 { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
677 { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
678 { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
679 { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
680 { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
681 { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
682 { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
683 { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
684 { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
685 { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
686 { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
687 { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
688 { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
689 { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
690 { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
691 { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
692 { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
693 { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
694 { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
695 { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
696 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
699 static int philips_tda827xo_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
701 struct saa7134_dev *dev = fe->dvb->priv;
702 struct tda1004x_state *state = fe->demodulator_priv;
703 u8 addr = state->config->tuner_address;
706 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,
707 .len = sizeof(tuner_buf) };
708 int i, tuner_freq, if_freq;
710 switch (params->u.ofdm.bandwidth) {
711 case BANDWIDTH_6_MHZ:
714 case BANDWIDTH_7_MHZ:
717 default: /* 8 MHz or Auto */
721 tuner_freq = params->frequency + if_freq;
724 while (tda827x_dvbt[i].lomax < tuner_freq) {
725 if(tda827x_dvbt[i + 1].lomax == 0)
730 N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
732 tuner_buf[1] = (N>>8) | 0x40;
733 tuner_buf[2] = N & 0xff;
736 tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
737 (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
738 tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
742 tuner_buf[10] = 0xff;
743 tuner_buf[11] = 0x00;
744 tuner_buf[12] = 0x00;
745 tuner_buf[13] = 0x40;
748 if (fe->ops.i2c_gate_ctrl)
749 fe->ops.i2c_gate_ctrl(fe, 1);
750 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
751 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
755 /* correct CP value */
757 tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
759 if (fe->ops.i2c_gate_ctrl)
760 fe->ops.i2c_gate_ctrl(fe, 1);
761 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
766 static int philips_tda827xo_tuner_sleep(struct dvb_frontend *fe)
768 struct saa7134_dev *dev = fe->dvb->priv;
769 struct tda1004x_state *state = fe->demodulator_priv;
770 u8 addr = state->config->tuner_address;
771 static u8 tda827x_sleep[] = { 0x30, 0xd0};
772 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827x_sleep,
773 .len = sizeof(tda827x_sleep) };
774 if (fe->ops.i2c_gate_ctrl)
775 fe->ops.i2c_gate_ctrl(fe, 1);
776 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
780 /* ------------------------------------------------------------------ */
782 struct tda827xa_data {
791 static struct tda827xa_data tda827xa_dvbt[] = {
792 { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
793 { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
794 { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
795 { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
796 { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
797 { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
798 { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
799 { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
800 { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
801 { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
802 { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
803 { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
804 { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
805 { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
806 { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
807 { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
808 { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
809 { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
810 { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
811 { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
812 { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
813 { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
814 { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
815 { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
816 { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
817 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
818 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
820 static int philips_tda827xa_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
822 struct saa7134_dev *dev = fe->dvb->priv;
823 struct tda1004x_state *state = fe->demodulator_priv;
824 u8 addr = state->config->tuner_address;
827 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
828 int i, tuner_freq, if_freq;
831 philips_tda827x_lna_gain( fe, 1);
834 switch (params->u.ofdm.bandwidth) {
835 case BANDWIDTH_6_MHZ:
838 case BANDWIDTH_7_MHZ:
841 default: /* 8 MHz or Auto */
845 tuner_freq = params->frequency + if_freq;
848 while (tda827xa_dvbt[i].lomax < tuner_freq) {
849 if(tda827xa_dvbt[i + 1].lomax == 0)
854 N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
855 tuner_buf[0] = 0; // subaddress
856 tuner_buf[1] = N >> 8;
857 tuner_buf[2] = N & 0xff;
860 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
861 tda827xa_dvbt[i].sbs;
862 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
866 tuner_buf[10] = 0x00;
868 if (fe->ops.i2c_gate_ctrl)
869 fe->ops.i2c_gate_ctrl(fe, 1);
870 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
871 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
878 tuner_buf[4] = 0x59; // lpsel, for 6MHz + 2
880 if (fe->ops.i2c_gate_ctrl)
881 fe->ops.i2c_gate_ctrl(fe, 1);
882 i2c_transfer(&dev->i2c_adap, &msg, 1);
887 if (fe->ops.i2c_gate_ctrl)
888 fe->ops.i2c_gate_ctrl(fe, 1);
889 i2c_transfer(&dev->i2c_adap, &msg, 1);
892 msg.flags = I2C_M_RD;
893 if (fe->ops.i2c_gate_ctrl)
894 fe->ops.i2c_gate_ctrl(fe, 1);
895 i2c_transfer(&dev->i2c_adap, &msg, 1);
899 dprintk("tda8275a AGC2 gain is: %d\n", tuner_buf[1]);
900 if ((tuner_buf[1]) < 2) {
901 philips_tda827x_lna_gain(fe, 0);
904 if (fe->ops.i2c_gate_ctrl)
905 fe->ops.i2c_gate_ctrl(fe, 1);
906 i2c_transfer(&dev->i2c_adap, &msg, 1);
910 tuner_buf[1] = 0x99; // lpsel, for 6MHz + 2
911 if (fe->ops.i2c_gate_ctrl)
912 fe->ops.i2c_gate_ctrl(fe, 1);
913 i2c_transfer(&dev->i2c_adap, &msg, 1);
917 if (fe->ops.i2c_gate_ctrl)
918 fe->ops.i2c_gate_ctrl(fe, 1);
919 i2c_transfer(&dev->i2c_adap, &msg, 1);
921 /* correct CP value */
923 tuner_buf[1] = 0x10 + tda827xa_dvbt[i].scr;
924 if (fe->ops.i2c_gate_ctrl)
925 fe->ops.i2c_gate_ctrl(fe, 1);
926 i2c_transfer(&dev->i2c_adap, &msg, 1);
930 tuner_buf[1] = 0x39; // lpsel, for 6MHz + 2
931 if (fe->ops.i2c_gate_ctrl)
932 fe->ops.i2c_gate_ctrl(fe, 1);
933 i2c_transfer(&dev->i2c_adap, &msg, 1);
938 tuner_buf[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
939 if (fe->ops.i2c_gate_ctrl)
940 fe->ops.i2c_gate_ctrl(fe, 1);
941 i2c_transfer(&dev->i2c_adap, &msg, 1);
947 static int philips_tda827xa_tuner_sleep(struct dvb_frontend *fe)
949 struct saa7134_dev *dev = fe->dvb->priv;
950 struct tda1004x_state *state = fe->demodulator_priv;
951 u8 addr = state->config->tuner_address;
952 static u8 tda827xa_sleep[] = { 0x30, 0x90};
953 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
954 .len = sizeof(tda827xa_sleep) };
955 if (fe->ops.i2c_gate_ctrl)
956 fe->ops.i2c_gate_ctrl(fe, 1);
957 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
958 if (fe->ops.i2c_gate_ctrl)
959 fe->ops.i2c_gate_ctrl(fe, 0);
963 /* ------------------------------------------------------------------
964 * upper layer: distinguish the silicon tuner versions
967 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
969 struct saa7134_dev *dev = fe->dvb->priv;
970 struct tda1004x_state *state = fe->demodulator_priv;
971 u8 addr = state->config->tuner_address;
973 struct i2c_msg tuner_msg = {.addr = addr,.flags = I2C_M_RD,.buf = &data, .len = 1};
974 state->conf_probed = 0;
975 if (fe->ops.i2c_gate_ctrl)
976 fe->ops.i2c_gate_ctrl(fe, 1);
977 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
978 printk("%s/dvb: could not read from tuner at addr: 0x%02x\n",dev->name, addr << 1);
981 if ((data & 0x3c) == 0) {
982 dprintk("tda827x tuner found\n");
983 state->conf_probed = 1;
985 dprintk("tda827xa tuner found\n");
986 state->conf_probed = 2;
988 switch (state->config->antenna_switch) {
990 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
991 saa7134_set_gpio(dev, 21, 0);
993 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
994 saa7134_set_gpio(dev, 21, 1);
1000 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
1002 struct saa7134_dev *dev = fe->dvb->priv;
1003 struct tda1004x_state *state = fe->demodulator_priv;
1004 switch (state->conf_probed) {
1005 case 1: philips_tda827xo_tuner_sleep(fe);
1007 case 2: philips_tda827xa_tuner_sleep(fe);
1009 default: dprintk("Huh? unknown tda827x version!\n");
1012 switch (state->config->antenna_switch) {
1014 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
1015 saa7134_set_gpio(dev, 21, 1);
1017 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
1018 saa7134_set_gpio(dev, 21, 0);
1024 static int philips_tda827x_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1026 struct saa7134_dev *dev = fe->dvb->priv;
1027 struct tda1004x_state *state = fe->demodulator_priv;
1028 switch (state->conf_probed) {
1029 case 1: philips_tda827xo_pll_set(fe, params);
1031 case 2: philips_tda827xa_pll_set(fe, params);
1033 default: dprintk("Huh? unknown tda827x version!\n");
1039 static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf,
1042 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
1043 if (dev->dvb.frontend) {
1044 if (tda_conf->i2c_gate)
1045 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1046 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1047 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1048 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_pll_set;
1050 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
1053 /* ------------------------------------------------------------------ */
1054 static struct tda1004x_config tda827x_lifeview_config = {
1055 .demod_address = 0x08,
1058 .xtal_freq = TDA10046_XTAL_16M,
1059 .agc_config = TDA10046_AGC_TDA827X,
1060 .gpio_config = TDA10046_GP11_I,
1061 .if_freq = TDA10046_FREQ_045,
1062 .tuner_address = 0x60,
1063 .request_firmware = philips_tda1004x_request_firmware
1066 static struct tda1004x_config philips_tiger_config = {
1067 .demod_address = 0x08,
1070 .xtal_freq = TDA10046_XTAL_16M,
1071 .agc_config = TDA10046_AGC_TDA827X,
1072 .gpio_config = TDA10046_GP11_I,
1073 .if_freq = TDA10046_FREQ_045,
1075 .tuner_address = 0x61,
1078 .request_firmware = philips_tda1004x_request_firmware
1081 static struct tda1004x_config cinergy_ht_config = {
1082 .demod_address = 0x08,
1085 .xtal_freq = TDA10046_XTAL_16M,
1086 .agc_config = TDA10046_AGC_TDA827X,
1087 .gpio_config = TDA10046_GP01_I,
1088 .if_freq = TDA10046_FREQ_045,
1090 .tuner_address = 0x61,
1092 .request_firmware = philips_tda1004x_request_firmware
1095 static struct tda1004x_config cinergy_ht_pci_config = {
1096 .demod_address = 0x08,
1099 .xtal_freq = TDA10046_XTAL_16M,
1100 .agc_config = TDA10046_AGC_TDA827X,
1101 .gpio_config = TDA10046_GP01_I,
1102 .if_freq = TDA10046_FREQ_045,
1104 .tuner_address = 0x60,
1106 .request_firmware = philips_tda1004x_request_firmware
1109 static struct tda1004x_config philips_tiger_s_config = {
1110 .demod_address = 0x08,
1113 .xtal_freq = TDA10046_XTAL_16M,
1114 .agc_config = TDA10046_AGC_TDA827X,
1115 .gpio_config = TDA10046_GP01_I,
1116 .if_freq = TDA10046_FREQ_045,
1118 .tuner_address = 0x61,
1121 .request_firmware = philips_tda1004x_request_firmware
1124 static struct tda1004x_config pinnacle_pctv_310i_config = {
1125 .demod_address = 0x08,
1128 .xtal_freq = TDA10046_XTAL_16M,
1129 .agc_config = TDA10046_AGC_TDA827X,
1130 .gpio_config = TDA10046_GP11_I,
1131 .if_freq = TDA10046_FREQ_045,
1133 .tuner_address = 0x61,
1135 .request_firmware = philips_tda1004x_request_firmware
1138 static struct tda1004x_config hauppauge_hvr_1110_config = {
1139 .demod_address = 0x08,
1142 .xtal_freq = TDA10046_XTAL_16M,
1143 .agc_config = TDA10046_AGC_TDA827X,
1144 .gpio_config = TDA10046_GP11_I,
1145 .if_freq = TDA10046_FREQ_045,
1147 .tuner_address = 0x61,
1148 .request_firmware = philips_tda1004x_request_firmware
1151 static struct tda1004x_config asus_p7131_dual_config = {
1152 .demod_address = 0x08,
1155 .xtal_freq = TDA10046_XTAL_16M,
1156 .agc_config = TDA10046_AGC_TDA827X,
1157 .gpio_config = TDA10046_GP11_I,
1158 .if_freq = TDA10046_FREQ_045,
1160 .tuner_address = 0x61,
1163 .request_firmware = philips_tda1004x_request_firmware
1166 static struct tda1004x_config lifeview_trio_config = {
1167 .demod_address = 0x09,
1170 .xtal_freq = TDA10046_XTAL_16M,
1171 .agc_config = TDA10046_AGC_TDA827X,
1172 .gpio_config = TDA10046_GP00_I,
1173 .if_freq = TDA10046_FREQ_045,
1174 .tuner_address = 0x60,
1175 .request_firmware = philips_tda1004x_request_firmware
1178 static struct tda1004x_config tevion_dvbt220rf_config = {
1179 .demod_address = 0x08,
1182 .xtal_freq = TDA10046_XTAL_16M,
1183 .agc_config = TDA10046_AGC_TDA827X,
1184 .gpio_config = TDA10046_GP11_I,
1185 .if_freq = TDA10046_FREQ_045,
1186 .tuner_address = 0x60,
1187 .request_firmware = philips_tda1004x_request_firmware
1190 static struct tda1004x_config md8800_dvbt_config = {
1191 .demod_address = 0x08,
1194 .xtal_freq = TDA10046_XTAL_16M,
1195 .agc_config = TDA10046_AGC_TDA827X,
1196 .gpio_config = TDA10046_GP01_I,
1197 .if_freq = TDA10046_FREQ_045,
1199 .tuner_address = 0x60,
1201 .request_firmware = philips_tda1004x_request_firmware
1204 /* ------------------------------------------------------------------
1205 * special case: this card uses saa713x GPIO22 for the mode switch
1208 static int ads_duo_tuner_init(struct dvb_frontend *fe)
1210 struct saa7134_dev *dev = fe->dvb->priv;
1211 philips_tda827x_tuner_init(fe);
1212 /* route TDA8275a AGC input to the channel decoder */
1213 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0400000);
1217 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
1219 struct saa7134_dev *dev = fe->dvb->priv;
1220 /* route TDA8275a AGC input to the analog IF chip*/
1221 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0400000);
1222 philips_tda827x_tuner_sleep(fe);
1226 static struct tda1004x_config ads_tech_duo_config = {
1227 .demod_address = 0x08,
1230 .xtal_freq = TDA10046_XTAL_16M,
1231 .agc_config = TDA10046_AGC_TDA827X,
1232 .gpio_config = TDA10046_GP00_I,
1233 .if_freq = TDA10046_FREQ_045,
1234 .tuner_address = 0x61,
1235 .request_firmware = philips_tda1004x_request_firmware
1238 /* ==================================================================
1239 * tda10086 based DVB-S cards, helper functions
1242 static struct tda10086_config flydvbs = {
1243 .demod_address = 0x0e,
1247 /* ==================================================================
1248 * nxt200x based ATSC cards, helper functions
1251 static struct nxt200x_config avertvhda180 = {
1252 .demod_address = 0x0a,
1255 static int nxt200x_set_pll_input(u8 *buf, int input)
1264 static struct nxt200x_config kworldatsc110 = {
1265 .demod_address = 0x0a,
1266 .set_pll_input = nxt200x_set_pll_input,
1269 /* ==================================================================
1273 static int dvb_init(struct saa7134_dev *dev)
1276 /* init struct videobuf_dvb */
1277 dev->ts.nr_bufs = 32;
1278 dev->ts.nr_packets = 32*4;
1279 dev->dvb.name = dev->name;
1280 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
1281 dev->pci, &dev->slock,
1282 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1283 V4L2_FIELD_ALTERNATE,
1284 sizeof(struct saa7134_buf),
1287 switch (dev->board) {
1288 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1289 printk("%s: pinnacle 300i dvb setup\n",dev->name);
1290 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1292 if (dev->dvb.frontend) {
1293 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1296 case SAA7134_BOARD_AVERMEDIA_777:
1297 case SAA7134_BOARD_AVERMEDIA_A16AR:
1298 printk("%s: avertv 777 dvb setup\n",dev->name);
1299 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1301 if (dev->dvb.frontend) {
1302 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
1305 case SAA7134_BOARD_MD7134:
1306 dev->dvb.frontend = dvb_attach(tda10046_attach,
1309 if (dev->dvb.frontend) {
1310 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1311 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1312 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1313 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Medion MD7134");
1316 case SAA7134_BOARD_PHILIPS_TOUGH:
1317 dev->dvb.frontend = dvb_attach(tda10046_attach,
1318 &philips_tu1216_60_config,
1320 if (dev->dvb.frontend) {
1321 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1322 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1323 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Philips TOUGH");
1326 case SAA7134_BOARD_FLYDVBTDUO:
1327 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1328 configure_tda827x_fe(dev, &tda827x_lifeview_config, "DVB-T Lifeview FlyDVB Duo");
1330 case SAA7134_BOARD_PHILIPS_EUROPA:
1331 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1332 dev->dvb.frontend = dvb_attach(tda10046_attach,
1333 &philips_europa_config,
1335 if (dev->dvb.frontend) {
1336 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1337 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1338 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1339 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1340 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1341 if (dev->board == SAA7134_BOARD_VIDEOMATE_DVBT_300)
1342 board_name = "DVB-T Compro VideoMate 300";
1344 board_name = "DVB-T Philips Europa";
1345 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
1348 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1349 dev->dvb.frontend = dvb_attach(tda10046_attach,
1350 &philips_tu1216_61_config,
1352 if (dev->dvb.frontend) {
1353 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1354 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1355 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Compro VideoMate 200");
1358 case SAA7134_BOARD_PHILIPS_TIGER:
1359 configure_tda827x_fe(dev, &philips_tiger_config, "DVB-T Philips Tiger");
1361 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1362 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, "DVB-T Pinnacle PCTV 310i");
1364 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1365 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, "DVB-T Hauppauge HVR 1110");
1367 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1368 configure_tda827x_fe(dev, &asus_p7131_dual_config, "DVB-T Asus P7137 Dual");
1370 case SAA7134_BOARD_FLYDVBT_LR301:
1371 configure_tda827x_fe(dev, &tda827x_lifeview_config, "DVB-T Lifeview FlyDVBT LR301");
1373 case SAA7134_BOARD_FLYDVB_TRIO:
1374 if(! use_frontend) { //terrestrial
1375 configure_tda827x_fe(dev, &lifeview_trio_config, NULL);
1376 } else { //satellite
1377 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1378 if (dev->dvb.frontend) {
1379 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1380 &dev->i2c_adap, 0) == NULL) {
1381 printk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
1383 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1384 0x08, 0, 0) == NULL) {
1385 printk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
1390 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1391 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1392 dev->dvb.frontend = dvb_attach(tda10046_attach,
1393 &ads_tech_duo_config,
1395 if (dev->dvb.frontend) {
1396 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1397 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1398 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_pll_set;
1399 if (dev->board == SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331)
1400 board_name = "DVB-T ADS DUO Cardbus PTV331";
1402 board_name = "DVB-T Lifeview FlyDVT Cardbus";
1403 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
1406 case SAA7134_BOARD_TEVION_DVBT_220RF:
1407 configure_tda827x_fe(dev, &tevion_dvbt220rf_config, "DVB-T Tevion 220RF");
1409 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1410 configure_tda827x_fe(dev, &md8800_dvbt_config, "DVB-T Medion MD8800");
1412 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1413 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1415 if (dev->dvb.frontend) {
1416 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1417 NULL, &dvb_pll_tdhu2);
1420 case SAA7134_BOARD_KWORLD_ATSC110:
1421 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1423 if (dev->dvb.frontend) {
1424 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1425 NULL, &dvb_pll_tuv1236d);
1428 case SAA7134_BOARD_FLYDVBS_LR300:
1429 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1431 if (dev->dvb.frontend) {
1432 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1433 &dev->i2c_adap, 0) == NULL) {
1434 printk("%s: No tda826x found!\n", __FUNCTION__);
1436 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1437 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1438 printk("%s: No ISL6421 found!\n", __FUNCTION__);
1442 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1443 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1445 if (dev->dvb.frontend) {
1446 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1447 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1448 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1449 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1450 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1451 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVBT Asus Europa 2 Hybrid");
1454 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1455 dev->dvb.frontend = dvb_attach(tda10046_attach,
1456 &philips_europa_config,
1458 if (dev->dvb.frontend) {
1459 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1460 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1461 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVBT Compro Videomate 200a");
1464 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1465 configure_tda827x_fe(dev, &cinergy_ht_config, "DVB-T Terratec Cinergy HT Cardbus");
1467 case SAA7134_BOARD_CINERGY_HT_PCI:
1468 configure_tda827x_fe(dev, &cinergy_ht_pci_config, "DVB-T Terratec Cinergy HT PCI");
1470 case SAA7134_BOARD_PHILIPS_TIGER_S:
1471 configure_tda827x_fe(dev, &philips_tiger_s_config, "DVB-T Philips Tiger S");
1474 printk("%s: Huh? unknown DVB card?\n",dev->name);
1478 if (NULL == dev->dvb.frontend) {
1479 printk("%s: frontend initialization failed\n",dev->name);
1483 /* register everything else */
1484 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1487 static int dvb_fini(struct saa7134_dev *dev)
1489 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1491 switch (dev->board) {
1492 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1493 /* otherwise we don't detect the tuner on next insmod */
1494 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1497 videobuf_dvb_unregister(&dev->dvb);
1501 static struct saa7134_mpeg_ops dvb_ops = {
1502 .type = SAA7134_MPEG_DVB,
1507 static int __init dvb_register(void)
1509 return saa7134_ts_register(&dvb_ops);
1512 static void __exit dvb_unregister(void)
1514 saa7134_ts_unregister(&dvb_ops);
1517 module_init(dvb_register);
1518 module_exit(dvb_unregister);
1520 /* ------------------------------------------------------------------ */