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_europa_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)
352 /* switch the board to dvb mode */
353 init_msg.addr = 0x43;
357 if (fe->ops.i2c_gate_ctrl)
358 fe->ops.i2c_gate_ctrl(fe, 1);
359 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
365 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
367 return philips_tda6651_pll_set(0x61, fe, params);
370 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
372 struct saa7134_dev *dev = fe->dvb->priv;
373 /* this message actually turns the tuner back to analog mode */
374 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
375 struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
377 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
380 /* switch the board to analog mode */
381 analog_msg.addr = 0x43;
382 analog_msg.len = 0x02;
385 if (fe->ops.i2c_gate_ctrl)
386 fe->ops.i2c_gate_ctrl(fe, 1);
387 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
391 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
393 struct saa7134_dev *dev = fe->dvb->priv;
395 if (dev->original_demod_sleep)
396 dev->original_demod_sleep(fe);
397 fe->ops.i2c_gate_ctrl(fe, 1);
401 static struct tda1004x_config philips_europa_config = {
403 .demod_address = 0x8,
406 .xtal_freq = TDA10046_XTAL_4M,
407 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
408 .if_freq = TDA10046_FREQ_052,
409 .request_firmware = NULL,
412 /* ------------------------------------------------------------------ */
414 static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
416 struct saa7134_dev *dev = fe->dvb->priv;
417 /* this message is to set up ATC and ALC */
418 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
419 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
421 if (fe->ops.i2c_gate_ctrl)
422 fe->ops.i2c_gate_ctrl(fe, 1);
423 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
430 static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
432 struct saa7134_dev *dev = fe->dvb->priv;
433 /* this message actually turns the tuner back to analog mode */
434 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
435 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
437 if (fe->ops.i2c_gate_ctrl)
438 fe->ops.i2c_gate_ctrl(fe, 1);
439 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
441 fmd1216_init[2] = 0x86;
442 fmd1216_init[3] = 0x54;
443 if (fe->ops.i2c_gate_ctrl)
444 fe->ops.i2c_gate_ctrl(fe, 1);
445 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
450 static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
452 struct saa7134_dev *dev = fe->dvb->priv;
454 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len =
456 int tuner_frequency = 0;
460 /* determine charge pump */
461 tuner_frequency = params->frequency + 36130000;
462 if (tuner_frequency < 87000000)
465 else if (tuner_frequency < 180000000) {
469 } else if (tuner_frequency < 195000000) {
474 } else if (tuner_frequency < 366000000) {
475 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
482 } else if (tuner_frequency < 478000000) {
483 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
491 } else if (tuner_frequency < 662000000) {
492 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
499 } else if (tuner_frequency < 840000000) {
500 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
508 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
517 /* calculate divisor */
518 /* ((36166000 + Finput) / 166666) rounded! */
519 divider = (tuner_frequency + 83333) / 166667;
521 /* setup tuner buffer */
522 tuner_buf[0] = (divider >> 8) & 0x7f;
523 tuner_buf[1] = divider & 0xff;
524 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
525 tuner_buf[3] = 0x40 | band;
527 if (fe->ops.i2c_gate_ctrl)
528 fe->ops.i2c_gate_ctrl(fe, 1);
529 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
534 static struct tda1004x_config medion_cardbus = {
535 .demod_address = 0x08,
538 .xtal_freq = TDA10046_XTAL_16M,
539 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
540 .if_freq = TDA10046_FREQ_3613,
541 .request_firmware = NULL,
544 /* ------------------------------------------------------------------ */
546 struct tda827x_data {
556 static struct tda827x_data tda827x_dvbt[] = {
557 { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
558 { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
559 { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
560 { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
561 { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
562 { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
563 { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
564 { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
565 { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
566 { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
567 { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
568 { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
569 { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
570 { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
571 { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
572 { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
573 { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
574 { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
575 { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
576 { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
577 { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
578 { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
579 { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
580 { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
581 { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
582 { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
583 { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
584 { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
585 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
588 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
593 static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
595 struct saa7134_dev *dev = fe->dvb->priv;
598 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,
599 .len = sizeof(tuner_buf) };
600 int i, tuner_freq, if_freq;
602 switch (params->u.ofdm.bandwidth) {
603 case BANDWIDTH_6_MHZ:
606 case BANDWIDTH_7_MHZ:
609 default: /* 8 MHz or Auto */
613 tuner_freq = params->frequency + if_freq;
616 while (tda827x_dvbt[i].lomax < tuner_freq) {
617 if(tda827x_dvbt[i + 1].lomax == 0)
622 N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
624 tuner_buf[1] = (N>>8) | 0x40;
625 tuner_buf[2] = N & 0xff;
628 tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
629 (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
630 tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
634 tuner_buf[10] = 0xff;
635 tuner_buf[11] = 0x00;
636 tuner_buf[12] = 0x00;
637 tuner_buf[13] = 0x40;
640 if (fe->ops.i2c_gate_ctrl)
641 fe->ops.i2c_gate_ctrl(fe, 1);
642 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
646 /* correct CP value */
648 tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
650 if (fe->ops.i2c_gate_ctrl)
651 fe->ops.i2c_gate_ctrl(fe, 1);
652 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
657 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
659 struct saa7134_dev *dev = fe->dvb->priv;
660 static u8 tda827x_sleep[] = { 0x30, 0xd0};
661 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
662 .len = sizeof(tda827x_sleep) };
663 if (fe->ops.i2c_gate_ctrl)
664 fe->ops.i2c_gate_ctrl(fe, 1);
665 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
669 static struct tda1004x_config tda827x_lifeview_config = {
670 .demod_address = 0x08,
673 .xtal_freq = TDA10046_XTAL_16M,
674 .agc_config = TDA10046_AGC_TDA827X,
675 .if_freq = TDA10046_FREQ_045,
676 .request_firmware = NULL,
679 /* ------------------------------------------------------------------ */
681 struct tda827xa_data {
690 static struct tda827xa_data tda827xa_dvbt[] = {
691 { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
692 { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
693 { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
694 { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
695 { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
696 { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
697 { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
698 { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
699 { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
700 { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
701 { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
702 { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
703 { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
704 { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
705 { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
706 { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
707 { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
708 { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
709 { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
710 { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
711 { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
712 { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
713 { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
714 { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
715 { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
716 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
717 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
720 static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
722 struct saa7134_dev *dev = fe->dvb->priv;
724 unsigned char reg2[2];
726 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
727 int i, tuner_freq, if_freq;
730 switch (params->u.ofdm.bandwidth) {
731 case BANDWIDTH_6_MHZ:
734 case BANDWIDTH_7_MHZ:
737 default: /* 8 MHz or Auto */
741 tuner_freq = params->frequency + if_freq;
744 while (tda827xa_dvbt[i].lomax < tuner_freq) {
745 if(tda827xa_dvbt[i + 1].lomax == 0)
750 N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
751 tuner_buf[0] = 0; // subaddress
752 tuner_buf[1] = N >> 8;
753 tuner_buf[2] = N & 0xff;
756 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
757 tda827xa_dvbt[i].sbs;
758 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
762 tuner_buf[10] = 0xff;
763 tuner_buf[11] = 0x60;
764 tuner_buf[12] = 0x00;
765 tuner_buf[13] = 0x39; // lpsel
767 if (fe->ops.i2c_gate_ctrl)
768 fe->ops.i2c_gate_ctrl(fe, 1);
769 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
776 if (fe->ops.i2c_gate_ctrl)
777 fe->ops.i2c_gate_ctrl(fe, 1);
778 i2c_transfer(&dev->i2c_adap, &msg, 1);
782 if (fe->ops.i2c_gate_ctrl)
783 fe->ops.i2c_gate_ctrl(fe, 1);
784 i2c_transfer(&dev->i2c_adap, &msg, 1);
787 /* correct CP value */
789 reg2[1] = 0x10 + tda827xa_dvbt[i].scr;
791 if (fe->ops.i2c_gate_ctrl)
792 fe->ops.i2c_gate_ctrl(fe, 1);
793 i2c_transfer(&dev->i2c_adap, &msg, 1);
797 reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
798 if (fe->ops.i2c_gate_ctrl)
799 fe->ops.i2c_gate_ctrl(fe, 1);
800 i2c_transfer(&dev->i2c_adap, &msg, 1);
806 static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe)
808 struct saa7134_dev *dev = fe->dvb->priv;
809 static u8 tda827xa_sleep[] = { 0x30, 0x90};
810 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
811 .len = sizeof(tda827xa_sleep) };
812 if (fe->ops.i2c_gate_ctrl)
813 fe->ops.i2c_gate_ctrl(fe, 1);
814 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
815 if (fe->ops.i2c_gate_ctrl)
816 fe->ops.i2c_gate_ctrl(fe, 0);
820 /* ------------------------------------------------------------------ */
822 static int tda8290_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
824 struct saa7134_dev *dev = fe->dvb->priv;
825 static u8 tda8290_close[] = { 0x21, 0xc0};
826 static u8 tda8290_open[] = { 0x21, 0x80};
827 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
829 tda8290_msg.buf = tda8290_close;
831 tda8290_msg.buf = tda8290_open;
833 if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1)
839 /* ------------------------------------------------------------------ */
841 static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
845 ret = philips_tda827xa_pll_set(0x61, fe, params);
851 static int philips_tiger_tuner_init(struct dvb_frontend *fe)
853 struct saa7134_dev *dev = fe->dvb->priv;
854 static u8 data[] = { 0x3c, 0x33, 0x6a};
855 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
857 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
862 static int philips_tiger_tuner_sleep(struct dvb_frontend *fe)
864 struct saa7134_dev *dev = fe->dvb->priv;
865 static u8 data[] = { 0x3c, 0x33, 0x68};
866 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
868 i2c_transfer(&dev->i2c_adap, &msg, 1);
869 philips_tda827xa_tuner_sleep( 0x61, fe);
873 static struct tda1004x_config philips_tiger_config = {
874 .demod_address = 0x08,
877 .xtal_freq = TDA10046_XTAL_16M,
878 .agc_config = TDA10046_AGC_TDA827X,
879 .if_freq = TDA10046_FREQ_045,
880 .request_firmware = NULL,
883 /* ------------------------------------------------------------------ */
885 static struct tda1004x_config pinnacle_pctv_310i_config = {
886 .demod_address = 0x08,
889 .xtal_freq = TDA10046_XTAL_16M,
890 .agc_config = TDA10046_AGC_TDA827X,
891 .if_freq = TDA10046_FREQ_045,
892 .request_firmware = philips_tda1004x_request_firmware,
895 /* ------------------------------------------------------------------ */
897 static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
899 struct saa7134_dev *dev = fe->dvb->priv;
900 static u8 data[] = { 0x3c, 0x33, 0x6a};
901 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
903 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
905 /* make sure the DVB-T antenna input is set */
906 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
910 static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
912 struct saa7134_dev *dev = fe->dvb->priv;
913 static u8 data[] = { 0x3c, 0x33, 0x68};
914 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
916 i2c_transfer(&dev->i2c_adap, &msg, 1);
917 philips_tda827xa_tuner_sleep( 0x61, fe);
918 /* reset antenna inputs for analog usage */
919 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
923 /* ------------------------------------------------------------------ */
925 static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
929 ret = philips_tda827xa_pll_set(0x60, fe, params);
933 static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
935 philips_tda827xa_tuner_sleep(0x60, fe);
939 static struct tda1004x_config lifeview_trio_config = {
940 .demod_address = 0x09,
943 .xtal_freq = TDA10046_XTAL_16M,
944 .agc_config = TDA10046_AGC_TDA827X_GPL,
945 .if_freq = TDA10046_FREQ_045,
946 .request_firmware = NULL,
949 /* ------------------------------------------------------------------ */
951 static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
955 ret = philips_tda827xa_pll_set(0x61, fe, params);
959 static int ads_duo_tuner_init(struct dvb_frontend *fe)
961 struct saa7134_dev *dev = fe->dvb->priv;
962 /* route TDA8275a AGC input to the channel decoder */
963 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
967 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
969 struct saa7134_dev *dev = fe->dvb->priv;
970 /* route TDA8275a AGC input to the analog IF chip*/
971 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
972 philips_tda827xa_tuner_sleep( 0x61, fe);
976 static struct tda1004x_config ads_tech_duo_config = {
977 .demod_address = 0x08,
980 .xtal_freq = TDA10046_XTAL_16M,
981 .agc_config = TDA10046_AGC_TDA827X_GPL,
982 .if_freq = TDA10046_FREQ_045,
983 .request_firmware = NULL,
986 /* ------------------------------------------------------------------ */
988 static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
991 ret = philips_tda827xa_pll_set(0x60, fe, params);
995 static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
997 philips_tda827xa_tuner_sleep( 0x61, fe);
1001 static struct tda1004x_config tevion_dvbt220rf_config = {
1002 .demod_address = 0x08,
1005 .xtal_freq = TDA10046_XTAL_16M,
1006 .agc_config = TDA10046_AGC_TDA827X,
1007 .if_freq = TDA10046_FREQ_045,
1008 .request_firmware = NULL,
1011 /* ------------------------------------------------------------------ */
1013 static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
1015 struct saa7134_dev *dev = fe->dvb->priv;
1016 static u8 data[] = { 0x3c, 0x33, 0x68};
1017 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
1019 i2c_transfer(&dev->i2c_adap, &msg, 1);
1020 philips_tda827xa_tuner_sleep( 0x61, fe);
1024 static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1027 struct saa7134_dev *dev = fe->dvb->priv;
1028 static u8 tda8290_close[] = { 0x21, 0xc0};
1029 static u8 tda8290_open[] = { 0x21, 0x80};
1030 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
1031 /* close tda8290 i2c bridge */
1032 tda8290_msg.buf = tda8290_close;
1033 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1037 ret = philips_tda827xa_pll_set(0x60, fe, params);
1040 /* open tda8290 i2c bridge */
1041 tda8290_msg.buf = tda8290_open;
1042 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1046 static struct tda1004x_config md8800_dvbt_config = {
1047 .demod_address = 0x08,
1050 .xtal_freq = TDA10046_XTAL_16M,
1051 .agc_config = TDA10046_AGC_TDA827X,
1052 .if_freq = TDA10046_FREQ_045,
1053 .request_firmware = NULL,
1056 static struct tda10086_config flydvbs = {
1057 .demod_address = 0x0e,
1061 /* ------------------------------------------------------------------ */
1063 static struct nxt200x_config avertvhda180 = {
1064 .demod_address = 0x0a,
1067 static int nxt200x_set_pll_input(u8 *buf, int input)
1076 static struct nxt200x_config kworldatsc110 = {
1077 .demod_address = 0x0a,
1078 .set_pll_input = nxt200x_set_pll_input,
1081 /* ------------------------------------------------------------------ */
1083 static int dvb_init(struct saa7134_dev *dev)
1085 /* init struct videobuf_dvb */
1086 dev->ts.nr_bufs = 32;
1087 dev->ts.nr_packets = 32*4;
1088 dev->dvb.name = dev->name;
1089 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
1090 dev->pci, &dev->slock,
1091 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1092 V4L2_FIELD_ALTERNATE,
1093 sizeof(struct saa7134_buf),
1096 switch (dev->board) {
1097 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1098 printk("%s: pinnacle 300i dvb setup\n",dev->name);
1099 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1101 if (dev->dvb.frontend) {
1102 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1105 case SAA7134_BOARD_AVERMEDIA_777:
1106 case SAA7134_BOARD_AVERMEDIA_A16AR:
1107 printk("%s: avertv 777 dvb setup\n",dev->name);
1108 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1110 if (dev->dvb.frontend) {
1111 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
1114 case SAA7134_BOARD_MD7134:
1115 dev->dvb.frontend = dvb_attach(tda10046_attach,
1118 if (dev->dvb.frontend) {
1119 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1120 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1121 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1124 case SAA7134_BOARD_PHILIPS_TOUGH:
1125 dev->dvb.frontend = dvb_attach(tda10046_attach,
1126 &philips_tu1216_60_config,
1128 if (dev->dvb.frontend) {
1129 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
1130 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
1133 case SAA7134_BOARD_FLYDVBTDUO:
1134 dev->dvb.frontend = dvb_attach(tda10046_attach,
1135 &tda827x_lifeview_config,
1137 if (dev->dvb.frontend) {
1138 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1139 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1140 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1143 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1144 dev->dvb.frontend = dvb_attach(tda10046_attach,
1145 &tda827x_lifeview_config,
1147 if (dev->dvb.frontend) {
1148 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1149 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1150 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1153 case SAA7134_BOARD_PHILIPS_EUROPA:
1154 dev->dvb.frontend = dvb_attach(tda10046_attach,
1155 &philips_europa_config,
1157 if (dev->dvb.frontend) {
1158 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1159 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1160 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1161 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1162 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1165 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1166 dev->dvb.frontend = dvb_attach(tda10046_attach,
1167 &philips_europa_config,
1169 if (dev->dvb.frontend) {
1170 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1171 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1172 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1173 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1174 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1177 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1178 dev->dvb.frontend = dvb_attach(tda10046_attach,
1179 &philips_tu1216_61_config,
1181 if (dev->dvb.frontend) {
1182 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
1183 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
1186 case SAA7134_BOARD_PHILIPS_TIGER:
1187 dev->dvb.frontend = dvb_attach(tda10046_attach,
1188 &philips_tiger_config,
1190 if (dev->dvb.frontend) {
1191 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1192 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1193 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1194 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1197 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1198 dev->dvb.frontend = dvb_attach(tda10046_attach,
1199 &pinnacle_pctv_310i_config,
1201 if (dev->dvb.frontend) {
1202 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1203 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1204 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1205 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1208 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1209 dev->dvb.frontend = dvb_attach(tda10046_attach,
1210 &philips_tiger_config,
1212 if (dev->dvb.frontend) {
1213 dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
1214 dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
1215 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1218 case SAA7134_BOARD_FLYDVBT_LR301:
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_FLYDVB_TRIO:
1229 dev->dvb.frontend = dvb_attach(tda10046_attach,
1230 &lifeview_trio_config,
1232 if (dev->dvb.frontend) {
1233 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1234 dev->dvb.frontend->ops.tuner_ops.set_params = lifeview_trio_tuner_set_params;
1237 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1238 dev->dvb.frontend = dvb_attach(tda10046_attach,
1239 &ads_tech_duo_config,
1241 if (dev->dvb.frontend) {
1242 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1243 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1244 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1247 case SAA7134_BOARD_TEVION_DVBT_220RF:
1248 dev->dvb.frontend = dvb_attach(tda10046_attach,
1249 &tevion_dvbt220rf_config,
1251 if (dev->dvb.frontend) {
1252 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1253 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
1256 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1257 dev->dvb.frontend = dvb_attach(tda10046_attach,
1258 &ads_tech_duo_config,
1260 if (dev->dvb.frontend) {
1261 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1262 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1263 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1266 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1267 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
1269 if (dev->dvb.frontend) {
1270 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1271 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1272 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1275 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1276 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1278 if (dev->dvb.frontend) {
1279 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1280 NULL, &dvb_pll_tdhu2);
1283 case SAA7134_BOARD_KWORLD_ATSC110:
1284 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1286 if (dev->dvb.frontend) {
1287 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1288 NULL, &dvb_pll_tuv1236d);
1291 case SAA7134_BOARD_FLYDVBS_LR300:
1292 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1294 if (dev->dvb.frontend) {
1295 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1296 &dev->i2c_adap, 0) == NULL) {
1297 printk("%s: No tda826x found!\n", __FUNCTION__);
1299 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1300 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1301 printk("%s: No ISL6421 found!\n", __FUNCTION__);
1305 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1306 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1308 if (dev->dvb.frontend) {
1309 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1310 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1311 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1312 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1313 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1318 printk("%s: Huh? unknown DVB card?\n",dev->name);
1322 if (NULL == dev->dvb.frontend) {
1323 printk("%s: frontend initialization failed\n",dev->name);
1327 /* register everything else */
1328 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1331 static int dvb_fini(struct saa7134_dev *dev)
1333 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1335 switch (dev->board) {
1336 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1337 /* otherwise we don't detect the tuner on next insmod */
1338 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1341 videobuf_dvb_unregister(&dev->dvb);
1345 static struct saa7134_mpeg_ops dvb_ops = {
1346 .type = SAA7134_MPEG_DVB,
1351 static int __init dvb_register(void)
1353 return saa7134_ts_register(&dvb_ops);
1356 static void __exit dvb_unregister(void)
1358 saa7134_ts_unregister(&dvb_ops);
1361 module_init(dvb_register);
1362 module_exit(dvb_unregister);
1364 /* ------------------------------------------------------------------ */