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>
36 #include <dvb_frontend.h>
39 #include "mt352_priv.h" /* FIXME */
42 #include "tuner-xc2028.h"
50 #include "tuner-simple.h"
62 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
63 MODULE_LICENSE("GPL");
65 static unsigned int antenna_pwr
;
67 module_param(antenna_pwr
, int, 0444);
68 MODULE_PARM_DESC(antenna_pwr
,"enable antenna power (Pinnacle 300i)");
70 static int use_frontend
;
71 module_param(use_frontend
, int, 0644);
72 MODULE_PARM_DESC(use_frontend
,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
75 module_param(debug
, int, 0644);
76 MODULE_PARM_DESC(debug
, "Turn on/off module debugging (default:off).");
78 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
80 #define dprintk(fmt, arg...) do { if (debug) \
81 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
84 #define wprintk(fmt, arg...) \
85 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
87 /* ------------------------------------------------------------------
88 * mt352 based DVB-T cards
91 static int pinnacle_antenna_pwr(struct saa7134_dev
*dev
, int on
)
96 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
97 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
101 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
102 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
105 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 28));
106 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
108 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
110 ok
= saa_readl(SAA7134_GPIO_GPSTATUS0
) & (1 << 27);
111 dprintk("%s %s\n", __func__
, ok
? "on" : "off");
114 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
118 static int mt352_pinnacle_init(struct dvb_frontend
* fe
)
120 static u8 clock_config
[] = { CLOCK_CTL
, 0x3d, 0x28 };
121 static u8 reset
[] = { RESET
, 0x80 };
122 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
123 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
124 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x31 };
125 static u8 fsm_ctl_cfg
[] = { 0x7b, 0x04 };
126 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x0f };
127 static u8 scan_ctl_cfg
[] = { SCAN_CTL
, 0x0d };
128 static u8 irq_cfg
[] = { INTERRUPT_EN_0
, 0x00, 0x00, 0x00, 0x00 };
129 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
131 dprintk("%s called\n", __func__
);
133 mt352_write(fe
, clock_config
, sizeof(clock_config
));
135 mt352_write(fe
, reset
, sizeof(reset
));
136 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
137 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
138 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
139 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
141 mt352_write(fe
, fsm_ctl_cfg
, sizeof(fsm_ctl_cfg
));
142 mt352_write(fe
, scan_ctl_cfg
, sizeof(scan_ctl_cfg
));
143 mt352_write(fe
, irq_cfg
, sizeof(irq_cfg
));
148 static int mt352_aver777_init(struct dvb_frontend
* fe
)
150 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
151 static u8 reset
[] = { RESET
, 0x80 };
152 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
153 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
154 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
156 mt352_write(fe
, clock_config
, sizeof(clock_config
));
158 mt352_write(fe
, reset
, sizeof(reset
));
159 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
160 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
161 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
166 static int mt352_avermedia_xc3028_init(struct dvb_frontend
*fe
)
168 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
169 static u8 reset
[] = { RESET
, 0x80 };
170 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
171 static u8 agc_cfg
[] = { AGC_TARGET
, 0xe };
172 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
174 mt352_write(fe
, clock_config
, sizeof(clock_config
));
176 mt352_write(fe
, reset
, sizeof(reset
));
177 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
178 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
179 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
183 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend
* fe
,
184 struct dvb_frontend_parameters
* params
)
186 u8 off
[] = { 0x00, 0xf1};
187 u8 on
[] = { 0x00, 0x71};
188 struct i2c_msg msg
= {.addr
=0x43, .flags
=0, .buf
=off
, .len
= sizeof(off
)};
190 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
191 struct v4l2_frequency f
;
193 /* set frequency (mt2050) */
195 f
.type
= V4L2_TUNER_DIGITAL_TV
;
196 f
.frequency
= params
->frequency
/ 1000 * 16 / 1000;
197 if (fe
->ops
.i2c_gate_ctrl
)
198 fe
->ops
.i2c_gate_ctrl(fe
, 1);
199 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
200 saa_call_all(dev
, tuner
, s_frequency
, &f
);
202 if (fe
->ops
.i2c_gate_ctrl
)
203 fe
->ops
.i2c_gate_ctrl(fe
, 1);
204 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
206 pinnacle_antenna_pwr(dev
, antenna_pwr
);
209 return mt352_pinnacle_init(fe
);
212 static struct mt352_config pinnacle_300i
= {
213 .demod_address
= 0x3c >> 1,
217 .demod_init
= mt352_pinnacle_init
,
220 static struct mt352_config avermedia_777
= {
221 .demod_address
= 0xf,
222 .demod_init
= mt352_aver777_init
,
225 static struct mt352_config avermedia_xc3028_mt352_dev
= {
226 .demod_address
= (0x1e >> 1),
228 .demod_init
= mt352_avermedia_xc3028_init
,
231 /* ==================================================================
232 * tda1004x based DVB-T cards, helper functions
235 static int philips_tda1004x_request_firmware(struct dvb_frontend
*fe
,
236 const struct firmware
**fw
, char *name
)
238 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
239 return request_firmware(fw
, name
, &dev
->pci
->dev
);
242 /* ------------------------------------------------------------------
243 * these tuners are tu1216, td1316(a)
246 static int philips_tda6651_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
248 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
249 struct tda1004x_state
*state
= fe
->demodulator_priv
;
250 u8 addr
= state
->config
->tuner_address
;
252 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tuner_buf
,.len
=
254 int tuner_frequency
= 0;
257 /* determine charge pump */
258 tuner_frequency
= params
->frequency
+ 36166000;
259 if (tuner_frequency
< 87000000)
261 else if (tuner_frequency
< 130000000)
263 else if (tuner_frequency
< 160000000)
265 else if (tuner_frequency
< 200000000)
267 else if (tuner_frequency
< 290000000)
269 else if (tuner_frequency
< 420000000)
271 else if (tuner_frequency
< 480000000)
273 else if (tuner_frequency
< 620000000)
275 else if (tuner_frequency
< 830000000)
277 else if (tuner_frequency
< 895000000)
283 if (params
->frequency
< 49000000)
285 else if (params
->frequency
< 161000000)
287 else if (params
->frequency
< 444000000)
289 else if (params
->frequency
< 861000000)
294 /* setup PLL filter */
295 switch (params
->u
.ofdm
.bandwidth
) {
296 case BANDWIDTH_6_MHZ
:
300 case BANDWIDTH_7_MHZ
:
304 case BANDWIDTH_8_MHZ
:
313 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
315 tuner_frequency
= (((params
->frequency
/ 1000) * 6) + 217496) / 1000;
317 /* setup tuner buffer */
318 tuner_buf
[0] = (tuner_frequency
>> 8) & 0x7f;
319 tuner_buf
[1] = tuner_frequency
& 0xff;
321 tuner_buf
[3] = (cp
<< 5) | (filter
<< 3) | band
;
323 if (fe
->ops
.i2c_gate_ctrl
)
324 fe
->ops
.i2c_gate_ctrl(fe
, 1);
325 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1) {
326 wprintk("could not write to tuner at addr: 0x%02x\n",
334 static int philips_tu1216_init(struct dvb_frontend
*fe
)
336 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
337 struct tda1004x_state
*state
= fe
->demodulator_priv
;
338 u8 addr
= state
->config
->tuner_address
;
339 static u8 tu1216_init
[] = { 0x0b, 0xf5, 0x85, 0xab };
340 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tu1216_init
,.len
= sizeof(tu1216_init
) };
342 /* setup PLL configuration */
343 if (fe
->ops
.i2c_gate_ctrl
)
344 fe
->ops
.i2c_gate_ctrl(fe
, 1);
345 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
352 /* ------------------------------------------------------------------ */
354 static struct tda1004x_config philips_tu1216_60_config
= {
355 .demod_address
= 0x8,
358 .xtal_freq
= TDA10046_XTAL_4M
,
359 .agc_config
= TDA10046_AGC_DEFAULT
,
360 .if_freq
= TDA10046_FREQ_3617
,
361 .tuner_address
= 0x60,
362 .request_firmware
= philips_tda1004x_request_firmware
365 static struct tda1004x_config philips_tu1216_61_config
= {
367 .demod_address
= 0x8,
370 .xtal_freq
= TDA10046_XTAL_4M
,
371 .agc_config
= TDA10046_AGC_DEFAULT
,
372 .if_freq
= TDA10046_FREQ_3617
,
373 .tuner_address
= 0x61,
374 .request_firmware
= philips_tda1004x_request_firmware
377 /* ------------------------------------------------------------------ */
379 static int philips_td1316_tuner_init(struct dvb_frontend
*fe
)
381 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
382 struct tda1004x_state
*state
= fe
->demodulator_priv
;
383 u8 addr
= state
->config
->tuner_address
;
384 static u8 msg
[] = { 0x0b, 0xf5, 0x86, 0xab };
385 struct i2c_msg init_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
387 /* setup PLL configuration */
388 if (fe
->ops
.i2c_gate_ctrl
)
389 fe
->ops
.i2c_gate_ctrl(fe
, 1);
390 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
395 static int philips_td1316_tuner_set_params(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
397 return philips_tda6651_pll_set(fe
, params
);
400 static int philips_td1316_tuner_sleep(struct dvb_frontend
*fe
)
402 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
403 struct tda1004x_state
*state
= fe
->demodulator_priv
;
404 u8 addr
= state
->config
->tuner_address
;
405 static u8 msg
[] = { 0x0b, 0xdc, 0x86, 0xa4 };
406 struct i2c_msg analog_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
408 /* switch the tuner to analog mode */
409 if (fe
->ops
.i2c_gate_ctrl
)
410 fe
->ops
.i2c_gate_ctrl(fe
, 1);
411 if (i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1) != 1)
416 /* ------------------------------------------------------------------ */
418 static int philips_europa_tuner_init(struct dvb_frontend
*fe
)
420 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
421 static u8 msg
[] = { 0x00, 0x40};
422 struct i2c_msg init_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
425 if (philips_td1316_tuner_init(fe
))
428 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
434 static int philips_europa_tuner_sleep(struct dvb_frontend
*fe
)
436 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
438 static u8 msg
[] = { 0x00, 0x14 };
439 struct i2c_msg analog_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
441 if (philips_td1316_tuner_sleep(fe
))
444 /* switch the board to analog mode */
445 if (fe
->ops
.i2c_gate_ctrl
)
446 fe
->ops
.i2c_gate_ctrl(fe
, 1);
447 i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1);
451 static int philips_europa_demod_sleep(struct dvb_frontend
*fe
)
453 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
455 if (dev
->original_demod_sleep
)
456 dev
->original_demod_sleep(fe
);
457 fe
->ops
.i2c_gate_ctrl(fe
, 1);
461 static struct tda1004x_config philips_europa_config
= {
463 .demod_address
= 0x8,
466 .xtal_freq
= TDA10046_XTAL_4M
,
467 .agc_config
= TDA10046_AGC_IFO_AUTO_POS
,
468 .if_freq
= TDA10046_FREQ_052
,
469 .tuner_address
= 0x61,
470 .request_firmware
= philips_tda1004x_request_firmware
473 static struct tda1004x_config medion_cardbus
= {
474 .demod_address
= 0x08,
477 .xtal_freq
= TDA10046_XTAL_16M
,
478 .agc_config
= TDA10046_AGC_IFO_AUTO_NEG
,
479 .if_freq
= TDA10046_FREQ_3613
,
480 .tuner_address
= 0x61,
481 .request_firmware
= philips_tda1004x_request_firmware
484 /* ------------------------------------------------------------------
485 * tda 1004x based cards with philips silicon tuner
488 static int tda8290_i2c_gate_ctrl( struct dvb_frontend
* fe
, int enable
)
490 struct tda1004x_state
*state
= fe
->demodulator_priv
;
492 u8 addr
= state
->config
->i2c_gate
;
493 static u8 tda8290_close
[] = { 0x21, 0xc0};
494 static u8 tda8290_open
[] = { 0x21, 0x80};
495 struct i2c_msg tda8290_msg
= {.addr
= addr
,.flags
= 0, .len
= 2};
497 tda8290_msg
.buf
= tda8290_close
;
499 tda8290_msg
.buf
= tda8290_open
;
501 if (i2c_transfer(state
->i2c
, &tda8290_msg
, 1) != 1) {
502 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
503 wprintk("could not access tda8290 I2C gate\n");
510 static int philips_tda827x_tuner_init(struct dvb_frontend
*fe
)
512 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
513 struct tda1004x_state
*state
= fe
->demodulator_priv
;
515 switch (state
->config
->antenna_switch
) {
517 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
518 saa7134_set_gpio(dev
, 21, 0);
520 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
521 saa7134_set_gpio(dev
, 21, 1);
527 static int philips_tda827x_tuner_sleep(struct dvb_frontend
*fe
)
529 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
530 struct tda1004x_state
*state
= fe
->demodulator_priv
;
532 switch (state
->config
->antenna_switch
) {
534 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
535 saa7134_set_gpio(dev
, 21, 1);
537 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
538 saa7134_set_gpio(dev
, 21, 0);
544 static int configure_tda827x_fe(struct saa7134_dev
*dev
,
545 struct tda1004x_config
*cdec_conf
,
546 struct tda827x_config
*tuner_conf
)
548 struct videobuf_dvb_frontend
*fe0
;
550 /* Get the first frontend */
551 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
553 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
, cdec_conf
, &dev
->i2c_adap
);
554 if (fe0
->dvb
.frontend
) {
555 if (cdec_conf
->i2c_gate
)
556 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= tda8290_i2c_gate_ctrl
;
557 if (dvb_attach(tda827x_attach
, fe0
->dvb
.frontend
,
558 cdec_conf
->tuner_address
,
559 &dev
->i2c_adap
, tuner_conf
))
562 wprintk("no tda827x tuner found at addr: %02x\n",
563 cdec_conf
->tuner_address
);
568 /* ------------------------------------------------------------------ */
570 static struct tda827x_config tda827x_cfg_0
= {
571 .init
= philips_tda827x_tuner_init
,
572 .sleep
= philips_tda827x_tuner_sleep
,
577 static struct tda827x_config tda827x_cfg_1
= {
578 .init
= philips_tda827x_tuner_init
,
579 .sleep
= philips_tda827x_tuner_sleep
,
584 static struct tda827x_config tda827x_cfg_2
= {
585 .init
= philips_tda827x_tuner_init
,
586 .sleep
= philips_tda827x_tuner_sleep
,
591 static struct tda827x_config tda827x_cfg_2_sw42
= {
592 .init
= philips_tda827x_tuner_init
,
593 .sleep
= philips_tda827x_tuner_sleep
,
598 /* ------------------------------------------------------------------ */
600 static struct tda1004x_config tda827x_lifeview_config
= {
601 .demod_address
= 0x08,
604 .xtal_freq
= TDA10046_XTAL_16M
,
605 .agc_config
= TDA10046_AGC_TDA827X
,
606 .gpio_config
= TDA10046_GP11_I
,
607 .if_freq
= TDA10046_FREQ_045
,
608 .tuner_address
= 0x60,
609 .request_firmware
= philips_tda1004x_request_firmware
612 static struct tda1004x_config philips_tiger_config
= {
613 .demod_address
= 0x08,
616 .xtal_freq
= TDA10046_XTAL_16M
,
617 .agc_config
= TDA10046_AGC_TDA827X
,
618 .gpio_config
= TDA10046_GP11_I
,
619 .if_freq
= TDA10046_FREQ_045
,
621 .tuner_address
= 0x61,
623 .request_firmware
= philips_tda1004x_request_firmware
626 static struct tda1004x_config cinergy_ht_config
= {
627 .demod_address
= 0x08,
630 .xtal_freq
= TDA10046_XTAL_16M
,
631 .agc_config
= TDA10046_AGC_TDA827X
,
632 .gpio_config
= TDA10046_GP01_I
,
633 .if_freq
= TDA10046_FREQ_045
,
635 .tuner_address
= 0x61,
636 .request_firmware
= philips_tda1004x_request_firmware
639 static struct tda1004x_config cinergy_ht_pci_config
= {
640 .demod_address
= 0x08,
643 .xtal_freq
= TDA10046_XTAL_16M
,
644 .agc_config
= TDA10046_AGC_TDA827X
,
645 .gpio_config
= TDA10046_GP01_I
,
646 .if_freq
= TDA10046_FREQ_045
,
648 .tuner_address
= 0x60,
649 .request_firmware
= philips_tda1004x_request_firmware
652 static struct tda1004x_config philips_tiger_s_config
= {
653 .demod_address
= 0x08,
656 .xtal_freq
= TDA10046_XTAL_16M
,
657 .agc_config
= TDA10046_AGC_TDA827X
,
658 .gpio_config
= TDA10046_GP01_I
,
659 .if_freq
= TDA10046_FREQ_045
,
661 .tuner_address
= 0x61,
663 .request_firmware
= philips_tda1004x_request_firmware
666 static struct tda1004x_config pinnacle_pctv_310i_config
= {
667 .demod_address
= 0x08,
670 .xtal_freq
= TDA10046_XTAL_16M
,
671 .agc_config
= TDA10046_AGC_TDA827X
,
672 .gpio_config
= TDA10046_GP11_I
,
673 .if_freq
= TDA10046_FREQ_045
,
675 .tuner_address
= 0x61,
676 .request_firmware
= philips_tda1004x_request_firmware
679 static struct tda1004x_config hauppauge_hvr_1110_config
= {
680 .demod_address
= 0x08,
683 .xtal_freq
= TDA10046_XTAL_16M
,
684 .agc_config
= TDA10046_AGC_TDA827X
,
685 .gpio_config
= TDA10046_GP11_I
,
686 .if_freq
= TDA10046_FREQ_045
,
688 .tuner_address
= 0x61,
689 .request_firmware
= philips_tda1004x_request_firmware
692 static struct tda1004x_config asus_p7131_dual_config
= {
693 .demod_address
= 0x08,
696 .xtal_freq
= TDA10046_XTAL_16M
,
697 .agc_config
= TDA10046_AGC_TDA827X
,
698 .gpio_config
= TDA10046_GP11_I
,
699 .if_freq
= TDA10046_FREQ_045
,
701 .tuner_address
= 0x61,
703 .request_firmware
= philips_tda1004x_request_firmware
706 static struct tda1004x_config lifeview_trio_config
= {
707 .demod_address
= 0x09,
710 .xtal_freq
= TDA10046_XTAL_16M
,
711 .agc_config
= TDA10046_AGC_TDA827X
,
712 .gpio_config
= TDA10046_GP00_I
,
713 .if_freq
= TDA10046_FREQ_045
,
714 .tuner_address
= 0x60,
715 .request_firmware
= philips_tda1004x_request_firmware
718 static struct tda1004x_config tevion_dvbt220rf_config
= {
719 .demod_address
= 0x08,
722 .xtal_freq
= TDA10046_XTAL_16M
,
723 .agc_config
= TDA10046_AGC_TDA827X
,
724 .gpio_config
= TDA10046_GP11_I
,
725 .if_freq
= TDA10046_FREQ_045
,
726 .tuner_address
= 0x60,
727 .request_firmware
= philips_tda1004x_request_firmware
730 static struct tda1004x_config md8800_dvbt_config
= {
731 .demod_address
= 0x08,
734 .xtal_freq
= TDA10046_XTAL_16M
,
735 .agc_config
= TDA10046_AGC_TDA827X
,
736 .gpio_config
= TDA10046_GP01_I
,
737 .if_freq
= TDA10046_FREQ_045
,
739 .tuner_address
= 0x60,
740 .request_firmware
= philips_tda1004x_request_firmware
743 static struct tda1004x_config asus_p7131_4871_config
= {
744 .demod_address
= 0x08,
747 .xtal_freq
= TDA10046_XTAL_16M
,
748 .agc_config
= TDA10046_AGC_TDA827X
,
749 .gpio_config
= TDA10046_GP01_I
,
750 .if_freq
= TDA10046_FREQ_045
,
752 .tuner_address
= 0x61,
754 .request_firmware
= philips_tda1004x_request_firmware
757 static struct tda1004x_config asus_p7131_hybrid_lna_config
= {
758 .demod_address
= 0x08,
761 .xtal_freq
= TDA10046_XTAL_16M
,
762 .agc_config
= TDA10046_AGC_TDA827X
,
763 .gpio_config
= TDA10046_GP11_I
,
764 .if_freq
= TDA10046_FREQ_045
,
766 .tuner_address
= 0x61,
768 .request_firmware
= philips_tda1004x_request_firmware
771 static struct tda1004x_config kworld_dvb_t_210_config
= {
772 .demod_address
= 0x08,
775 .xtal_freq
= TDA10046_XTAL_16M
,
776 .agc_config
= TDA10046_AGC_TDA827X
,
777 .gpio_config
= TDA10046_GP11_I
,
778 .if_freq
= TDA10046_FREQ_045
,
780 .tuner_address
= 0x61,
782 .request_firmware
= philips_tda1004x_request_firmware
785 static struct tda1004x_config avermedia_super_007_config
= {
786 .demod_address
= 0x08,
789 .xtal_freq
= TDA10046_XTAL_16M
,
790 .agc_config
= TDA10046_AGC_TDA827X
,
791 .gpio_config
= TDA10046_GP01_I
,
792 .if_freq
= TDA10046_FREQ_045
,
794 .tuner_address
= 0x60,
796 .request_firmware
= philips_tda1004x_request_firmware
799 static struct tda1004x_config twinhan_dtv_dvb_3056_config
= {
800 .demod_address
= 0x08,
803 .xtal_freq
= TDA10046_XTAL_16M
,
804 .agc_config
= TDA10046_AGC_TDA827X
,
805 .gpio_config
= TDA10046_GP01_I
,
806 .if_freq
= TDA10046_FREQ_045
,
808 .tuner_address
= 0x61,
810 .request_firmware
= philips_tda1004x_request_firmware
813 static struct tda1004x_config asus_tiger_3in1_config
= {
814 .demod_address
= 0x0b,
817 .xtal_freq
= TDA10046_XTAL_16M
,
818 .agc_config
= TDA10046_AGC_TDA827X
,
819 .gpio_config
= TDA10046_GP11_I
,
820 .if_freq
= TDA10046_FREQ_045
,
822 .tuner_address
= 0x61,
824 .request_firmware
= philips_tda1004x_request_firmware
827 /* ------------------------------------------------------------------
828 * special case: this card uses saa713x GPIO22 for the mode switch
831 static int ads_duo_tuner_init(struct dvb_frontend
*fe
)
833 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
834 philips_tda827x_tuner_init(fe
);
835 /* route TDA8275a AGC input to the channel decoder */
836 saa7134_set_gpio(dev
, 22, 1);
840 static int ads_duo_tuner_sleep(struct dvb_frontend
*fe
)
842 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
843 /* route TDA8275a AGC input to the analog IF chip*/
844 saa7134_set_gpio(dev
, 22, 0);
845 philips_tda827x_tuner_sleep(fe
);
849 static struct tda827x_config ads_duo_cfg
= {
850 .init
= ads_duo_tuner_init
,
851 .sleep
= ads_duo_tuner_sleep
,
855 static struct tda1004x_config ads_tech_duo_config
= {
856 .demod_address
= 0x08,
859 .xtal_freq
= TDA10046_XTAL_16M
,
860 .agc_config
= TDA10046_AGC_TDA827X
,
861 .gpio_config
= TDA10046_GP00_I
,
862 .if_freq
= TDA10046_FREQ_045
,
863 .tuner_address
= 0x61,
864 .request_firmware
= philips_tda1004x_request_firmware
867 static struct zl10353_config behold_h6_config
= {
868 .demod_address
= 0x1e>>1,
871 .disable_i2c_gate_ctrl
= 1,
874 /* ==================================================================
875 * tda10086 based DVB-S cards, helper functions
878 static struct tda10086_config flydvbs
= {
879 .demod_address
= 0x0e,
882 .xtal_freq
= TDA10086_XTAL_16M
,
885 static struct tda10086_config sd1878_4m
= {
886 .demod_address
= 0x0e,
889 .xtal_freq
= TDA10086_XTAL_4M
,
892 /* ------------------------------------------------------------------
893 * special case: lnb supply is connected to the gated i2c
896 static int md8800_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
899 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
900 if (fe
->ops
.i2c_gate_ctrl
) {
901 fe
->ops
.i2c_gate_ctrl(fe
, 1);
902 if (dev
->original_set_voltage
)
903 res
= dev
->original_set_voltage(fe
, voltage
);
904 fe
->ops
.i2c_gate_ctrl(fe
, 0);
909 static int md8800_set_high_voltage(struct dvb_frontend
*fe
, long arg
)
912 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
913 if (fe
->ops
.i2c_gate_ctrl
) {
914 fe
->ops
.i2c_gate_ctrl(fe
, 1);
915 if (dev
->original_set_high_voltage
)
916 res
= dev
->original_set_high_voltage(fe
, arg
);
917 fe
->ops
.i2c_gate_ctrl(fe
, 0);
922 static int md8800_set_voltage2(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
924 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
925 u8 wbuf
[2] = { 0x1f, 00 };
927 struct i2c_msg msg
[] = { { .addr
= 0x08, .flags
= 0, .buf
= wbuf
, .len
= 1 },
928 { .addr
= 0x08, .flags
= I2C_M_RD
, .buf
= &rbuf
, .len
= 1 } };
930 if (i2c_transfer(&dev
->i2c_adap
, msg
, 2) != 2)
932 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
933 if (voltage
== SEC_VOLTAGE_18
)
934 wbuf
[1] = rbuf
| 0x10;
936 wbuf
[1] = rbuf
& 0xef;
938 i2c_transfer(&dev
->i2c_adap
, msg
, 1);
942 static int md8800_set_high_voltage2(struct dvb_frontend
*fe
, long arg
)
944 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
945 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__
);
949 /* ==================================================================
950 * nxt200x based ATSC cards, helper functions
953 static struct nxt200x_config avertvhda180
= {
954 .demod_address
= 0x0a,
957 static struct nxt200x_config kworldatsc110
= {
958 .demod_address
= 0x0a,
961 /* ------------------------------------------------------------------ */
963 static struct mt312_config avertv_a700_mt312
= {
964 .demod_address
= 0x0e,
965 .voltage_inverted
= 1,
968 static struct zl10036_config avertv_a700_tuner
= {
969 .tuner_address
= 0x60,
972 static struct mt312_config zl10313_compro_s350_config
= {
973 .demod_address
= 0x0e,
976 static struct lgdt3305_config hcw_lgdt3305_config
= {
978 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
979 .tpclk_edge
= LGDT3305_TPCLK_RISING_EDGE
,
980 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
982 .spectral_inversion
= 1,
987 static struct tda10048_config hcw_tda10048_config
= {
988 .demod_address
= 0x10 >> 1,
989 .output_mode
= TDA10048_SERIAL_OUTPUT
,
990 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
991 .inversion
= TDA10048_INVERSION_ON
,
992 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
993 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
994 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
995 .clk_freq_khz
= TDA10048_CLK_16000
,
996 .disable_gate_access
= 1,
999 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
1000 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
1001 .if_lvl
= 1, .rfagc_top
= 0x58, },
1002 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
1003 .if_lvl
= 1, .rfagc_top
= 0x58, },
1006 static struct tda18271_config hcw_tda18271_config
= {
1007 .std_map
= &hauppauge_tda18271_std_map
,
1008 .gate
= TDA18271_GATE_ANALOG
,
1010 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1013 static struct tda829x_config tda829x_no_probe
= {
1014 .probe_tuner
= TDA829X_DONT_PROBE
,
1017 static struct tda10048_config zolid_tda10048_config
= {
1018 .demod_address
= 0x10 >> 1,
1019 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1020 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1021 .inversion
= TDA10048_INVERSION_ON
,
1022 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1023 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1024 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1025 .clk_freq_khz
= TDA10048_CLK_16000
,
1026 .disable_gate_access
= 1,
1029 static struct tda18271_config zolid_tda18271_config
= {
1030 .gate
= TDA18271_GATE_ANALOG
,
1033 /* ==================================================================
1037 static int dvb_init(struct saa7134_dev
*dev
)
1040 int attach_xc3028
= 0;
1041 struct videobuf_dvb_frontend
*fe0
;
1043 /* FIXME: add support for multi-frontend */
1044 mutex_init(&dev
->frontends
.lock
);
1045 INIT_LIST_HEAD(&dev
->frontends
.felist
);
1047 printk(KERN_INFO
"%s() allocating 1 frontend\n", __func__
);
1048 fe0
= videobuf_dvb_alloc_frontend(&dev
->frontends
, 1);
1050 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
1054 /* init struct videobuf_dvb */
1055 dev
->ts
.nr_bufs
= 32;
1056 dev
->ts
.nr_packets
= 32*4;
1057 fe0
->dvb
.name
= dev
->name
;
1058 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &saa7134_ts_qops
,
1059 &dev
->pci
->dev
, &dev
->slock
,
1060 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
1061 V4L2_FIELD_ALTERNATE
,
1062 sizeof(struct saa7134_buf
),
1065 switch (dev
->board
) {
1066 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
1067 dprintk("pinnacle 300i dvb setup\n");
1068 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &pinnacle_300i
,
1070 if (fe0
->dvb
.frontend
) {
1071 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= mt352_pinnacle_tuner_set_params
;
1074 case SAA7134_BOARD_AVERMEDIA_777
:
1075 case SAA7134_BOARD_AVERMEDIA_A16AR
:
1076 dprintk("avertv 777 dvb setup\n");
1077 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_777
,
1079 if (fe0
->dvb
.frontend
) {
1080 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1081 &dev
->i2c_adap
, 0x61,
1082 TUNER_PHILIPS_TD1316
);
1085 case SAA7134_BOARD_AVERMEDIA_A16D
:
1086 dprintk("AverMedia A16D dvb setup\n");
1087 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1088 &avermedia_xc3028_mt352_dev
,
1092 case SAA7134_BOARD_MD7134
:
1093 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1096 if (fe0
->dvb
.frontend
) {
1097 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1098 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1099 TUNER_PHILIPS_FMD1216ME_MK3
);
1102 case SAA7134_BOARD_PHILIPS_TOUGH
:
1103 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1104 &philips_tu1216_60_config
,
1106 if (fe0
->dvb
.frontend
) {
1107 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1108 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1111 case SAA7134_BOARD_FLYDVBTDUO
:
1112 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS
:
1113 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1114 &tda827x_cfg_0
) < 0)
1115 goto dettach_frontend
;
1117 case SAA7134_BOARD_PHILIPS_EUROPA
:
1118 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
1119 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1120 &philips_europa_config
,
1122 if (fe0
->dvb
.frontend
) {
1123 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1124 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1125 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1126 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1127 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1130 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
1131 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1132 &philips_tu1216_61_config
,
1134 if (fe0
->dvb
.frontend
) {
1135 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1136 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1139 case SAA7134_BOARD_KWORLD_DVBT_210
:
1140 if (configure_tda827x_fe(dev
, &kworld_dvb_t_210_config
,
1141 &tda827x_cfg_2
) < 0)
1142 goto dettach_frontend
;
1144 case SAA7134_BOARD_HAUPPAUGE_HVR1120
:
1145 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1146 &hcw_tda10048_config
,
1148 if (fe0
->dvb
.frontend
!= NULL
) {
1149 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1150 &dev
->i2c_adap
, 0x4b,
1152 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1153 0x60, &dev
->i2c_adap
,
1154 &hcw_tda18271_config
);
1157 case SAA7134_BOARD_PHILIPS_TIGER
:
1158 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1159 &tda827x_cfg_0
) < 0)
1160 goto dettach_frontend
;
1162 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
1163 if (configure_tda827x_fe(dev
, &pinnacle_pctv_310i_config
,
1164 &tda827x_cfg_1
) < 0)
1165 goto dettach_frontend
;
1167 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
1168 if (configure_tda827x_fe(dev
, &hauppauge_hvr_1110_config
,
1169 &tda827x_cfg_1
) < 0)
1170 goto dettach_frontend
;
1172 case SAA7134_BOARD_HAUPPAUGE_HVR1150
:
1173 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1174 &hcw_lgdt3305_config
,
1176 if (fe0
->dvb
.frontend
) {
1177 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1178 &dev
->i2c_adap
, 0x4b,
1180 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1181 0x60, &dev
->i2c_adap
,
1182 &hcw_tda18271_config
);
1185 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
1186 if (configure_tda827x_fe(dev
, &asus_p7131_dual_config
,
1187 &tda827x_cfg_0
) < 0)
1188 goto dettach_frontend
;
1190 case SAA7134_BOARD_FLYDVBT_LR301
:
1191 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1192 &tda827x_cfg_0
) < 0)
1193 goto dettach_frontend
;
1195 case SAA7134_BOARD_FLYDVB_TRIO
:
1196 if (!use_frontend
) { /* terrestrial */
1197 if (configure_tda827x_fe(dev
, &lifeview_trio_config
,
1198 &tda827x_cfg_0
) < 0)
1199 goto dettach_frontend
;
1200 } else { /* satellite */
1201 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
, &dev
->i2c_adap
);
1202 if (fe0
->dvb
.frontend
) {
1203 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x63,
1204 &dev
->i2c_adap
, 0) == NULL
) {
1205 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__
);
1206 goto dettach_frontend
;
1208 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
, &dev
->i2c_adap
,
1209 0x08, 0, 0) == NULL
) {
1210 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__
);
1211 goto dettach_frontend
;
1216 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331
:
1217 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS
:
1218 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1219 &ads_tech_duo_config
,
1221 if (fe0
->dvb
.frontend
) {
1222 if (dvb_attach(tda827x_attach
,fe0
->dvb
.frontend
,
1223 ads_tech_duo_config
.tuner_address
, &dev
->i2c_adap
,
1224 &ads_duo_cfg
) == NULL
) {
1225 wprintk("no tda827x tuner found at addr: %02x\n",
1226 ads_tech_duo_config
.tuner_address
);
1227 goto dettach_frontend
;
1230 wprintk("failed to attach tda10046\n");
1232 case SAA7134_BOARD_TEVION_DVBT_220RF
:
1233 if (configure_tda827x_fe(dev
, &tevion_dvbt220rf_config
,
1234 &tda827x_cfg_0
) < 0)
1235 goto dettach_frontend
;
1237 case SAA7134_BOARD_MEDION_MD8800_QUADRO
:
1238 if (!use_frontend
) { /* terrestrial */
1239 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1240 &tda827x_cfg_0
) < 0)
1241 goto dettach_frontend
;
1242 } else { /* satellite */
1243 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1244 &flydvbs
, &dev
->i2c_adap
);
1245 if (fe0
->dvb
.frontend
) {
1246 struct dvb_frontend
*fe
= fe0
->dvb
.frontend
;
1247 u8 dev_id
= dev
->eedata
[2];
1249 struct i2c_msg msg
= {.addr
= 0x08, .flags
= 0, .len
= 1};
1251 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
,
1252 0x60, &dev
->i2c_adap
, 0) == NULL
) {
1253 wprintk("%s: Medion Quadro, no tda826x "
1254 "found !\n", __func__
);
1255 goto dettach_frontend
;
1257 if (dev_id
!= 0x08) {
1258 /* we need to open the i2c gate (we know it exists) */
1259 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1260 if (dvb_attach(isl6405_attach
, fe
,
1261 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1262 wprintk("%s: Medion Quadro, no ISL6405 "
1263 "found !\n", __func__
);
1264 goto dettach_frontend
;
1266 if (dev_id
== 0x07) {
1267 /* fire up the 2nd section of the LNB supply since
1268 we can't do this from the other section */
1270 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1272 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1273 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1274 fe
->ops
.set_voltage
= md8800_set_voltage
;
1275 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1276 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1278 fe
->ops
.set_voltage
= md8800_set_voltage2
;
1279 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage2
;
1284 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
1285 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &avertvhda180
,
1287 if (fe0
->dvb
.frontend
)
1288 dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x61,
1289 NULL
, DVB_PLL_TDHU2
);
1291 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI
:
1292 case SAA7134_BOARD_KWORLD_ATSC110
:
1293 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &kworldatsc110
,
1295 if (fe0
->dvb
.frontend
)
1296 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1297 &dev
->i2c_adap
, 0x61,
1298 TUNER_PHILIPS_TUV1236D
);
1300 case SAA7134_BOARD_FLYDVBS_LR300
:
1301 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1303 if (fe0
->dvb
.frontend
) {
1304 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1305 &dev
->i2c_adap
, 0) == NULL
) {
1306 wprintk("%s: No tda826x found!\n", __func__
);
1307 goto dettach_frontend
;
1309 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1310 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1311 wprintk("%s: No ISL6421 found!\n", __func__
);
1312 goto dettach_frontend
;
1316 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID
:
1317 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1320 if (fe0
->dvb
.frontend
) {
1321 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1322 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1324 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1325 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1326 TUNER_PHILIPS_FMD1216ME_MK3
);
1329 case SAA7134_BOARD_VIDEOMATE_DVBT_200A
:
1330 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1331 &philips_europa_config
,
1333 if (fe0
->dvb
.frontend
) {
1334 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_td1316_tuner_init
;
1335 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1338 case SAA7134_BOARD_CINERGY_HT_PCMCIA
:
1339 if (configure_tda827x_fe(dev
, &cinergy_ht_config
,
1340 &tda827x_cfg_0
) < 0)
1341 goto dettach_frontend
;
1343 case SAA7134_BOARD_CINERGY_HT_PCI
:
1344 if (configure_tda827x_fe(dev
, &cinergy_ht_pci_config
,
1345 &tda827x_cfg_0
) < 0)
1346 goto dettach_frontend
;
1348 case SAA7134_BOARD_PHILIPS_TIGER_S
:
1349 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1350 &tda827x_cfg_2
) < 0)
1351 goto dettach_frontend
;
1353 case SAA7134_BOARD_ASUS_P7131_4871
:
1354 if (configure_tda827x_fe(dev
, &asus_p7131_4871_config
,
1355 &tda827x_cfg_2
) < 0)
1356 goto dettach_frontend
;
1358 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
1359 if (configure_tda827x_fe(dev
, &asus_p7131_hybrid_lna_config
,
1360 &tda827x_cfg_2
) < 0)
1361 goto dettach_frontend
;
1363 case SAA7134_BOARD_AVERMEDIA_SUPER_007
:
1364 if (configure_tda827x_fe(dev
, &avermedia_super_007_config
,
1365 &tda827x_cfg_0
) < 0)
1366 goto dettach_frontend
;
1368 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056
:
1369 if (configure_tda827x_fe(dev
, &twinhan_dtv_dvb_3056_config
,
1370 &tda827x_cfg_2_sw42
) < 0)
1371 goto dettach_frontend
;
1373 case SAA7134_BOARD_PHILIPS_SNAKE
:
1374 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1376 if (fe0
->dvb
.frontend
) {
1377 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1378 &dev
->i2c_adap
, 0) == NULL
) {
1379 wprintk("%s: No tda826x found!\n", __func__
);
1380 goto dettach_frontend
;
1382 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1383 &dev
->i2c_adap
, 0, 0) == NULL
) {
1384 wprintk("%s: No lnbp21 found!\n", __func__
);
1385 goto dettach_frontend
;
1389 case SAA7134_BOARD_CREATIX_CTX953
:
1390 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1391 &tda827x_cfg_0
) < 0)
1392 goto dettach_frontend
;
1394 case SAA7134_BOARD_MSI_TVANYWHERE_AD11
:
1395 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1396 &tda827x_cfg_2
) < 0)
1397 goto dettach_frontend
;
1399 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
1400 dprintk("AverMedia E506R dvb setup\n");
1401 saa7134_set_gpio(dev
, 25, 0);
1403 saa7134_set_gpio(dev
, 25, 1);
1404 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1405 &avermedia_xc3028_mt352_dev
,
1409 case SAA7134_BOARD_MD7134_BRIDGE_2
:
1410 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1411 &sd1878_4m
, &dev
->i2c_adap
);
1412 if (fe0
->dvb
.frontend
) {
1413 struct dvb_frontend
*fe
;
1414 if (dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1415 &dev
->i2c_adap
, DVB_PLL_PHILIPS_SD1878_TDA8261
) == NULL
) {
1416 wprintk("%s: MD7134 DVB-S, no SD1878 "
1417 "found !\n", __func__
);
1418 goto dettach_frontend
;
1420 /* we need to open the i2c gate (we know it exists) */
1421 fe
= fe0
->dvb
.frontend
;
1422 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1423 if (dvb_attach(isl6405_attach
, fe
,
1424 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1425 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1426 "found !\n", __func__
);
1427 goto dettach_frontend
;
1429 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1430 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1431 fe
->ops
.set_voltage
= md8800_set_voltage
;
1432 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1433 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1436 case SAA7134_BOARD_AVERMEDIA_M103
:
1437 saa7134_set_gpio(dev
, 25, 0);
1439 saa7134_set_gpio(dev
, 25, 1);
1440 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1441 &avermedia_xc3028_mt352_dev
,
1445 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1
:
1446 if (!use_frontend
) { /* terrestrial */
1447 if (configure_tda827x_fe(dev
, &asus_tiger_3in1_config
,
1448 &tda827x_cfg_2
) < 0)
1449 goto dettach_frontend
;
1450 } else { /* satellite */
1451 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1452 &flydvbs
, &dev
->i2c_adap
);
1453 if (fe0
->dvb
.frontend
) {
1454 if (dvb_attach(tda826x_attach
,
1455 fe0
->dvb
.frontend
, 0x60,
1456 &dev
->i2c_adap
, 0) == NULL
) {
1457 wprintk("%s: Asus Tiger 3in1, no "
1458 "tda826x found!\n", __func__
);
1459 goto dettach_frontend
;
1461 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1462 &dev
->i2c_adap
, 0, 0) == NULL
) {
1463 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1464 " found!\n", __func__
);
1465 goto dettach_frontend
;
1470 case SAA7134_BOARD_ASUSTeK_TIGER
:
1471 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1472 &tda827x_cfg_0
) < 0)
1473 goto dettach_frontend
;
1475 case SAA7134_BOARD_BEHOLD_H6
:
1476 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1479 if (fe0
->dvb
.frontend
) {
1480 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1481 &dev
->i2c_adap
, 0x61,
1482 TUNER_PHILIPS_FMD1216MEX_MK3
);
1485 case SAA7134_BOARD_AVERMEDIA_A700_PRO
:
1486 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID
:
1487 /* Zarlink ZL10313 */
1488 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1489 &avertv_a700_mt312
, &dev
->i2c_adap
);
1490 if (fe0
->dvb
.frontend
) {
1491 if (dvb_attach(zl10036_attach
, fe0
->dvb
.frontend
,
1492 &avertv_a700_tuner
, &dev
->i2c_adap
) == NULL
) {
1493 wprintk("%s: No zl10036 found!\n",
1498 case SAA7134_BOARD_VIDEOMATE_S350
:
1499 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1500 &zl10313_compro_s350_config
, &dev
->i2c_adap
);
1501 if (fe0
->dvb
.frontend
)
1502 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1503 0x60, &dev
->i2c_adap
) == NULL
)
1504 wprintk("%s: No zl10039 found!\n",
1508 case SAA7134_BOARD_ZOLID_HYBRID_PCI
:
1509 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1510 &zolid_tda10048_config
,
1512 if (fe0
->dvb
.frontend
!= NULL
) {
1513 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1514 &dev
->i2c_adap
, 0x4b,
1516 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1517 0x60, &dev
->i2c_adap
,
1518 &zolid_tda18271_config
);
1522 wprintk("Huh? unknown DVB card?\n");
1526 if (attach_xc3028
) {
1527 struct dvb_frontend
*fe
;
1528 struct xc2028_config cfg
= {
1529 .i2c_adap
= &dev
->i2c_adap
,
1533 if (!fe0
->dvb
.frontend
)
1534 goto dettach_frontend
;
1536 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
1538 printk(KERN_ERR
"%s/2: xc3028 attach failed\n",
1540 goto dettach_frontend
;
1544 if (NULL
== fe0
->dvb
.frontend
) {
1545 printk(KERN_ERR
"%s/dvb: frontend initialization failed\n", dev
->name
);
1546 goto dettach_frontend
;
1548 /* define general-purpose callback pointer */
1549 fe0
->dvb
.frontend
->callback
= saa7134_tuner_callback
;
1551 /* register everything else */
1552 ret
= videobuf_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1553 &dev
->pci
->dev
, adapter_nr
, 0);
1555 /* this sequence is necessary to make the tda1004x load its firmware
1556 * and to enter analog mode of hybrid boards
1559 if (fe0
->dvb
.frontend
->ops
.init
)
1560 fe0
->dvb
.frontend
->ops
.init(fe0
->dvb
.frontend
);
1561 if (fe0
->dvb
.frontend
->ops
.sleep
)
1562 fe0
->dvb
.frontend
->ops
.sleep(fe0
->dvb
.frontend
);
1563 if (fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
)
1564 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep(fe0
->dvb
.frontend
);
1569 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
1573 static int dvb_fini(struct saa7134_dev
*dev
)
1575 struct videobuf_dvb_frontend
*fe0
;
1577 /* Get the first frontend */
1578 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
1582 /* FIXME: I suspect that this code is bogus, since the entry for
1583 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1584 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1586 if (dev
->board
== SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
) {
1587 struct v4l2_priv_tun_config tda9887_cfg
;
1588 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
1590 tda9887_cfg
.tuner
= TUNER_TDA9887
;
1591 tda9887_cfg
.priv
= &on
;
1593 /* otherwise we don't detect the tuner on next insmod */
1594 saa_call_all(dev
, tuner
, s_config
, &tda9887_cfg
);
1595 } else if (dev
->board
== SAA7134_BOARD_MEDION_MD8800_QUADRO
) {
1596 if ((dev
->eedata
[2] == 0x07) && use_frontend
) {
1597 /* turn off the 2nd lnb supply */
1599 struct i2c_msg msg
= {.addr
= 0x08, .buf
= &data
, .flags
= 0, .len
= 1};
1600 struct dvb_frontend
*fe
;
1601 fe
= fe0
->dvb
.frontend
;
1602 if (fe
->ops
.i2c_gate_ctrl
) {
1603 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1604 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1605 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1609 videobuf_dvb_unregister_bus(&dev
->frontends
);
1613 static struct saa7134_mpeg_ops dvb_ops
= {
1614 .type
= SAA7134_MPEG_DVB
,
1619 static int __init
dvb_register(void)
1621 return saa7134_ts_register(&dvb_ops
);
1624 static void __exit
dvb_unregister(void)
1626 saa7134_ts_unregister(&dvb_ops
);
1629 module_init(dvb_register
);
1630 module_exit(dvb_unregister
);
1632 /* ------------------------------------------------------------------ */