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 /* ------------------------------------------------------------------ */
54 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
59 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
60 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
64 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
65 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
68 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
69 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
71 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
73 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
74 printk("%s: %s %s\n", dev->name, __FUNCTION__,
78 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
82 static int mt352_pinnacle_init(struct dvb_frontend* fe)
84 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
85 static u8 reset [] = { RESET, 0x80 };
86 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
87 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
88 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
89 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
90 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
91 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
92 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
93 struct saa7134_dev *dev= fe->dvb->priv;
95 printk("%s: %s called\n",dev->name,__FUNCTION__);
97 mt352_write(fe, clock_config, sizeof(clock_config));
99 mt352_write(fe, reset, sizeof(reset));
100 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
101 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
102 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
103 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
105 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
106 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
107 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
112 static int mt352_aver777_init(struct dvb_frontend* fe)
114 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
115 static u8 reset [] = { RESET, 0x80 };
116 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
117 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
118 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
120 mt352_write(fe, clock_config, sizeof(clock_config));
122 mt352_write(fe, reset, sizeof(reset));
123 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
124 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
125 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
130 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
131 struct dvb_frontend_parameters* params)
133 u8 off[] = { 0x00, 0xf1};
134 u8 on[] = { 0x00, 0x71};
135 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
137 struct saa7134_dev *dev = fe->dvb->priv;
138 struct v4l2_frequency f;
140 /* set frequency (mt2050) */
142 f.type = V4L2_TUNER_DIGITAL_TV;
143 f.frequency = params->frequency / 1000 * 16 / 1000;
144 if (fe->ops.i2c_gate_ctrl)
145 fe->ops.i2c_gate_ctrl(fe, 1);
146 i2c_transfer(&dev->i2c_adap, &msg, 1);
147 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
149 if (fe->ops.i2c_gate_ctrl)
150 fe->ops.i2c_gate_ctrl(fe, 1);
151 i2c_transfer(&dev->i2c_adap, &msg, 1);
153 pinnacle_antenna_pwr(dev, antenna_pwr);
156 return mt352_pinnacle_init(fe);
159 static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
165 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
167 params->u.ofdm.bandwidth);
171 static struct mt352_config pinnacle_300i = {
172 .demod_address = 0x3c >> 1,
176 .demod_init = mt352_pinnacle_init,
179 static struct mt352_config avermedia_777 = {
180 .demod_address = 0xf,
181 .demod_init = mt352_aver777_init,
184 /* ------------------------------------------------------------------ */
185 static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
187 struct saa7134_dev *dev = fe->dvb->priv;
189 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
191 int tuner_frequency = 0;
194 /* determine charge pump */
195 tuner_frequency = params->frequency + 36166000;
196 if (tuner_frequency < 87000000)
198 else if (tuner_frequency < 130000000)
200 else if (tuner_frequency < 160000000)
202 else if (tuner_frequency < 200000000)
204 else if (tuner_frequency < 290000000)
206 else if (tuner_frequency < 420000000)
208 else if (tuner_frequency < 480000000)
210 else if (tuner_frequency < 620000000)
212 else if (tuner_frequency < 830000000)
214 else if (tuner_frequency < 895000000)
220 if (params->frequency < 49000000)
222 else if (params->frequency < 161000000)
224 else if (params->frequency < 444000000)
226 else if (params->frequency < 861000000)
231 /* setup PLL filter */
232 switch (params->u.ofdm.bandwidth) {
233 case BANDWIDTH_6_MHZ:
237 case BANDWIDTH_7_MHZ:
241 case BANDWIDTH_8_MHZ:
250 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
252 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
254 /* setup tuner buffer */
255 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
256 tuner_buf[1] = tuner_frequency & 0xff;
258 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
260 if (fe->ops.i2c_gate_ctrl)
261 fe->ops.i2c_gate_ctrl(fe, 1);
262 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
268 static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe)
270 struct saa7134_dev *dev = fe->dvb->priv;
271 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
272 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
274 /* setup PLL configuration */
275 if (fe->ops.i2c_gate_ctrl)
276 fe->ops.i2c_gate_ctrl(fe, 1);
277 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
284 /* ------------------------------------------------------------------ */
286 static int philips_tu1216_tuner_60_init(struct dvb_frontend *fe)
288 return philips_tda6651_pll_init(0x60, fe);
291 static int philips_tu1216_tuner_60_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
293 return philips_tda6651_pll_set(0x60, fe, params);
296 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
297 const struct firmware **fw, char *name)
299 struct saa7134_dev *dev = fe->dvb->priv;
300 return request_firmware(fw, name, &dev->pci->dev);
303 static struct tda1004x_config philips_tu1216_60_config = {
305 .demod_address = 0x8,
308 .xtal_freq = TDA10046_XTAL_4M,
309 .agc_config = TDA10046_AGC_DEFAULT,
310 .if_freq = TDA10046_FREQ_3617,
311 .request_firmware = philips_tda1004x_request_firmware,
314 /* ------------------------------------------------------------------ */
316 static int philips_tu1216_tuner_61_init(struct dvb_frontend *fe)
318 return philips_tda6651_pll_init(0x61, fe);
321 static int philips_tu1216_tuner_61_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
323 return philips_tda6651_pll_set(0x61, fe, params);
326 static struct tda1004x_config philips_tu1216_61_config = {
328 .demod_address = 0x8,
331 .xtal_freq = TDA10046_XTAL_4M,
332 .agc_config = TDA10046_AGC_DEFAULT,
333 .if_freq = TDA10046_FREQ_3617,
334 .request_firmware = philips_tda1004x_request_firmware,
337 /* ------------------------------------------------------------------ */
339 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
341 struct saa7134_dev *dev = fe->dvb->priv;
342 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
343 struct i2c_msg init_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
345 /* setup PLL configuration */
346 if (fe->ops.i2c_gate_ctrl)
347 fe->ops.i2c_gate_ctrl(fe, 1);
348 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
350 if (fe->ops.i2c_gate_ctrl)
351 fe->ops.i2c_gate_ctrl(fe, 0);
355 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
357 return philips_tda6651_pll_set(0x61, fe, params);
360 static int philips_europa_tuner_init(struct dvb_frontend *fe)
362 struct saa7134_dev *dev = fe->dvb->priv;
363 static u8 msg[] = { 0x00, 0x40};
364 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
367 if (philips_td1316_tuner_init(fe))
370 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
376 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
378 struct saa7134_dev *dev = fe->dvb->priv;
379 /* this message actually turns the tuner back to analog mode */
380 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
381 struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
383 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
386 /* switch the board to analog mode */
387 analog_msg.addr = 0x43;
388 analog_msg.len = 0x02;
391 if (fe->ops.i2c_gate_ctrl)
392 fe->ops.i2c_gate_ctrl(fe, 1);
393 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
397 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
399 struct saa7134_dev *dev = fe->dvb->priv;
401 if (dev->original_demod_sleep)
402 dev->original_demod_sleep(fe);
403 fe->ops.i2c_gate_ctrl(fe, 1);
407 static struct tda1004x_config philips_europa_config = {
409 .demod_address = 0x8,
412 .xtal_freq = TDA10046_XTAL_4M,
413 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
414 .if_freq = TDA10046_FREQ_052,
415 .request_firmware = NULL,
418 /* ------------------------------------------------------------------ */
420 static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
422 struct saa7134_dev *dev = fe->dvb->priv;
423 /* this message is to set up ATC and ALC */
424 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
425 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
427 if (fe->ops.i2c_gate_ctrl)
428 fe->ops.i2c_gate_ctrl(fe, 1);
429 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
436 static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
438 struct saa7134_dev *dev = fe->dvb->priv;
439 /* this message actually turns the tuner back to analog mode */
440 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
441 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
443 if (fe->ops.i2c_gate_ctrl)
444 fe->ops.i2c_gate_ctrl(fe, 1);
445 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
447 fmd1216_init[2] = 0x86;
448 fmd1216_init[3] = 0x54;
449 if (fe->ops.i2c_gate_ctrl)
450 fe->ops.i2c_gate_ctrl(fe, 1);
451 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
456 static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
458 struct saa7134_dev *dev = fe->dvb->priv;
460 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len =
462 int tuner_frequency = 0;
466 /* determine charge pump */
467 tuner_frequency = params->frequency + 36130000;
468 if (tuner_frequency < 87000000)
471 else if (tuner_frequency < 180000000) {
475 } else if (tuner_frequency < 195000000) {
480 } else if (tuner_frequency < 366000000) {
481 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
488 } else if (tuner_frequency < 478000000) {
489 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
497 } else if (tuner_frequency < 662000000) {
498 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
505 } else if (tuner_frequency < 840000000) {
506 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
514 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
523 /* calculate divisor */
524 /* ((36166000 + Finput) / 166666) rounded! */
525 divider = (tuner_frequency + 83333) / 166667;
527 /* setup tuner buffer */
528 tuner_buf[0] = (divider >> 8) & 0x7f;
529 tuner_buf[1] = divider & 0xff;
530 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
531 tuner_buf[3] = 0x40 | band;
533 if (fe->ops.i2c_gate_ctrl)
534 fe->ops.i2c_gate_ctrl(fe, 1);
535 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
540 static struct tda1004x_config medion_cardbus = {
541 .demod_address = 0x08,
544 .xtal_freq = TDA10046_XTAL_16M,
545 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
546 .if_freq = TDA10046_FREQ_3613,
547 .request_firmware = NULL,
550 /* ------------------------------------------------------------------ */
552 struct tda827x_data {
562 static struct tda827x_data tda827x_dvbt[] = {
563 { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
564 { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
565 { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
566 { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
567 { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
568 { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
569 { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
570 { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
571 { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
572 { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
573 { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
574 { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
575 { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
576 { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
577 { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
578 { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
579 { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
580 { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
581 { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
582 { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
583 { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
584 { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
585 { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
586 { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
587 { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
588 { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
589 { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
590 { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
591 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
594 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
599 static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
601 struct saa7134_dev *dev = fe->dvb->priv;
604 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,
605 .len = sizeof(tuner_buf) };
606 int i, tuner_freq, if_freq;
608 switch (params->u.ofdm.bandwidth) {
609 case BANDWIDTH_6_MHZ:
612 case BANDWIDTH_7_MHZ:
615 default: /* 8 MHz or Auto */
619 tuner_freq = params->frequency + if_freq;
622 while (tda827x_dvbt[i].lomax < tuner_freq) {
623 if(tda827x_dvbt[i + 1].lomax == 0)
628 N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
630 tuner_buf[1] = (N>>8) | 0x40;
631 tuner_buf[2] = N & 0xff;
634 tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
635 (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
636 tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
640 tuner_buf[10] = 0xff;
641 tuner_buf[11] = 0x00;
642 tuner_buf[12] = 0x00;
643 tuner_buf[13] = 0x40;
646 if (fe->ops.i2c_gate_ctrl)
647 fe->ops.i2c_gate_ctrl(fe, 1);
648 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
652 /* correct CP value */
654 tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
656 if (fe->ops.i2c_gate_ctrl)
657 fe->ops.i2c_gate_ctrl(fe, 1);
658 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
663 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
665 struct saa7134_dev *dev = fe->dvb->priv;
666 static u8 tda827x_sleep[] = { 0x30, 0xd0};
667 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
668 .len = sizeof(tda827x_sleep) };
669 if (fe->ops.i2c_gate_ctrl)
670 fe->ops.i2c_gate_ctrl(fe, 1);
671 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
675 static struct tda1004x_config tda827x_lifeview_config = {
676 .demod_address = 0x08,
679 .xtal_freq = TDA10046_XTAL_16M,
680 .agc_config = TDA10046_AGC_TDA827X,
681 .if_freq = TDA10046_FREQ_045,
682 .request_firmware = NULL,
685 /* ------------------------------------------------------------------ */
687 struct tda827xa_data {
696 static struct tda827xa_data tda827xa_dvbt[] = {
697 { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
698 { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
699 { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
700 { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
701 { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
702 { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
703 { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
704 { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
705 { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
706 { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
707 { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
708 { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
709 { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
710 { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
711 { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
712 { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
713 { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
714 { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
715 { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
716 { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
717 { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
718 { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
719 { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
720 { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
721 { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
722 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
723 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
726 static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
728 struct saa7134_dev *dev = fe->dvb->priv;
730 unsigned char reg2[2];
732 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
733 int i, tuner_freq, if_freq;
736 switch (params->u.ofdm.bandwidth) {
737 case BANDWIDTH_6_MHZ:
740 case BANDWIDTH_7_MHZ:
743 default: /* 8 MHz or Auto */
747 tuner_freq = params->frequency + if_freq;
750 while (tda827xa_dvbt[i].lomax < tuner_freq) {
751 if(tda827xa_dvbt[i + 1].lomax == 0)
756 N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
757 tuner_buf[0] = 0; // subaddress
758 tuner_buf[1] = N >> 8;
759 tuner_buf[2] = N & 0xff;
762 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
763 tda827xa_dvbt[i].sbs;
764 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
768 tuner_buf[10] = 0xff;
769 tuner_buf[11] = 0x60;
770 tuner_buf[12] = 0x00;
771 tuner_buf[13] = 0x39; // lpsel
773 if (fe->ops.i2c_gate_ctrl)
774 fe->ops.i2c_gate_ctrl(fe, 1);
775 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
782 if (fe->ops.i2c_gate_ctrl)
783 fe->ops.i2c_gate_ctrl(fe, 1);
784 i2c_transfer(&dev->i2c_adap, &msg, 1);
788 if (fe->ops.i2c_gate_ctrl)
789 fe->ops.i2c_gate_ctrl(fe, 1);
790 i2c_transfer(&dev->i2c_adap, &msg, 1);
793 /* correct CP value */
795 reg2[1] = 0x10 + tda827xa_dvbt[i].scr;
797 if (fe->ops.i2c_gate_ctrl)
798 fe->ops.i2c_gate_ctrl(fe, 1);
799 i2c_transfer(&dev->i2c_adap, &msg, 1);
803 reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
804 if (fe->ops.i2c_gate_ctrl)
805 fe->ops.i2c_gate_ctrl(fe, 1);
806 i2c_transfer(&dev->i2c_adap, &msg, 1);
812 static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe)
814 struct saa7134_dev *dev = fe->dvb->priv;
815 static u8 tda827xa_sleep[] = { 0x30, 0x90};
816 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
817 .len = sizeof(tda827xa_sleep) };
818 if (fe->ops.i2c_gate_ctrl)
819 fe->ops.i2c_gate_ctrl(fe, 1);
820 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
821 if (fe->ops.i2c_gate_ctrl)
822 fe->ops.i2c_gate_ctrl(fe, 0);
826 /* ------------------------------------------------------------------ */
828 static int tda8290_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
830 struct saa7134_dev *dev = fe->dvb->priv;
831 static u8 tda8290_close[] = { 0x21, 0xc0};
832 static u8 tda8290_open[] = { 0x21, 0x80};
833 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
835 tda8290_msg.buf = tda8290_close;
837 tda8290_msg.buf = tda8290_open;
839 if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1)
845 /* ------------------------------------------------------------------ */
847 static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
851 ret = philips_tda827xa_pll_set(0x61, fe, params);
857 static int philips_tiger_tuner_init(struct dvb_frontend *fe)
859 struct saa7134_dev *dev = fe->dvb->priv;
860 static u8 data[] = { 0x3c, 0x33, 0x6a};
861 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
863 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
868 static int philips_tiger_tuner_sleep(struct dvb_frontend *fe)
870 struct saa7134_dev *dev = fe->dvb->priv;
871 static u8 data[] = { 0x3c, 0x33, 0x68};
872 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
874 i2c_transfer(&dev->i2c_adap, &msg, 1);
875 philips_tda827xa_tuner_sleep( 0x61, fe);
879 static struct tda1004x_config philips_tiger_config = {
880 .demod_address = 0x08,
883 .xtal_freq = TDA10046_XTAL_16M,
884 .agc_config = TDA10046_AGC_TDA827X,
885 .if_freq = TDA10046_FREQ_045,
886 .request_firmware = NULL,
889 /* ------------------------------------------------------------------ */
891 static struct tda1004x_config pinnacle_pctv_310i_config = {
892 .demod_address = 0x08,
895 .xtal_freq = TDA10046_XTAL_16M,
896 .agc_config = TDA10046_AGC_TDA827X,
897 .if_freq = TDA10046_FREQ_045,
898 .request_firmware = philips_tda1004x_request_firmware,
901 /* ------------------------------------------------------------------ */
903 static struct tda1004x_config asus_p7131_dual_config = {
904 .demod_address = 0x08,
907 .xtal_freq = TDA10046_XTAL_16M,
908 .agc_config = TDA10046_AGC_TDA827X,
909 .if_freq = TDA10046_FREQ_045,
910 .request_firmware = philips_tda1004x_request_firmware,
913 static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
915 struct saa7134_dev *dev = fe->dvb->priv;
916 static u8 data[] = { 0x3c, 0x33, 0x6a};
917 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
919 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
921 /* make sure the DVB-T antenna input is set */
922 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
926 static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
928 struct saa7134_dev *dev = fe->dvb->priv;
929 static u8 data[] = { 0x3c, 0x33, 0x68};
930 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
932 i2c_transfer(&dev->i2c_adap, &msg, 1);
933 philips_tda827xa_tuner_sleep( 0x61, fe);
934 /* reset antenna inputs for analog usage */
935 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
939 /* ------------------------------------------------------------------ */
941 static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
945 ret = philips_tda827xa_pll_set(0x60, fe, params);
949 static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
951 philips_tda827xa_tuner_sleep(0x60, fe);
955 static struct tda1004x_config lifeview_trio_config = {
956 .demod_address = 0x09,
959 .xtal_freq = TDA10046_XTAL_16M,
960 .agc_config = TDA10046_AGC_TDA827X_GPL,
961 .if_freq = TDA10046_FREQ_045,
962 .request_firmware = NULL,
965 /* ------------------------------------------------------------------ */
967 static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
971 ret = philips_tda827xa_pll_set(0x61, fe, params);
975 static int ads_duo_tuner_init(struct dvb_frontend *fe)
977 struct saa7134_dev *dev = fe->dvb->priv;
978 /* route TDA8275a AGC input to the channel decoder */
979 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
983 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
985 struct saa7134_dev *dev = fe->dvb->priv;
986 /* route TDA8275a AGC input to the analog IF chip*/
987 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
988 philips_tda827xa_tuner_sleep( 0x61, fe);
992 static struct tda1004x_config ads_tech_duo_config = {
993 .demod_address = 0x08,
996 .xtal_freq = TDA10046_XTAL_16M,
997 .agc_config = TDA10046_AGC_TDA827X_GPL,
998 .if_freq = TDA10046_FREQ_045,
999 .request_firmware = NULL,
1002 /* ------------------------------------------------------------------ */
1004 static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1007 ret = philips_tda827xa_pll_set(0x60, fe, params);
1011 static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
1013 philips_tda827xa_tuner_sleep( 0x61, fe);
1017 static struct tda1004x_config tevion_dvbt220rf_config = {
1018 .demod_address = 0x08,
1021 .xtal_freq = TDA10046_XTAL_16M,
1022 .agc_config = TDA10046_AGC_TDA827X,
1023 .if_freq = TDA10046_FREQ_045,
1024 .request_firmware = NULL,
1027 /* ------------------------------------------------------------------ */
1029 static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
1031 struct saa7134_dev *dev = fe->dvb->priv;
1032 static u8 data[] = { 0x3c, 0x33, 0x68};
1033 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
1035 i2c_transfer(&dev->i2c_adap, &msg, 1);
1036 philips_tda827xa_tuner_sleep( 0x61, fe);
1040 static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1043 struct saa7134_dev *dev = fe->dvb->priv;
1044 static u8 tda8290_close[] = { 0x21, 0xc0};
1045 static u8 tda8290_open[] = { 0x21, 0x80};
1046 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
1047 /* close tda8290 i2c bridge */
1048 tda8290_msg.buf = tda8290_close;
1049 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1053 ret = philips_tda827xa_pll_set(0x60, fe, params);
1056 /* open tda8290 i2c bridge */
1057 tda8290_msg.buf = tda8290_open;
1058 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1062 static struct tda1004x_config md8800_dvbt_config = {
1063 .demod_address = 0x08,
1066 .xtal_freq = TDA10046_XTAL_16M,
1067 .agc_config = TDA10046_AGC_TDA827X,
1068 .if_freq = TDA10046_FREQ_045,
1069 .request_firmware = NULL,
1072 static struct tda10086_config flydvbs = {
1073 .demod_address = 0x0e,
1077 /* ------------------------------------------------------------------ */
1079 static struct nxt200x_config avertvhda180 = {
1080 .demod_address = 0x0a,
1083 static int nxt200x_set_pll_input(u8 *buf, int input)
1092 static struct nxt200x_config kworldatsc110 = {
1093 .demod_address = 0x0a,
1094 .set_pll_input = nxt200x_set_pll_input,
1097 /* ------------------------------------------------------------------ */
1099 static int dvb_init(struct saa7134_dev *dev)
1101 /* init struct videobuf_dvb */
1102 dev->ts.nr_bufs = 32;
1103 dev->ts.nr_packets = 32*4;
1104 dev->dvb.name = dev->name;
1105 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
1106 dev->pci, &dev->slock,
1107 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1108 V4L2_FIELD_ALTERNATE,
1109 sizeof(struct saa7134_buf),
1112 switch (dev->board) {
1113 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1114 printk("%s: pinnacle 300i dvb setup\n",dev->name);
1115 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1117 if (dev->dvb.frontend) {
1118 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1121 case SAA7134_BOARD_AVERMEDIA_777:
1122 case SAA7134_BOARD_AVERMEDIA_A16AR:
1123 printk("%s: avertv 777 dvb setup\n",dev->name);
1124 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1126 if (dev->dvb.frontend) {
1127 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
1130 case SAA7134_BOARD_MD7134:
1131 dev->dvb.frontend = dvb_attach(tda10046_attach,
1134 if (dev->dvb.frontend) {
1135 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1136 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1137 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1140 case SAA7134_BOARD_PHILIPS_TOUGH:
1141 dev->dvb.frontend = dvb_attach(tda10046_attach,
1142 &philips_tu1216_60_config,
1144 if (dev->dvb.frontend) {
1145 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
1146 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
1149 case SAA7134_BOARD_FLYDVBTDUO:
1150 dev->dvb.frontend = dvb_attach(tda10046_attach,
1151 &tda827x_lifeview_config,
1153 if (dev->dvb.frontend) {
1154 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1155 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1156 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1159 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1160 dev->dvb.frontend = dvb_attach(tda10046_attach,
1161 &tda827x_lifeview_config,
1163 if (dev->dvb.frontend) {
1164 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1165 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1166 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1169 case SAA7134_BOARD_PHILIPS_EUROPA:
1170 dev->dvb.frontend = dvb_attach(tda10046_attach,
1171 &philips_europa_config,
1173 if (dev->dvb.frontend) {
1174 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1175 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1176 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1177 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1178 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1181 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1182 dev->dvb.frontend = dvb_attach(tda10046_attach,
1183 &philips_europa_config,
1185 if (dev->dvb.frontend) {
1186 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1187 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1188 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1189 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1190 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1193 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1194 dev->dvb.frontend = dvb_attach(tda10046_attach,
1195 &philips_tu1216_61_config,
1197 if (dev->dvb.frontend) {
1198 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
1199 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
1202 case SAA7134_BOARD_PHILIPS_TIGER:
1203 dev->dvb.frontend = dvb_attach(tda10046_attach,
1204 &philips_tiger_config,
1206 if (dev->dvb.frontend) {
1207 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1208 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1209 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1210 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1213 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1214 dev->dvb.frontend = dvb_attach(tda10046_attach,
1215 &pinnacle_pctv_310i_config,
1217 if (dev->dvb.frontend) {
1218 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1219 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1220 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1221 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1224 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1225 dev->dvb.frontend = dvb_attach(tda10046_attach,
1226 &asus_p7131_dual_config,
1228 if (dev->dvb.frontend) {
1229 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1230 dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
1231 dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
1232 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1235 case SAA7134_BOARD_FLYDVBT_LR301:
1236 dev->dvb.frontend = dvb_attach(tda10046_attach,
1237 &tda827x_lifeview_config,
1239 if (dev->dvb.frontend) {
1240 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1241 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1242 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1245 case SAA7134_BOARD_FLYDVB_TRIO:
1246 dev->dvb.frontend = dvb_attach(tda10046_attach,
1247 &lifeview_trio_config,
1249 if (dev->dvb.frontend) {
1250 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1251 dev->dvb.frontend->ops.tuner_ops.set_params = lifeview_trio_tuner_set_params;
1254 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1255 dev->dvb.frontend = dvb_attach(tda10046_attach,
1256 &ads_tech_duo_config,
1258 if (dev->dvb.frontend) {
1259 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1260 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1261 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1264 case SAA7134_BOARD_TEVION_DVBT_220RF:
1265 dev->dvb.frontend = dvb_attach(tda10046_attach,
1266 &tevion_dvbt220rf_config,
1268 if (dev->dvb.frontend) {
1269 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1270 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
1273 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1274 dev->dvb.frontend = dvb_attach(tda10046_attach,
1275 &ads_tech_duo_config,
1277 if (dev->dvb.frontend) {
1278 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1279 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1280 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1283 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1284 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
1286 if (dev->dvb.frontend) {
1287 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1288 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1289 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1292 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1293 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1295 if (dev->dvb.frontend) {
1296 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1297 NULL, &dvb_pll_tdhu2);
1300 case SAA7134_BOARD_KWORLD_ATSC110:
1301 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1303 if (dev->dvb.frontend) {
1304 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1305 NULL, &dvb_pll_tuv1236d);
1308 case SAA7134_BOARD_FLYDVBS_LR300:
1309 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1311 if (dev->dvb.frontend) {
1312 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1313 &dev->i2c_adap, 0) == NULL) {
1314 printk("%s: No tda826x found!\n", __FUNCTION__);
1316 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1317 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1318 printk("%s: No ISL6421 found!\n", __FUNCTION__);
1322 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1323 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1325 if (dev->dvb.frontend) {
1326 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1327 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1328 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1329 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1330 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1333 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1334 dev->dvb.frontend = dvb_attach(tda10046_attach,
1335 &philips_europa_config,
1337 if (dev->dvb.frontend) {
1338 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1339 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1343 printk("%s: Huh? unknown DVB card?\n",dev->name);
1347 if (NULL == dev->dvb.frontend) {
1348 printk("%s: frontend initialization failed\n",dev->name);
1352 /* register everything else */
1353 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1356 static int dvb_fini(struct saa7134_dev *dev)
1358 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1360 switch (dev->board) {
1361 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1362 /* otherwise we don't detect the tuner on next insmod */
1363 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1366 videobuf_dvb_unregister(&dev->dvb);
1370 static struct saa7134_mpeg_ops dvb_ops = {
1371 .type = SAA7134_MPEG_DVB,
1376 static int __init dvb_register(void)
1378 return saa7134_ts_register(&dvb_ops);
1381 static void __exit dvb_unregister(void)
1383 saa7134_ts_unregister(&dvb_ops);
1386 module_init(dvb_register);
1387 module_exit(dvb_unregister);
1389 /* ------------------------------------------------------------------ */