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/delay.h>
28 #include <linux/kthread.h>
29 #include <linux/suspend.h>
31 #include "saa7134-reg.h"
33 #include <media/v4l2-common.h>
35 #include <dvb_frontend.h>
38 #include "mt352_priv.h" /* FIXME */
41 #include "tuner-xc2028.h"
50 #include "tuner-simple.h"
64 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
65 MODULE_LICENSE("GPL");
67 static unsigned int antenna_pwr
;
69 module_param(antenna_pwr
, int, 0444);
70 MODULE_PARM_DESC(antenna_pwr
,"enable antenna power (Pinnacle 300i)");
72 static int use_frontend
;
73 module_param(use_frontend
, int, 0644);
74 MODULE_PARM_DESC(use_frontend
,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
77 module_param(debug
, int, 0644);
78 MODULE_PARM_DESC(debug
, "Turn on/off module debugging (default:off).");
80 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
82 #define dprintk(fmt, arg...) do { if (debug) \
83 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
86 #define wprintk(fmt, arg...) \
87 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
89 /* ------------------------------------------------------------------
90 * mt352 based DVB-T cards
93 static int pinnacle_antenna_pwr(struct saa7134_dev
*dev
, int on
)
98 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
99 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
103 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
104 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
107 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 28));
108 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
110 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
112 ok
= saa_readl(SAA7134_GPIO_GPSTATUS0
) & (1 << 27);
113 dprintk("%s %s\n", __func__
, ok
? "on" : "off");
116 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
120 static int mt352_pinnacle_init(struct dvb_frontend
* fe
)
122 static u8 clock_config
[] = { CLOCK_CTL
, 0x3d, 0x28 };
123 static u8 reset
[] = { RESET
, 0x80 };
124 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
125 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
126 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x31 };
127 static u8 fsm_ctl_cfg
[] = { 0x7b, 0x04 };
128 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x0f };
129 static u8 scan_ctl_cfg
[] = { SCAN_CTL
, 0x0d };
130 static u8 irq_cfg
[] = { INTERRUPT_EN_0
, 0x00, 0x00, 0x00, 0x00 };
131 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
133 dprintk("%s called\n", __func__
);
135 mt352_write(fe
, clock_config
, sizeof(clock_config
));
137 mt352_write(fe
, reset
, sizeof(reset
));
138 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
139 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
140 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
141 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
143 mt352_write(fe
, fsm_ctl_cfg
, sizeof(fsm_ctl_cfg
));
144 mt352_write(fe
, scan_ctl_cfg
, sizeof(scan_ctl_cfg
));
145 mt352_write(fe
, irq_cfg
, sizeof(irq_cfg
));
150 static int mt352_aver777_init(struct dvb_frontend
* fe
)
152 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
153 static u8 reset
[] = { RESET
, 0x80 };
154 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
155 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
156 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
158 mt352_write(fe
, clock_config
, sizeof(clock_config
));
160 mt352_write(fe
, reset
, sizeof(reset
));
161 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
162 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
163 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
168 static int mt352_avermedia_xc3028_init(struct dvb_frontend
*fe
)
170 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
171 static u8 reset
[] = { RESET
, 0x80 };
172 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
173 static u8 agc_cfg
[] = { AGC_TARGET
, 0xe };
174 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
176 mt352_write(fe
, clock_config
, sizeof(clock_config
));
178 mt352_write(fe
, reset
, sizeof(reset
));
179 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
180 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
181 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
185 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend
* fe
,
186 struct dvb_frontend_parameters
* params
)
188 u8 off
[] = { 0x00, 0xf1};
189 u8 on
[] = { 0x00, 0x71};
190 struct i2c_msg msg
= {.addr
=0x43, .flags
=0, .buf
=off
, .len
= sizeof(off
)};
192 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
193 struct v4l2_frequency f
;
195 /* set frequency (mt2050) */
197 f
.type
= V4L2_TUNER_DIGITAL_TV
;
198 f
.frequency
= params
->frequency
/ 1000 * 16 / 1000;
199 if (fe
->ops
.i2c_gate_ctrl
)
200 fe
->ops
.i2c_gate_ctrl(fe
, 1);
201 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
202 saa_call_all(dev
, tuner
, s_frequency
, &f
);
204 if (fe
->ops
.i2c_gate_ctrl
)
205 fe
->ops
.i2c_gate_ctrl(fe
, 1);
206 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
208 pinnacle_antenna_pwr(dev
, antenna_pwr
);
211 return mt352_pinnacle_init(fe
);
214 static struct mt352_config pinnacle_300i
= {
215 .demod_address
= 0x3c >> 1,
219 .demod_init
= mt352_pinnacle_init
,
222 static struct mt352_config avermedia_777
= {
223 .demod_address
= 0xf,
224 .demod_init
= mt352_aver777_init
,
227 static struct mt352_config avermedia_xc3028_mt352_dev
= {
228 .demod_address
= (0x1e >> 1),
230 .demod_init
= mt352_avermedia_xc3028_init
,
233 static struct tda18271_std_map mb86a20s_tda18271_std_map
= {
234 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
235 .if_lvl
= 7, .rfagc_top
= 0x37, },
238 static struct tda18271_config kworld_tda18271_config
= {
239 .std_map
= &mb86a20s_tda18271_std_map
,
240 .gate
= TDA18271_GATE_DIGITAL
,
241 .config
= 3, /* Use tuner callback for AGC */
245 static const struct mb86a20s_config kworld_mb86a20s_config
= {
246 .demod_address
= 0x10,
249 static int kworld_sbtvd_gate_ctrl(struct dvb_frontend
* fe
, int enable
)
251 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
253 unsigned char initmsg
[] = {0x45, 0x97};
254 unsigned char msg_enable
[] = {0x45, 0xc1};
255 unsigned char msg_disable
[] = {0x45, 0x81};
256 struct i2c_msg msg
= {.addr
= 0x4b, .flags
= 0, .buf
= initmsg
, .len
= 2};
258 if (i2c_transfer(&dev
->i2c_adap
, &msg
, 1) != 1) {
259 wprintk("could not access the I2C gate\n");
263 msg
.buf
= msg_enable
;
265 msg
.buf
= msg_disable
;
266 if (i2c_transfer(&dev
->i2c_adap
, &msg
, 1) != 1) {
267 wprintk("could not access the I2C gate\n");
274 /* ==================================================================
275 * tda1004x based DVB-T cards, helper functions
278 static int philips_tda1004x_request_firmware(struct dvb_frontend
*fe
,
279 const struct firmware
**fw
, char *name
)
281 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
282 return request_firmware(fw
, name
, &dev
->pci
->dev
);
285 /* ------------------------------------------------------------------
286 * these tuners are tu1216, td1316(a)
289 static int philips_tda6651_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
291 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
292 struct tda1004x_state
*state
= fe
->demodulator_priv
;
293 u8 addr
= state
->config
->tuner_address
;
295 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tuner_buf
,.len
=
297 int tuner_frequency
= 0;
300 /* determine charge pump */
301 tuner_frequency
= params
->frequency
+ 36166000;
302 if (tuner_frequency
< 87000000)
304 else if (tuner_frequency
< 130000000)
306 else if (tuner_frequency
< 160000000)
308 else if (tuner_frequency
< 200000000)
310 else if (tuner_frequency
< 290000000)
312 else if (tuner_frequency
< 420000000)
314 else if (tuner_frequency
< 480000000)
316 else if (tuner_frequency
< 620000000)
318 else if (tuner_frequency
< 830000000)
320 else if (tuner_frequency
< 895000000)
326 if (params
->frequency
< 49000000)
328 else if (params
->frequency
< 161000000)
330 else if (params
->frequency
< 444000000)
332 else if (params
->frequency
< 861000000)
337 /* setup PLL filter */
338 switch (params
->u
.ofdm
.bandwidth
) {
339 case BANDWIDTH_6_MHZ
:
343 case BANDWIDTH_7_MHZ
:
347 case BANDWIDTH_8_MHZ
:
356 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
358 tuner_frequency
= (((params
->frequency
/ 1000) * 6) + 217496) / 1000;
360 /* setup tuner buffer */
361 tuner_buf
[0] = (tuner_frequency
>> 8) & 0x7f;
362 tuner_buf
[1] = tuner_frequency
& 0xff;
364 tuner_buf
[3] = (cp
<< 5) | (filter
<< 3) | band
;
366 if (fe
->ops
.i2c_gate_ctrl
)
367 fe
->ops
.i2c_gate_ctrl(fe
, 1);
368 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1) {
369 wprintk("could not write to tuner at addr: 0x%02x\n",
377 static int philips_tu1216_init(struct dvb_frontend
*fe
)
379 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
380 struct tda1004x_state
*state
= fe
->demodulator_priv
;
381 u8 addr
= state
->config
->tuner_address
;
382 static u8 tu1216_init
[] = { 0x0b, 0xf5, 0x85, 0xab };
383 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tu1216_init
,.len
= sizeof(tu1216_init
) };
385 /* setup PLL configuration */
386 if (fe
->ops
.i2c_gate_ctrl
)
387 fe
->ops
.i2c_gate_ctrl(fe
, 1);
388 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
395 /* ------------------------------------------------------------------ */
397 static struct tda1004x_config philips_tu1216_60_config
= {
398 .demod_address
= 0x8,
401 .xtal_freq
= TDA10046_XTAL_4M
,
402 .agc_config
= TDA10046_AGC_DEFAULT
,
403 .if_freq
= TDA10046_FREQ_3617
,
404 .tuner_address
= 0x60,
405 .request_firmware
= philips_tda1004x_request_firmware
408 static struct tda1004x_config philips_tu1216_61_config
= {
410 .demod_address
= 0x8,
413 .xtal_freq
= TDA10046_XTAL_4M
,
414 .agc_config
= TDA10046_AGC_DEFAULT
,
415 .if_freq
= TDA10046_FREQ_3617
,
416 .tuner_address
= 0x61,
417 .request_firmware
= philips_tda1004x_request_firmware
420 /* ------------------------------------------------------------------ */
422 static int philips_td1316_tuner_init(struct dvb_frontend
*fe
)
424 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
425 struct tda1004x_state
*state
= fe
->demodulator_priv
;
426 u8 addr
= state
->config
->tuner_address
;
427 static u8 msg
[] = { 0x0b, 0xf5, 0x86, 0xab };
428 struct i2c_msg init_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
430 /* setup PLL configuration */
431 if (fe
->ops
.i2c_gate_ctrl
)
432 fe
->ops
.i2c_gate_ctrl(fe
, 1);
433 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
438 static int philips_td1316_tuner_set_params(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
440 return philips_tda6651_pll_set(fe
, params
);
443 static int philips_td1316_tuner_sleep(struct dvb_frontend
*fe
)
445 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
446 struct tda1004x_state
*state
= fe
->demodulator_priv
;
447 u8 addr
= state
->config
->tuner_address
;
448 static u8 msg
[] = { 0x0b, 0xdc, 0x86, 0xa4 };
449 struct i2c_msg analog_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
451 /* switch the tuner to analog mode */
452 if (fe
->ops
.i2c_gate_ctrl
)
453 fe
->ops
.i2c_gate_ctrl(fe
, 1);
454 if (i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1) != 1)
459 /* ------------------------------------------------------------------ */
461 static int philips_europa_tuner_init(struct dvb_frontend
*fe
)
463 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
464 static u8 msg
[] = { 0x00, 0x40};
465 struct i2c_msg init_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
468 if (philips_td1316_tuner_init(fe
))
471 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
477 static int philips_europa_tuner_sleep(struct dvb_frontend
*fe
)
479 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
481 static u8 msg
[] = { 0x00, 0x14 };
482 struct i2c_msg analog_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
484 if (philips_td1316_tuner_sleep(fe
))
487 /* switch the board to analog mode */
488 if (fe
->ops
.i2c_gate_ctrl
)
489 fe
->ops
.i2c_gate_ctrl(fe
, 1);
490 i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1);
494 static int philips_europa_demod_sleep(struct dvb_frontend
*fe
)
496 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
498 if (dev
->original_demod_sleep
)
499 dev
->original_demod_sleep(fe
);
500 fe
->ops
.i2c_gate_ctrl(fe
, 1);
504 static struct tda1004x_config philips_europa_config
= {
506 .demod_address
= 0x8,
509 .xtal_freq
= TDA10046_XTAL_4M
,
510 .agc_config
= TDA10046_AGC_IFO_AUTO_POS
,
511 .if_freq
= TDA10046_FREQ_052
,
512 .tuner_address
= 0x61,
513 .request_firmware
= philips_tda1004x_request_firmware
516 static struct tda1004x_config medion_cardbus
= {
517 .demod_address
= 0x08,
520 .xtal_freq
= TDA10046_XTAL_16M
,
521 .agc_config
= TDA10046_AGC_IFO_AUTO_NEG
,
522 .if_freq
= TDA10046_FREQ_3613
,
523 .tuner_address
= 0x61,
524 .request_firmware
= philips_tda1004x_request_firmware
527 static struct tda1004x_config technotrend_budget_t3000_config
= {
528 .demod_address
= 0x8,
531 .xtal_freq
= TDA10046_XTAL_4M
,
532 .agc_config
= TDA10046_AGC_DEFAULT
,
533 .if_freq
= TDA10046_FREQ_3617
,
534 .tuner_address
= 0x63,
535 .request_firmware
= philips_tda1004x_request_firmware
538 /* ------------------------------------------------------------------
539 * tda 1004x based cards with philips silicon tuner
542 static int tda8290_i2c_gate_ctrl( struct dvb_frontend
* fe
, int enable
)
544 struct tda1004x_state
*state
= fe
->demodulator_priv
;
546 u8 addr
= state
->config
->i2c_gate
;
547 static u8 tda8290_close
[] = { 0x21, 0xc0};
548 static u8 tda8290_open
[] = { 0x21, 0x80};
549 struct i2c_msg tda8290_msg
= {.addr
= addr
,.flags
= 0, .len
= 2};
551 tda8290_msg
.buf
= tda8290_close
;
553 tda8290_msg
.buf
= tda8290_open
;
555 if (i2c_transfer(state
->i2c
, &tda8290_msg
, 1) != 1) {
556 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
557 wprintk("could not access tda8290 I2C gate\n");
564 static int philips_tda827x_tuner_init(struct dvb_frontend
*fe
)
566 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
567 struct tda1004x_state
*state
= fe
->demodulator_priv
;
569 switch (state
->config
->antenna_switch
) {
571 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
572 saa7134_set_gpio(dev
, 21, 0);
574 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
575 saa7134_set_gpio(dev
, 21, 1);
581 static int philips_tda827x_tuner_sleep(struct dvb_frontend
*fe
)
583 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
584 struct tda1004x_state
*state
= fe
->demodulator_priv
;
586 switch (state
->config
->antenna_switch
) {
588 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
589 saa7134_set_gpio(dev
, 21, 1);
591 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
592 saa7134_set_gpio(dev
, 21, 0);
598 static int configure_tda827x_fe(struct saa7134_dev
*dev
,
599 struct tda1004x_config
*cdec_conf
,
600 struct tda827x_config
*tuner_conf
)
602 struct videobuf_dvb_frontend
*fe0
;
604 /* Get the first frontend */
605 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
607 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
, cdec_conf
, &dev
->i2c_adap
);
608 if (fe0
->dvb
.frontend
) {
609 if (cdec_conf
->i2c_gate
)
610 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= tda8290_i2c_gate_ctrl
;
611 if (dvb_attach(tda827x_attach
, fe0
->dvb
.frontend
,
612 cdec_conf
->tuner_address
,
613 &dev
->i2c_adap
, tuner_conf
))
616 wprintk("no tda827x tuner found at addr: %02x\n",
617 cdec_conf
->tuner_address
);
622 /* ------------------------------------------------------------------ */
624 static struct tda827x_config tda827x_cfg_0
= {
625 .init
= philips_tda827x_tuner_init
,
626 .sleep
= philips_tda827x_tuner_sleep
,
631 static struct tda827x_config tda827x_cfg_1
= {
632 .init
= philips_tda827x_tuner_init
,
633 .sleep
= philips_tda827x_tuner_sleep
,
638 static struct tda827x_config tda827x_cfg_2
= {
639 .init
= philips_tda827x_tuner_init
,
640 .sleep
= philips_tda827x_tuner_sleep
,
645 static struct tda827x_config tda827x_cfg_2_sw42
= {
646 .init
= philips_tda827x_tuner_init
,
647 .sleep
= philips_tda827x_tuner_sleep
,
652 /* ------------------------------------------------------------------ */
654 static struct tda1004x_config tda827x_lifeview_config
= {
655 .demod_address
= 0x08,
658 .xtal_freq
= TDA10046_XTAL_16M
,
659 .agc_config
= TDA10046_AGC_TDA827X
,
660 .gpio_config
= TDA10046_GP11_I
,
661 .if_freq
= TDA10046_FREQ_045
,
662 .tuner_address
= 0x60,
663 .request_firmware
= philips_tda1004x_request_firmware
666 static struct tda1004x_config philips_tiger_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,
677 .request_firmware
= philips_tda1004x_request_firmware
680 static struct tda1004x_config cinergy_ht_config
= {
681 .demod_address
= 0x08,
684 .xtal_freq
= TDA10046_XTAL_16M
,
685 .agc_config
= TDA10046_AGC_TDA827X
,
686 .gpio_config
= TDA10046_GP01_I
,
687 .if_freq
= TDA10046_FREQ_045
,
689 .tuner_address
= 0x61,
690 .request_firmware
= philips_tda1004x_request_firmware
693 static struct tda1004x_config cinergy_ht_pci_config
= {
694 .demod_address
= 0x08,
697 .xtal_freq
= TDA10046_XTAL_16M
,
698 .agc_config
= TDA10046_AGC_TDA827X
,
699 .gpio_config
= TDA10046_GP01_I
,
700 .if_freq
= TDA10046_FREQ_045
,
702 .tuner_address
= 0x60,
703 .request_firmware
= philips_tda1004x_request_firmware
706 static struct tda1004x_config philips_tiger_s_config
= {
707 .demod_address
= 0x08,
710 .xtal_freq
= TDA10046_XTAL_16M
,
711 .agc_config
= TDA10046_AGC_TDA827X
,
712 .gpio_config
= TDA10046_GP01_I
,
713 .if_freq
= TDA10046_FREQ_045
,
715 .tuner_address
= 0x61,
717 .request_firmware
= philips_tda1004x_request_firmware
720 static struct tda1004x_config pinnacle_pctv_310i_config
= {
721 .demod_address
= 0x08,
724 .xtal_freq
= TDA10046_XTAL_16M
,
725 .agc_config
= TDA10046_AGC_TDA827X
,
726 .gpio_config
= TDA10046_GP11_I
,
727 .if_freq
= TDA10046_FREQ_045
,
729 .tuner_address
= 0x61,
730 .request_firmware
= philips_tda1004x_request_firmware
733 static struct tda1004x_config hauppauge_hvr_1110_config
= {
734 .demod_address
= 0x08,
737 .xtal_freq
= TDA10046_XTAL_16M
,
738 .agc_config
= TDA10046_AGC_TDA827X
,
739 .gpio_config
= TDA10046_GP11_I
,
740 .if_freq
= TDA10046_FREQ_045
,
742 .tuner_address
= 0x61,
743 .request_firmware
= philips_tda1004x_request_firmware
746 static struct tda1004x_config asus_p7131_dual_config
= {
747 .demod_address
= 0x08,
750 .xtal_freq
= TDA10046_XTAL_16M
,
751 .agc_config
= TDA10046_AGC_TDA827X
,
752 .gpio_config
= TDA10046_GP11_I
,
753 .if_freq
= TDA10046_FREQ_045
,
755 .tuner_address
= 0x61,
757 .request_firmware
= philips_tda1004x_request_firmware
760 static struct tda1004x_config lifeview_trio_config
= {
761 .demod_address
= 0x09,
764 .xtal_freq
= TDA10046_XTAL_16M
,
765 .agc_config
= TDA10046_AGC_TDA827X
,
766 .gpio_config
= TDA10046_GP00_I
,
767 .if_freq
= TDA10046_FREQ_045
,
768 .tuner_address
= 0x60,
769 .request_firmware
= philips_tda1004x_request_firmware
772 static struct tda1004x_config tevion_dvbt220rf_config
= {
773 .demod_address
= 0x08,
776 .xtal_freq
= TDA10046_XTAL_16M
,
777 .agc_config
= TDA10046_AGC_TDA827X
,
778 .gpio_config
= TDA10046_GP11_I
,
779 .if_freq
= TDA10046_FREQ_045
,
780 .tuner_address
= 0x60,
781 .request_firmware
= philips_tda1004x_request_firmware
784 static struct tda1004x_config md8800_dvbt_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,
794 .request_firmware
= philips_tda1004x_request_firmware
797 static struct tda1004x_config asus_p7131_4871_config
= {
798 .demod_address
= 0x08,
801 .xtal_freq
= TDA10046_XTAL_16M
,
802 .agc_config
= TDA10046_AGC_TDA827X
,
803 .gpio_config
= TDA10046_GP01_I
,
804 .if_freq
= TDA10046_FREQ_045
,
806 .tuner_address
= 0x61,
808 .request_firmware
= philips_tda1004x_request_firmware
811 static struct tda1004x_config asus_p7131_hybrid_lna_config
= {
812 .demod_address
= 0x08,
815 .xtal_freq
= TDA10046_XTAL_16M
,
816 .agc_config
= TDA10046_AGC_TDA827X
,
817 .gpio_config
= TDA10046_GP11_I
,
818 .if_freq
= TDA10046_FREQ_045
,
820 .tuner_address
= 0x61,
822 .request_firmware
= philips_tda1004x_request_firmware
825 static struct tda1004x_config kworld_dvb_t_210_config
= {
826 .demod_address
= 0x08,
829 .xtal_freq
= TDA10046_XTAL_16M
,
830 .agc_config
= TDA10046_AGC_TDA827X
,
831 .gpio_config
= TDA10046_GP11_I
,
832 .if_freq
= TDA10046_FREQ_045
,
834 .tuner_address
= 0x61,
836 .request_firmware
= philips_tda1004x_request_firmware
839 static struct tda1004x_config avermedia_super_007_config
= {
840 .demod_address
= 0x08,
843 .xtal_freq
= TDA10046_XTAL_16M
,
844 .agc_config
= TDA10046_AGC_TDA827X
,
845 .gpio_config
= TDA10046_GP01_I
,
846 .if_freq
= TDA10046_FREQ_045
,
848 .tuner_address
= 0x60,
850 .request_firmware
= philips_tda1004x_request_firmware
853 static struct tda1004x_config twinhan_dtv_dvb_3056_config
= {
854 .demod_address
= 0x08,
857 .xtal_freq
= TDA10046_XTAL_16M
,
858 .agc_config
= TDA10046_AGC_TDA827X
,
859 .gpio_config
= TDA10046_GP01_I
,
860 .if_freq
= TDA10046_FREQ_045
,
862 .tuner_address
= 0x61,
864 .request_firmware
= philips_tda1004x_request_firmware
867 static struct tda1004x_config asus_tiger_3in1_config
= {
868 .demod_address
= 0x0b,
871 .xtal_freq
= TDA10046_XTAL_16M
,
872 .agc_config
= TDA10046_AGC_TDA827X
,
873 .gpio_config
= TDA10046_GP11_I
,
874 .if_freq
= TDA10046_FREQ_045
,
876 .tuner_address
= 0x61,
878 .request_firmware
= philips_tda1004x_request_firmware
881 /* ------------------------------------------------------------------
882 * special case: this card uses saa713x GPIO22 for the mode switch
885 static int ads_duo_tuner_init(struct dvb_frontend
*fe
)
887 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
888 philips_tda827x_tuner_init(fe
);
889 /* route TDA8275a AGC input to the channel decoder */
890 saa7134_set_gpio(dev
, 22, 1);
894 static int ads_duo_tuner_sleep(struct dvb_frontend
*fe
)
896 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
897 /* route TDA8275a AGC input to the analog IF chip*/
898 saa7134_set_gpio(dev
, 22, 0);
899 philips_tda827x_tuner_sleep(fe
);
903 static struct tda827x_config ads_duo_cfg
= {
904 .init
= ads_duo_tuner_init
,
905 .sleep
= ads_duo_tuner_sleep
,
909 static struct tda1004x_config ads_tech_duo_config
= {
910 .demod_address
= 0x08,
913 .xtal_freq
= TDA10046_XTAL_16M
,
914 .agc_config
= TDA10046_AGC_TDA827X
,
915 .gpio_config
= TDA10046_GP00_I
,
916 .if_freq
= TDA10046_FREQ_045
,
917 .tuner_address
= 0x61,
918 .request_firmware
= philips_tda1004x_request_firmware
921 static struct zl10353_config behold_h6_config
= {
922 .demod_address
= 0x1e>>1,
925 .disable_i2c_gate_ctrl
= 1,
928 static struct xc5000_config behold_x7_tunerconfig
= {
929 .i2c_address
= 0xc2>>1,
931 .radio_input
= XC5000_RADIO_FM1
,
934 static struct zl10353_config behold_x7_config
= {
935 .demod_address
= 0x1e>>1,
939 .disable_i2c_gate_ctrl
= 1,
942 /* ==================================================================
943 * tda10086 based DVB-S cards, helper functions
946 static struct tda10086_config flydvbs
= {
947 .demod_address
= 0x0e,
950 .xtal_freq
= TDA10086_XTAL_16M
,
953 static struct tda10086_config sd1878_4m
= {
954 .demod_address
= 0x0e,
957 .xtal_freq
= TDA10086_XTAL_4M
,
960 /* ------------------------------------------------------------------
961 * special case: lnb supply is connected to the gated i2c
964 static int md8800_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
967 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
968 if (fe
->ops
.i2c_gate_ctrl
) {
969 fe
->ops
.i2c_gate_ctrl(fe
, 1);
970 if (dev
->original_set_voltage
)
971 res
= dev
->original_set_voltage(fe
, voltage
);
972 fe
->ops
.i2c_gate_ctrl(fe
, 0);
977 static int md8800_set_high_voltage(struct dvb_frontend
*fe
, long arg
)
980 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
981 if (fe
->ops
.i2c_gate_ctrl
) {
982 fe
->ops
.i2c_gate_ctrl(fe
, 1);
983 if (dev
->original_set_high_voltage
)
984 res
= dev
->original_set_high_voltage(fe
, arg
);
985 fe
->ops
.i2c_gate_ctrl(fe
, 0);
990 static int md8800_set_voltage2(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
992 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
993 u8 wbuf
[2] = { 0x1f, 00 };
995 struct i2c_msg msg
[] = { { .addr
= 0x08, .flags
= 0, .buf
= wbuf
, .len
= 1 },
996 { .addr
= 0x08, .flags
= I2C_M_RD
, .buf
= &rbuf
, .len
= 1 } };
998 if (i2c_transfer(&dev
->i2c_adap
, msg
, 2) != 2)
1000 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1001 if (voltage
== SEC_VOLTAGE_18
)
1002 wbuf
[1] = rbuf
| 0x10;
1004 wbuf
[1] = rbuf
& 0xef;
1006 i2c_transfer(&dev
->i2c_adap
, msg
, 1);
1010 static int md8800_set_high_voltage2(struct dvb_frontend
*fe
, long arg
)
1012 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
1013 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__
);
1017 /* ==================================================================
1018 * nxt200x based ATSC cards, helper functions
1021 static struct nxt200x_config avertvhda180
= {
1022 .demod_address
= 0x0a,
1025 static struct nxt200x_config kworldatsc110
= {
1026 .demod_address
= 0x0a,
1029 /* ------------------------------------------------------------------ */
1031 static struct mt312_config avertv_a700_mt312
= {
1032 .demod_address
= 0x0e,
1033 .voltage_inverted
= 1,
1036 static struct zl10036_config avertv_a700_tuner
= {
1037 .tuner_address
= 0x60,
1040 static struct mt312_config zl10313_compro_s350_config
= {
1041 .demod_address
= 0x0e,
1044 static struct lgdt3305_config hcw_lgdt3305_config
= {
1046 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
1047 .tpclk_edge
= LGDT3305_TPCLK_RISING_EDGE
,
1048 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
1050 .spectral_inversion
= 1,
1055 static struct tda10048_config hcw_tda10048_config
= {
1056 .demod_address
= 0x10 >> 1,
1057 .output_mode
= TDA10048_SERIAL_OUTPUT
,
1058 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1059 .inversion
= TDA10048_INVERSION_ON
,
1060 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1061 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1062 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1063 .clk_freq_khz
= TDA10048_CLK_16000
,
1064 .disable_gate_access
= 1,
1067 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
1068 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
1069 .if_lvl
= 1, .rfagc_top
= 0x58, },
1070 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
1071 .if_lvl
= 1, .rfagc_top
= 0x58, },
1074 static struct tda18271_config hcw_tda18271_config
= {
1075 .std_map
= &hauppauge_tda18271_std_map
,
1076 .gate
= TDA18271_GATE_ANALOG
,
1078 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1081 static struct tda829x_config tda829x_no_probe
= {
1082 .probe_tuner
= TDA829X_DONT_PROBE
,
1085 static struct tda10048_config zolid_tda10048_config
= {
1086 .demod_address
= 0x10 >> 1,
1087 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1088 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1089 .inversion
= TDA10048_INVERSION_ON
,
1090 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1091 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1092 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1093 .clk_freq_khz
= TDA10048_CLK_16000
,
1094 .disable_gate_access
= 1,
1097 static struct tda18271_config zolid_tda18271_config
= {
1098 .gate
= TDA18271_GATE_ANALOG
,
1101 static struct tda10048_config dtv1000s_tda10048_config
= {
1102 .demod_address
= 0x10 >> 1,
1103 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1104 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1105 .inversion
= TDA10048_INVERSION_ON
,
1106 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1107 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
1108 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
1109 .clk_freq_khz
= TDA10048_CLK_16000
,
1110 .disable_gate_access
= 1,
1113 static struct tda18271_std_map dtv1000s_tda18271_std_map
= {
1114 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
1115 .if_lvl
= 1, .rfagc_top
= 0x37, },
1116 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
1117 .if_lvl
= 1, .rfagc_top
= 0x37, },
1118 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
1119 .if_lvl
= 1, .rfagc_top
= 0x37, },
1122 static struct tda18271_config dtv1000s_tda18271_config
= {
1123 .std_map
= &dtv1000s_tda18271_std_map
,
1124 .gate
= TDA18271_GATE_ANALOG
,
1127 static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config
= {
1128 .prod
= LGS8GXX_PROD_LGS8G75
,
1129 .demod_address
= 0x1d,
1133 .if_clk_freq
= 30400, /* 30.4 MHz */
1134 .if_freq
= 4000, /* 4.00 MHz */
1138 .adc_vpp
= 3, /* 2.0 Vpp */
1142 static struct tda18271_config prohdtv_pro2_tda18271_config
= {
1143 .gate
= TDA18271_GATE_ANALOG
,
1144 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1147 /* ==================================================================
1151 static int dvb_init(struct saa7134_dev
*dev
)
1154 int attach_xc3028
= 0;
1155 struct videobuf_dvb_frontend
*fe0
;
1157 /* FIXME: add support for multi-frontend */
1158 mutex_init(&dev
->frontends
.lock
);
1159 INIT_LIST_HEAD(&dev
->frontends
.felist
);
1161 printk(KERN_INFO
"%s() allocating 1 frontend\n", __func__
);
1162 fe0
= videobuf_dvb_alloc_frontend(&dev
->frontends
, 1);
1164 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
1168 /* init struct videobuf_dvb */
1169 dev
->ts
.nr_bufs
= 32;
1170 dev
->ts
.nr_packets
= 32*4;
1171 fe0
->dvb
.name
= dev
->name
;
1172 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &saa7134_ts_qops
,
1173 &dev
->pci
->dev
, &dev
->slock
,
1174 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
1175 V4L2_FIELD_ALTERNATE
,
1176 sizeof(struct saa7134_buf
),
1179 switch (dev
->board
) {
1180 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
1181 dprintk("pinnacle 300i dvb setup\n");
1182 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &pinnacle_300i
,
1184 if (fe0
->dvb
.frontend
) {
1185 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= mt352_pinnacle_tuner_set_params
;
1188 case SAA7134_BOARD_AVERMEDIA_777
:
1189 case SAA7134_BOARD_AVERMEDIA_A16AR
:
1190 dprintk("avertv 777 dvb setup\n");
1191 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_777
,
1193 if (fe0
->dvb
.frontend
) {
1194 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1195 &dev
->i2c_adap
, 0x61,
1196 TUNER_PHILIPS_TD1316
);
1199 case SAA7134_BOARD_AVERMEDIA_A16D
:
1200 dprintk("AverMedia A16D dvb setup\n");
1201 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1202 &avermedia_xc3028_mt352_dev
,
1206 case SAA7134_BOARD_MD7134
:
1207 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1210 if (fe0
->dvb
.frontend
) {
1211 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1212 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1213 TUNER_PHILIPS_FMD1216ME_MK3
);
1216 case SAA7134_BOARD_PHILIPS_TOUGH
:
1217 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1218 &philips_tu1216_60_config
,
1220 if (fe0
->dvb
.frontend
) {
1221 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1222 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1225 case SAA7134_BOARD_FLYDVBTDUO
:
1226 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS
:
1227 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1228 &tda827x_cfg_0
) < 0)
1229 goto dettach_frontend
;
1231 case SAA7134_BOARD_PHILIPS_EUROPA
:
1232 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
1233 case SAA7134_BOARD_ASUS_EUROPA_HYBRID
:
1234 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1235 &philips_europa_config
,
1237 if (fe0
->dvb
.frontend
) {
1238 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1239 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1240 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1241 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1242 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1245 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000
:
1246 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1247 &technotrend_budget_t3000_config
,
1249 if (fe0
->dvb
.frontend
) {
1250 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1251 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1252 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1253 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1254 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1257 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
1258 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1259 &philips_tu1216_61_config
,
1261 if (fe0
->dvb
.frontend
) {
1262 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1263 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1266 case SAA7134_BOARD_KWORLD_DVBT_210
:
1267 if (configure_tda827x_fe(dev
, &kworld_dvb_t_210_config
,
1268 &tda827x_cfg_2
) < 0)
1269 goto dettach_frontend
;
1271 case SAA7134_BOARD_HAUPPAUGE_HVR1120
:
1272 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1273 &hcw_tda10048_config
,
1275 if (fe0
->dvb
.frontend
!= NULL
) {
1276 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1277 &dev
->i2c_adap
, 0x4b,
1279 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1280 0x60, &dev
->i2c_adap
,
1281 &hcw_tda18271_config
);
1284 case SAA7134_BOARD_PHILIPS_TIGER
:
1285 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1286 &tda827x_cfg_0
) < 0)
1287 goto dettach_frontend
;
1289 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
1290 if (configure_tda827x_fe(dev
, &pinnacle_pctv_310i_config
,
1291 &tda827x_cfg_1
) < 0)
1292 goto dettach_frontend
;
1294 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
1295 if (configure_tda827x_fe(dev
, &hauppauge_hvr_1110_config
,
1296 &tda827x_cfg_1
) < 0)
1297 goto dettach_frontend
;
1299 case SAA7134_BOARD_HAUPPAUGE_HVR1150
:
1300 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1301 &hcw_lgdt3305_config
,
1303 if (fe0
->dvb
.frontend
) {
1304 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1305 &dev
->i2c_adap
, 0x4b,
1307 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1308 0x60, &dev
->i2c_adap
,
1309 &hcw_tda18271_config
);
1312 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
1313 if (configure_tda827x_fe(dev
, &asus_p7131_dual_config
,
1314 &tda827x_cfg_0
) < 0)
1315 goto dettach_frontend
;
1317 case SAA7134_BOARD_FLYDVBT_LR301
:
1318 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1319 &tda827x_cfg_0
) < 0)
1320 goto dettach_frontend
;
1322 case SAA7134_BOARD_FLYDVB_TRIO
:
1323 if (!use_frontend
) { /* terrestrial */
1324 if (configure_tda827x_fe(dev
, &lifeview_trio_config
,
1325 &tda827x_cfg_0
) < 0)
1326 goto dettach_frontend
;
1327 } else { /* satellite */
1328 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
, &dev
->i2c_adap
);
1329 if (fe0
->dvb
.frontend
) {
1330 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x63,
1331 &dev
->i2c_adap
, 0) == NULL
) {
1332 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__
);
1333 goto dettach_frontend
;
1335 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
, &dev
->i2c_adap
,
1336 0x08, 0, 0) == NULL
) {
1337 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__
);
1338 goto dettach_frontend
;
1343 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331
:
1344 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS
:
1345 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1346 &ads_tech_duo_config
,
1348 if (fe0
->dvb
.frontend
) {
1349 if (dvb_attach(tda827x_attach
,fe0
->dvb
.frontend
,
1350 ads_tech_duo_config
.tuner_address
, &dev
->i2c_adap
,
1351 &ads_duo_cfg
) == NULL
) {
1352 wprintk("no tda827x tuner found at addr: %02x\n",
1353 ads_tech_duo_config
.tuner_address
);
1354 goto dettach_frontend
;
1357 wprintk("failed to attach tda10046\n");
1359 case SAA7134_BOARD_TEVION_DVBT_220RF
:
1360 if (configure_tda827x_fe(dev
, &tevion_dvbt220rf_config
,
1361 &tda827x_cfg_0
) < 0)
1362 goto dettach_frontend
;
1364 case SAA7134_BOARD_MEDION_MD8800_QUADRO
:
1365 if (!use_frontend
) { /* terrestrial */
1366 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1367 &tda827x_cfg_0
) < 0)
1368 goto dettach_frontend
;
1369 } else { /* satellite */
1370 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1371 &flydvbs
, &dev
->i2c_adap
);
1372 if (fe0
->dvb
.frontend
) {
1373 struct dvb_frontend
*fe
= fe0
->dvb
.frontend
;
1374 u8 dev_id
= dev
->eedata
[2];
1376 struct i2c_msg msg
= {.addr
= 0x08, .flags
= 0, .len
= 1};
1378 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
,
1379 0x60, &dev
->i2c_adap
, 0) == NULL
) {
1380 wprintk("%s: Medion Quadro, no tda826x "
1381 "found !\n", __func__
);
1382 goto dettach_frontend
;
1384 if (dev_id
!= 0x08) {
1385 /* we need to open the i2c gate (we know it exists) */
1386 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1387 if (dvb_attach(isl6405_attach
, fe
,
1388 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1389 wprintk("%s: Medion Quadro, no ISL6405 "
1390 "found !\n", __func__
);
1391 goto dettach_frontend
;
1393 if (dev_id
== 0x07) {
1394 /* fire up the 2nd section of the LNB supply since
1395 we can't do this from the other section */
1397 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1399 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1400 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1401 fe
->ops
.set_voltage
= md8800_set_voltage
;
1402 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1403 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1405 fe
->ops
.set_voltage
= md8800_set_voltage2
;
1406 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage2
;
1411 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
1412 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &avertvhda180
,
1414 if (fe0
->dvb
.frontend
)
1415 dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x61,
1416 NULL
, DVB_PLL_TDHU2
);
1418 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI
:
1419 case SAA7134_BOARD_KWORLD_ATSC110
:
1420 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &kworldatsc110
,
1422 if (fe0
->dvb
.frontend
)
1423 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1424 &dev
->i2c_adap
, 0x61,
1425 TUNER_PHILIPS_TUV1236D
);
1427 case SAA7134_BOARD_FLYDVBS_LR300
:
1428 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1430 if (fe0
->dvb
.frontend
) {
1431 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1432 &dev
->i2c_adap
, 0) == NULL
) {
1433 wprintk("%s: No tda826x found!\n", __func__
);
1434 goto dettach_frontend
;
1436 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1437 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1438 wprintk("%s: No ISL6421 found!\n", __func__
);
1439 goto dettach_frontend
;
1443 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID
:
1444 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1447 if (fe0
->dvb
.frontend
) {
1448 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1449 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1451 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1452 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1453 TUNER_PHILIPS_FMD1216ME_MK3
);
1456 case SAA7134_BOARD_VIDEOMATE_DVBT_200A
:
1457 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1458 &philips_europa_config
,
1460 if (fe0
->dvb
.frontend
) {
1461 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_td1316_tuner_init
;
1462 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1465 case SAA7134_BOARD_CINERGY_HT_PCMCIA
:
1466 if (configure_tda827x_fe(dev
, &cinergy_ht_config
,
1467 &tda827x_cfg_0
) < 0)
1468 goto dettach_frontend
;
1470 case SAA7134_BOARD_CINERGY_HT_PCI
:
1471 if (configure_tda827x_fe(dev
, &cinergy_ht_pci_config
,
1472 &tda827x_cfg_0
) < 0)
1473 goto dettach_frontend
;
1475 case SAA7134_BOARD_PHILIPS_TIGER_S
:
1476 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1477 &tda827x_cfg_2
) < 0)
1478 goto dettach_frontend
;
1480 case SAA7134_BOARD_ASUS_P7131_4871
:
1481 if (configure_tda827x_fe(dev
, &asus_p7131_4871_config
,
1482 &tda827x_cfg_2
) < 0)
1483 goto dettach_frontend
;
1485 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
1486 if (configure_tda827x_fe(dev
, &asus_p7131_hybrid_lna_config
,
1487 &tda827x_cfg_2
) < 0)
1488 goto dettach_frontend
;
1490 case SAA7134_BOARD_AVERMEDIA_SUPER_007
:
1491 if (configure_tda827x_fe(dev
, &avermedia_super_007_config
,
1492 &tda827x_cfg_0
) < 0)
1493 goto dettach_frontend
;
1495 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056
:
1496 if (configure_tda827x_fe(dev
, &twinhan_dtv_dvb_3056_config
,
1497 &tda827x_cfg_2_sw42
) < 0)
1498 goto dettach_frontend
;
1500 case SAA7134_BOARD_PHILIPS_SNAKE
:
1501 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1503 if (fe0
->dvb
.frontend
) {
1504 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1505 &dev
->i2c_adap
, 0) == NULL
) {
1506 wprintk("%s: No tda826x found!\n", __func__
);
1507 goto dettach_frontend
;
1509 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1510 &dev
->i2c_adap
, 0, 0) == NULL
) {
1511 wprintk("%s: No lnbp21 found!\n", __func__
);
1512 goto dettach_frontend
;
1516 case SAA7134_BOARD_CREATIX_CTX953
:
1517 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1518 &tda827x_cfg_0
) < 0)
1519 goto dettach_frontend
;
1521 case SAA7134_BOARD_MSI_TVANYWHERE_AD11
:
1522 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1523 &tda827x_cfg_2
) < 0)
1524 goto dettach_frontend
;
1526 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
1527 dprintk("AverMedia E506R dvb setup\n");
1528 saa7134_set_gpio(dev
, 25, 0);
1530 saa7134_set_gpio(dev
, 25, 1);
1531 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1532 &avermedia_xc3028_mt352_dev
,
1536 case SAA7134_BOARD_MD7134_BRIDGE_2
:
1537 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1538 &sd1878_4m
, &dev
->i2c_adap
);
1539 if (fe0
->dvb
.frontend
) {
1540 struct dvb_frontend
*fe
;
1541 if (dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1542 &dev
->i2c_adap
, DVB_PLL_PHILIPS_SD1878_TDA8261
) == NULL
) {
1543 wprintk("%s: MD7134 DVB-S, no SD1878 "
1544 "found !\n", __func__
);
1545 goto dettach_frontend
;
1547 /* we need to open the i2c gate (we know it exists) */
1548 fe
= fe0
->dvb
.frontend
;
1549 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1550 if (dvb_attach(isl6405_attach
, fe
,
1551 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1552 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1553 "found !\n", __func__
);
1554 goto dettach_frontend
;
1556 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1557 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1558 fe
->ops
.set_voltage
= md8800_set_voltage
;
1559 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1560 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1563 case SAA7134_BOARD_AVERMEDIA_M103
:
1564 saa7134_set_gpio(dev
, 25, 0);
1566 saa7134_set_gpio(dev
, 25, 1);
1567 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1568 &avermedia_xc3028_mt352_dev
,
1572 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1
:
1573 if (!use_frontend
) { /* terrestrial */
1574 if (configure_tda827x_fe(dev
, &asus_tiger_3in1_config
,
1575 &tda827x_cfg_2
) < 0)
1576 goto dettach_frontend
;
1577 } else { /* satellite */
1578 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1579 &flydvbs
, &dev
->i2c_adap
);
1580 if (fe0
->dvb
.frontend
) {
1581 if (dvb_attach(tda826x_attach
,
1582 fe0
->dvb
.frontend
, 0x60,
1583 &dev
->i2c_adap
, 0) == NULL
) {
1584 wprintk("%s: Asus Tiger 3in1, no "
1585 "tda826x found!\n", __func__
);
1586 goto dettach_frontend
;
1588 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1589 &dev
->i2c_adap
, 0, 0) == NULL
) {
1590 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1591 " found!\n", __func__
);
1592 goto dettach_frontend
;
1597 case SAA7134_BOARD_ASUSTeK_TIGER
:
1598 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1599 &tda827x_cfg_0
) < 0)
1600 goto dettach_frontend
;
1602 case SAA7134_BOARD_BEHOLD_H6
:
1603 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1606 if (fe0
->dvb
.frontend
) {
1607 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1608 &dev
->i2c_adap
, 0x61,
1609 TUNER_PHILIPS_FMD1216MEX_MK3
);
1612 case SAA7134_BOARD_BEHOLD_X7
:
1613 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1616 if (fe0
->dvb
.frontend
) {
1617 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1618 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1621 case SAA7134_BOARD_BEHOLD_H7
:
1622 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1625 if (fe0
->dvb
.frontend
) {
1626 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1627 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1630 case SAA7134_BOARD_AVERMEDIA_A700_PRO
:
1631 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID
:
1632 /* Zarlink ZL10313 */
1633 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1634 &avertv_a700_mt312
, &dev
->i2c_adap
);
1635 if (fe0
->dvb
.frontend
) {
1636 if (dvb_attach(zl10036_attach
, fe0
->dvb
.frontend
,
1637 &avertv_a700_tuner
, &dev
->i2c_adap
) == NULL
) {
1638 wprintk("%s: No zl10036 found!\n",
1643 case SAA7134_BOARD_VIDEOMATE_S350
:
1644 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1645 &zl10313_compro_s350_config
, &dev
->i2c_adap
);
1646 if (fe0
->dvb
.frontend
)
1647 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1648 0x60, &dev
->i2c_adap
) == NULL
)
1649 wprintk("%s: No zl10039 found!\n",
1653 case SAA7134_BOARD_ZOLID_HYBRID_PCI
:
1654 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1655 &zolid_tda10048_config
,
1657 if (fe0
->dvb
.frontend
!= NULL
) {
1658 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1659 &dev
->i2c_adap
, 0x4b,
1661 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1662 0x60, &dev
->i2c_adap
,
1663 &zolid_tda18271_config
);
1666 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S
:
1667 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1668 &dtv1000s_tda10048_config
,
1670 if (fe0
->dvb
.frontend
!= NULL
) {
1671 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1672 &dev
->i2c_adap
, 0x4b,
1674 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1675 0x60, &dev
->i2c_adap
,
1676 &dtv1000s_tda18271_config
);
1679 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG
:
1680 /* Switch to digital mode */
1681 saa7134_tuner_callback(dev
, 0,
1682 TDA18271_CALLBACK_CMD_AGC_ENABLE
, 1);
1683 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1684 &kworld_mb86a20s_config
,
1686 if (fe0
->dvb
.frontend
!= NULL
) {
1687 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1688 &dev
->i2c_adap
, 0x4b,
1690 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1691 0x60, &dev
->i2c_adap
,
1692 &kworld_tda18271_config
);
1693 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= kworld_sbtvd_gate_ctrl
;
1696 /* mb86a20s need to use the I2C gateway */
1698 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2
:
1699 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1700 &prohdtv_pro2_lgs8g75_config
,
1702 if (fe0
->dvb
.frontend
!= NULL
) {
1703 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1704 &dev
->i2c_adap
, 0x4b,
1706 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1707 0x60, &dev
->i2c_adap
,
1708 &prohdtv_pro2_tda18271_config
);
1712 wprintk("Huh? unknown DVB card?\n");
1716 if (attach_xc3028
) {
1717 struct dvb_frontend
*fe
;
1718 struct xc2028_config cfg
= {
1719 .i2c_adap
= &dev
->i2c_adap
,
1723 if (!fe0
->dvb
.frontend
)
1724 goto dettach_frontend
;
1726 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
1728 printk(KERN_ERR
"%s/2: xc3028 attach failed\n",
1730 goto dettach_frontend
;
1734 if (NULL
== fe0
->dvb
.frontend
) {
1735 printk(KERN_ERR
"%s/dvb: frontend initialization failed\n", dev
->name
);
1736 goto dettach_frontend
;
1738 /* define general-purpose callback pointer */
1739 fe0
->dvb
.frontend
->callback
= saa7134_tuner_callback
;
1741 /* register everything else */
1742 ret
= videobuf_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1743 &dev
->pci
->dev
, adapter_nr
, 0, NULL
);
1745 /* this sequence is necessary to make the tda1004x load its firmware
1746 * and to enter analog mode of hybrid boards
1749 if (fe0
->dvb
.frontend
->ops
.init
)
1750 fe0
->dvb
.frontend
->ops
.init(fe0
->dvb
.frontend
);
1751 if (fe0
->dvb
.frontend
->ops
.sleep
)
1752 fe0
->dvb
.frontend
->ops
.sleep(fe0
->dvb
.frontend
);
1753 if (fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
)
1754 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep(fe0
->dvb
.frontend
);
1759 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
1763 static int dvb_fini(struct saa7134_dev
*dev
)
1765 struct videobuf_dvb_frontend
*fe0
;
1767 /* Get the first frontend */
1768 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
1772 /* FIXME: I suspect that this code is bogus, since the entry for
1773 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1774 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1776 if (dev
->board
== SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
) {
1777 struct v4l2_priv_tun_config tda9887_cfg
;
1778 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
1780 tda9887_cfg
.tuner
= TUNER_TDA9887
;
1781 tda9887_cfg
.priv
= &on
;
1783 /* otherwise we don't detect the tuner on next insmod */
1784 saa_call_all(dev
, tuner
, s_config
, &tda9887_cfg
);
1785 } else if (dev
->board
== SAA7134_BOARD_MEDION_MD8800_QUADRO
) {
1786 if ((dev
->eedata
[2] == 0x07) && use_frontend
) {
1787 /* turn off the 2nd lnb supply */
1789 struct i2c_msg msg
= {.addr
= 0x08, .buf
= &data
, .flags
= 0, .len
= 1};
1790 struct dvb_frontend
*fe
;
1791 fe
= fe0
->dvb
.frontend
;
1792 if (fe
->ops
.i2c_gate_ctrl
) {
1793 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1794 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1795 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1799 videobuf_dvb_unregister_bus(&dev
->frontends
);
1803 static struct saa7134_mpeg_ops dvb_ops
= {
1804 .type
= SAA7134_MPEG_DVB
,
1809 static int __init
dvb_register(void)
1811 return saa7134_ts_register(&dvb_ops
);
1814 static void __exit
dvb_unregister(void)
1816 saa7134_ts_unregister(&dvb_ops
);
1819 module_init(dvb_register
);
1820 module_exit(dvb_unregister
);
1822 /* ------------------------------------------------------------------ */