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 = philips_tda1004x_request_firmware,
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 = philips_tda1004x_request_firmware,
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,
685 .gpio_config = TDA10046_GP11_I,
686 .if_freq = TDA10046_FREQ_045,
687 .request_firmware = philips_tda1004x_request_firmware,
690 /* ------------------------------------------------------------------ */
692 struct tda827xa_data {
701 static struct tda827xa_data tda827xa_dvbt[] = {
702 { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
703 { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
704 { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
705 { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
706 { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
707 { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
708 { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
709 { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
710 { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
711 { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
712 { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
713 { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
714 { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
715 { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
716 { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
717 { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
718 { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
719 { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
720 { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
721 { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
722 { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
723 { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
724 { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
725 { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
726 { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
727 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
728 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
731 static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
733 struct saa7134_dev *dev = fe->dvb->priv;
735 unsigned char reg2[2];
737 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
738 int i, tuner_freq, if_freq;
741 switch (params->u.ofdm.bandwidth) {
742 case BANDWIDTH_6_MHZ:
745 case BANDWIDTH_7_MHZ:
748 default: /* 8 MHz or Auto */
752 tuner_freq = params->frequency + if_freq;
755 while (tda827xa_dvbt[i].lomax < tuner_freq) {
756 if(tda827xa_dvbt[i + 1].lomax == 0)
761 N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
762 tuner_buf[0] = 0; // subaddress
763 tuner_buf[1] = N >> 8;
764 tuner_buf[2] = N & 0xff;
767 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
768 tda827xa_dvbt[i].sbs;
769 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
773 tuner_buf[10] = 0xff;
774 tuner_buf[11] = 0x60;
775 tuner_buf[12] = 0x00;
776 tuner_buf[13] = 0x39; // lpsel
778 if (fe->ops.i2c_gate_ctrl)
779 fe->ops.i2c_gate_ctrl(fe, 1);
780 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
787 if (fe->ops.i2c_gate_ctrl)
788 fe->ops.i2c_gate_ctrl(fe, 1);
789 i2c_transfer(&dev->i2c_adap, &msg, 1);
793 if (fe->ops.i2c_gate_ctrl)
794 fe->ops.i2c_gate_ctrl(fe, 1);
795 i2c_transfer(&dev->i2c_adap, &msg, 1);
798 /* correct CP value */
800 reg2[1] = 0x10 + tda827xa_dvbt[i].scr;
802 if (fe->ops.i2c_gate_ctrl)
803 fe->ops.i2c_gate_ctrl(fe, 1);
804 i2c_transfer(&dev->i2c_adap, &msg, 1);
808 reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
809 if (fe->ops.i2c_gate_ctrl)
810 fe->ops.i2c_gate_ctrl(fe, 1);
811 i2c_transfer(&dev->i2c_adap, &msg, 1);
817 static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe)
819 struct saa7134_dev *dev = fe->dvb->priv;
820 static u8 tda827xa_sleep[] = { 0x30, 0x90};
821 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
822 .len = sizeof(tda827xa_sleep) };
823 if (fe->ops.i2c_gate_ctrl)
824 fe->ops.i2c_gate_ctrl(fe, 1);
825 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
826 if (fe->ops.i2c_gate_ctrl)
827 fe->ops.i2c_gate_ctrl(fe, 0);
831 /* ------------------------------------------------------------------ */
833 static int tda8290_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
835 struct saa7134_dev *dev = fe->dvb->priv;
836 static u8 tda8290_close[] = { 0x21, 0xc0};
837 static u8 tda8290_open[] = { 0x21, 0x80};
838 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
840 tda8290_msg.buf = tda8290_close;
842 tda8290_msg.buf = tda8290_open;
844 if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1)
850 /* ------------------------------------------------------------------ */
852 static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
856 ret = philips_tda827xa_pll_set(0x61, fe, params);
862 static int philips_tiger_tuner_init(struct dvb_frontend *fe)
864 struct saa7134_dev *dev = fe->dvb->priv;
865 static u8 data[] = { 0x3c, 0x33, 0x6a};
866 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
868 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
873 static int philips_tiger_tuner_sleep(struct dvb_frontend *fe)
875 struct saa7134_dev *dev = fe->dvb->priv;
876 static u8 data[] = { 0x3c, 0x33, 0x68};
877 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
879 i2c_transfer(&dev->i2c_adap, &msg, 1);
880 philips_tda827xa_tuner_sleep( 0x61, fe);
884 static struct tda1004x_config philips_tiger_config = {
885 .demod_address = 0x08,
888 .xtal_freq = TDA10046_XTAL_16M,
889 .agc_config = TDA10046_AGC_TDA827X,
890 .gpio_config = TDA10046_GP11_I,
891 .if_freq = TDA10046_FREQ_045,
892 .request_firmware = philips_tda1004x_request_firmware,
894 /* ------------------------------------------------------------------ */
896 static int cinergy_ht_tuner_init(struct dvb_frontend *fe)
898 struct saa7134_dev *dev = fe->dvb->priv;
899 static u8 data[] = { 0x3c, 0x33, 0x62};
900 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
902 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
907 static int cinergy_ht_tuner_sleep(struct dvb_frontend *fe)
909 struct saa7134_dev *dev = fe->dvb->priv;
910 static u8 data[] = { 0x3c, 0x33, 0x60};
911 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
913 i2c_transfer(&dev->i2c_adap, &msg, 1);
914 philips_tda827xa_tuner_sleep( 0x61, fe);
918 static struct tda1004x_config cinergy_ht_config = {
919 .demod_address = 0x08,
922 .xtal_freq = TDA10046_XTAL_16M,
923 .agc_config = TDA10046_AGC_TDA827X,
924 .gpio_config = TDA10046_GP01_I,
925 .if_freq = TDA10046_FREQ_045,
926 .request_firmware = philips_tda1004x_request_firmware,
929 /* ------------------------------------------------------------------ */
931 static struct tda1004x_config pinnacle_pctv_310i_config = {
932 .demod_address = 0x08,
935 .xtal_freq = TDA10046_XTAL_16M,
936 .agc_config = TDA10046_AGC_TDA827X,
937 .gpio_config = TDA10046_GP11_I,
938 .if_freq = TDA10046_FREQ_045,
939 .request_firmware = philips_tda1004x_request_firmware,
942 /* ------------------------------------------------------------------ */
944 static struct tda1004x_config hauppauge_hvr_1110_config = {
945 .demod_address = 0x08,
948 .xtal_freq = TDA10046_XTAL_16M,
949 .agc_config = TDA10046_AGC_TDA827X,
950 .gpio_config = TDA10046_GP11_I,
951 .if_freq = TDA10046_FREQ_045,
952 .request_firmware = philips_tda1004x_request_firmware,
955 /* ------------------------------------------------------------------ */
957 static struct tda1004x_config asus_p7131_dual_config = {
958 .demod_address = 0x08,
961 .xtal_freq = TDA10046_XTAL_16M,
962 .agc_config = TDA10046_AGC_TDA827X,
963 .gpio_config = TDA10046_GP11_I,
964 .if_freq = TDA10046_FREQ_045,
965 .request_firmware = philips_tda1004x_request_firmware,
968 static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
970 struct saa7134_dev *dev = fe->dvb->priv;
971 static u8 data[] = { 0x3c, 0x33, 0x6a};
972 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
974 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
976 /* make sure the DVB-T antenna input is set */
977 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
981 static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
983 struct saa7134_dev *dev = fe->dvb->priv;
984 static u8 data[] = { 0x3c, 0x33, 0x68};
985 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
987 i2c_transfer(&dev->i2c_adap, &msg, 1);
988 philips_tda827xa_tuner_sleep( 0x61, fe);
989 /* reset antenna inputs for analog usage */
990 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
994 /* ------------------------------------------------------------------ */
996 static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1000 ret = philips_tda827xa_pll_set(0x60, fe, params);
1004 static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
1006 philips_tda827xa_tuner_sleep(0x60, fe);
1010 static struct tda1004x_config lifeview_trio_config = {
1011 .demod_address = 0x09,
1014 .xtal_freq = TDA10046_XTAL_16M,
1015 .agc_config = TDA10046_AGC_TDA827X,
1016 .gpio_config = TDA10046_GP00_I,
1017 .if_freq = TDA10046_FREQ_045,
1018 .request_firmware = philips_tda1004x_request_firmware,
1021 /* ------------------------------------------------------------------ */
1023 static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1027 ret = philips_tda827xa_pll_set(0x61, fe, params);
1031 static int ads_duo_tuner_init(struct dvb_frontend *fe)
1033 struct saa7134_dev *dev = fe->dvb->priv;
1034 /* route TDA8275a AGC input to the channel decoder */
1035 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
1039 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
1041 struct saa7134_dev *dev = fe->dvb->priv;
1042 /* route TDA8275a AGC input to the analog IF chip*/
1043 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
1044 philips_tda827xa_tuner_sleep( 0x61, fe);
1048 static struct tda1004x_config ads_tech_duo_config = {
1049 .demod_address = 0x08,
1052 .xtal_freq = TDA10046_XTAL_16M,
1053 .agc_config = TDA10046_AGC_TDA827X,
1054 .gpio_config = TDA10046_GP00_I,
1055 .if_freq = TDA10046_FREQ_045,
1056 .request_firmware = philips_tda1004x_request_firmware,
1059 /* ------------------------------------------------------------------ */
1061 static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1064 ret = philips_tda827xa_pll_set(0x60, fe, params);
1068 static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
1070 philips_tda827xa_tuner_sleep( 0x61, fe);
1074 static struct tda1004x_config tevion_dvbt220rf_config = {
1075 .demod_address = 0x08,
1078 .xtal_freq = TDA10046_XTAL_16M,
1079 .agc_config = TDA10046_AGC_TDA827X,
1080 .gpio_config = TDA10046_GP11_I,
1081 .if_freq = TDA10046_FREQ_045,
1082 .request_firmware = philips_tda1004x_request_firmware,
1085 /* ------------------------------------------------------------------ */
1087 static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
1089 struct saa7134_dev *dev = fe->dvb->priv;
1090 static u8 data[] = { 0x3c, 0x33, 0x68};
1091 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
1093 i2c_transfer(&dev->i2c_adap, &msg, 1);
1094 philips_tda827xa_tuner_sleep( 0x61, fe);
1098 static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1101 struct saa7134_dev *dev = fe->dvb->priv;
1102 static u8 tda8290_close[] = { 0x21, 0xc0};
1103 static u8 tda8290_open[] = { 0x21, 0x80};
1104 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
1105 /* close tda8290 i2c bridge */
1106 tda8290_msg.buf = tda8290_close;
1107 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1111 ret = philips_tda827xa_pll_set(0x60, fe, params);
1114 /* open tda8290 i2c bridge */
1115 tda8290_msg.buf = tda8290_open;
1116 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1120 static struct tda1004x_config md8800_dvbt_config = {
1121 .demod_address = 0x08,
1124 .xtal_freq = TDA10046_XTAL_16M,
1125 .agc_config = TDA10046_AGC_TDA827X,
1126 .gpio_config = TDA10046_GP11_I,
1127 .if_freq = TDA10046_FREQ_045,
1128 .request_firmware = philips_tda1004x_request_firmware,
1131 static struct tda10086_config flydvbs = {
1132 .demod_address = 0x0e,
1136 /* ------------------------------------------------------------------ */
1138 static struct nxt200x_config avertvhda180 = {
1139 .demod_address = 0x0a,
1142 static int nxt200x_set_pll_input(u8 *buf, int input)
1151 static struct nxt200x_config kworldatsc110 = {
1152 .demod_address = 0x0a,
1153 .set_pll_input = nxt200x_set_pll_input,
1156 /* ------------------------------------------------------------------ */
1158 static int dvb_init(struct saa7134_dev *dev)
1160 /* init struct videobuf_dvb */
1161 dev->ts.nr_bufs = 32;
1162 dev->ts.nr_packets = 32*4;
1163 dev->dvb.name = dev->name;
1164 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
1165 dev->pci, &dev->slock,
1166 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1167 V4L2_FIELD_ALTERNATE,
1168 sizeof(struct saa7134_buf),
1171 switch (dev->board) {
1172 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1173 printk("%s: pinnacle 300i dvb setup\n",dev->name);
1174 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1176 if (dev->dvb.frontend) {
1177 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1180 case SAA7134_BOARD_AVERMEDIA_777:
1181 case SAA7134_BOARD_AVERMEDIA_A16AR:
1182 printk("%s: avertv 777 dvb setup\n",dev->name);
1183 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1185 if (dev->dvb.frontend) {
1186 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
1189 case SAA7134_BOARD_MD7134:
1190 dev->dvb.frontend = dvb_attach(tda10046_attach,
1193 if (dev->dvb.frontend) {
1194 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1195 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1196 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1199 case SAA7134_BOARD_PHILIPS_TOUGH:
1200 dev->dvb.frontend = dvb_attach(tda10046_attach,
1201 &philips_tu1216_60_config,
1203 if (dev->dvb.frontend) {
1204 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
1205 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
1208 case SAA7134_BOARD_FLYDVBTDUO:
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_FLYDVBT_DUO_CARDBUS:
1219 dev->dvb.frontend = dvb_attach(tda10046_attach,
1220 &tda827x_lifeview_config,
1222 if (dev->dvb.frontend) {
1223 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1224 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1225 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1228 case SAA7134_BOARD_PHILIPS_EUROPA:
1229 dev->dvb.frontend = dvb_attach(tda10046_attach,
1230 &philips_europa_config,
1232 if (dev->dvb.frontend) {
1233 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1234 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1235 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1236 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1237 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1240 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1241 dev->dvb.frontend = dvb_attach(tda10046_attach,
1242 &philips_europa_config,
1244 if (dev->dvb.frontend) {
1245 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1246 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1247 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1248 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1249 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1252 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1253 dev->dvb.frontend = dvb_attach(tda10046_attach,
1254 &philips_tu1216_61_config,
1256 if (dev->dvb.frontend) {
1257 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
1258 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
1261 case SAA7134_BOARD_PHILIPS_TIGER:
1262 dev->dvb.frontend = dvb_attach(tda10046_attach,
1263 &philips_tiger_config,
1265 if (dev->dvb.frontend) {
1266 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1267 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1268 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1269 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1272 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1273 dev->dvb.frontend = dvb_attach(tda10046_attach,
1274 &pinnacle_pctv_310i_config,
1276 if (dev->dvb.frontend) {
1277 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1278 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1279 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1280 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1283 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1284 dev->dvb.frontend = dvb_attach(tda10046_attach,
1285 &hauppauge_hvr_1110_config,
1287 if (dev->dvb.frontend) {
1288 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1289 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1290 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1291 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1294 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1295 dev->dvb.frontend = dvb_attach(tda10046_attach,
1296 &asus_p7131_dual_config,
1298 if (dev->dvb.frontend) {
1299 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1300 dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
1301 dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
1302 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1305 case SAA7134_BOARD_FLYDVBT_LR301:
1306 dev->dvb.frontend = dvb_attach(tda10046_attach,
1307 &tda827x_lifeview_config,
1309 if (dev->dvb.frontend) {
1310 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1311 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1312 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1315 case SAA7134_BOARD_FLYDVB_TRIO:
1316 if(! use_frontend) { //terrestrial
1317 dev->dvb.frontend = dvb_attach(tda10046_attach,
1318 &lifeview_trio_config,
1320 if (dev->dvb.frontend) {
1321 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1322 dev->dvb.frontend->ops.tuner_ops.set_params =
1323 lifeview_trio_tuner_set_params;
1325 } else { //satellite
1326 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1327 if (dev->dvb.frontend) {
1328 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1329 &dev->i2c_adap, 0) == NULL) {
1330 printk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
1332 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1333 0x08, 0, 0) == NULL) {
1334 printk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
1339 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1340 dev->dvb.frontend = dvb_attach(tda10046_attach,
1341 &ads_tech_duo_config,
1343 if (dev->dvb.frontend) {
1344 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1345 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1346 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1349 case SAA7134_BOARD_TEVION_DVBT_220RF:
1350 dev->dvb.frontend = dvb_attach(tda10046_attach,
1351 &tevion_dvbt220rf_config,
1353 if (dev->dvb.frontend) {
1354 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1355 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
1358 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1359 dev->dvb.frontend = dvb_attach(tda10046_attach,
1360 &ads_tech_duo_config,
1362 if (dev->dvb.frontend) {
1363 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1364 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1365 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1368 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1369 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
1371 if (dev->dvb.frontend) {
1372 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1373 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1374 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1377 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1378 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1380 if (dev->dvb.frontend) {
1381 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1382 NULL, &dvb_pll_tdhu2);
1385 case SAA7134_BOARD_KWORLD_ATSC110:
1386 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1388 if (dev->dvb.frontend) {
1389 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1390 NULL, &dvb_pll_tuv1236d);
1393 case SAA7134_BOARD_FLYDVBS_LR300:
1394 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1396 if (dev->dvb.frontend) {
1397 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1398 &dev->i2c_adap, 0) == NULL) {
1399 printk("%s: No tda826x found!\n", __FUNCTION__);
1401 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1402 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1403 printk("%s: No ISL6421 found!\n", __FUNCTION__);
1407 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1408 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1410 if (dev->dvb.frontend) {
1411 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1412 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1413 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1414 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1415 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1418 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1419 dev->dvb.frontend = dvb_attach(tda10046_attach,
1420 &philips_europa_config,
1422 if (dev->dvb.frontend) {
1423 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1424 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1427 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1428 dev->dvb.frontend = dvb_attach(tda10046_attach,
1431 if (dev->dvb.frontend) {
1432 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1433 dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
1434 dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
1435 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1439 case SAA7134_BOARD_CINERGY_HT_PCI:
1440 dev->dvb.frontend = dvb_attach(tda10046_attach,
1443 if (dev->dvb.frontend) {
1444 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1445 dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
1446 dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
1447 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1452 printk("%s: Huh? unknown DVB card?\n",dev->name);
1456 if (NULL == dev->dvb.frontend) {
1457 printk("%s: frontend initialization failed\n",dev->name);
1461 /* register everything else */
1462 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1465 static int dvb_fini(struct saa7134_dev *dev)
1467 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1469 switch (dev->board) {
1470 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1471 /* otherwise we don't detect the tuner on next insmod */
1472 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1475 videobuf_dvb_unregister(&dev->dvb);
1479 static struct saa7134_mpeg_ops dvb_ops = {
1480 .type = SAA7134_MPEG_DVB,
1485 static int __init dvb_register(void)
1487 return saa7134_ts_register(&dvb_ops);
1490 static void __exit dvb_unregister(void)
1492 saa7134_ts_unregister(&dvb_ops);
1495 module_init(dvb_register);
1496 module_exit(dvb_unregister);
1498 /* ------------------------------------------------------------------ */