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)");
57 /* ------------------------------------------------------------------ */
58 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
63 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
64 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
68 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
69 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
72 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
73 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
75 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
77 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
78 printk("%s: %s %s\n", dev->name, __FUNCTION__,
82 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
86 static int mt352_pinnacle_init(struct dvb_frontend* fe)
88 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
89 static u8 reset [] = { RESET, 0x80 };
90 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
91 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
92 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
93 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
94 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
95 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
96 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
97 struct saa7134_dev *dev= fe->dvb->priv;
99 printk("%s: %s called\n",dev->name,__FUNCTION__);
101 mt352_write(fe, clock_config, sizeof(clock_config));
103 mt352_write(fe, reset, sizeof(reset));
104 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
105 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
106 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
107 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
109 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
110 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
111 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
116 static int mt352_aver777_init(struct dvb_frontend* fe)
118 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
119 static u8 reset [] = { RESET, 0x80 };
120 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
121 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
122 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
124 mt352_write(fe, clock_config, sizeof(clock_config));
126 mt352_write(fe, reset, sizeof(reset));
127 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
128 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
129 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
134 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
135 struct dvb_frontend_parameters* params)
137 u8 off[] = { 0x00, 0xf1};
138 u8 on[] = { 0x00, 0x71};
139 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
141 struct saa7134_dev *dev = fe->dvb->priv;
142 struct v4l2_frequency f;
144 /* set frequency (mt2050) */
146 f.type = V4L2_TUNER_DIGITAL_TV;
147 f.frequency = params->frequency / 1000 * 16 / 1000;
148 if (fe->ops.i2c_gate_ctrl)
149 fe->ops.i2c_gate_ctrl(fe, 1);
150 i2c_transfer(&dev->i2c_adap, &msg, 1);
151 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
153 if (fe->ops.i2c_gate_ctrl)
154 fe->ops.i2c_gate_ctrl(fe, 1);
155 i2c_transfer(&dev->i2c_adap, &msg, 1);
157 pinnacle_antenna_pwr(dev, antenna_pwr);
160 return mt352_pinnacle_init(fe);
163 static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
169 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
171 params->u.ofdm.bandwidth);
175 static struct mt352_config pinnacle_300i = {
176 .demod_address = 0x3c >> 1,
180 .demod_init = mt352_pinnacle_init,
183 static struct mt352_config avermedia_777 = {
184 .demod_address = 0xf,
185 .demod_init = mt352_aver777_init,
188 /* ------------------------------------------------------------------ */
189 static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
191 struct saa7134_dev *dev = fe->dvb->priv;
193 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
195 int tuner_frequency = 0;
198 /* determine charge pump */
199 tuner_frequency = params->frequency + 36166000;
200 if (tuner_frequency < 87000000)
202 else if (tuner_frequency < 130000000)
204 else if (tuner_frequency < 160000000)
206 else if (tuner_frequency < 200000000)
208 else if (tuner_frequency < 290000000)
210 else if (tuner_frequency < 420000000)
212 else if (tuner_frequency < 480000000)
214 else if (tuner_frequency < 620000000)
216 else if (tuner_frequency < 830000000)
218 else if (tuner_frequency < 895000000)
224 if (params->frequency < 49000000)
226 else if (params->frequency < 161000000)
228 else if (params->frequency < 444000000)
230 else if (params->frequency < 861000000)
235 /* setup PLL filter */
236 switch (params->u.ofdm.bandwidth) {
237 case BANDWIDTH_6_MHZ:
241 case BANDWIDTH_7_MHZ:
245 case BANDWIDTH_8_MHZ:
254 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
256 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
258 /* setup tuner buffer */
259 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
260 tuner_buf[1] = tuner_frequency & 0xff;
262 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
264 if (fe->ops.i2c_gate_ctrl)
265 fe->ops.i2c_gate_ctrl(fe, 1);
266 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
272 static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe)
274 struct saa7134_dev *dev = fe->dvb->priv;
275 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
276 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
278 /* setup PLL configuration */
279 if (fe->ops.i2c_gate_ctrl)
280 fe->ops.i2c_gate_ctrl(fe, 1);
281 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
288 /* ------------------------------------------------------------------ */
290 static int philips_tu1216_tuner_60_init(struct dvb_frontend *fe)
292 return philips_tda6651_pll_init(0x60, fe);
295 static int philips_tu1216_tuner_60_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
297 return philips_tda6651_pll_set(0x60, fe, params);
300 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
301 const struct firmware **fw, char *name)
303 struct saa7134_dev *dev = fe->dvb->priv;
304 return request_firmware(fw, name, &dev->pci->dev);
307 static struct tda1004x_config philips_tu1216_60_config = {
309 .demod_address = 0x8,
312 .xtal_freq = TDA10046_XTAL_4M,
313 .agc_config = TDA10046_AGC_DEFAULT,
314 .if_freq = TDA10046_FREQ_3617,
315 .request_firmware = philips_tda1004x_request_firmware,
318 /* ------------------------------------------------------------------ */
320 static int philips_tu1216_tuner_61_init(struct dvb_frontend *fe)
322 return philips_tda6651_pll_init(0x61, fe);
325 static int philips_tu1216_tuner_61_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
327 return philips_tda6651_pll_set(0x61, fe, params);
330 static struct tda1004x_config philips_tu1216_61_config = {
332 .demod_address = 0x8,
335 .xtal_freq = TDA10046_XTAL_4M,
336 .agc_config = TDA10046_AGC_DEFAULT,
337 .if_freq = TDA10046_FREQ_3617,
338 .request_firmware = philips_tda1004x_request_firmware,
341 /* ------------------------------------------------------------------ */
343 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
345 struct saa7134_dev *dev = fe->dvb->priv;
346 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
347 struct i2c_msg init_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
349 /* setup PLL configuration */
350 if (fe->ops.i2c_gate_ctrl)
351 fe->ops.i2c_gate_ctrl(fe, 1);
352 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
354 if (fe->ops.i2c_gate_ctrl)
355 fe->ops.i2c_gate_ctrl(fe, 0);
359 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
361 return philips_tda6651_pll_set(0x61, fe, params);
364 static int philips_europa_tuner_init(struct dvb_frontend *fe)
366 struct saa7134_dev *dev = fe->dvb->priv;
367 static u8 msg[] = { 0x00, 0x40};
368 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
371 if (philips_td1316_tuner_init(fe))
374 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
380 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
382 struct saa7134_dev *dev = fe->dvb->priv;
383 /* this message actually turns the tuner back to analog mode */
384 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
385 struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
387 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
390 /* switch the board to analog mode */
391 analog_msg.addr = 0x43;
392 analog_msg.len = 0x02;
395 if (fe->ops.i2c_gate_ctrl)
396 fe->ops.i2c_gate_ctrl(fe, 1);
397 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
401 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
403 struct saa7134_dev *dev = fe->dvb->priv;
405 if (dev->original_demod_sleep)
406 dev->original_demod_sleep(fe);
407 fe->ops.i2c_gate_ctrl(fe, 1);
411 static struct tda1004x_config philips_europa_config = {
413 .demod_address = 0x8,
416 .xtal_freq = TDA10046_XTAL_4M,
417 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
418 .if_freq = TDA10046_FREQ_052,
419 .request_firmware = NULL,
422 /* ------------------------------------------------------------------ */
424 static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
426 struct saa7134_dev *dev = fe->dvb->priv;
427 /* this message is to set up ATC and ALC */
428 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
429 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
431 if (fe->ops.i2c_gate_ctrl)
432 fe->ops.i2c_gate_ctrl(fe, 1);
433 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
440 static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
442 struct saa7134_dev *dev = fe->dvb->priv;
443 /* this message actually turns the tuner back to analog mode */
444 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
445 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
447 if (fe->ops.i2c_gate_ctrl)
448 fe->ops.i2c_gate_ctrl(fe, 1);
449 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
451 fmd1216_init[2] = 0x86;
452 fmd1216_init[3] = 0x54;
453 if (fe->ops.i2c_gate_ctrl)
454 fe->ops.i2c_gate_ctrl(fe, 1);
455 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
460 static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
462 struct saa7134_dev *dev = fe->dvb->priv;
464 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len =
466 int tuner_frequency = 0;
470 /* determine charge pump */
471 tuner_frequency = params->frequency + 36130000;
472 if (tuner_frequency < 87000000)
475 else if (tuner_frequency < 180000000) {
479 } else if (tuner_frequency < 195000000) {
484 } else if (tuner_frequency < 366000000) {
485 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
492 } else if (tuner_frequency < 478000000) {
493 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
501 } else if (tuner_frequency < 662000000) {
502 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
509 } else if (tuner_frequency < 840000000) {
510 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
518 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
527 /* calculate divisor */
528 /* ((36166000 + Finput) / 166666) rounded! */
529 divider = (tuner_frequency + 83333) / 166667;
531 /* setup tuner buffer */
532 tuner_buf[0] = (divider >> 8) & 0x7f;
533 tuner_buf[1] = divider & 0xff;
534 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
535 tuner_buf[3] = 0x40 | band;
537 if (fe->ops.i2c_gate_ctrl)
538 fe->ops.i2c_gate_ctrl(fe, 1);
539 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
544 static struct tda1004x_config medion_cardbus = {
545 .demod_address = 0x08,
548 .xtal_freq = TDA10046_XTAL_16M,
549 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
550 .if_freq = TDA10046_FREQ_3613,
551 .request_firmware = NULL,
554 /* ------------------------------------------------------------------ */
556 struct tda827x_data {
566 static struct tda827x_data tda827x_dvbt[] = {
567 { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
568 { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
569 { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
570 { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
571 { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
572 { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
573 { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
574 { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
575 { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
576 { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
577 { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
578 { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
579 { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
580 { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
581 { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
582 { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
583 { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
584 { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
585 { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
586 { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
587 { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
588 { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
589 { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
590 { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
591 { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
592 { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
593 { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
594 { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
595 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
598 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
603 static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
605 struct saa7134_dev *dev = fe->dvb->priv;
608 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,
609 .len = sizeof(tuner_buf) };
610 int i, tuner_freq, if_freq;
612 switch (params->u.ofdm.bandwidth) {
613 case BANDWIDTH_6_MHZ:
616 case BANDWIDTH_7_MHZ:
619 default: /* 8 MHz or Auto */
623 tuner_freq = params->frequency + if_freq;
626 while (tda827x_dvbt[i].lomax < tuner_freq) {
627 if(tda827x_dvbt[i + 1].lomax == 0)
632 N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
634 tuner_buf[1] = (N>>8) | 0x40;
635 tuner_buf[2] = N & 0xff;
638 tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
639 (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
640 tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
644 tuner_buf[10] = 0xff;
645 tuner_buf[11] = 0x00;
646 tuner_buf[12] = 0x00;
647 tuner_buf[13] = 0x40;
650 if (fe->ops.i2c_gate_ctrl)
651 fe->ops.i2c_gate_ctrl(fe, 1);
652 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
656 /* correct CP value */
658 tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
660 if (fe->ops.i2c_gate_ctrl)
661 fe->ops.i2c_gate_ctrl(fe, 1);
662 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
667 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
669 struct saa7134_dev *dev = fe->dvb->priv;
670 static u8 tda827x_sleep[] = { 0x30, 0xd0};
671 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
672 .len = sizeof(tda827x_sleep) };
673 if (fe->ops.i2c_gate_ctrl)
674 fe->ops.i2c_gate_ctrl(fe, 1);
675 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
679 static struct tda1004x_config tda827x_lifeview_config = {
680 .demod_address = 0x08,
683 .xtal_freq = TDA10046_XTAL_16M,
684 .agc_config = TDA10046_AGC_TDA827X_GP11,
685 .if_freq = TDA10046_FREQ_045,
686 .request_firmware = NULL,
689 /* ------------------------------------------------------------------ */
691 struct tda827xa_data {
700 static struct tda827xa_data tda827xa_dvbt[] = {
701 { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
702 { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
703 { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
704 { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
705 { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
706 { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
707 { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
708 { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
709 { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
710 { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
711 { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
712 { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
713 { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
714 { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
715 { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
716 { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
717 { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
718 { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
719 { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
720 { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
721 { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
722 { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
723 { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
724 { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
725 { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
726 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
727 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
730 static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
732 struct saa7134_dev *dev = fe->dvb->priv;
734 unsigned char reg2[2];
736 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
737 int i, tuner_freq, if_freq;
740 switch (params->u.ofdm.bandwidth) {
741 case BANDWIDTH_6_MHZ:
744 case BANDWIDTH_7_MHZ:
747 default: /* 8 MHz or Auto */
751 tuner_freq = params->frequency + if_freq;
754 while (tda827xa_dvbt[i].lomax < tuner_freq) {
755 if(tda827xa_dvbt[i + 1].lomax == 0)
760 N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
761 tuner_buf[0] = 0; // subaddress
762 tuner_buf[1] = N >> 8;
763 tuner_buf[2] = N & 0xff;
766 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
767 tda827xa_dvbt[i].sbs;
768 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
772 tuner_buf[10] = 0xff;
773 tuner_buf[11] = 0x60;
774 tuner_buf[12] = 0x00;
775 tuner_buf[13] = 0x39; // lpsel
777 if (fe->ops.i2c_gate_ctrl)
778 fe->ops.i2c_gate_ctrl(fe, 1);
779 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
786 if (fe->ops.i2c_gate_ctrl)
787 fe->ops.i2c_gate_ctrl(fe, 1);
788 i2c_transfer(&dev->i2c_adap, &msg, 1);
792 if (fe->ops.i2c_gate_ctrl)
793 fe->ops.i2c_gate_ctrl(fe, 1);
794 i2c_transfer(&dev->i2c_adap, &msg, 1);
797 /* correct CP value */
799 reg2[1] = 0x10 + tda827xa_dvbt[i].scr;
801 if (fe->ops.i2c_gate_ctrl)
802 fe->ops.i2c_gate_ctrl(fe, 1);
803 i2c_transfer(&dev->i2c_adap, &msg, 1);
807 reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
808 if (fe->ops.i2c_gate_ctrl)
809 fe->ops.i2c_gate_ctrl(fe, 1);
810 i2c_transfer(&dev->i2c_adap, &msg, 1);
816 static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe)
818 struct saa7134_dev *dev = fe->dvb->priv;
819 static u8 tda827xa_sleep[] = { 0x30, 0x90};
820 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
821 .len = sizeof(tda827xa_sleep) };
822 if (fe->ops.i2c_gate_ctrl)
823 fe->ops.i2c_gate_ctrl(fe, 1);
824 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
825 if (fe->ops.i2c_gate_ctrl)
826 fe->ops.i2c_gate_ctrl(fe, 0);
830 /* ------------------------------------------------------------------ */
832 static int tda8290_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
834 struct saa7134_dev *dev = fe->dvb->priv;
835 static u8 tda8290_close[] = { 0x21, 0xc0};
836 static u8 tda8290_open[] = { 0x21, 0x80};
837 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
839 tda8290_msg.buf = tda8290_close;
841 tda8290_msg.buf = tda8290_open;
843 if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1)
849 /* ------------------------------------------------------------------ */
851 static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
855 ret = philips_tda827xa_pll_set(0x61, fe, params);
861 static int philips_tiger_tuner_init(struct dvb_frontend *fe)
863 struct saa7134_dev *dev = fe->dvb->priv;
864 static u8 data[] = { 0x3c, 0x33, 0x6a};
865 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
867 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
872 static int philips_tiger_tuner_sleep(struct dvb_frontend *fe)
874 struct saa7134_dev *dev = fe->dvb->priv;
875 static u8 data[] = { 0x3c, 0x33, 0x68};
876 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
878 i2c_transfer(&dev->i2c_adap, &msg, 1);
879 philips_tda827xa_tuner_sleep( 0x61, fe);
883 static struct tda1004x_config philips_tiger_config = {
884 .demod_address = 0x08,
887 .xtal_freq = TDA10046_XTAL_16M,
888 .agc_config = TDA10046_AGC_TDA827X_GP11,
889 .if_freq = TDA10046_FREQ_045,
890 .request_firmware = NULL,
892 /* ------------------------------------------------------------------ */
894 static int cinergy_ht_tuner_init(struct dvb_frontend *fe)
896 struct saa7134_dev *dev = fe->dvb->priv;
897 static u8 data[] = { 0x3c, 0x33, 0x62};
898 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
900 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
905 static int cinergy_ht_tuner_sleep(struct dvb_frontend *fe)
907 struct saa7134_dev *dev = fe->dvb->priv;
908 static u8 data[] = { 0x3c, 0x33, 0x60};
909 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
911 i2c_transfer(&dev->i2c_adap, &msg, 1);
912 philips_tda827xa_tuner_sleep( 0x61, fe);
916 static struct tda1004x_config cinergy_ht_config = {
917 .demod_address = 0x08,
920 .xtal_freq = TDA10046_XTAL_16M,
921 .agc_config = TDA10046_AGC_TDA827X_GP01,
922 .if_freq = TDA10046_FREQ_045,
923 .request_firmware = NULL,
926 /* ------------------------------------------------------------------ */
928 static struct tda1004x_config pinnacle_pctv_310i_config = {
929 .demod_address = 0x08,
932 .xtal_freq = TDA10046_XTAL_16M,
933 .agc_config = TDA10046_AGC_TDA827X_GP11,
934 .if_freq = TDA10046_FREQ_045,
935 .request_firmware = philips_tda1004x_request_firmware,
938 /* ------------------------------------------------------------------ */
940 static struct tda1004x_config hauppauge_hvr_1110_config = {
941 .demod_address = 0x08,
944 .xtal_freq = TDA10046_XTAL_16M,
945 .agc_config = TDA10046_AGC_TDA827X_GP11,
946 .if_freq = TDA10046_FREQ_045,
947 .request_firmware = philips_tda1004x_request_firmware,
950 /* ------------------------------------------------------------------ */
952 static struct tda1004x_config asus_p7131_dual_config = {
953 .demod_address = 0x08,
956 .xtal_freq = TDA10046_XTAL_16M,
957 .agc_config = TDA10046_AGC_TDA827X_GP11,
958 .if_freq = TDA10046_FREQ_045,
959 .request_firmware = philips_tda1004x_request_firmware,
962 static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
964 struct saa7134_dev *dev = fe->dvb->priv;
965 static u8 data[] = { 0x3c, 0x33, 0x6a};
966 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
968 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
970 /* make sure the DVB-T antenna input is set */
971 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
975 static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
977 struct saa7134_dev *dev = fe->dvb->priv;
978 static u8 data[] = { 0x3c, 0x33, 0x68};
979 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
981 i2c_transfer(&dev->i2c_adap, &msg, 1);
982 philips_tda827xa_tuner_sleep( 0x61, fe);
983 /* reset antenna inputs for analog usage */
984 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
988 /* ------------------------------------------------------------------ */
990 static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
994 ret = philips_tda827xa_pll_set(0x60, fe, params);
998 static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
1000 philips_tda827xa_tuner_sleep(0x60, fe);
1004 static struct tda1004x_config lifeview_trio_config = {
1005 .demod_address = 0x09,
1008 .xtal_freq = TDA10046_XTAL_16M,
1009 .agc_config = TDA10046_AGC_TDA827X_GP00,
1010 .if_freq = TDA10046_FREQ_045,
1011 .request_firmware = NULL,
1014 /* ------------------------------------------------------------------ */
1016 static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1020 ret = philips_tda827xa_pll_set(0x61, fe, params);
1024 static int ads_duo_tuner_init(struct dvb_frontend *fe)
1026 struct saa7134_dev *dev = fe->dvb->priv;
1027 /* route TDA8275a AGC input to the channel decoder */
1028 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
1032 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
1034 struct saa7134_dev *dev = fe->dvb->priv;
1035 /* route TDA8275a AGC input to the analog IF chip*/
1036 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
1037 philips_tda827xa_tuner_sleep( 0x61, fe);
1041 static struct tda1004x_config ads_tech_duo_config = {
1042 .demod_address = 0x08,
1045 .xtal_freq = TDA10046_XTAL_16M,
1046 .agc_config = TDA10046_AGC_TDA827X_GP00,
1047 .if_freq = TDA10046_FREQ_045,
1048 .request_firmware = NULL,
1051 /* ------------------------------------------------------------------ */
1053 static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1056 ret = philips_tda827xa_pll_set(0x60, fe, params);
1060 static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
1062 philips_tda827xa_tuner_sleep( 0x61, fe);
1066 static struct tda1004x_config tevion_dvbt220rf_config = {
1067 .demod_address = 0x08,
1070 .xtal_freq = TDA10046_XTAL_16M,
1071 .agc_config = TDA10046_AGC_TDA827X_GP11,
1072 .if_freq = TDA10046_FREQ_045,
1073 .request_firmware = NULL,
1076 /* ------------------------------------------------------------------ */
1078 static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
1080 struct saa7134_dev *dev = fe->dvb->priv;
1081 static u8 data[] = { 0x3c, 0x33, 0x68};
1082 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
1084 i2c_transfer(&dev->i2c_adap, &msg, 1);
1085 philips_tda827xa_tuner_sleep( 0x61, fe);
1089 static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1092 struct saa7134_dev *dev = fe->dvb->priv;
1093 static u8 tda8290_close[] = { 0x21, 0xc0};
1094 static u8 tda8290_open[] = { 0x21, 0x80};
1095 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
1096 /* close tda8290 i2c bridge */
1097 tda8290_msg.buf = tda8290_close;
1098 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1102 ret = philips_tda827xa_pll_set(0x60, fe, params);
1105 /* open tda8290 i2c bridge */
1106 tda8290_msg.buf = tda8290_open;
1107 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1111 static struct tda1004x_config md8800_dvbt_config = {
1112 .demod_address = 0x08,
1115 .xtal_freq = TDA10046_XTAL_16M,
1116 .agc_config = TDA10046_AGC_TDA827X_GP11,
1117 .if_freq = TDA10046_FREQ_045,
1118 .request_firmware = NULL,
1121 static struct tda10086_config flydvbs = {
1122 .demod_address = 0x0e,
1126 /* ------------------------------------------------------------------ */
1128 static struct nxt200x_config avertvhda180 = {
1129 .demod_address = 0x0a,
1132 static int nxt200x_set_pll_input(u8 *buf, int input)
1141 static struct nxt200x_config kworldatsc110 = {
1142 .demod_address = 0x0a,
1143 .set_pll_input = nxt200x_set_pll_input,
1146 /* ------------------------------------------------------------------ */
1148 static int dvb_init(struct saa7134_dev *dev)
1150 /* init struct videobuf_dvb */
1151 dev->ts.nr_bufs = 32;
1152 dev->ts.nr_packets = 32*4;
1153 dev->dvb.name = dev->name;
1154 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
1155 dev->pci, &dev->slock,
1156 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1157 V4L2_FIELD_ALTERNATE,
1158 sizeof(struct saa7134_buf),
1161 switch (dev->board) {
1162 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1163 printk("%s: pinnacle 300i dvb setup\n",dev->name);
1164 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1166 if (dev->dvb.frontend) {
1167 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1170 case SAA7134_BOARD_AVERMEDIA_777:
1171 case SAA7134_BOARD_AVERMEDIA_A16AR:
1172 printk("%s: avertv 777 dvb setup\n",dev->name);
1173 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1175 if (dev->dvb.frontend) {
1176 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
1179 case SAA7134_BOARD_MD7134:
1180 dev->dvb.frontend = dvb_attach(tda10046_attach,
1183 if (dev->dvb.frontend) {
1184 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1185 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1186 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1189 case SAA7134_BOARD_PHILIPS_TOUGH:
1190 dev->dvb.frontend = dvb_attach(tda10046_attach,
1191 &philips_tu1216_60_config,
1193 if (dev->dvb.frontend) {
1194 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
1195 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
1198 case SAA7134_BOARD_FLYDVBTDUO:
1199 dev->dvb.frontend = dvb_attach(tda10046_attach,
1200 &tda827x_lifeview_config,
1202 if (dev->dvb.frontend) {
1203 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1204 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1205 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1208 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1209 dev->dvb.frontend = dvb_attach(tda10046_attach,
1210 &tda827x_lifeview_config,
1212 if (dev->dvb.frontend) {
1213 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1214 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1215 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1218 case SAA7134_BOARD_PHILIPS_EUROPA:
1219 dev->dvb.frontend = dvb_attach(tda10046_attach,
1220 &philips_europa_config,
1222 if (dev->dvb.frontend) {
1223 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1224 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1225 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1226 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1227 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1230 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1231 dev->dvb.frontend = dvb_attach(tda10046_attach,
1232 &philips_europa_config,
1234 if (dev->dvb.frontend) {
1235 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1236 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1237 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1238 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1239 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1242 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1243 dev->dvb.frontend = dvb_attach(tda10046_attach,
1244 &philips_tu1216_61_config,
1246 if (dev->dvb.frontend) {
1247 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
1248 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
1251 case SAA7134_BOARD_PHILIPS_TIGER:
1252 dev->dvb.frontend = dvb_attach(tda10046_attach,
1253 &philips_tiger_config,
1255 if (dev->dvb.frontend) {
1256 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1257 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1258 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1259 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1262 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1263 dev->dvb.frontend = dvb_attach(tda10046_attach,
1264 &pinnacle_pctv_310i_config,
1266 if (dev->dvb.frontend) {
1267 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1268 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1269 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1270 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1273 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1274 dev->dvb.frontend = dvb_attach(tda10046_attach,
1275 &hauppauge_hvr_1110_config,
1277 if (dev->dvb.frontend) {
1278 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1279 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1280 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1281 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1284 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1285 dev->dvb.frontend = dvb_attach(tda10046_attach,
1286 &asus_p7131_dual_config,
1288 if (dev->dvb.frontend) {
1289 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1290 dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
1291 dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
1292 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1295 case SAA7134_BOARD_FLYDVBT_LR301:
1296 dev->dvb.frontend = dvb_attach(tda10046_attach,
1297 &tda827x_lifeview_config,
1299 if (dev->dvb.frontend) {
1300 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1301 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1302 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1305 case SAA7134_BOARD_FLYDVB_TRIO:
1306 if(! use_frontend) { //terrestrial
1307 dev->dvb.frontend = dvb_attach(tda10046_attach,
1308 &lifeview_trio_config,
1310 if (dev->dvb.frontend) {
1311 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1312 dev->dvb.frontend->ops.tuner_ops.set_params =
1313 lifeview_trio_tuner_set_params;
1315 } else { //satellite
1316 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1317 if (dev->dvb.frontend) {
1318 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1319 &dev->i2c_adap, 0) == NULL) {
1320 printk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
1322 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1323 0x08, 0, 0) == NULL) {
1324 printk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
1329 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1330 dev->dvb.frontend = dvb_attach(tda10046_attach,
1331 &ads_tech_duo_config,
1333 if (dev->dvb.frontend) {
1334 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1335 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1336 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1339 case SAA7134_BOARD_TEVION_DVBT_220RF:
1340 dev->dvb.frontend = dvb_attach(tda10046_attach,
1341 &tevion_dvbt220rf_config,
1343 if (dev->dvb.frontend) {
1344 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1345 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
1348 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1349 dev->dvb.frontend = dvb_attach(tda10046_attach,
1350 &ads_tech_duo_config,
1352 if (dev->dvb.frontend) {
1353 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1354 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1355 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1358 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1359 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
1361 if (dev->dvb.frontend) {
1362 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1363 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1364 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1367 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1368 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1370 if (dev->dvb.frontend) {
1371 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1372 NULL, &dvb_pll_tdhu2);
1375 case SAA7134_BOARD_KWORLD_ATSC110:
1376 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1378 if (dev->dvb.frontend) {
1379 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1380 NULL, &dvb_pll_tuv1236d);
1383 case SAA7134_BOARD_FLYDVBS_LR300:
1384 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1386 if (dev->dvb.frontend) {
1387 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1388 &dev->i2c_adap, 0) == NULL) {
1389 printk("%s: No tda826x found!\n", __FUNCTION__);
1391 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1392 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1393 printk("%s: No ISL6421 found!\n", __FUNCTION__);
1397 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1398 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1400 if (dev->dvb.frontend) {
1401 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1402 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1403 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1404 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1405 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1408 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1409 dev->dvb.frontend = dvb_attach(tda10046_attach,
1410 &philips_europa_config,
1412 if (dev->dvb.frontend) {
1413 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1414 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1417 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1418 dev->dvb.frontend = dvb_attach(tda10046_attach,
1421 if (dev->dvb.frontend) {
1422 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1423 dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
1424 dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
1425 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1430 printk("%s: Huh? unknown DVB card?\n",dev->name);
1434 if (NULL == dev->dvb.frontend) {
1435 printk("%s: frontend initialization failed\n",dev->name);
1439 /* register everything else */
1440 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1443 static int dvb_fini(struct saa7134_dev *dev)
1445 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1447 switch (dev->board) {
1448 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1449 /* otherwise we don't detect the tuner on next insmod */
1450 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1453 videobuf_dvb_unregister(&dev->dvb);
1457 static struct saa7134_mpeg_ops dvb_ops = {
1458 .type = SAA7134_MPEG_DVB,
1463 static int __init dvb_register(void)
1465 return saa7134_ts_register(&dvb_ops);
1468 static void __exit dvb_unregister(void)
1470 saa7134_ts_unregister(&dvb_ops);
1473 module_init(dvb_register);
1474 module_exit(dvb_unregister);
1476 /* ------------------------------------------------------------------ */