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"
61 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
62 MODULE_LICENSE("GPL");
64 static unsigned int antenna_pwr
;
66 module_param(antenna_pwr
, int, 0444);
67 MODULE_PARM_DESC(antenna_pwr
,"enable antenna power (Pinnacle 300i)");
69 static int use_frontend
;
70 module_param(use_frontend
, int, 0644);
71 MODULE_PARM_DESC(use_frontend
,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
74 module_param(debug
, int, 0644);
75 MODULE_PARM_DESC(debug
, "Turn on/off module debugging (default:off).");
77 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
79 #define dprintk(fmt, arg...) do { if (debug) \
80 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
83 #define wprintk(fmt, arg...) \
84 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
86 /* ------------------------------------------------------------------
87 * mt352 based DVB-T cards
90 static int pinnacle_antenna_pwr(struct saa7134_dev
*dev
, int on
)
95 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
96 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
100 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
101 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
104 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 28));
105 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
107 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
109 ok
= saa_readl(SAA7134_GPIO_GPSTATUS0
) & (1 << 27);
110 dprintk("%s %s\n", __func__
, ok
? "on" : "off");
113 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
117 static int mt352_pinnacle_init(struct dvb_frontend
* fe
)
119 static u8 clock_config
[] = { CLOCK_CTL
, 0x3d, 0x28 };
120 static u8 reset
[] = { RESET
, 0x80 };
121 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
122 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
123 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x31 };
124 static u8 fsm_ctl_cfg
[] = { 0x7b, 0x04 };
125 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x0f };
126 static u8 scan_ctl_cfg
[] = { SCAN_CTL
, 0x0d };
127 static u8 irq_cfg
[] = { INTERRUPT_EN_0
, 0x00, 0x00, 0x00, 0x00 };
128 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
130 dprintk("%s called\n", __func__
);
132 mt352_write(fe
, clock_config
, sizeof(clock_config
));
134 mt352_write(fe
, reset
, sizeof(reset
));
135 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
136 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
137 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
138 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
140 mt352_write(fe
, fsm_ctl_cfg
, sizeof(fsm_ctl_cfg
));
141 mt352_write(fe
, scan_ctl_cfg
, sizeof(scan_ctl_cfg
));
142 mt352_write(fe
, irq_cfg
, sizeof(irq_cfg
));
147 static int mt352_aver777_init(struct dvb_frontend
* fe
)
149 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
150 static u8 reset
[] = { RESET
, 0x80 };
151 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
152 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
153 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
155 mt352_write(fe
, clock_config
, sizeof(clock_config
));
157 mt352_write(fe
, reset
, sizeof(reset
));
158 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
159 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
160 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
165 static int mt352_avermedia_xc3028_init(struct dvb_frontend
*fe
)
167 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
168 static u8 reset
[] = { RESET
, 0x80 };
169 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
170 static u8 agc_cfg
[] = { AGC_TARGET
, 0xe };
171 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
173 mt352_write(fe
, clock_config
, sizeof(clock_config
));
175 mt352_write(fe
, reset
, sizeof(reset
));
176 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
177 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
178 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
182 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend
* fe
,
183 struct dvb_frontend_parameters
* params
)
185 u8 off
[] = { 0x00, 0xf1};
186 u8 on
[] = { 0x00, 0x71};
187 struct i2c_msg msg
= {.addr
=0x43, .flags
=0, .buf
=off
, .len
= sizeof(off
)};
189 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
190 struct v4l2_frequency f
;
192 /* set frequency (mt2050) */
194 f
.type
= V4L2_TUNER_DIGITAL_TV
;
195 f
.frequency
= params
->frequency
/ 1000 * 16 / 1000;
196 if (fe
->ops
.i2c_gate_ctrl
)
197 fe
->ops
.i2c_gate_ctrl(fe
, 1);
198 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
199 saa_call_all(dev
, tuner
, s_frequency
, &f
);
201 if (fe
->ops
.i2c_gate_ctrl
)
202 fe
->ops
.i2c_gate_ctrl(fe
, 1);
203 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
205 pinnacle_antenna_pwr(dev
, antenna_pwr
);
208 return mt352_pinnacle_init(fe
);
211 static struct mt352_config pinnacle_300i
= {
212 .demod_address
= 0x3c >> 1,
216 .demod_init
= mt352_pinnacle_init
,
219 static struct mt352_config avermedia_777
= {
220 .demod_address
= 0xf,
221 .demod_init
= mt352_aver777_init
,
224 static struct mt352_config avermedia_xc3028_mt352_dev
= {
225 .demod_address
= (0x1e >> 1),
227 .demod_init
= mt352_avermedia_xc3028_init
,
230 /* ==================================================================
231 * tda1004x based DVB-T cards, helper functions
234 static int philips_tda1004x_request_firmware(struct dvb_frontend
*fe
,
235 const struct firmware
**fw
, char *name
)
237 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
238 return request_firmware(fw
, name
, &dev
->pci
->dev
);
241 /* ------------------------------------------------------------------
242 * these tuners are tu1216, td1316(a)
245 static int philips_tda6651_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
247 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
248 struct tda1004x_state
*state
= fe
->demodulator_priv
;
249 u8 addr
= state
->config
->tuner_address
;
251 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tuner_buf
,.len
=
253 int tuner_frequency
= 0;
256 /* determine charge pump */
257 tuner_frequency
= params
->frequency
+ 36166000;
258 if (tuner_frequency
< 87000000)
260 else if (tuner_frequency
< 130000000)
262 else if (tuner_frequency
< 160000000)
264 else if (tuner_frequency
< 200000000)
266 else if (tuner_frequency
< 290000000)
268 else if (tuner_frequency
< 420000000)
270 else if (tuner_frequency
< 480000000)
272 else if (tuner_frequency
< 620000000)
274 else if (tuner_frequency
< 830000000)
276 else if (tuner_frequency
< 895000000)
282 if (params
->frequency
< 49000000)
284 else if (params
->frequency
< 161000000)
286 else if (params
->frequency
< 444000000)
288 else if (params
->frequency
< 861000000)
293 /* setup PLL filter */
294 switch (params
->u
.ofdm
.bandwidth
) {
295 case BANDWIDTH_6_MHZ
:
299 case BANDWIDTH_7_MHZ
:
303 case BANDWIDTH_8_MHZ
:
312 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
314 tuner_frequency
= (((params
->frequency
/ 1000) * 6) + 217496) / 1000;
316 /* setup tuner buffer */
317 tuner_buf
[0] = (tuner_frequency
>> 8) & 0x7f;
318 tuner_buf
[1] = tuner_frequency
& 0xff;
320 tuner_buf
[3] = (cp
<< 5) | (filter
<< 3) | band
;
322 if (fe
->ops
.i2c_gate_ctrl
)
323 fe
->ops
.i2c_gate_ctrl(fe
, 1);
324 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1) {
325 wprintk("could not write to tuner at addr: 0x%02x\n",
333 static int philips_tu1216_init(struct dvb_frontend
*fe
)
335 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
336 struct tda1004x_state
*state
= fe
->demodulator_priv
;
337 u8 addr
= state
->config
->tuner_address
;
338 static u8 tu1216_init
[] = { 0x0b, 0xf5, 0x85, 0xab };
339 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tu1216_init
,.len
= sizeof(tu1216_init
) };
341 /* setup PLL configuration */
342 if (fe
->ops
.i2c_gate_ctrl
)
343 fe
->ops
.i2c_gate_ctrl(fe
, 1);
344 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
351 /* ------------------------------------------------------------------ */
353 static struct tda1004x_config philips_tu1216_60_config
= {
354 .demod_address
= 0x8,
357 .xtal_freq
= TDA10046_XTAL_4M
,
358 .agc_config
= TDA10046_AGC_DEFAULT
,
359 .if_freq
= TDA10046_FREQ_3617
,
360 .tuner_address
= 0x60,
361 .request_firmware
= philips_tda1004x_request_firmware
364 static struct tda1004x_config philips_tu1216_61_config
= {
366 .demod_address
= 0x8,
369 .xtal_freq
= TDA10046_XTAL_4M
,
370 .agc_config
= TDA10046_AGC_DEFAULT
,
371 .if_freq
= TDA10046_FREQ_3617
,
372 .tuner_address
= 0x61,
373 .request_firmware
= philips_tda1004x_request_firmware
376 /* ------------------------------------------------------------------ */
378 static int philips_td1316_tuner_init(struct dvb_frontend
*fe
)
380 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
381 struct tda1004x_state
*state
= fe
->demodulator_priv
;
382 u8 addr
= state
->config
->tuner_address
;
383 static u8 msg
[] = { 0x0b, 0xf5, 0x86, 0xab };
384 struct i2c_msg init_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
386 /* setup PLL configuration */
387 if (fe
->ops
.i2c_gate_ctrl
)
388 fe
->ops
.i2c_gate_ctrl(fe
, 1);
389 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
394 static int philips_td1316_tuner_set_params(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
396 return philips_tda6651_pll_set(fe
, params
);
399 static int philips_td1316_tuner_sleep(struct dvb_frontend
*fe
)
401 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
402 struct tda1004x_state
*state
= fe
->demodulator_priv
;
403 u8 addr
= state
->config
->tuner_address
;
404 static u8 msg
[] = { 0x0b, 0xdc, 0x86, 0xa4 };
405 struct i2c_msg analog_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
407 /* switch the tuner to analog mode */
408 if (fe
->ops
.i2c_gate_ctrl
)
409 fe
->ops
.i2c_gate_ctrl(fe
, 1);
410 if (i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1) != 1)
415 /* ------------------------------------------------------------------ */
417 static int philips_europa_tuner_init(struct dvb_frontend
*fe
)
419 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
420 static u8 msg
[] = { 0x00, 0x40};
421 struct i2c_msg init_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
424 if (philips_td1316_tuner_init(fe
))
427 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
433 static int philips_europa_tuner_sleep(struct dvb_frontend
*fe
)
435 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
437 static u8 msg
[] = { 0x00, 0x14 };
438 struct i2c_msg analog_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
440 if (philips_td1316_tuner_sleep(fe
))
443 /* switch the board to analog mode */
444 if (fe
->ops
.i2c_gate_ctrl
)
445 fe
->ops
.i2c_gate_ctrl(fe
, 1);
446 i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1);
450 static int philips_europa_demod_sleep(struct dvb_frontend
*fe
)
452 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
454 if (dev
->original_demod_sleep
)
455 dev
->original_demod_sleep(fe
);
456 fe
->ops
.i2c_gate_ctrl(fe
, 1);
460 static struct tda1004x_config philips_europa_config
= {
462 .demod_address
= 0x8,
465 .xtal_freq
= TDA10046_XTAL_4M
,
466 .agc_config
= TDA10046_AGC_IFO_AUTO_POS
,
467 .if_freq
= TDA10046_FREQ_052
,
468 .tuner_address
= 0x61,
469 .request_firmware
= philips_tda1004x_request_firmware
472 static struct tda1004x_config medion_cardbus
= {
473 .demod_address
= 0x08,
476 .xtal_freq
= TDA10046_XTAL_16M
,
477 .agc_config
= TDA10046_AGC_IFO_AUTO_NEG
,
478 .if_freq
= TDA10046_FREQ_3613
,
479 .tuner_address
= 0x61,
480 .request_firmware
= philips_tda1004x_request_firmware
483 /* ------------------------------------------------------------------
484 * tda 1004x based cards with philips silicon tuner
487 static int tda8290_i2c_gate_ctrl( struct dvb_frontend
* fe
, int enable
)
489 struct tda1004x_state
*state
= fe
->demodulator_priv
;
491 u8 addr
= state
->config
->i2c_gate
;
492 static u8 tda8290_close
[] = { 0x21, 0xc0};
493 static u8 tda8290_open
[] = { 0x21, 0x80};
494 struct i2c_msg tda8290_msg
= {.addr
= addr
,.flags
= 0, .len
= 2};
496 tda8290_msg
.buf
= tda8290_close
;
498 tda8290_msg
.buf
= tda8290_open
;
500 if (i2c_transfer(state
->i2c
, &tda8290_msg
, 1) != 1) {
501 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
502 wprintk("could not access tda8290 I2C gate\n");
509 static int philips_tda827x_tuner_init(struct dvb_frontend
*fe
)
511 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
512 struct tda1004x_state
*state
= fe
->demodulator_priv
;
514 switch (state
->config
->antenna_switch
) {
516 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
517 saa7134_set_gpio(dev
, 21, 0);
519 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
520 saa7134_set_gpio(dev
, 21, 1);
526 static int philips_tda827x_tuner_sleep(struct dvb_frontend
*fe
)
528 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
529 struct tda1004x_state
*state
= fe
->demodulator_priv
;
531 switch (state
->config
->antenna_switch
) {
533 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
534 saa7134_set_gpio(dev
, 21, 1);
536 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
537 saa7134_set_gpio(dev
, 21, 0);
543 static int configure_tda827x_fe(struct saa7134_dev
*dev
,
544 struct tda1004x_config
*cdec_conf
,
545 struct tda827x_config
*tuner_conf
)
547 struct videobuf_dvb_frontend
*fe0
;
549 /* Get the first frontend */
550 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
552 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
, cdec_conf
, &dev
->i2c_adap
);
553 if (fe0
->dvb
.frontend
) {
554 if (cdec_conf
->i2c_gate
)
555 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= tda8290_i2c_gate_ctrl
;
556 if (dvb_attach(tda827x_attach
, fe0
->dvb
.frontend
,
557 cdec_conf
->tuner_address
,
558 &dev
->i2c_adap
, tuner_conf
))
561 wprintk("no tda827x tuner found at addr: %02x\n",
562 cdec_conf
->tuner_address
);
567 /* ------------------------------------------------------------------ */
569 static struct tda827x_config tda827x_cfg_0
= {
570 .init
= philips_tda827x_tuner_init
,
571 .sleep
= philips_tda827x_tuner_sleep
,
576 static struct tda827x_config tda827x_cfg_1
= {
577 .init
= philips_tda827x_tuner_init
,
578 .sleep
= philips_tda827x_tuner_sleep
,
583 static struct tda827x_config tda827x_cfg_2
= {
584 .init
= philips_tda827x_tuner_init
,
585 .sleep
= philips_tda827x_tuner_sleep
,
590 static struct tda827x_config tda827x_cfg_2_sw42
= {
591 .init
= philips_tda827x_tuner_init
,
592 .sleep
= philips_tda827x_tuner_sleep
,
597 /* ------------------------------------------------------------------ */
599 static struct tda1004x_config tda827x_lifeview_config
= {
600 .demod_address
= 0x08,
603 .xtal_freq
= TDA10046_XTAL_16M
,
604 .agc_config
= TDA10046_AGC_TDA827X
,
605 .gpio_config
= TDA10046_GP11_I
,
606 .if_freq
= TDA10046_FREQ_045
,
607 .tuner_address
= 0x60,
608 .request_firmware
= philips_tda1004x_request_firmware
611 static struct tda1004x_config philips_tiger_config
= {
612 .demod_address
= 0x08,
615 .xtal_freq
= TDA10046_XTAL_16M
,
616 .agc_config
= TDA10046_AGC_TDA827X
,
617 .gpio_config
= TDA10046_GP11_I
,
618 .if_freq
= TDA10046_FREQ_045
,
620 .tuner_address
= 0x61,
622 .request_firmware
= philips_tda1004x_request_firmware
625 static struct tda1004x_config cinergy_ht_config
= {
626 .demod_address
= 0x08,
629 .xtal_freq
= TDA10046_XTAL_16M
,
630 .agc_config
= TDA10046_AGC_TDA827X
,
631 .gpio_config
= TDA10046_GP01_I
,
632 .if_freq
= TDA10046_FREQ_045
,
634 .tuner_address
= 0x61,
635 .request_firmware
= philips_tda1004x_request_firmware
638 static struct tda1004x_config cinergy_ht_pci_config
= {
639 .demod_address
= 0x08,
642 .xtal_freq
= TDA10046_XTAL_16M
,
643 .agc_config
= TDA10046_AGC_TDA827X
,
644 .gpio_config
= TDA10046_GP01_I
,
645 .if_freq
= TDA10046_FREQ_045
,
647 .tuner_address
= 0x60,
648 .request_firmware
= philips_tda1004x_request_firmware
651 static struct tda1004x_config philips_tiger_s_config
= {
652 .demod_address
= 0x08,
655 .xtal_freq
= TDA10046_XTAL_16M
,
656 .agc_config
= TDA10046_AGC_TDA827X
,
657 .gpio_config
= TDA10046_GP01_I
,
658 .if_freq
= TDA10046_FREQ_045
,
660 .tuner_address
= 0x61,
662 .request_firmware
= philips_tda1004x_request_firmware
665 static struct tda1004x_config pinnacle_pctv_310i_config
= {
666 .demod_address
= 0x08,
669 .xtal_freq
= TDA10046_XTAL_16M
,
670 .agc_config
= TDA10046_AGC_TDA827X
,
671 .gpio_config
= TDA10046_GP11_I
,
672 .if_freq
= TDA10046_FREQ_045
,
674 .tuner_address
= 0x61,
675 .request_firmware
= philips_tda1004x_request_firmware
678 static struct tda1004x_config hauppauge_hvr_1110_config
= {
679 .demod_address
= 0x08,
682 .xtal_freq
= TDA10046_XTAL_16M
,
683 .agc_config
= TDA10046_AGC_TDA827X
,
684 .gpio_config
= TDA10046_GP11_I
,
685 .if_freq
= TDA10046_FREQ_045
,
687 .tuner_address
= 0x61,
688 .request_firmware
= philips_tda1004x_request_firmware
691 static struct tda1004x_config asus_p7131_dual_config
= {
692 .demod_address
= 0x08,
695 .xtal_freq
= TDA10046_XTAL_16M
,
696 .agc_config
= TDA10046_AGC_TDA827X
,
697 .gpio_config
= TDA10046_GP11_I
,
698 .if_freq
= TDA10046_FREQ_045
,
700 .tuner_address
= 0x61,
702 .request_firmware
= philips_tda1004x_request_firmware
705 static struct tda1004x_config lifeview_trio_config
= {
706 .demod_address
= 0x09,
709 .xtal_freq
= TDA10046_XTAL_16M
,
710 .agc_config
= TDA10046_AGC_TDA827X
,
711 .gpio_config
= TDA10046_GP00_I
,
712 .if_freq
= TDA10046_FREQ_045
,
713 .tuner_address
= 0x60,
714 .request_firmware
= philips_tda1004x_request_firmware
717 static struct tda1004x_config tevion_dvbt220rf_config
= {
718 .demod_address
= 0x08,
721 .xtal_freq
= TDA10046_XTAL_16M
,
722 .agc_config
= TDA10046_AGC_TDA827X
,
723 .gpio_config
= TDA10046_GP11_I
,
724 .if_freq
= TDA10046_FREQ_045
,
725 .tuner_address
= 0x60,
726 .request_firmware
= philips_tda1004x_request_firmware
729 static struct tda1004x_config md8800_dvbt_config
= {
730 .demod_address
= 0x08,
733 .xtal_freq
= TDA10046_XTAL_16M
,
734 .agc_config
= TDA10046_AGC_TDA827X
,
735 .gpio_config
= TDA10046_GP01_I
,
736 .if_freq
= TDA10046_FREQ_045
,
738 .tuner_address
= 0x60,
739 .request_firmware
= philips_tda1004x_request_firmware
742 static struct tda1004x_config asus_p7131_4871_config
= {
743 .demod_address
= 0x08,
746 .xtal_freq
= TDA10046_XTAL_16M
,
747 .agc_config
= TDA10046_AGC_TDA827X
,
748 .gpio_config
= TDA10046_GP01_I
,
749 .if_freq
= TDA10046_FREQ_045
,
751 .tuner_address
= 0x61,
753 .request_firmware
= philips_tda1004x_request_firmware
756 static struct tda1004x_config asus_p7131_hybrid_lna_config
= {
757 .demod_address
= 0x08,
760 .xtal_freq
= TDA10046_XTAL_16M
,
761 .agc_config
= TDA10046_AGC_TDA827X
,
762 .gpio_config
= TDA10046_GP11_I
,
763 .if_freq
= TDA10046_FREQ_045
,
765 .tuner_address
= 0x61,
767 .request_firmware
= philips_tda1004x_request_firmware
770 static struct tda1004x_config kworld_dvb_t_210_config
= {
771 .demod_address
= 0x08,
774 .xtal_freq
= TDA10046_XTAL_16M
,
775 .agc_config
= TDA10046_AGC_TDA827X
,
776 .gpio_config
= TDA10046_GP11_I
,
777 .if_freq
= TDA10046_FREQ_045
,
779 .tuner_address
= 0x61,
781 .request_firmware
= philips_tda1004x_request_firmware
784 static struct tda1004x_config avermedia_super_007_config
= {
785 .demod_address
= 0x08,
788 .xtal_freq
= TDA10046_XTAL_16M
,
789 .agc_config
= TDA10046_AGC_TDA827X
,
790 .gpio_config
= TDA10046_GP01_I
,
791 .if_freq
= TDA10046_FREQ_045
,
793 .tuner_address
= 0x60,
795 .request_firmware
= philips_tda1004x_request_firmware
798 static struct tda1004x_config twinhan_dtv_dvb_3056_config
= {
799 .demod_address
= 0x08,
802 .xtal_freq
= TDA10046_XTAL_16M
,
803 .agc_config
= TDA10046_AGC_TDA827X
,
804 .gpio_config
= TDA10046_GP01_I
,
805 .if_freq
= TDA10046_FREQ_045
,
807 .tuner_address
= 0x61,
809 .request_firmware
= philips_tda1004x_request_firmware
812 static struct tda1004x_config asus_tiger_3in1_config
= {
813 .demod_address
= 0x0b,
816 .xtal_freq
= TDA10046_XTAL_16M
,
817 .agc_config
= TDA10046_AGC_TDA827X
,
818 .gpio_config
= TDA10046_GP11_I
,
819 .if_freq
= TDA10046_FREQ_045
,
821 .tuner_address
= 0x61,
823 .request_firmware
= philips_tda1004x_request_firmware
826 /* ------------------------------------------------------------------
827 * special case: this card uses saa713x GPIO22 for the mode switch
830 static int ads_duo_tuner_init(struct dvb_frontend
*fe
)
832 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
833 philips_tda827x_tuner_init(fe
);
834 /* route TDA8275a AGC input to the channel decoder */
835 saa7134_set_gpio(dev
, 22, 1);
839 static int ads_duo_tuner_sleep(struct dvb_frontend
*fe
)
841 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
842 /* route TDA8275a AGC input to the analog IF chip*/
843 saa7134_set_gpio(dev
, 22, 0);
844 philips_tda827x_tuner_sleep(fe
);
848 static struct tda827x_config ads_duo_cfg
= {
849 .init
= ads_duo_tuner_init
,
850 .sleep
= ads_duo_tuner_sleep
,
854 static struct tda1004x_config ads_tech_duo_config
= {
855 .demod_address
= 0x08,
858 .xtal_freq
= TDA10046_XTAL_16M
,
859 .agc_config
= TDA10046_AGC_TDA827X
,
860 .gpio_config
= TDA10046_GP00_I
,
861 .if_freq
= TDA10046_FREQ_045
,
862 .tuner_address
= 0x61,
863 .request_firmware
= philips_tda1004x_request_firmware
866 static struct zl10353_config behold_h6_config
= {
867 .demod_address
= 0x1e>>1,
870 .disable_i2c_gate_ctrl
= 1,
873 /* ==================================================================
874 * tda10086 based DVB-S cards, helper functions
877 static struct tda10086_config flydvbs
= {
878 .demod_address
= 0x0e,
881 .xtal_freq
= TDA10086_XTAL_16M
,
884 static struct tda10086_config sd1878_4m
= {
885 .demod_address
= 0x0e,
888 .xtal_freq
= TDA10086_XTAL_4M
,
891 /* ------------------------------------------------------------------
892 * special case: lnb supply is connected to the gated i2c
895 static int md8800_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
898 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
899 if (fe
->ops
.i2c_gate_ctrl
) {
900 fe
->ops
.i2c_gate_ctrl(fe
, 1);
901 if (dev
->original_set_voltage
)
902 res
= dev
->original_set_voltage(fe
, voltage
);
903 fe
->ops
.i2c_gate_ctrl(fe
, 0);
908 static int md8800_set_high_voltage(struct dvb_frontend
*fe
, long arg
)
911 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
912 if (fe
->ops
.i2c_gate_ctrl
) {
913 fe
->ops
.i2c_gate_ctrl(fe
, 1);
914 if (dev
->original_set_high_voltage
)
915 res
= dev
->original_set_high_voltage(fe
, arg
);
916 fe
->ops
.i2c_gate_ctrl(fe
, 0);
921 static int md8800_set_voltage2(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
923 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
924 u8 wbuf
[2] = { 0x1f, 00 };
926 struct i2c_msg msg
[] = { { .addr
= 0x08, .flags
= 0, .buf
= wbuf
, .len
= 1 },
927 { .addr
= 0x08, .flags
= I2C_M_RD
, .buf
= &rbuf
, .len
= 1 } };
929 if (i2c_transfer(&dev
->i2c_adap
, msg
, 2) != 2)
931 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
932 if (voltage
== SEC_VOLTAGE_18
)
933 wbuf
[1] = rbuf
| 0x10;
935 wbuf
[1] = rbuf
& 0xef;
937 i2c_transfer(&dev
->i2c_adap
, msg
, 1);
941 static int md8800_set_high_voltage2(struct dvb_frontend
*fe
, long arg
)
943 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
944 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__
);
948 /* ==================================================================
949 * nxt200x based ATSC cards, helper functions
952 static struct nxt200x_config avertvhda180
= {
953 .demod_address
= 0x0a,
956 static struct nxt200x_config kworldatsc110
= {
957 .demod_address
= 0x0a,
960 /* ------------------------------------------------------------------ */
962 static struct mt312_config avertv_a700_mt312
= {
963 .demod_address
= 0x0e,
964 .voltage_inverted
= 1,
967 static struct zl10036_config avertv_a700_tuner
= {
968 .tuner_address
= 0x60,
971 static struct lgdt3305_config hcw_lgdt3305_config
= {
973 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
974 .tpclk_edge
= LGDT3305_TPCLK_RISING_EDGE
,
975 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
977 .spectral_inversion
= 1,
982 static struct tda10048_config hcw_tda10048_config
= {
983 .demod_address
= 0x10 >> 1,
984 .output_mode
= TDA10048_SERIAL_OUTPUT
,
985 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
986 .inversion
= TDA10048_INVERSION_ON
,
987 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
988 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
989 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
990 .clk_freq_khz
= TDA10048_CLK_16000
,
991 .disable_gate_access
= 1,
994 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
995 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
996 .if_lvl
= 1, .rfagc_top
= 0x58, },
997 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
998 .if_lvl
= 1, .rfagc_top
= 0x58, },
1001 static struct tda18271_config hcw_tda18271_config
= {
1002 .std_map
= &hauppauge_tda18271_std_map
,
1003 .gate
= TDA18271_GATE_ANALOG
,
1007 static struct tda829x_config tda829x_no_probe
= {
1008 .probe_tuner
= TDA829X_DONT_PROBE
,
1011 /* ==================================================================
1015 static int dvb_init(struct saa7134_dev
*dev
)
1018 int attach_xc3028
= 0;
1019 struct videobuf_dvb_frontend
*fe0
;
1021 /* FIXME: add support for multi-frontend */
1022 mutex_init(&dev
->frontends
.lock
);
1023 INIT_LIST_HEAD(&dev
->frontends
.felist
);
1025 printk(KERN_INFO
"%s() allocating 1 frontend\n", __func__
);
1026 fe0
= videobuf_dvb_alloc_frontend(&dev
->frontends
, 1);
1028 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
1032 /* init struct videobuf_dvb */
1033 dev
->ts
.nr_bufs
= 32;
1034 dev
->ts
.nr_packets
= 32*4;
1035 fe0
->dvb
.name
= dev
->name
;
1036 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &saa7134_ts_qops
,
1037 &dev
->pci
->dev
, &dev
->slock
,
1038 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
1039 V4L2_FIELD_ALTERNATE
,
1040 sizeof(struct saa7134_buf
),
1043 switch (dev
->board
) {
1044 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
1045 dprintk("pinnacle 300i dvb setup\n");
1046 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &pinnacle_300i
,
1048 if (fe0
->dvb
.frontend
) {
1049 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= mt352_pinnacle_tuner_set_params
;
1052 case SAA7134_BOARD_AVERMEDIA_777
:
1053 case SAA7134_BOARD_AVERMEDIA_A16AR
:
1054 dprintk("avertv 777 dvb setup\n");
1055 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_777
,
1057 if (fe0
->dvb
.frontend
) {
1058 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1059 &dev
->i2c_adap
, 0x61,
1060 TUNER_PHILIPS_TD1316
);
1063 case SAA7134_BOARD_AVERMEDIA_A16D
:
1064 dprintk("AverMedia A16D dvb setup\n");
1065 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1066 &avermedia_xc3028_mt352_dev
,
1070 case SAA7134_BOARD_MD7134
:
1071 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1074 if (fe0
->dvb
.frontend
) {
1075 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1076 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1077 TUNER_PHILIPS_FMD1216ME_MK3
);
1080 case SAA7134_BOARD_PHILIPS_TOUGH
:
1081 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1082 &philips_tu1216_60_config
,
1084 if (fe0
->dvb
.frontend
) {
1085 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1086 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1089 case SAA7134_BOARD_FLYDVBTDUO
:
1090 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS
:
1091 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1092 &tda827x_cfg_0
) < 0)
1093 goto dettach_frontend
;
1095 case SAA7134_BOARD_PHILIPS_EUROPA
:
1096 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
1097 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1098 &philips_europa_config
,
1100 if (fe0
->dvb
.frontend
) {
1101 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1102 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1103 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1104 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1105 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1108 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
1109 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1110 &philips_tu1216_61_config
,
1112 if (fe0
->dvb
.frontend
) {
1113 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1114 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1117 case SAA7134_BOARD_KWORLD_DVBT_210
:
1118 if (configure_tda827x_fe(dev
, &kworld_dvb_t_210_config
,
1119 &tda827x_cfg_2
) < 0)
1120 goto dettach_frontend
;
1122 case SAA7134_BOARD_HAUPPAUGE_HVR1120
:
1123 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1124 &hcw_tda10048_config
,
1126 if (fe0
->dvb
.frontend
!= NULL
) {
1127 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1128 &dev
->i2c_adap
, 0x4b,
1130 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1131 0x60, &dev
->i2c_adap
,
1132 &hcw_tda18271_config
);
1135 case SAA7134_BOARD_PHILIPS_TIGER
:
1136 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1137 &tda827x_cfg_0
) < 0)
1138 goto dettach_frontend
;
1140 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
1141 if (configure_tda827x_fe(dev
, &pinnacle_pctv_310i_config
,
1142 &tda827x_cfg_1
) < 0)
1143 goto dettach_frontend
;
1145 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
1146 if (configure_tda827x_fe(dev
, &hauppauge_hvr_1110_config
,
1147 &tda827x_cfg_1
) < 0)
1148 goto dettach_frontend
;
1150 case SAA7134_BOARD_HAUPPAUGE_HVR1150
:
1151 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1152 &hcw_lgdt3305_config
,
1154 if (fe0
->dvb
.frontend
) {
1155 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1156 &dev
->i2c_adap
, 0x4b,
1158 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1159 0x60, &dev
->i2c_adap
,
1160 &hcw_tda18271_config
);
1163 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
1164 if (configure_tda827x_fe(dev
, &asus_p7131_dual_config
,
1165 &tda827x_cfg_0
) < 0)
1166 goto dettach_frontend
;
1168 case SAA7134_BOARD_FLYDVBT_LR301
:
1169 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1170 &tda827x_cfg_0
) < 0)
1171 goto dettach_frontend
;
1173 case SAA7134_BOARD_FLYDVB_TRIO
:
1174 if (!use_frontend
) { /* terrestrial */
1175 if (configure_tda827x_fe(dev
, &lifeview_trio_config
,
1176 &tda827x_cfg_0
) < 0)
1177 goto dettach_frontend
;
1178 } else { /* satellite */
1179 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
, &dev
->i2c_adap
);
1180 if (fe0
->dvb
.frontend
) {
1181 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x63,
1182 &dev
->i2c_adap
, 0) == NULL
) {
1183 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__
);
1184 goto dettach_frontend
;
1186 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
, &dev
->i2c_adap
,
1187 0x08, 0, 0) == NULL
) {
1188 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__
);
1189 goto dettach_frontend
;
1194 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331
:
1195 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS
:
1196 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1197 &ads_tech_duo_config
,
1199 if (fe0
->dvb
.frontend
) {
1200 if (dvb_attach(tda827x_attach
,fe0
->dvb
.frontend
,
1201 ads_tech_duo_config
.tuner_address
, &dev
->i2c_adap
,
1202 &ads_duo_cfg
) == NULL
) {
1203 wprintk("no tda827x tuner found at addr: %02x\n",
1204 ads_tech_duo_config
.tuner_address
);
1205 goto dettach_frontend
;
1208 wprintk("failed to attach tda10046\n");
1210 case SAA7134_BOARD_TEVION_DVBT_220RF
:
1211 if (configure_tda827x_fe(dev
, &tevion_dvbt220rf_config
,
1212 &tda827x_cfg_0
) < 0)
1213 goto dettach_frontend
;
1215 case SAA7134_BOARD_MEDION_MD8800_QUADRO
:
1216 if (!use_frontend
) { /* terrestrial */
1217 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1218 &tda827x_cfg_0
) < 0)
1219 goto dettach_frontend
;
1220 } else { /* satellite */
1221 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1222 &flydvbs
, &dev
->i2c_adap
);
1223 if (fe0
->dvb
.frontend
) {
1224 struct dvb_frontend
*fe
= fe0
->dvb
.frontend
;
1225 u8 dev_id
= dev
->eedata
[2];
1227 struct i2c_msg msg
= {.addr
= 0x08, .flags
= 0, .len
= 1};
1229 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
,
1230 0x60, &dev
->i2c_adap
, 0) == NULL
) {
1231 wprintk("%s: Medion Quadro, no tda826x "
1232 "found !\n", __func__
);
1233 goto dettach_frontend
;
1235 if (dev_id
!= 0x08) {
1236 /* we need to open the i2c gate (we know it exists) */
1237 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1238 if (dvb_attach(isl6405_attach
, fe
,
1239 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1240 wprintk("%s: Medion Quadro, no ISL6405 "
1241 "found !\n", __func__
);
1242 goto dettach_frontend
;
1244 if (dev_id
== 0x07) {
1245 /* fire up the 2nd section of the LNB supply since
1246 we can't do this from the other section */
1248 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1250 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1251 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1252 fe
->ops
.set_voltage
= md8800_set_voltage
;
1253 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1254 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1256 fe
->ops
.set_voltage
= md8800_set_voltage2
;
1257 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage2
;
1262 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
1263 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &avertvhda180
,
1265 if (fe0
->dvb
.frontend
)
1266 dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x61,
1267 NULL
, DVB_PLL_TDHU2
);
1269 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI
:
1270 case SAA7134_BOARD_KWORLD_ATSC110
:
1271 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &kworldatsc110
,
1273 if (fe0
->dvb
.frontend
)
1274 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1275 &dev
->i2c_adap
, 0x61,
1276 TUNER_PHILIPS_TUV1236D
);
1278 case SAA7134_BOARD_FLYDVBS_LR300
:
1279 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1281 if (fe0
->dvb
.frontend
) {
1282 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1283 &dev
->i2c_adap
, 0) == NULL
) {
1284 wprintk("%s: No tda826x found!\n", __func__
);
1285 goto dettach_frontend
;
1287 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1288 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1289 wprintk("%s: No ISL6421 found!\n", __func__
);
1290 goto dettach_frontend
;
1294 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID
:
1295 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1298 if (fe0
->dvb
.frontend
) {
1299 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1300 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1302 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1303 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1304 TUNER_PHILIPS_FMD1216ME_MK3
);
1307 case SAA7134_BOARD_VIDEOMATE_DVBT_200A
:
1308 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1309 &philips_europa_config
,
1311 if (fe0
->dvb
.frontend
) {
1312 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_td1316_tuner_init
;
1313 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1316 case SAA7134_BOARD_CINERGY_HT_PCMCIA
:
1317 if (configure_tda827x_fe(dev
, &cinergy_ht_config
,
1318 &tda827x_cfg_0
) < 0)
1319 goto dettach_frontend
;
1321 case SAA7134_BOARD_CINERGY_HT_PCI
:
1322 if (configure_tda827x_fe(dev
, &cinergy_ht_pci_config
,
1323 &tda827x_cfg_0
) < 0)
1324 goto dettach_frontend
;
1326 case SAA7134_BOARD_PHILIPS_TIGER_S
:
1327 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1328 &tda827x_cfg_2
) < 0)
1329 goto dettach_frontend
;
1331 case SAA7134_BOARD_ASUS_P7131_4871
:
1332 if (configure_tda827x_fe(dev
, &asus_p7131_4871_config
,
1333 &tda827x_cfg_2
) < 0)
1334 goto dettach_frontend
;
1336 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
1337 if (configure_tda827x_fe(dev
, &asus_p7131_hybrid_lna_config
,
1338 &tda827x_cfg_2
) < 0)
1339 goto dettach_frontend
;
1341 case SAA7134_BOARD_AVERMEDIA_SUPER_007
:
1342 if (configure_tda827x_fe(dev
, &avermedia_super_007_config
,
1343 &tda827x_cfg_0
) < 0)
1344 goto dettach_frontend
;
1346 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056
:
1347 if (configure_tda827x_fe(dev
, &twinhan_dtv_dvb_3056_config
,
1348 &tda827x_cfg_2_sw42
) < 0)
1349 goto dettach_frontend
;
1351 case SAA7134_BOARD_PHILIPS_SNAKE
:
1352 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1354 if (fe0
->dvb
.frontend
) {
1355 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1356 &dev
->i2c_adap
, 0) == NULL
) {
1357 wprintk("%s: No tda826x found!\n", __func__
);
1358 goto dettach_frontend
;
1360 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1361 &dev
->i2c_adap
, 0, 0) == NULL
) {
1362 wprintk("%s: No lnbp21 found!\n", __func__
);
1363 goto dettach_frontend
;
1367 case SAA7134_BOARD_CREATIX_CTX953
:
1368 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1369 &tda827x_cfg_0
) < 0)
1370 goto dettach_frontend
;
1372 case SAA7134_BOARD_MSI_TVANYWHERE_AD11
:
1373 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1374 &tda827x_cfg_2
) < 0)
1375 goto dettach_frontend
;
1377 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
1378 dprintk("AverMedia E506R dvb setup\n");
1379 saa7134_set_gpio(dev
, 25, 0);
1381 saa7134_set_gpio(dev
, 25, 1);
1382 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1383 &avermedia_xc3028_mt352_dev
,
1387 case SAA7134_BOARD_MD7134_BRIDGE_2
:
1388 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1389 &sd1878_4m
, &dev
->i2c_adap
);
1390 if (fe0
->dvb
.frontend
) {
1391 struct dvb_frontend
*fe
;
1392 if (dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1393 &dev
->i2c_adap
, DVB_PLL_PHILIPS_SD1878_TDA8261
) == NULL
) {
1394 wprintk("%s: MD7134 DVB-S, no SD1878 "
1395 "found !\n", __func__
);
1396 goto dettach_frontend
;
1398 /* we need to open the i2c gate (we know it exists) */
1399 fe
= fe0
->dvb
.frontend
;
1400 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1401 if (dvb_attach(isl6405_attach
, fe
,
1402 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1403 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1404 "found !\n", __func__
);
1405 goto dettach_frontend
;
1407 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1408 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1409 fe
->ops
.set_voltage
= md8800_set_voltage
;
1410 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1411 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1414 case SAA7134_BOARD_AVERMEDIA_M103
:
1415 saa7134_set_gpio(dev
, 25, 0);
1417 saa7134_set_gpio(dev
, 25, 1);
1418 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1419 &avermedia_xc3028_mt352_dev
,
1423 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1
:
1424 if (!use_frontend
) { /* terrestrial */
1425 if (configure_tda827x_fe(dev
, &asus_tiger_3in1_config
,
1426 &tda827x_cfg_2
) < 0)
1427 goto dettach_frontend
;
1428 } else { /* satellite */
1429 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1430 &flydvbs
, &dev
->i2c_adap
);
1431 if (fe0
->dvb
.frontend
) {
1432 if (dvb_attach(tda826x_attach
,
1433 fe0
->dvb
.frontend
, 0x60,
1434 &dev
->i2c_adap
, 0) == NULL
) {
1435 wprintk("%s: Asus Tiger 3in1, no "
1436 "tda826x found!\n", __func__
);
1437 goto dettach_frontend
;
1439 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1440 &dev
->i2c_adap
, 0, 0) == NULL
) {
1441 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1442 " found!\n", __func__
);
1443 goto dettach_frontend
;
1448 case SAA7134_BOARD_ASUSTeK_TIGER
:
1449 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1450 &tda827x_cfg_0
) < 0)
1451 goto dettach_frontend
;
1453 case SAA7134_BOARD_BEHOLD_H6
:
1454 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1457 if (fe0
->dvb
.frontend
) {
1458 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1459 &dev
->i2c_adap
, 0x61,
1460 TUNER_PHILIPS_FMD1216ME_MK3
);
1463 case SAA7134_BOARD_AVERMEDIA_A700_PRO
:
1464 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID
:
1465 /* Zarlink ZL10313 */
1466 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1467 &avertv_a700_mt312
, &dev
->i2c_adap
);
1468 if (fe0
->dvb
.frontend
) {
1469 if (dvb_attach(zl10036_attach
, fe0
->dvb
.frontend
,
1470 &avertv_a700_tuner
, &dev
->i2c_adap
) == NULL
) {
1471 wprintk("%s: No zl10036 found!\n",
1477 wprintk("Huh? unknown DVB card?\n");
1481 if (attach_xc3028
) {
1482 struct dvb_frontend
*fe
;
1483 struct xc2028_config cfg
= {
1484 .i2c_adap
= &dev
->i2c_adap
,
1488 if (!fe0
->dvb
.frontend
)
1489 goto dettach_frontend
;
1491 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
1493 printk(KERN_ERR
"%s/2: xc3028 attach failed\n",
1495 goto dettach_frontend
;
1499 if (NULL
== fe0
->dvb
.frontend
) {
1500 printk(KERN_ERR
"%s/dvb: frontend initialization failed\n", dev
->name
);
1501 goto dettach_frontend
;
1503 /* define general-purpose callback pointer */
1504 fe0
->dvb
.frontend
->callback
= saa7134_tuner_callback
;
1506 /* register everything else */
1507 ret
= videobuf_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1508 &dev
->pci
->dev
, adapter_nr
, 0);
1510 /* this sequence is necessary to make the tda1004x load its firmware
1511 * and to enter analog mode of hybrid boards
1514 if (fe0
->dvb
.frontend
->ops
.init
)
1515 fe0
->dvb
.frontend
->ops
.init(fe0
->dvb
.frontend
);
1516 if (fe0
->dvb
.frontend
->ops
.sleep
)
1517 fe0
->dvb
.frontend
->ops
.sleep(fe0
->dvb
.frontend
);
1518 if (fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
)
1519 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep(fe0
->dvb
.frontend
);
1524 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
1528 static int dvb_fini(struct saa7134_dev
*dev
)
1530 struct videobuf_dvb_frontend
*fe0
;
1532 /* Get the first frontend */
1533 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
1537 /* FIXME: I suspect that this code is bogus, since the entry for
1538 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1539 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1541 if (dev
->board
== SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
) {
1542 struct v4l2_priv_tun_config tda9887_cfg
;
1543 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
1545 tda9887_cfg
.tuner
= TUNER_TDA9887
;
1546 tda9887_cfg
.priv
= &on
;
1548 /* otherwise we don't detect the tuner on next insmod */
1549 saa_call_all(dev
, tuner
, s_config
, &tda9887_cfg
);
1550 } else if (dev
->board
== SAA7134_BOARD_MEDION_MD8800_QUADRO
) {
1551 if ((dev
->eedata
[2] == 0x07) && use_frontend
) {
1552 /* turn off the 2nd lnb supply */
1554 struct i2c_msg msg
= {.addr
= 0x08, .buf
= &data
, .flags
= 0, .len
= 1};
1555 struct dvb_frontend
*fe
;
1556 fe
= fe0
->dvb
.frontend
;
1557 if (fe
->ops
.i2c_gate_ctrl
) {
1558 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1559 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1560 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1564 videobuf_dvb_unregister_bus(&dev
->frontends
);
1568 static struct saa7134_mpeg_ops dvb_ops
= {
1569 .type
= SAA7134_MPEG_DVB
,
1574 static int __init
dvb_register(void)
1576 return saa7134_ts_register(&dvb_ops
);
1579 static void __exit
dvb_unregister(void)
1581 saa7134_ts_unregister(&dvb_ops
);
1584 module_init(dvb_register
);
1585 module_exit(dvb_unregister
);
1587 /* ------------------------------------------------------------------ */