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_GP11,
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_GP11,
885 .if_freq = TDA10046_FREQ_045,
886 .request_firmware = NULL,
888 /* ------------------------------------------------------------------ */
890 static int cinergy_ht_tuner_init(struct dvb_frontend *fe)
892 struct saa7134_dev *dev = fe->dvb->priv;
893 static u8 data[] = { 0x3c, 0x33, 0x62};
894 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
896 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
901 static int cinergy_ht_tuner_sleep(struct dvb_frontend *fe)
903 struct saa7134_dev *dev = fe->dvb->priv;
904 static u8 data[] = { 0x3c, 0x33, 0x60};
905 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
907 i2c_transfer(&dev->i2c_adap, &msg, 1);
908 philips_tda827xa_tuner_sleep( 0x61, fe);
912 static struct tda1004x_config cinergy_ht_config = {
913 .demod_address = 0x08,
916 .xtal_freq = TDA10046_XTAL_16M,
917 .agc_config = TDA10046_AGC_TDA827X_GP01,
918 .if_freq = TDA10046_FREQ_045,
919 .request_firmware = NULL,
922 /* ------------------------------------------------------------------ */
924 static struct tda1004x_config pinnacle_pctv_310i_config = {
925 .demod_address = 0x08,
928 .xtal_freq = TDA10046_XTAL_16M,
929 .agc_config = TDA10046_AGC_TDA827X_GP11,
930 .if_freq = TDA10046_FREQ_045,
931 .request_firmware = philips_tda1004x_request_firmware,
934 /* ------------------------------------------------------------------ */
936 static struct tda1004x_config hauppauge_hvr_1110_config = {
937 .demod_address = 0x08,
940 .xtal_freq = TDA10046_XTAL_16M,
941 .agc_config = TDA10046_AGC_TDA827X_GP11,
942 .if_freq = TDA10046_FREQ_045,
943 .request_firmware = philips_tda1004x_request_firmware,
946 /* ------------------------------------------------------------------ */
948 static struct tda1004x_config asus_p7131_dual_config = {
949 .demod_address = 0x08,
952 .xtal_freq = TDA10046_XTAL_16M,
953 .agc_config = TDA10046_AGC_TDA827X_GP11,
954 .if_freq = TDA10046_FREQ_045,
955 .request_firmware = philips_tda1004x_request_firmware,
958 static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
960 struct saa7134_dev *dev = fe->dvb->priv;
961 static u8 data[] = { 0x3c, 0x33, 0x6a};
962 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
964 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
966 /* make sure the DVB-T antenna input is set */
967 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
971 static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
973 struct saa7134_dev *dev = fe->dvb->priv;
974 static u8 data[] = { 0x3c, 0x33, 0x68};
975 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
977 i2c_transfer(&dev->i2c_adap, &msg, 1);
978 philips_tda827xa_tuner_sleep( 0x61, fe);
979 /* reset antenna inputs for analog usage */
980 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
984 /* ------------------------------------------------------------------ */
986 static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
990 ret = philips_tda827xa_pll_set(0x60, fe, params);
994 static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
996 philips_tda827xa_tuner_sleep(0x60, fe);
1000 static struct tda1004x_config lifeview_trio_config = {
1001 .demod_address = 0x09,
1004 .xtal_freq = TDA10046_XTAL_16M,
1005 .agc_config = TDA10046_AGC_TDA827X_GP00,
1006 .if_freq = TDA10046_FREQ_045,
1007 .request_firmware = NULL,
1010 /* ------------------------------------------------------------------ */
1012 static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1016 ret = philips_tda827xa_pll_set(0x61, fe, params);
1020 static int ads_duo_tuner_init(struct dvb_frontend *fe)
1022 struct saa7134_dev *dev = fe->dvb->priv;
1023 /* route TDA8275a AGC input to the channel decoder */
1024 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
1028 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
1030 struct saa7134_dev *dev = fe->dvb->priv;
1031 /* route TDA8275a AGC input to the analog IF chip*/
1032 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
1033 philips_tda827xa_tuner_sleep( 0x61, fe);
1037 static struct tda1004x_config ads_tech_duo_config = {
1038 .demod_address = 0x08,
1041 .xtal_freq = TDA10046_XTAL_16M,
1042 .agc_config = TDA10046_AGC_TDA827X_GP00,
1043 .if_freq = TDA10046_FREQ_045,
1044 .request_firmware = NULL,
1047 /* ------------------------------------------------------------------ */
1049 static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1052 ret = philips_tda827xa_pll_set(0x60, fe, params);
1056 static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
1058 philips_tda827xa_tuner_sleep( 0x61, fe);
1062 static struct tda1004x_config tevion_dvbt220rf_config = {
1063 .demod_address = 0x08,
1066 .xtal_freq = TDA10046_XTAL_16M,
1067 .agc_config = TDA10046_AGC_TDA827X_GP11,
1068 .if_freq = TDA10046_FREQ_045,
1069 .request_firmware = NULL,
1072 /* ------------------------------------------------------------------ */
1074 static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
1076 struct saa7134_dev *dev = fe->dvb->priv;
1077 static u8 data[] = { 0x3c, 0x33, 0x68};
1078 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
1080 i2c_transfer(&dev->i2c_adap, &msg, 1);
1081 philips_tda827xa_tuner_sleep( 0x61, fe);
1085 static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1088 struct saa7134_dev *dev = fe->dvb->priv;
1089 static u8 tda8290_close[] = { 0x21, 0xc0};
1090 static u8 tda8290_open[] = { 0x21, 0x80};
1091 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
1092 /* close tda8290 i2c bridge */
1093 tda8290_msg.buf = tda8290_close;
1094 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1098 ret = philips_tda827xa_pll_set(0x60, fe, params);
1101 /* open tda8290 i2c bridge */
1102 tda8290_msg.buf = tda8290_open;
1103 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1107 static struct tda1004x_config md8800_dvbt_config = {
1108 .demod_address = 0x08,
1111 .xtal_freq = TDA10046_XTAL_16M,
1112 .agc_config = TDA10046_AGC_TDA827X_GP11,
1113 .if_freq = TDA10046_FREQ_045,
1114 .request_firmware = NULL,
1117 static struct tda10086_config flydvbs = {
1118 .demod_address = 0x0e,
1122 /* ------------------------------------------------------------------ */
1124 static struct nxt200x_config avertvhda180 = {
1125 .demod_address = 0x0a,
1128 static int nxt200x_set_pll_input(u8 *buf, int input)
1137 static struct nxt200x_config kworldatsc110 = {
1138 .demod_address = 0x0a,
1139 .set_pll_input = nxt200x_set_pll_input,
1142 /* ------------------------------------------------------------------ */
1144 static int dvb_init(struct saa7134_dev *dev)
1146 /* init struct videobuf_dvb */
1147 dev->ts.nr_bufs = 32;
1148 dev->ts.nr_packets = 32*4;
1149 dev->dvb.name = dev->name;
1150 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
1151 dev->pci, &dev->slock,
1152 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1153 V4L2_FIELD_ALTERNATE,
1154 sizeof(struct saa7134_buf),
1157 switch (dev->board) {
1158 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1159 printk("%s: pinnacle 300i dvb setup\n",dev->name);
1160 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1162 if (dev->dvb.frontend) {
1163 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1166 case SAA7134_BOARD_AVERMEDIA_777:
1167 case SAA7134_BOARD_AVERMEDIA_A16AR:
1168 printk("%s: avertv 777 dvb setup\n",dev->name);
1169 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1171 if (dev->dvb.frontend) {
1172 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
1175 case SAA7134_BOARD_MD7134:
1176 dev->dvb.frontend = dvb_attach(tda10046_attach,
1179 if (dev->dvb.frontend) {
1180 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1181 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1182 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1185 case SAA7134_BOARD_PHILIPS_TOUGH:
1186 dev->dvb.frontend = dvb_attach(tda10046_attach,
1187 &philips_tu1216_60_config,
1189 if (dev->dvb.frontend) {
1190 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
1191 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
1194 case SAA7134_BOARD_FLYDVBTDUO:
1195 dev->dvb.frontend = dvb_attach(tda10046_attach,
1196 &tda827x_lifeview_config,
1198 if (dev->dvb.frontend) {
1199 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1200 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1201 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1204 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1205 dev->dvb.frontend = dvb_attach(tda10046_attach,
1206 &tda827x_lifeview_config,
1208 if (dev->dvb.frontend) {
1209 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1210 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1211 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1214 case SAA7134_BOARD_PHILIPS_EUROPA:
1215 dev->dvb.frontend = dvb_attach(tda10046_attach,
1216 &philips_europa_config,
1218 if (dev->dvb.frontend) {
1219 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1220 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1221 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1222 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1223 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1226 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1227 dev->dvb.frontend = dvb_attach(tda10046_attach,
1228 &philips_europa_config,
1230 if (dev->dvb.frontend) {
1231 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1232 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1233 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1234 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1235 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1238 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1239 dev->dvb.frontend = dvb_attach(tda10046_attach,
1240 &philips_tu1216_61_config,
1242 if (dev->dvb.frontend) {
1243 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
1244 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
1247 case SAA7134_BOARD_PHILIPS_TIGER:
1248 dev->dvb.frontend = dvb_attach(tda10046_attach,
1249 &philips_tiger_config,
1251 if (dev->dvb.frontend) {
1252 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1253 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1254 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1255 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1258 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1259 dev->dvb.frontend = dvb_attach(tda10046_attach,
1260 &pinnacle_pctv_310i_config,
1262 if (dev->dvb.frontend) {
1263 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1264 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1265 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1266 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1269 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1270 dev->dvb.frontend = dvb_attach(tda10046_attach,
1271 &hauppauge_hvr_1110_config,
1273 if (dev->dvb.frontend) {
1274 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1275 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1276 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1277 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1280 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1281 dev->dvb.frontend = dvb_attach(tda10046_attach,
1282 &asus_p7131_dual_config,
1284 if (dev->dvb.frontend) {
1285 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1286 dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
1287 dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
1288 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1291 case SAA7134_BOARD_FLYDVBT_LR301:
1292 dev->dvb.frontend = dvb_attach(tda10046_attach,
1293 &tda827x_lifeview_config,
1295 if (dev->dvb.frontend) {
1296 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1297 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1298 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1301 case SAA7134_BOARD_FLYDVB_TRIO:
1302 dev->dvb.frontend = dvb_attach(tda10046_attach,
1303 &lifeview_trio_config,
1305 if (dev->dvb.frontend) {
1306 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1307 dev->dvb.frontend->ops.tuner_ops.set_params = lifeview_trio_tuner_set_params;
1310 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1311 dev->dvb.frontend = dvb_attach(tda10046_attach,
1312 &ads_tech_duo_config,
1314 if (dev->dvb.frontend) {
1315 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1316 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1317 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1320 case SAA7134_BOARD_TEVION_DVBT_220RF:
1321 dev->dvb.frontend = dvb_attach(tda10046_attach,
1322 &tevion_dvbt220rf_config,
1324 if (dev->dvb.frontend) {
1325 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1326 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
1329 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1330 dev->dvb.frontend = dvb_attach(tda10046_attach,
1331 &ads_tech_duo_config,
1333 if (dev->dvb.frontend) {
1334 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1335 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1336 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1339 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1340 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
1342 if (dev->dvb.frontend) {
1343 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1344 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1345 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1348 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1349 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1351 if (dev->dvb.frontend) {
1352 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1353 NULL, &dvb_pll_tdhu2);
1356 case SAA7134_BOARD_KWORLD_ATSC110:
1357 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1359 if (dev->dvb.frontend) {
1360 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1361 NULL, &dvb_pll_tuv1236d);
1364 case SAA7134_BOARD_FLYDVBS_LR300:
1365 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1367 if (dev->dvb.frontend) {
1368 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1369 &dev->i2c_adap, 0) == NULL) {
1370 printk("%s: No tda826x found!\n", __FUNCTION__);
1372 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1373 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1374 printk("%s: No ISL6421 found!\n", __FUNCTION__);
1378 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1379 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1381 if (dev->dvb.frontend) {
1382 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1383 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1384 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1385 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1386 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1389 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1390 dev->dvb.frontend = dvb_attach(tda10046_attach,
1391 &philips_europa_config,
1393 if (dev->dvb.frontend) {
1394 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1395 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1398 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1399 dev->dvb.frontend = dvb_attach(tda10046_attach,
1402 if (dev->dvb.frontend) {
1403 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1404 dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
1405 dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
1406 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1411 printk("%s: Huh? unknown DVB card?\n",dev->name);
1415 if (NULL == dev->dvb.frontend) {
1416 printk("%s: frontend initialization failed\n",dev->name);
1420 /* register everything else */
1421 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1424 static int dvb_fini(struct saa7134_dev *dev)
1426 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1428 switch (dev->board) {
1429 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1430 /* otherwise we don't detect the tuner on next insmod */
1431 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1434 videobuf_dvb_unregister(&dev->dvb);
1438 static struct saa7134_mpeg_ops dvb_ops = {
1439 .type = SAA7134_MPEG_DVB,
1444 static int __init dvb_register(void)
1446 return saa7134_ts_register(&dvb_ops);
1449 static void __exit dvb_unregister(void)
1451 saa7134_ts_unregister(&dvb_ops);
1454 module_init(dvb_register);
1455 module_exit(dvb_unregister);
1457 /* ------------------------------------------------------------------ */