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"
63 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
64 MODULE_LICENSE("GPL");
66 static unsigned int antenna_pwr
;
68 module_param(antenna_pwr
, int, 0444);
69 MODULE_PARM_DESC(antenna_pwr
,"enable antenna power (Pinnacle 300i)");
71 static int use_frontend
;
72 module_param(use_frontend
, int, 0644);
73 MODULE_PARM_DESC(use_frontend
,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
76 module_param(debug
, int, 0644);
77 MODULE_PARM_DESC(debug
, "Turn on/off module debugging (default:off).");
79 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
81 #define dprintk(fmt, arg...) do { if (debug) \
82 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
85 #define wprintk(fmt, arg...) \
86 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
88 /* ------------------------------------------------------------------
89 * mt352 based DVB-T cards
92 static int pinnacle_antenna_pwr(struct saa7134_dev
*dev
, int on
)
97 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
98 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
102 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
103 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
106 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 28));
107 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
109 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
111 ok
= saa_readl(SAA7134_GPIO_GPSTATUS0
) & (1 << 27);
112 dprintk("%s %s\n", __func__
, ok
? "on" : "off");
115 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
119 static int mt352_pinnacle_init(struct dvb_frontend
* fe
)
121 static u8 clock_config
[] = { CLOCK_CTL
, 0x3d, 0x28 };
122 static u8 reset
[] = { RESET
, 0x80 };
123 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
124 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
125 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x31 };
126 static u8 fsm_ctl_cfg
[] = { 0x7b, 0x04 };
127 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x0f };
128 static u8 scan_ctl_cfg
[] = { SCAN_CTL
, 0x0d };
129 static u8 irq_cfg
[] = { INTERRUPT_EN_0
, 0x00, 0x00, 0x00, 0x00 };
130 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
132 dprintk("%s called\n", __func__
);
134 mt352_write(fe
, clock_config
, sizeof(clock_config
));
136 mt352_write(fe
, reset
, sizeof(reset
));
137 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
138 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
139 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
140 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
142 mt352_write(fe
, fsm_ctl_cfg
, sizeof(fsm_ctl_cfg
));
143 mt352_write(fe
, scan_ctl_cfg
, sizeof(scan_ctl_cfg
));
144 mt352_write(fe
, irq_cfg
, sizeof(irq_cfg
));
149 static int mt352_aver777_init(struct dvb_frontend
* fe
)
151 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
152 static u8 reset
[] = { RESET
, 0x80 };
153 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
154 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
155 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
157 mt352_write(fe
, clock_config
, sizeof(clock_config
));
159 mt352_write(fe
, reset
, sizeof(reset
));
160 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
161 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
162 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
167 static int mt352_avermedia_xc3028_init(struct dvb_frontend
*fe
)
169 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
170 static u8 reset
[] = { RESET
, 0x80 };
171 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
172 static u8 agc_cfg
[] = { AGC_TARGET
, 0xe };
173 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
175 mt352_write(fe
, clock_config
, sizeof(clock_config
));
177 mt352_write(fe
, reset
, sizeof(reset
));
178 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
179 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
180 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
184 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend
* fe
,
185 struct dvb_frontend_parameters
* params
)
187 u8 off
[] = { 0x00, 0xf1};
188 u8 on
[] = { 0x00, 0x71};
189 struct i2c_msg msg
= {.addr
=0x43, .flags
=0, .buf
=off
, .len
= sizeof(off
)};
191 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
192 struct v4l2_frequency f
;
194 /* set frequency (mt2050) */
196 f
.type
= V4L2_TUNER_DIGITAL_TV
;
197 f
.frequency
= params
->frequency
/ 1000 * 16 / 1000;
198 if (fe
->ops
.i2c_gate_ctrl
)
199 fe
->ops
.i2c_gate_ctrl(fe
, 1);
200 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
201 saa_call_all(dev
, tuner
, s_frequency
, &f
);
203 if (fe
->ops
.i2c_gate_ctrl
)
204 fe
->ops
.i2c_gate_ctrl(fe
, 1);
205 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
207 pinnacle_antenna_pwr(dev
, antenna_pwr
);
210 return mt352_pinnacle_init(fe
);
213 static struct mt352_config pinnacle_300i
= {
214 .demod_address
= 0x3c >> 1,
218 .demod_init
= mt352_pinnacle_init
,
221 static struct mt352_config avermedia_777
= {
222 .demod_address
= 0xf,
223 .demod_init
= mt352_aver777_init
,
226 static struct mt352_config avermedia_xc3028_mt352_dev
= {
227 .demod_address
= (0x1e >> 1),
229 .demod_init
= mt352_avermedia_xc3028_init
,
232 static struct tda18271_std_map mb86a20s_tda18271_std_map
= {
233 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
234 .if_lvl
= 7, .rfagc_top
= 0x37, },
237 static struct tda18271_config kworld_tda18271_config
= {
238 .std_map
= &mb86a20s_tda18271_std_map
,
239 .gate
= TDA18271_GATE_DIGITAL
,
240 .config
= 3, /* Use tuner callback for AGC */
244 static const struct mb86a20s_config kworld_mb86a20s_config
= {
245 .demod_address
= 0x10,
248 static int kworld_sbtvd_gate_ctrl(struct dvb_frontend
* fe
, int enable
)
250 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
252 unsigned char initmsg
[] = {0x45, 0x97};
253 unsigned char msg_enable
[] = {0x45, 0xc1};
254 unsigned char msg_disable
[] = {0x45, 0x81};
255 struct i2c_msg msg
= {.addr
= 0x4b, .flags
= 0, .buf
= initmsg
, .len
= 2};
257 if (i2c_transfer(&dev
->i2c_adap
, &msg
, 1) != 1) {
258 wprintk("could not access the I2C gate\n");
262 msg
.buf
= msg_enable
;
264 msg
.buf
= msg_disable
;
265 if (i2c_transfer(&dev
->i2c_adap
, &msg
, 1) != 1) {
266 wprintk("could not access the I2C gate\n");
273 /* ==================================================================
274 * tda1004x based DVB-T cards, helper functions
277 static int philips_tda1004x_request_firmware(struct dvb_frontend
*fe
,
278 const struct firmware
**fw
, char *name
)
280 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
281 return request_firmware(fw
, name
, &dev
->pci
->dev
);
284 /* ------------------------------------------------------------------
285 * these tuners are tu1216, td1316(a)
288 static int philips_tda6651_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
290 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
291 struct tda1004x_state
*state
= fe
->demodulator_priv
;
292 u8 addr
= state
->config
->tuner_address
;
294 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tuner_buf
,.len
=
296 int tuner_frequency
= 0;
299 /* determine charge pump */
300 tuner_frequency
= params
->frequency
+ 36166000;
301 if (tuner_frequency
< 87000000)
303 else if (tuner_frequency
< 130000000)
305 else if (tuner_frequency
< 160000000)
307 else if (tuner_frequency
< 200000000)
309 else if (tuner_frequency
< 290000000)
311 else if (tuner_frequency
< 420000000)
313 else if (tuner_frequency
< 480000000)
315 else if (tuner_frequency
< 620000000)
317 else if (tuner_frequency
< 830000000)
319 else if (tuner_frequency
< 895000000)
325 if (params
->frequency
< 49000000)
327 else if (params
->frequency
< 161000000)
329 else if (params
->frequency
< 444000000)
331 else if (params
->frequency
< 861000000)
336 /* setup PLL filter */
337 switch (params
->u
.ofdm
.bandwidth
) {
338 case BANDWIDTH_6_MHZ
:
342 case BANDWIDTH_7_MHZ
:
346 case BANDWIDTH_8_MHZ
:
355 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
357 tuner_frequency
= (((params
->frequency
/ 1000) * 6) + 217496) / 1000;
359 /* setup tuner buffer */
360 tuner_buf
[0] = (tuner_frequency
>> 8) & 0x7f;
361 tuner_buf
[1] = tuner_frequency
& 0xff;
363 tuner_buf
[3] = (cp
<< 5) | (filter
<< 3) | band
;
365 if (fe
->ops
.i2c_gate_ctrl
)
366 fe
->ops
.i2c_gate_ctrl(fe
, 1);
367 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1) {
368 wprintk("could not write to tuner at addr: 0x%02x\n",
376 static int philips_tu1216_init(struct dvb_frontend
*fe
)
378 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
379 struct tda1004x_state
*state
= fe
->demodulator_priv
;
380 u8 addr
= state
->config
->tuner_address
;
381 static u8 tu1216_init
[] = { 0x0b, 0xf5, 0x85, 0xab };
382 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tu1216_init
,.len
= sizeof(tu1216_init
) };
384 /* setup PLL configuration */
385 if (fe
->ops
.i2c_gate_ctrl
)
386 fe
->ops
.i2c_gate_ctrl(fe
, 1);
387 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
394 /* ------------------------------------------------------------------ */
396 static struct tda1004x_config philips_tu1216_60_config
= {
397 .demod_address
= 0x8,
400 .xtal_freq
= TDA10046_XTAL_4M
,
401 .agc_config
= TDA10046_AGC_DEFAULT
,
402 .if_freq
= TDA10046_FREQ_3617
,
403 .tuner_address
= 0x60,
404 .request_firmware
= philips_tda1004x_request_firmware
407 static struct tda1004x_config philips_tu1216_61_config
= {
409 .demod_address
= 0x8,
412 .xtal_freq
= TDA10046_XTAL_4M
,
413 .agc_config
= TDA10046_AGC_DEFAULT
,
414 .if_freq
= TDA10046_FREQ_3617
,
415 .tuner_address
= 0x61,
416 .request_firmware
= philips_tda1004x_request_firmware
419 /* ------------------------------------------------------------------ */
421 static int philips_td1316_tuner_init(struct dvb_frontend
*fe
)
423 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
424 struct tda1004x_state
*state
= fe
->demodulator_priv
;
425 u8 addr
= state
->config
->tuner_address
;
426 static u8 msg
[] = { 0x0b, 0xf5, 0x86, 0xab };
427 struct i2c_msg init_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
429 /* setup PLL configuration */
430 if (fe
->ops
.i2c_gate_ctrl
)
431 fe
->ops
.i2c_gate_ctrl(fe
, 1);
432 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
437 static int philips_td1316_tuner_set_params(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
439 return philips_tda6651_pll_set(fe
, params
);
442 static int philips_td1316_tuner_sleep(struct dvb_frontend
*fe
)
444 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
445 struct tda1004x_state
*state
= fe
->demodulator_priv
;
446 u8 addr
= state
->config
->tuner_address
;
447 static u8 msg
[] = { 0x0b, 0xdc, 0x86, 0xa4 };
448 struct i2c_msg analog_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
450 /* switch the tuner to analog mode */
451 if (fe
->ops
.i2c_gate_ctrl
)
452 fe
->ops
.i2c_gate_ctrl(fe
, 1);
453 if (i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1) != 1)
458 /* ------------------------------------------------------------------ */
460 static int philips_europa_tuner_init(struct dvb_frontend
*fe
)
462 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
463 static u8 msg
[] = { 0x00, 0x40};
464 struct i2c_msg init_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
467 if (philips_td1316_tuner_init(fe
))
470 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
476 static int philips_europa_tuner_sleep(struct dvb_frontend
*fe
)
478 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
480 static u8 msg
[] = { 0x00, 0x14 };
481 struct i2c_msg analog_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
483 if (philips_td1316_tuner_sleep(fe
))
486 /* switch the board to analog mode */
487 if (fe
->ops
.i2c_gate_ctrl
)
488 fe
->ops
.i2c_gate_ctrl(fe
, 1);
489 i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1);
493 static int philips_europa_demod_sleep(struct dvb_frontend
*fe
)
495 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
497 if (dev
->original_demod_sleep
)
498 dev
->original_demod_sleep(fe
);
499 fe
->ops
.i2c_gate_ctrl(fe
, 1);
503 static struct tda1004x_config philips_europa_config
= {
505 .demod_address
= 0x8,
508 .xtal_freq
= TDA10046_XTAL_4M
,
509 .agc_config
= TDA10046_AGC_IFO_AUTO_POS
,
510 .if_freq
= TDA10046_FREQ_052
,
511 .tuner_address
= 0x61,
512 .request_firmware
= philips_tda1004x_request_firmware
515 static struct tda1004x_config medion_cardbus
= {
516 .demod_address
= 0x08,
519 .xtal_freq
= TDA10046_XTAL_16M
,
520 .agc_config
= TDA10046_AGC_IFO_AUTO_NEG
,
521 .if_freq
= TDA10046_FREQ_3613
,
522 .tuner_address
= 0x61,
523 .request_firmware
= philips_tda1004x_request_firmware
526 static struct tda1004x_config technotrend_budget_t3000_config
= {
527 .demod_address
= 0x8,
530 .xtal_freq
= TDA10046_XTAL_4M
,
531 .agc_config
= TDA10046_AGC_DEFAULT
,
532 .if_freq
= TDA10046_FREQ_3617
,
533 .tuner_address
= 0x63,
534 .request_firmware
= philips_tda1004x_request_firmware
537 /* ------------------------------------------------------------------
538 * tda 1004x based cards with philips silicon tuner
541 static int tda8290_i2c_gate_ctrl( struct dvb_frontend
* fe
, int enable
)
543 struct tda1004x_state
*state
= fe
->demodulator_priv
;
545 u8 addr
= state
->config
->i2c_gate
;
546 static u8 tda8290_close
[] = { 0x21, 0xc0};
547 static u8 tda8290_open
[] = { 0x21, 0x80};
548 struct i2c_msg tda8290_msg
= {.addr
= addr
,.flags
= 0, .len
= 2};
550 tda8290_msg
.buf
= tda8290_close
;
552 tda8290_msg
.buf
= tda8290_open
;
554 if (i2c_transfer(state
->i2c
, &tda8290_msg
, 1) != 1) {
555 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
556 wprintk("could not access tda8290 I2C gate\n");
563 static int philips_tda827x_tuner_init(struct dvb_frontend
*fe
)
565 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
566 struct tda1004x_state
*state
= fe
->demodulator_priv
;
568 switch (state
->config
->antenna_switch
) {
570 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
571 saa7134_set_gpio(dev
, 21, 0);
573 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
574 saa7134_set_gpio(dev
, 21, 1);
580 static int philips_tda827x_tuner_sleep(struct dvb_frontend
*fe
)
582 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
583 struct tda1004x_state
*state
= fe
->demodulator_priv
;
585 switch (state
->config
->antenna_switch
) {
587 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
588 saa7134_set_gpio(dev
, 21, 1);
590 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
591 saa7134_set_gpio(dev
, 21, 0);
597 static int configure_tda827x_fe(struct saa7134_dev
*dev
,
598 struct tda1004x_config
*cdec_conf
,
599 struct tda827x_config
*tuner_conf
)
601 struct videobuf_dvb_frontend
*fe0
;
603 /* Get the first frontend */
604 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
606 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
, cdec_conf
, &dev
->i2c_adap
);
607 if (fe0
->dvb
.frontend
) {
608 if (cdec_conf
->i2c_gate
)
609 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= tda8290_i2c_gate_ctrl
;
610 if (dvb_attach(tda827x_attach
, fe0
->dvb
.frontend
,
611 cdec_conf
->tuner_address
,
612 &dev
->i2c_adap
, tuner_conf
))
615 wprintk("no tda827x tuner found at addr: %02x\n",
616 cdec_conf
->tuner_address
);
621 /* ------------------------------------------------------------------ */
623 static struct tda827x_config tda827x_cfg_0
= {
624 .init
= philips_tda827x_tuner_init
,
625 .sleep
= philips_tda827x_tuner_sleep
,
630 static struct tda827x_config tda827x_cfg_1
= {
631 .init
= philips_tda827x_tuner_init
,
632 .sleep
= philips_tda827x_tuner_sleep
,
637 static struct tda827x_config tda827x_cfg_2
= {
638 .init
= philips_tda827x_tuner_init
,
639 .sleep
= philips_tda827x_tuner_sleep
,
644 static struct tda827x_config tda827x_cfg_2_sw42
= {
645 .init
= philips_tda827x_tuner_init
,
646 .sleep
= philips_tda827x_tuner_sleep
,
651 /* ------------------------------------------------------------------ */
653 static struct tda1004x_config tda827x_lifeview_config
= {
654 .demod_address
= 0x08,
657 .xtal_freq
= TDA10046_XTAL_16M
,
658 .agc_config
= TDA10046_AGC_TDA827X
,
659 .gpio_config
= TDA10046_GP11_I
,
660 .if_freq
= TDA10046_FREQ_045
,
661 .tuner_address
= 0x60,
662 .request_firmware
= philips_tda1004x_request_firmware
665 static struct tda1004x_config philips_tiger_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,
676 .request_firmware
= philips_tda1004x_request_firmware
679 static struct tda1004x_config cinergy_ht_config
= {
680 .demod_address
= 0x08,
683 .xtal_freq
= TDA10046_XTAL_16M
,
684 .agc_config
= TDA10046_AGC_TDA827X
,
685 .gpio_config
= TDA10046_GP01_I
,
686 .if_freq
= TDA10046_FREQ_045
,
688 .tuner_address
= 0x61,
689 .request_firmware
= philips_tda1004x_request_firmware
692 static struct tda1004x_config cinergy_ht_pci_config
= {
693 .demod_address
= 0x08,
696 .xtal_freq
= TDA10046_XTAL_16M
,
697 .agc_config
= TDA10046_AGC_TDA827X
,
698 .gpio_config
= TDA10046_GP01_I
,
699 .if_freq
= TDA10046_FREQ_045
,
701 .tuner_address
= 0x60,
702 .request_firmware
= philips_tda1004x_request_firmware
705 static struct tda1004x_config philips_tiger_s_config
= {
706 .demod_address
= 0x08,
709 .xtal_freq
= TDA10046_XTAL_16M
,
710 .agc_config
= TDA10046_AGC_TDA827X
,
711 .gpio_config
= TDA10046_GP01_I
,
712 .if_freq
= TDA10046_FREQ_045
,
714 .tuner_address
= 0x61,
716 .request_firmware
= philips_tda1004x_request_firmware
719 static struct tda1004x_config pinnacle_pctv_310i_config
= {
720 .demod_address
= 0x08,
723 .xtal_freq
= TDA10046_XTAL_16M
,
724 .agc_config
= TDA10046_AGC_TDA827X
,
725 .gpio_config
= TDA10046_GP11_I
,
726 .if_freq
= TDA10046_FREQ_045
,
728 .tuner_address
= 0x61,
729 .request_firmware
= philips_tda1004x_request_firmware
732 static struct tda1004x_config hauppauge_hvr_1110_config
= {
733 .demod_address
= 0x08,
736 .xtal_freq
= TDA10046_XTAL_16M
,
737 .agc_config
= TDA10046_AGC_TDA827X
,
738 .gpio_config
= TDA10046_GP11_I
,
739 .if_freq
= TDA10046_FREQ_045
,
741 .tuner_address
= 0x61,
742 .request_firmware
= philips_tda1004x_request_firmware
745 static struct tda1004x_config asus_p7131_dual_config
= {
746 .demod_address
= 0x08,
749 .xtal_freq
= TDA10046_XTAL_16M
,
750 .agc_config
= TDA10046_AGC_TDA827X
,
751 .gpio_config
= TDA10046_GP11_I
,
752 .if_freq
= TDA10046_FREQ_045
,
754 .tuner_address
= 0x61,
756 .request_firmware
= philips_tda1004x_request_firmware
759 static struct tda1004x_config lifeview_trio_config
= {
760 .demod_address
= 0x09,
763 .xtal_freq
= TDA10046_XTAL_16M
,
764 .agc_config
= TDA10046_AGC_TDA827X
,
765 .gpio_config
= TDA10046_GP00_I
,
766 .if_freq
= TDA10046_FREQ_045
,
767 .tuner_address
= 0x60,
768 .request_firmware
= philips_tda1004x_request_firmware
771 static struct tda1004x_config tevion_dvbt220rf_config
= {
772 .demod_address
= 0x08,
775 .xtal_freq
= TDA10046_XTAL_16M
,
776 .agc_config
= TDA10046_AGC_TDA827X
,
777 .gpio_config
= TDA10046_GP11_I
,
778 .if_freq
= TDA10046_FREQ_045
,
779 .tuner_address
= 0x60,
780 .request_firmware
= philips_tda1004x_request_firmware
783 static struct tda1004x_config md8800_dvbt_config
= {
784 .demod_address
= 0x08,
787 .xtal_freq
= TDA10046_XTAL_16M
,
788 .agc_config
= TDA10046_AGC_TDA827X
,
789 .gpio_config
= TDA10046_GP01_I
,
790 .if_freq
= TDA10046_FREQ_045
,
792 .tuner_address
= 0x60,
793 .request_firmware
= philips_tda1004x_request_firmware
796 static struct tda1004x_config asus_p7131_4871_config
= {
797 .demod_address
= 0x08,
800 .xtal_freq
= TDA10046_XTAL_16M
,
801 .agc_config
= TDA10046_AGC_TDA827X
,
802 .gpio_config
= TDA10046_GP01_I
,
803 .if_freq
= TDA10046_FREQ_045
,
805 .tuner_address
= 0x61,
807 .request_firmware
= philips_tda1004x_request_firmware
810 static struct tda1004x_config asus_p7131_hybrid_lna_config
= {
811 .demod_address
= 0x08,
814 .xtal_freq
= TDA10046_XTAL_16M
,
815 .agc_config
= TDA10046_AGC_TDA827X
,
816 .gpio_config
= TDA10046_GP11_I
,
817 .if_freq
= TDA10046_FREQ_045
,
819 .tuner_address
= 0x61,
821 .request_firmware
= philips_tda1004x_request_firmware
824 static struct tda1004x_config kworld_dvb_t_210_config
= {
825 .demod_address
= 0x08,
828 .xtal_freq
= TDA10046_XTAL_16M
,
829 .agc_config
= TDA10046_AGC_TDA827X
,
830 .gpio_config
= TDA10046_GP11_I
,
831 .if_freq
= TDA10046_FREQ_045
,
833 .tuner_address
= 0x61,
835 .request_firmware
= philips_tda1004x_request_firmware
838 static struct tda1004x_config avermedia_super_007_config
= {
839 .demod_address
= 0x08,
842 .xtal_freq
= TDA10046_XTAL_16M
,
843 .agc_config
= TDA10046_AGC_TDA827X
,
844 .gpio_config
= TDA10046_GP01_I
,
845 .if_freq
= TDA10046_FREQ_045
,
847 .tuner_address
= 0x60,
849 .request_firmware
= philips_tda1004x_request_firmware
852 static struct tda1004x_config twinhan_dtv_dvb_3056_config
= {
853 .demod_address
= 0x08,
856 .xtal_freq
= TDA10046_XTAL_16M
,
857 .agc_config
= TDA10046_AGC_TDA827X
,
858 .gpio_config
= TDA10046_GP01_I
,
859 .if_freq
= TDA10046_FREQ_045
,
861 .tuner_address
= 0x61,
863 .request_firmware
= philips_tda1004x_request_firmware
866 static struct tda1004x_config asus_tiger_3in1_config
= {
867 .demod_address
= 0x0b,
870 .xtal_freq
= TDA10046_XTAL_16M
,
871 .agc_config
= TDA10046_AGC_TDA827X
,
872 .gpio_config
= TDA10046_GP11_I
,
873 .if_freq
= TDA10046_FREQ_045
,
875 .tuner_address
= 0x61,
877 .request_firmware
= philips_tda1004x_request_firmware
880 /* ------------------------------------------------------------------
881 * special case: this card uses saa713x GPIO22 for the mode switch
884 static int ads_duo_tuner_init(struct dvb_frontend
*fe
)
886 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
887 philips_tda827x_tuner_init(fe
);
888 /* route TDA8275a AGC input to the channel decoder */
889 saa7134_set_gpio(dev
, 22, 1);
893 static int ads_duo_tuner_sleep(struct dvb_frontend
*fe
)
895 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
896 /* route TDA8275a AGC input to the analog IF chip*/
897 saa7134_set_gpio(dev
, 22, 0);
898 philips_tda827x_tuner_sleep(fe
);
902 static struct tda827x_config ads_duo_cfg
= {
903 .init
= ads_duo_tuner_init
,
904 .sleep
= ads_duo_tuner_sleep
,
908 static struct tda1004x_config ads_tech_duo_config
= {
909 .demod_address
= 0x08,
912 .xtal_freq
= TDA10046_XTAL_16M
,
913 .agc_config
= TDA10046_AGC_TDA827X
,
914 .gpio_config
= TDA10046_GP00_I
,
915 .if_freq
= TDA10046_FREQ_045
,
916 .tuner_address
= 0x61,
917 .request_firmware
= philips_tda1004x_request_firmware
920 static struct zl10353_config behold_h6_config
= {
921 .demod_address
= 0x1e>>1,
924 .disable_i2c_gate_ctrl
= 1,
927 static struct xc5000_config behold_x7_tunerconfig
= {
928 .i2c_address
= 0xc2>>1,
930 .radio_input
= XC5000_RADIO_FM1
,
933 static struct zl10353_config behold_x7_config
= {
934 .demod_address
= 0x1e>>1,
938 .disable_i2c_gate_ctrl
= 1,
941 /* ==================================================================
942 * tda10086 based DVB-S cards, helper functions
945 static struct tda10086_config flydvbs
= {
946 .demod_address
= 0x0e,
949 .xtal_freq
= TDA10086_XTAL_16M
,
952 static struct tda10086_config sd1878_4m
= {
953 .demod_address
= 0x0e,
956 .xtal_freq
= TDA10086_XTAL_4M
,
959 /* ------------------------------------------------------------------
960 * special case: lnb supply is connected to the gated i2c
963 static int md8800_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
966 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
967 if (fe
->ops
.i2c_gate_ctrl
) {
968 fe
->ops
.i2c_gate_ctrl(fe
, 1);
969 if (dev
->original_set_voltage
)
970 res
= dev
->original_set_voltage(fe
, voltage
);
971 fe
->ops
.i2c_gate_ctrl(fe
, 0);
976 static int md8800_set_high_voltage(struct dvb_frontend
*fe
, long arg
)
979 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
980 if (fe
->ops
.i2c_gate_ctrl
) {
981 fe
->ops
.i2c_gate_ctrl(fe
, 1);
982 if (dev
->original_set_high_voltage
)
983 res
= dev
->original_set_high_voltage(fe
, arg
);
984 fe
->ops
.i2c_gate_ctrl(fe
, 0);
989 static int md8800_set_voltage2(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
991 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
992 u8 wbuf
[2] = { 0x1f, 00 };
994 struct i2c_msg msg
[] = { { .addr
= 0x08, .flags
= 0, .buf
= wbuf
, .len
= 1 },
995 { .addr
= 0x08, .flags
= I2C_M_RD
, .buf
= &rbuf
, .len
= 1 } };
997 if (i2c_transfer(&dev
->i2c_adap
, msg
, 2) != 2)
999 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1000 if (voltage
== SEC_VOLTAGE_18
)
1001 wbuf
[1] = rbuf
| 0x10;
1003 wbuf
[1] = rbuf
& 0xef;
1005 i2c_transfer(&dev
->i2c_adap
, msg
, 1);
1009 static int md8800_set_high_voltage2(struct dvb_frontend
*fe
, long arg
)
1011 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
1012 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__
);
1016 /* ==================================================================
1017 * nxt200x based ATSC cards, helper functions
1020 static struct nxt200x_config avertvhda180
= {
1021 .demod_address
= 0x0a,
1024 static struct nxt200x_config kworldatsc110
= {
1025 .demod_address
= 0x0a,
1028 /* ------------------------------------------------------------------ */
1030 static struct mt312_config avertv_a700_mt312
= {
1031 .demod_address
= 0x0e,
1032 .voltage_inverted
= 1,
1035 static struct zl10036_config avertv_a700_tuner
= {
1036 .tuner_address
= 0x60,
1039 static struct mt312_config zl10313_compro_s350_config
= {
1040 .demod_address
= 0x0e,
1043 static struct lgdt3305_config hcw_lgdt3305_config
= {
1045 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
1046 .tpclk_edge
= LGDT3305_TPCLK_RISING_EDGE
,
1047 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
1049 .spectral_inversion
= 1,
1054 static struct tda10048_config hcw_tda10048_config
= {
1055 .demod_address
= 0x10 >> 1,
1056 .output_mode
= TDA10048_SERIAL_OUTPUT
,
1057 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1058 .inversion
= TDA10048_INVERSION_ON
,
1059 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1060 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1061 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1062 .clk_freq_khz
= TDA10048_CLK_16000
,
1063 .disable_gate_access
= 1,
1066 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
1067 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
1068 .if_lvl
= 1, .rfagc_top
= 0x58, },
1069 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
1070 .if_lvl
= 1, .rfagc_top
= 0x58, },
1073 static struct tda18271_config hcw_tda18271_config
= {
1074 .std_map
= &hauppauge_tda18271_std_map
,
1075 .gate
= TDA18271_GATE_ANALOG
,
1077 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1080 static struct tda829x_config tda829x_no_probe
= {
1081 .probe_tuner
= TDA829X_DONT_PROBE
,
1084 static struct tda10048_config zolid_tda10048_config
= {
1085 .demod_address
= 0x10 >> 1,
1086 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1087 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1088 .inversion
= TDA10048_INVERSION_ON
,
1089 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1090 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1091 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1092 .clk_freq_khz
= TDA10048_CLK_16000
,
1093 .disable_gate_access
= 1,
1096 static struct tda18271_config zolid_tda18271_config
= {
1097 .gate
= TDA18271_GATE_ANALOG
,
1100 static struct tda10048_config dtv1000s_tda10048_config
= {
1101 .demod_address
= 0x10 >> 1,
1102 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1103 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1104 .inversion
= TDA10048_INVERSION_ON
,
1105 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1106 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
1107 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
1108 .clk_freq_khz
= TDA10048_CLK_16000
,
1109 .disable_gate_access
= 1,
1112 static struct tda18271_std_map dtv1000s_tda18271_std_map
= {
1113 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
1114 .if_lvl
= 1, .rfagc_top
= 0x37, },
1115 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
1116 .if_lvl
= 1, .rfagc_top
= 0x37, },
1117 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
1118 .if_lvl
= 1, .rfagc_top
= 0x37, },
1121 static struct tda18271_config dtv1000s_tda18271_config
= {
1122 .std_map
= &dtv1000s_tda18271_std_map
,
1123 .gate
= TDA18271_GATE_ANALOG
,
1126 /* ==================================================================
1130 static int dvb_init(struct saa7134_dev
*dev
)
1133 int attach_xc3028
= 0;
1134 struct videobuf_dvb_frontend
*fe0
;
1136 /* FIXME: add support for multi-frontend */
1137 mutex_init(&dev
->frontends
.lock
);
1138 INIT_LIST_HEAD(&dev
->frontends
.felist
);
1140 printk(KERN_INFO
"%s() allocating 1 frontend\n", __func__
);
1141 fe0
= videobuf_dvb_alloc_frontend(&dev
->frontends
, 1);
1143 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
1147 /* init struct videobuf_dvb */
1148 dev
->ts
.nr_bufs
= 32;
1149 dev
->ts
.nr_packets
= 32*4;
1150 fe0
->dvb
.name
= dev
->name
;
1151 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &saa7134_ts_qops
,
1152 &dev
->pci
->dev
, &dev
->slock
,
1153 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
1154 V4L2_FIELD_ALTERNATE
,
1155 sizeof(struct saa7134_buf
),
1158 switch (dev
->board
) {
1159 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
1160 dprintk("pinnacle 300i dvb setup\n");
1161 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &pinnacle_300i
,
1163 if (fe0
->dvb
.frontend
) {
1164 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= mt352_pinnacle_tuner_set_params
;
1167 case SAA7134_BOARD_AVERMEDIA_777
:
1168 case SAA7134_BOARD_AVERMEDIA_A16AR
:
1169 dprintk("avertv 777 dvb setup\n");
1170 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_777
,
1172 if (fe0
->dvb
.frontend
) {
1173 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1174 &dev
->i2c_adap
, 0x61,
1175 TUNER_PHILIPS_TD1316
);
1178 case SAA7134_BOARD_AVERMEDIA_A16D
:
1179 dprintk("AverMedia A16D dvb setup\n");
1180 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1181 &avermedia_xc3028_mt352_dev
,
1185 case SAA7134_BOARD_MD7134
:
1186 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1189 if (fe0
->dvb
.frontend
) {
1190 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1191 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1192 TUNER_PHILIPS_FMD1216ME_MK3
);
1195 case SAA7134_BOARD_PHILIPS_TOUGH
:
1196 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1197 &philips_tu1216_60_config
,
1199 if (fe0
->dvb
.frontend
) {
1200 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1201 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1204 case SAA7134_BOARD_FLYDVBTDUO
:
1205 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS
:
1206 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1207 &tda827x_cfg_0
) < 0)
1208 goto dettach_frontend
;
1210 case SAA7134_BOARD_PHILIPS_EUROPA
:
1211 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
1212 case SAA7134_BOARD_ASUS_EUROPA_HYBRID
:
1213 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1214 &philips_europa_config
,
1216 if (fe0
->dvb
.frontend
) {
1217 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1218 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1219 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1220 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1221 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1224 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000
:
1225 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1226 &technotrend_budget_t3000_config
,
1228 if (fe0
->dvb
.frontend
) {
1229 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1230 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1231 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1232 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1233 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1236 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
1237 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1238 &philips_tu1216_61_config
,
1240 if (fe0
->dvb
.frontend
) {
1241 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1242 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1245 case SAA7134_BOARD_KWORLD_DVBT_210
:
1246 if (configure_tda827x_fe(dev
, &kworld_dvb_t_210_config
,
1247 &tda827x_cfg_2
) < 0)
1248 goto dettach_frontend
;
1250 case SAA7134_BOARD_HAUPPAUGE_HVR1120
:
1251 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1252 &hcw_tda10048_config
,
1254 if (fe0
->dvb
.frontend
!= NULL
) {
1255 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1256 &dev
->i2c_adap
, 0x4b,
1258 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1259 0x60, &dev
->i2c_adap
,
1260 &hcw_tda18271_config
);
1263 case SAA7134_BOARD_PHILIPS_TIGER
:
1264 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1265 &tda827x_cfg_0
) < 0)
1266 goto dettach_frontend
;
1268 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
1269 if (configure_tda827x_fe(dev
, &pinnacle_pctv_310i_config
,
1270 &tda827x_cfg_1
) < 0)
1271 goto dettach_frontend
;
1273 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
1274 if (configure_tda827x_fe(dev
, &hauppauge_hvr_1110_config
,
1275 &tda827x_cfg_1
) < 0)
1276 goto dettach_frontend
;
1278 case SAA7134_BOARD_HAUPPAUGE_HVR1150
:
1279 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1280 &hcw_lgdt3305_config
,
1282 if (fe0
->dvb
.frontend
) {
1283 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1284 &dev
->i2c_adap
, 0x4b,
1286 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1287 0x60, &dev
->i2c_adap
,
1288 &hcw_tda18271_config
);
1291 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
1292 if (configure_tda827x_fe(dev
, &asus_p7131_dual_config
,
1293 &tda827x_cfg_0
) < 0)
1294 goto dettach_frontend
;
1296 case SAA7134_BOARD_FLYDVBT_LR301
:
1297 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1298 &tda827x_cfg_0
) < 0)
1299 goto dettach_frontend
;
1301 case SAA7134_BOARD_FLYDVB_TRIO
:
1302 if (!use_frontend
) { /* terrestrial */
1303 if (configure_tda827x_fe(dev
, &lifeview_trio_config
,
1304 &tda827x_cfg_0
) < 0)
1305 goto dettach_frontend
;
1306 } else { /* satellite */
1307 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
, &dev
->i2c_adap
);
1308 if (fe0
->dvb
.frontend
) {
1309 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x63,
1310 &dev
->i2c_adap
, 0) == NULL
) {
1311 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__
);
1312 goto dettach_frontend
;
1314 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
, &dev
->i2c_adap
,
1315 0x08, 0, 0) == NULL
) {
1316 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__
);
1317 goto dettach_frontend
;
1322 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331
:
1323 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS
:
1324 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1325 &ads_tech_duo_config
,
1327 if (fe0
->dvb
.frontend
) {
1328 if (dvb_attach(tda827x_attach
,fe0
->dvb
.frontend
,
1329 ads_tech_duo_config
.tuner_address
, &dev
->i2c_adap
,
1330 &ads_duo_cfg
) == NULL
) {
1331 wprintk("no tda827x tuner found at addr: %02x\n",
1332 ads_tech_duo_config
.tuner_address
);
1333 goto dettach_frontend
;
1336 wprintk("failed to attach tda10046\n");
1338 case SAA7134_BOARD_TEVION_DVBT_220RF
:
1339 if (configure_tda827x_fe(dev
, &tevion_dvbt220rf_config
,
1340 &tda827x_cfg_0
) < 0)
1341 goto dettach_frontend
;
1343 case SAA7134_BOARD_MEDION_MD8800_QUADRO
:
1344 if (!use_frontend
) { /* terrestrial */
1345 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1346 &tda827x_cfg_0
) < 0)
1347 goto dettach_frontend
;
1348 } else { /* satellite */
1349 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1350 &flydvbs
, &dev
->i2c_adap
);
1351 if (fe0
->dvb
.frontend
) {
1352 struct dvb_frontend
*fe
= fe0
->dvb
.frontend
;
1353 u8 dev_id
= dev
->eedata
[2];
1355 struct i2c_msg msg
= {.addr
= 0x08, .flags
= 0, .len
= 1};
1357 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
,
1358 0x60, &dev
->i2c_adap
, 0) == NULL
) {
1359 wprintk("%s: Medion Quadro, no tda826x "
1360 "found !\n", __func__
);
1361 goto dettach_frontend
;
1363 if (dev_id
!= 0x08) {
1364 /* we need to open the i2c gate (we know it exists) */
1365 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1366 if (dvb_attach(isl6405_attach
, fe
,
1367 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1368 wprintk("%s: Medion Quadro, no ISL6405 "
1369 "found !\n", __func__
);
1370 goto dettach_frontend
;
1372 if (dev_id
== 0x07) {
1373 /* fire up the 2nd section of the LNB supply since
1374 we can't do this from the other section */
1376 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1378 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1379 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1380 fe
->ops
.set_voltage
= md8800_set_voltage
;
1381 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1382 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1384 fe
->ops
.set_voltage
= md8800_set_voltage2
;
1385 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage2
;
1390 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
1391 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &avertvhda180
,
1393 if (fe0
->dvb
.frontend
)
1394 dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x61,
1395 NULL
, DVB_PLL_TDHU2
);
1397 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI
:
1398 case SAA7134_BOARD_KWORLD_ATSC110
:
1399 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &kworldatsc110
,
1401 if (fe0
->dvb
.frontend
)
1402 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1403 &dev
->i2c_adap
, 0x61,
1404 TUNER_PHILIPS_TUV1236D
);
1406 case SAA7134_BOARD_FLYDVBS_LR300
:
1407 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1409 if (fe0
->dvb
.frontend
) {
1410 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1411 &dev
->i2c_adap
, 0) == NULL
) {
1412 wprintk("%s: No tda826x found!\n", __func__
);
1413 goto dettach_frontend
;
1415 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1416 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1417 wprintk("%s: No ISL6421 found!\n", __func__
);
1418 goto dettach_frontend
;
1422 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID
:
1423 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1426 if (fe0
->dvb
.frontend
) {
1427 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1428 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1430 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1431 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1432 TUNER_PHILIPS_FMD1216ME_MK3
);
1435 case SAA7134_BOARD_VIDEOMATE_DVBT_200A
:
1436 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1437 &philips_europa_config
,
1439 if (fe0
->dvb
.frontend
) {
1440 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_td1316_tuner_init
;
1441 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1444 case SAA7134_BOARD_CINERGY_HT_PCMCIA
:
1445 if (configure_tda827x_fe(dev
, &cinergy_ht_config
,
1446 &tda827x_cfg_0
) < 0)
1447 goto dettach_frontend
;
1449 case SAA7134_BOARD_CINERGY_HT_PCI
:
1450 if (configure_tda827x_fe(dev
, &cinergy_ht_pci_config
,
1451 &tda827x_cfg_0
) < 0)
1452 goto dettach_frontend
;
1454 case SAA7134_BOARD_PHILIPS_TIGER_S
:
1455 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1456 &tda827x_cfg_2
) < 0)
1457 goto dettach_frontend
;
1459 case SAA7134_BOARD_ASUS_P7131_4871
:
1460 if (configure_tda827x_fe(dev
, &asus_p7131_4871_config
,
1461 &tda827x_cfg_2
) < 0)
1462 goto dettach_frontend
;
1464 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
1465 if (configure_tda827x_fe(dev
, &asus_p7131_hybrid_lna_config
,
1466 &tda827x_cfg_2
) < 0)
1467 goto dettach_frontend
;
1469 case SAA7134_BOARD_AVERMEDIA_SUPER_007
:
1470 if (configure_tda827x_fe(dev
, &avermedia_super_007_config
,
1471 &tda827x_cfg_0
) < 0)
1472 goto dettach_frontend
;
1474 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056
:
1475 if (configure_tda827x_fe(dev
, &twinhan_dtv_dvb_3056_config
,
1476 &tda827x_cfg_2_sw42
) < 0)
1477 goto dettach_frontend
;
1479 case SAA7134_BOARD_PHILIPS_SNAKE
:
1480 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1482 if (fe0
->dvb
.frontend
) {
1483 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1484 &dev
->i2c_adap
, 0) == NULL
) {
1485 wprintk("%s: No tda826x found!\n", __func__
);
1486 goto dettach_frontend
;
1488 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1489 &dev
->i2c_adap
, 0, 0) == NULL
) {
1490 wprintk("%s: No lnbp21 found!\n", __func__
);
1491 goto dettach_frontend
;
1495 case SAA7134_BOARD_CREATIX_CTX953
:
1496 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1497 &tda827x_cfg_0
) < 0)
1498 goto dettach_frontend
;
1500 case SAA7134_BOARD_MSI_TVANYWHERE_AD11
:
1501 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1502 &tda827x_cfg_2
) < 0)
1503 goto dettach_frontend
;
1505 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
1506 dprintk("AverMedia E506R dvb setup\n");
1507 saa7134_set_gpio(dev
, 25, 0);
1509 saa7134_set_gpio(dev
, 25, 1);
1510 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1511 &avermedia_xc3028_mt352_dev
,
1515 case SAA7134_BOARD_MD7134_BRIDGE_2
:
1516 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1517 &sd1878_4m
, &dev
->i2c_adap
);
1518 if (fe0
->dvb
.frontend
) {
1519 struct dvb_frontend
*fe
;
1520 if (dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1521 &dev
->i2c_adap
, DVB_PLL_PHILIPS_SD1878_TDA8261
) == NULL
) {
1522 wprintk("%s: MD7134 DVB-S, no SD1878 "
1523 "found !\n", __func__
);
1524 goto dettach_frontend
;
1526 /* we need to open the i2c gate (we know it exists) */
1527 fe
= fe0
->dvb
.frontend
;
1528 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1529 if (dvb_attach(isl6405_attach
, fe
,
1530 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1531 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1532 "found !\n", __func__
);
1533 goto dettach_frontend
;
1535 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1536 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1537 fe
->ops
.set_voltage
= md8800_set_voltage
;
1538 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1539 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1542 case SAA7134_BOARD_AVERMEDIA_M103
:
1543 saa7134_set_gpio(dev
, 25, 0);
1545 saa7134_set_gpio(dev
, 25, 1);
1546 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1547 &avermedia_xc3028_mt352_dev
,
1551 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1
:
1552 if (!use_frontend
) { /* terrestrial */
1553 if (configure_tda827x_fe(dev
, &asus_tiger_3in1_config
,
1554 &tda827x_cfg_2
) < 0)
1555 goto dettach_frontend
;
1556 } else { /* satellite */
1557 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1558 &flydvbs
, &dev
->i2c_adap
);
1559 if (fe0
->dvb
.frontend
) {
1560 if (dvb_attach(tda826x_attach
,
1561 fe0
->dvb
.frontend
, 0x60,
1562 &dev
->i2c_adap
, 0) == NULL
) {
1563 wprintk("%s: Asus Tiger 3in1, no "
1564 "tda826x found!\n", __func__
);
1565 goto dettach_frontend
;
1567 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1568 &dev
->i2c_adap
, 0, 0) == NULL
) {
1569 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1570 " found!\n", __func__
);
1571 goto dettach_frontend
;
1576 case SAA7134_BOARD_ASUSTeK_TIGER
:
1577 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1578 &tda827x_cfg_0
) < 0)
1579 goto dettach_frontend
;
1581 case SAA7134_BOARD_BEHOLD_H6
:
1582 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1585 if (fe0
->dvb
.frontend
) {
1586 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1587 &dev
->i2c_adap
, 0x61,
1588 TUNER_PHILIPS_FMD1216MEX_MK3
);
1591 case SAA7134_BOARD_BEHOLD_X7
:
1592 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1595 if (fe0
->dvb
.frontend
) {
1596 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1597 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1600 case SAA7134_BOARD_BEHOLD_H7
:
1601 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1604 if (fe0
->dvb
.frontend
) {
1605 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1606 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1609 case SAA7134_BOARD_AVERMEDIA_A700_PRO
:
1610 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID
:
1611 /* Zarlink ZL10313 */
1612 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1613 &avertv_a700_mt312
, &dev
->i2c_adap
);
1614 if (fe0
->dvb
.frontend
) {
1615 if (dvb_attach(zl10036_attach
, fe0
->dvb
.frontend
,
1616 &avertv_a700_tuner
, &dev
->i2c_adap
) == NULL
) {
1617 wprintk("%s: No zl10036 found!\n",
1622 case SAA7134_BOARD_VIDEOMATE_S350
:
1623 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1624 &zl10313_compro_s350_config
, &dev
->i2c_adap
);
1625 if (fe0
->dvb
.frontend
)
1626 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1627 0x60, &dev
->i2c_adap
) == NULL
)
1628 wprintk("%s: No zl10039 found!\n",
1632 case SAA7134_BOARD_ZOLID_HYBRID_PCI
:
1633 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1634 &zolid_tda10048_config
,
1636 if (fe0
->dvb
.frontend
!= NULL
) {
1637 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1638 &dev
->i2c_adap
, 0x4b,
1640 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1641 0x60, &dev
->i2c_adap
,
1642 &zolid_tda18271_config
);
1645 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S
:
1646 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1647 &dtv1000s_tda10048_config
,
1649 if (fe0
->dvb
.frontend
!= NULL
) {
1650 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1651 &dev
->i2c_adap
, 0x4b,
1653 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1654 0x60, &dev
->i2c_adap
,
1655 &dtv1000s_tda18271_config
);
1658 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG
:
1659 /* Switch to digital mode */
1660 saa7134_tuner_callback(dev
, 0,
1661 TDA18271_CALLBACK_CMD_AGC_ENABLE
, 1);
1662 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1663 &kworld_mb86a20s_config
,
1665 if (fe0
->dvb
.frontend
!= NULL
) {
1666 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1667 &dev
->i2c_adap
, 0x4b,
1669 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1670 0x60, &dev
->i2c_adap
,
1671 &kworld_tda18271_config
);
1672 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= kworld_sbtvd_gate_ctrl
;
1675 /* mb86a20s need to use the I2C gateway */
1678 wprintk("Huh? unknown DVB card?\n");
1682 if (attach_xc3028
) {
1683 struct dvb_frontend
*fe
;
1684 struct xc2028_config cfg
= {
1685 .i2c_adap
= &dev
->i2c_adap
,
1689 if (!fe0
->dvb
.frontend
)
1690 goto dettach_frontend
;
1692 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
1694 printk(KERN_ERR
"%s/2: xc3028 attach failed\n",
1696 goto dettach_frontend
;
1700 if (NULL
== fe0
->dvb
.frontend
) {
1701 printk(KERN_ERR
"%s/dvb: frontend initialization failed\n", dev
->name
);
1702 goto dettach_frontend
;
1704 /* define general-purpose callback pointer */
1705 fe0
->dvb
.frontend
->callback
= saa7134_tuner_callback
;
1707 /* register everything else */
1708 ret
= videobuf_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1709 &dev
->pci
->dev
, adapter_nr
, 0, NULL
);
1711 /* this sequence is necessary to make the tda1004x load its firmware
1712 * and to enter analog mode of hybrid boards
1715 if (fe0
->dvb
.frontend
->ops
.init
)
1716 fe0
->dvb
.frontend
->ops
.init(fe0
->dvb
.frontend
);
1717 if (fe0
->dvb
.frontend
->ops
.sleep
)
1718 fe0
->dvb
.frontend
->ops
.sleep(fe0
->dvb
.frontend
);
1719 if (fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
)
1720 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep(fe0
->dvb
.frontend
);
1725 videobuf_dvb_dealloc_frontends(&dev
->frontends
);
1729 static int dvb_fini(struct saa7134_dev
*dev
)
1731 struct videobuf_dvb_frontend
*fe0
;
1733 /* Get the first frontend */
1734 fe0
= videobuf_dvb_get_frontend(&dev
->frontends
, 1);
1738 /* FIXME: I suspect that this code is bogus, since the entry for
1739 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1740 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1742 if (dev
->board
== SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
) {
1743 struct v4l2_priv_tun_config tda9887_cfg
;
1744 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
1746 tda9887_cfg
.tuner
= TUNER_TDA9887
;
1747 tda9887_cfg
.priv
= &on
;
1749 /* otherwise we don't detect the tuner on next insmod */
1750 saa_call_all(dev
, tuner
, s_config
, &tda9887_cfg
);
1751 } else if (dev
->board
== SAA7134_BOARD_MEDION_MD8800_QUADRO
) {
1752 if ((dev
->eedata
[2] == 0x07) && use_frontend
) {
1753 /* turn off the 2nd lnb supply */
1755 struct i2c_msg msg
= {.addr
= 0x08, .buf
= &data
, .flags
= 0, .len
= 1};
1756 struct dvb_frontend
*fe
;
1757 fe
= fe0
->dvb
.frontend
;
1758 if (fe
->ops
.i2c_gate_ctrl
) {
1759 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1760 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1761 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1765 videobuf_dvb_unregister_bus(&dev
->frontends
);
1769 static struct saa7134_mpeg_ops dvb_ops
= {
1770 .type
= SAA7134_MPEG_DVB
,
1775 static int __init
dvb_register(void)
1777 return saa7134_ts_register(&dvb_ops
);
1780 static void __exit
dvb_unregister(void)
1782 saa7134_ts_unregister(&dvb_ops
);
1785 module_init(dvb_register
);
1786 module_exit(dvb_unregister
);
1788 /* ------------------------------------------------------------------ */