3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5 * Extended 3 / 2005 by Hartmut Hackmann to support various
6 * cards with the tda10046 DVB-T channel decoder
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/init.h>
24 #include <linux/list.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/slab.h>
28 #include <linux/delay.h>
29 #include <linux/kthread.h>
30 #include <linux/suspend.h>
32 #include "saa7134-reg.h"
34 #include <media/v4l2-common.h>
36 #include <dvb_frontend.h>
39 #include "mt352_priv.h" /* FIXME */
42 #include "tuner-xc2028.h"
50 #include "tuner-simple.h"
52 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
53 MODULE_LICENSE("GPL");
55 static unsigned int antenna_pwr
;
57 module_param(antenna_pwr
, int, 0444);
58 MODULE_PARM_DESC(antenna_pwr
,"enable antenna power (Pinnacle 300i)");
60 static int use_frontend
;
61 module_param(use_frontend
, int, 0644);
62 MODULE_PARM_DESC(use_frontend
,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
65 module_param(debug
, int, 0644);
66 MODULE_PARM_DESC(debug
, "Turn on/off module debugging (default:off).");
68 #define dprintk(fmt, arg...) do { if (debug) \
69 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
72 #define wprintk(fmt, arg...) \
73 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
75 /* ------------------------------------------------------------------
76 * mt352 based DVB-T cards
79 static int pinnacle_antenna_pwr(struct saa7134_dev
*dev
, int on
)
84 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
85 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
89 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
90 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
93 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 28));
94 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
96 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
98 ok
= saa_readl(SAA7134_GPIO_GPSTATUS0
) & (1 << 27);
99 dprintk("%s %s\n", __func__
, ok
? "on" : "off");
102 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
106 static int mt352_pinnacle_init(struct dvb_frontend
* fe
)
108 static u8 clock_config
[] = { CLOCK_CTL
, 0x3d, 0x28 };
109 static u8 reset
[] = { RESET
, 0x80 };
110 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
111 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
112 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x31 };
113 static u8 fsm_ctl_cfg
[] = { 0x7b, 0x04 };
114 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x0f };
115 static u8 scan_ctl_cfg
[] = { SCAN_CTL
, 0x0d };
116 static u8 irq_cfg
[] = { INTERRUPT_EN_0
, 0x00, 0x00, 0x00, 0x00 };
117 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
119 dprintk("%s called\n", __func__
);
121 mt352_write(fe
, clock_config
, sizeof(clock_config
));
123 mt352_write(fe
, reset
, sizeof(reset
));
124 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
125 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
126 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
127 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
129 mt352_write(fe
, fsm_ctl_cfg
, sizeof(fsm_ctl_cfg
));
130 mt352_write(fe
, scan_ctl_cfg
, sizeof(scan_ctl_cfg
));
131 mt352_write(fe
, irq_cfg
, sizeof(irq_cfg
));
136 static int mt352_aver777_init(struct dvb_frontend
* fe
)
138 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
139 static u8 reset
[] = { RESET
, 0x80 };
140 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
141 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
142 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
144 mt352_write(fe
, clock_config
, sizeof(clock_config
));
146 mt352_write(fe
, reset
, sizeof(reset
));
147 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
148 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
149 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
154 static int mt352_aver_a16d_init(struct dvb_frontend
*fe
)
156 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
157 static u8 reset
[] = { RESET
, 0x80 };
158 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
159 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
160 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
162 mt352_write(fe
, clock_config
, sizeof(clock_config
));
164 mt352_write(fe
, reset
, sizeof(reset
));
165 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
166 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
167 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
174 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend
* fe
,
175 struct dvb_frontend_parameters
* params
)
177 u8 off
[] = { 0x00, 0xf1};
178 u8 on
[] = { 0x00, 0x71};
179 struct i2c_msg msg
= {.addr
=0x43, .flags
=0, .buf
=off
, .len
= sizeof(off
)};
181 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
182 struct v4l2_frequency f
;
184 /* set frequency (mt2050) */
186 f
.type
= V4L2_TUNER_DIGITAL_TV
;
187 f
.frequency
= params
->frequency
/ 1000 * 16 / 1000;
188 if (fe
->ops
.i2c_gate_ctrl
)
189 fe
->ops
.i2c_gate_ctrl(fe
, 1);
190 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
191 saa7134_i2c_call_clients(dev
,VIDIOC_S_FREQUENCY
,&f
);
193 if (fe
->ops
.i2c_gate_ctrl
)
194 fe
->ops
.i2c_gate_ctrl(fe
, 1);
195 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
197 pinnacle_antenna_pwr(dev
, antenna_pwr
);
200 return mt352_pinnacle_init(fe
);
203 static struct mt352_config pinnacle_300i
= {
204 .demod_address
= 0x3c >> 1,
208 .demod_init
= mt352_pinnacle_init
,
211 static struct mt352_config avermedia_777
= {
212 .demod_address
= 0xf,
213 .demod_init
= mt352_aver777_init
,
216 static struct mt352_config avermedia_16d
= {
217 .demod_address
= 0xf,
218 .demod_init
= mt352_aver_a16d_init
,
221 static struct mt352_config avermedia_e506r_mt352_dev
= {
222 .demod_address
= (0x1e >> 1),
226 /* ==================================================================
227 * tda1004x based DVB-T cards, helper functions
230 static int philips_tda1004x_request_firmware(struct dvb_frontend
*fe
,
231 const struct firmware
**fw
, char *name
)
233 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
234 return request_firmware(fw
, name
, &dev
->pci
->dev
);
237 /* ------------------------------------------------------------------
238 * these tuners are tu1216, td1316(a)
241 static int philips_tda6651_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
243 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
244 struct tda1004x_state
*state
= fe
->demodulator_priv
;
245 u8 addr
= state
->config
->tuner_address
;
247 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tuner_buf
,.len
=
249 int tuner_frequency
= 0;
252 /* determine charge pump */
253 tuner_frequency
= params
->frequency
+ 36166000;
254 if (tuner_frequency
< 87000000)
256 else if (tuner_frequency
< 130000000)
258 else if (tuner_frequency
< 160000000)
260 else if (tuner_frequency
< 200000000)
262 else if (tuner_frequency
< 290000000)
264 else if (tuner_frequency
< 420000000)
266 else if (tuner_frequency
< 480000000)
268 else if (tuner_frequency
< 620000000)
270 else if (tuner_frequency
< 830000000)
272 else if (tuner_frequency
< 895000000)
278 if (params
->frequency
< 49000000)
280 else if (params
->frequency
< 161000000)
282 else if (params
->frequency
< 444000000)
284 else if (params
->frequency
< 861000000)
289 /* setup PLL filter */
290 switch (params
->u
.ofdm
.bandwidth
) {
291 case BANDWIDTH_6_MHZ
:
295 case BANDWIDTH_7_MHZ
:
299 case BANDWIDTH_8_MHZ
:
308 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
310 tuner_frequency
= (((params
->frequency
/ 1000) * 6) + 217496) / 1000;
312 /* setup tuner buffer */
313 tuner_buf
[0] = (tuner_frequency
>> 8) & 0x7f;
314 tuner_buf
[1] = tuner_frequency
& 0xff;
316 tuner_buf
[3] = (cp
<< 5) | (filter
<< 3) | band
;
318 if (fe
->ops
.i2c_gate_ctrl
)
319 fe
->ops
.i2c_gate_ctrl(fe
, 1);
320 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1) {
321 wprintk("could not write to tuner at addr: 0x%02x\n",
329 static int philips_tu1216_init(struct dvb_frontend
*fe
)
331 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
332 struct tda1004x_state
*state
= fe
->demodulator_priv
;
333 u8 addr
= state
->config
->tuner_address
;
334 static u8 tu1216_init
[] = { 0x0b, 0xf5, 0x85, 0xab };
335 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tu1216_init
,.len
= sizeof(tu1216_init
) };
337 /* setup PLL configuration */
338 if (fe
->ops
.i2c_gate_ctrl
)
339 fe
->ops
.i2c_gate_ctrl(fe
, 1);
340 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
347 /* ------------------------------------------------------------------ */
349 static struct tda1004x_config philips_tu1216_60_config
= {
350 .demod_address
= 0x8,
353 .xtal_freq
= TDA10046_XTAL_4M
,
354 .agc_config
= TDA10046_AGC_DEFAULT
,
355 .if_freq
= TDA10046_FREQ_3617
,
356 .tuner_address
= 0x60,
357 .request_firmware
= philips_tda1004x_request_firmware
360 static struct tda1004x_config philips_tu1216_61_config
= {
362 .demod_address
= 0x8,
365 .xtal_freq
= TDA10046_XTAL_4M
,
366 .agc_config
= TDA10046_AGC_DEFAULT
,
367 .if_freq
= TDA10046_FREQ_3617
,
368 .tuner_address
= 0x61,
369 .request_firmware
= philips_tda1004x_request_firmware
372 /* ------------------------------------------------------------------ */
374 static int philips_td1316_tuner_init(struct dvb_frontend
*fe
)
376 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
377 struct tda1004x_state
*state
= fe
->demodulator_priv
;
378 u8 addr
= state
->config
->tuner_address
;
379 static u8 msg
[] = { 0x0b, 0xf5, 0x86, 0xab };
380 struct i2c_msg init_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
382 /* setup PLL configuration */
383 if (fe
->ops
.i2c_gate_ctrl
)
384 fe
->ops
.i2c_gate_ctrl(fe
, 1);
385 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
390 static int philips_td1316_tuner_set_params(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
392 return philips_tda6651_pll_set(fe
, params
);
395 static int philips_td1316_tuner_sleep(struct dvb_frontend
*fe
)
397 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
398 struct tda1004x_state
*state
= fe
->demodulator_priv
;
399 u8 addr
= state
->config
->tuner_address
;
400 static u8 msg
[] = { 0x0b, 0xdc, 0x86, 0xa4 };
401 struct i2c_msg analog_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
403 /* switch the tuner to analog mode */
404 if (fe
->ops
.i2c_gate_ctrl
)
405 fe
->ops
.i2c_gate_ctrl(fe
, 1);
406 if (i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1) != 1)
411 /* ------------------------------------------------------------------ */
413 static int philips_europa_tuner_init(struct dvb_frontend
*fe
)
415 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
416 static u8 msg
[] = { 0x00, 0x40};
417 struct i2c_msg init_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
420 if (philips_td1316_tuner_init(fe
))
423 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
429 static int philips_europa_tuner_sleep(struct dvb_frontend
*fe
)
431 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
433 static u8 msg
[] = { 0x00, 0x14 };
434 struct i2c_msg analog_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
436 if (philips_td1316_tuner_sleep(fe
))
439 /* switch the board to analog mode */
440 if (fe
->ops
.i2c_gate_ctrl
)
441 fe
->ops
.i2c_gate_ctrl(fe
, 1);
442 i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1);
446 static int philips_europa_demod_sleep(struct dvb_frontend
*fe
)
448 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
450 if (dev
->original_demod_sleep
)
451 dev
->original_demod_sleep(fe
);
452 fe
->ops
.i2c_gate_ctrl(fe
, 1);
456 static struct tda1004x_config philips_europa_config
= {
458 .demod_address
= 0x8,
461 .xtal_freq
= TDA10046_XTAL_4M
,
462 .agc_config
= TDA10046_AGC_IFO_AUTO_POS
,
463 .if_freq
= TDA10046_FREQ_052
,
464 .tuner_address
= 0x61,
465 .request_firmware
= philips_tda1004x_request_firmware
468 static struct tda1004x_config medion_cardbus
= {
469 .demod_address
= 0x08,
472 .xtal_freq
= TDA10046_XTAL_16M
,
473 .agc_config
= TDA10046_AGC_IFO_AUTO_NEG
,
474 .if_freq
= TDA10046_FREQ_3613
,
475 .tuner_address
= 0x61,
476 .request_firmware
= philips_tda1004x_request_firmware
479 /* ------------------------------------------------------------------
480 * tda 1004x based cards with philips silicon tuner
483 static int tda8290_i2c_gate_ctrl( struct dvb_frontend
* fe
, int enable
)
485 struct tda1004x_state
*state
= fe
->demodulator_priv
;
487 u8 addr
= state
->config
->i2c_gate
;
488 static u8 tda8290_close
[] = { 0x21, 0xc0};
489 static u8 tda8290_open
[] = { 0x21, 0x80};
490 struct i2c_msg tda8290_msg
= {.addr
= addr
,.flags
= 0, .len
= 2};
492 tda8290_msg
.buf
= tda8290_close
;
494 tda8290_msg
.buf
= tda8290_open
;
496 if (i2c_transfer(state
->i2c
, &tda8290_msg
, 1) != 1) {
497 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
498 wprintk("could not access tda8290 I2C gate\n");
505 static int philips_tda827x_tuner_init(struct dvb_frontend
*fe
)
507 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
508 struct tda1004x_state
*state
= fe
->demodulator_priv
;
510 switch (state
->config
->antenna_switch
) {
512 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
513 saa7134_set_gpio(dev
, 21, 0);
515 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
516 saa7134_set_gpio(dev
, 21, 1);
522 static int philips_tda827x_tuner_sleep(struct dvb_frontend
*fe
)
524 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
525 struct tda1004x_state
*state
= fe
->demodulator_priv
;
527 switch (state
->config
->antenna_switch
) {
529 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
530 saa7134_set_gpio(dev
, 21, 1);
532 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
533 saa7134_set_gpio(dev
, 21, 0);
539 static void configure_tda827x_fe(struct saa7134_dev
*dev
, struct tda1004x_config
*cdec_conf
,
540 struct tda827x_config
*tuner_conf
)
542 dev
->dvb
.frontend
= dvb_attach(tda10046_attach
, cdec_conf
, &dev
->i2c_adap
);
543 if (dev
->dvb
.frontend
) {
544 if (cdec_conf
->i2c_gate
)
545 dev
->dvb
.frontend
->ops
.i2c_gate_ctrl
= tda8290_i2c_gate_ctrl
;
546 if (dvb_attach(tda827x_attach
, dev
->dvb
.frontend
, cdec_conf
->tuner_address
,
547 &dev
->i2c_adap
, tuner_conf
) == NULL
) {
548 wprintk("no tda827x tuner found at addr: %02x\n",
549 cdec_conf
->tuner_address
);
554 /* ------------------------------------------------------------------ */
556 static struct tda827x_config tda827x_cfg_0
= {
557 .tuner_callback
= saa7134_tuner_callback
,
558 .init
= philips_tda827x_tuner_init
,
559 .sleep
= philips_tda827x_tuner_sleep
,
564 static struct tda827x_config tda827x_cfg_1
= {
565 .tuner_callback
= saa7134_tuner_callback
,
566 .init
= philips_tda827x_tuner_init
,
567 .sleep
= philips_tda827x_tuner_sleep
,
572 static struct tda827x_config tda827x_cfg_2
= {
573 .tuner_callback
= saa7134_tuner_callback
,
574 .init
= philips_tda827x_tuner_init
,
575 .sleep
= philips_tda827x_tuner_sleep
,
580 static struct tda827x_config tda827x_cfg_2_sw42
= {
581 .tuner_callback
= saa7134_tuner_callback
,
582 .init
= philips_tda827x_tuner_init
,
583 .sleep
= philips_tda827x_tuner_sleep
,
588 /* ------------------------------------------------------------------ */
590 static struct tda1004x_config tda827x_lifeview_config
= {
591 .demod_address
= 0x08,
594 .xtal_freq
= TDA10046_XTAL_16M
,
595 .agc_config
= TDA10046_AGC_TDA827X
,
596 .gpio_config
= TDA10046_GP11_I
,
597 .if_freq
= TDA10046_FREQ_045
,
598 .tuner_address
= 0x60,
599 .request_firmware
= philips_tda1004x_request_firmware
602 static struct tda1004x_config philips_tiger_config
= {
603 .demod_address
= 0x08,
606 .xtal_freq
= TDA10046_XTAL_16M
,
607 .agc_config
= TDA10046_AGC_TDA827X
,
608 .gpio_config
= TDA10046_GP11_I
,
609 .if_freq
= TDA10046_FREQ_045
,
611 .tuner_address
= 0x61,
613 .request_firmware
= philips_tda1004x_request_firmware
616 static struct tda1004x_config cinergy_ht_config
= {
617 .demod_address
= 0x08,
620 .xtal_freq
= TDA10046_XTAL_16M
,
621 .agc_config
= TDA10046_AGC_TDA827X
,
622 .gpio_config
= TDA10046_GP01_I
,
623 .if_freq
= TDA10046_FREQ_045
,
625 .tuner_address
= 0x61,
626 .request_firmware
= philips_tda1004x_request_firmware
629 static struct tda1004x_config cinergy_ht_pci_config
= {
630 .demod_address
= 0x08,
633 .xtal_freq
= TDA10046_XTAL_16M
,
634 .agc_config
= TDA10046_AGC_TDA827X
,
635 .gpio_config
= TDA10046_GP01_I
,
636 .if_freq
= TDA10046_FREQ_045
,
638 .tuner_address
= 0x60,
639 .request_firmware
= philips_tda1004x_request_firmware
642 static struct tda1004x_config philips_tiger_s_config
= {
643 .demod_address
= 0x08,
646 .xtal_freq
= TDA10046_XTAL_16M
,
647 .agc_config
= TDA10046_AGC_TDA827X
,
648 .gpio_config
= TDA10046_GP01_I
,
649 .if_freq
= TDA10046_FREQ_045
,
651 .tuner_address
= 0x61,
653 .request_firmware
= philips_tda1004x_request_firmware
656 static struct tda1004x_config pinnacle_pctv_310i_config
= {
657 .demod_address
= 0x08,
660 .xtal_freq
= TDA10046_XTAL_16M
,
661 .agc_config
= TDA10046_AGC_TDA827X
,
662 .gpio_config
= TDA10046_GP11_I
,
663 .if_freq
= TDA10046_FREQ_045
,
665 .tuner_address
= 0x61,
666 .request_firmware
= philips_tda1004x_request_firmware
669 static struct tda1004x_config hauppauge_hvr_1110_config
= {
670 .demod_address
= 0x08,
673 .xtal_freq
= TDA10046_XTAL_16M
,
674 .agc_config
= TDA10046_AGC_TDA827X
,
675 .gpio_config
= TDA10046_GP11_I
,
676 .if_freq
= TDA10046_FREQ_045
,
678 .tuner_address
= 0x61,
679 .request_firmware
= philips_tda1004x_request_firmware
682 static struct tda1004x_config asus_p7131_dual_config
= {
683 .demod_address
= 0x08,
686 .xtal_freq
= TDA10046_XTAL_16M
,
687 .agc_config
= TDA10046_AGC_TDA827X
,
688 .gpio_config
= TDA10046_GP11_I
,
689 .if_freq
= TDA10046_FREQ_045
,
691 .tuner_address
= 0x61,
693 .request_firmware
= philips_tda1004x_request_firmware
696 static struct tda1004x_config lifeview_trio_config
= {
697 .demod_address
= 0x09,
700 .xtal_freq
= TDA10046_XTAL_16M
,
701 .agc_config
= TDA10046_AGC_TDA827X
,
702 .gpio_config
= TDA10046_GP00_I
,
703 .if_freq
= TDA10046_FREQ_045
,
704 .tuner_address
= 0x60,
705 .request_firmware
= philips_tda1004x_request_firmware
708 static struct tda1004x_config tevion_dvbt220rf_config
= {
709 .demod_address
= 0x08,
712 .xtal_freq
= TDA10046_XTAL_16M
,
713 .agc_config
= TDA10046_AGC_TDA827X
,
714 .gpio_config
= TDA10046_GP11_I
,
715 .if_freq
= TDA10046_FREQ_045
,
716 .tuner_address
= 0x60,
717 .request_firmware
= philips_tda1004x_request_firmware
720 static struct tda1004x_config md8800_dvbt_config
= {
721 .demod_address
= 0x08,
724 .xtal_freq
= TDA10046_XTAL_16M
,
725 .agc_config
= TDA10046_AGC_TDA827X
,
726 .gpio_config
= TDA10046_GP01_I
,
727 .if_freq
= TDA10046_FREQ_045
,
729 .tuner_address
= 0x60,
730 .request_firmware
= philips_tda1004x_request_firmware
733 static struct tda1004x_config asus_p7131_4871_config
= {
734 .demod_address
= 0x08,
737 .xtal_freq
= TDA10046_XTAL_16M
,
738 .agc_config
= TDA10046_AGC_TDA827X
,
739 .gpio_config
= TDA10046_GP01_I
,
740 .if_freq
= TDA10046_FREQ_045
,
742 .tuner_address
= 0x61,
744 .request_firmware
= philips_tda1004x_request_firmware
747 static struct tda1004x_config asus_p7131_hybrid_lna_config
= {
748 .demod_address
= 0x08,
751 .xtal_freq
= TDA10046_XTAL_16M
,
752 .agc_config
= TDA10046_AGC_TDA827X
,
753 .gpio_config
= TDA10046_GP11_I
,
754 .if_freq
= TDA10046_FREQ_045
,
756 .tuner_address
= 0x61,
758 .request_firmware
= philips_tda1004x_request_firmware
761 static struct tda1004x_config kworld_dvb_t_210_config
= {
762 .demod_address
= 0x08,
765 .xtal_freq
= TDA10046_XTAL_16M
,
766 .agc_config
= TDA10046_AGC_TDA827X
,
767 .gpio_config
= TDA10046_GP11_I
,
768 .if_freq
= TDA10046_FREQ_045
,
770 .tuner_address
= 0x61,
772 .request_firmware
= philips_tda1004x_request_firmware
775 static struct tda1004x_config avermedia_super_007_config
= {
776 .demod_address
= 0x08,
779 .xtal_freq
= TDA10046_XTAL_16M
,
780 .agc_config
= TDA10046_AGC_TDA827X
,
781 .gpio_config
= TDA10046_GP01_I
,
782 .if_freq
= TDA10046_FREQ_045
,
784 .tuner_address
= 0x60,
786 .request_firmware
= philips_tda1004x_request_firmware
789 static struct tda1004x_config twinhan_dtv_dvb_3056_config
= {
790 .demod_address
= 0x08,
793 .xtal_freq
= TDA10046_XTAL_16M
,
794 .agc_config
= TDA10046_AGC_TDA827X
,
795 .gpio_config
= TDA10046_GP01_I
,
796 .if_freq
= TDA10046_FREQ_045
,
798 .tuner_address
= 0x61,
800 .request_firmware
= philips_tda1004x_request_firmware
803 /* ------------------------------------------------------------------
804 * special case: this card uses saa713x GPIO22 for the mode switch
807 static int ads_duo_tuner_init(struct dvb_frontend
*fe
)
809 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
810 philips_tda827x_tuner_init(fe
);
811 /* route TDA8275a AGC input to the channel decoder */
812 saa7134_set_gpio(dev
, 22, 1);
816 static int ads_duo_tuner_sleep(struct dvb_frontend
*fe
)
818 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
819 /* route TDA8275a AGC input to the analog IF chip*/
820 saa7134_set_gpio(dev
, 22, 0);
821 philips_tda827x_tuner_sleep(fe
);
825 static struct tda827x_config ads_duo_cfg
= {
826 .tuner_callback
= saa7134_tuner_callback
,
827 .init
= ads_duo_tuner_init
,
828 .sleep
= ads_duo_tuner_sleep
,
832 static struct tda1004x_config ads_tech_duo_config
= {
833 .demod_address
= 0x08,
836 .xtal_freq
= TDA10046_XTAL_16M
,
837 .agc_config
= TDA10046_AGC_TDA827X
,
838 .gpio_config
= TDA10046_GP00_I
,
839 .if_freq
= TDA10046_FREQ_045
,
840 .tuner_address
= 0x61,
841 .request_firmware
= philips_tda1004x_request_firmware
844 /* ==================================================================
845 * tda10086 based DVB-S cards, helper functions
848 static struct tda10086_config flydvbs
= {
849 .demod_address
= 0x0e,
854 /* ------------------------------------------------------------------
855 * special case: lnb supply is connected to the gated i2c
858 static int md8800_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
861 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
862 if (fe
->ops
.i2c_gate_ctrl
) {
863 fe
->ops
.i2c_gate_ctrl(fe
, 1);
864 if (dev
->original_set_voltage
)
865 res
= dev
->original_set_voltage(fe
, voltage
);
866 fe
->ops
.i2c_gate_ctrl(fe
, 0);
871 static int md8800_set_high_voltage(struct dvb_frontend
*fe
, long arg
)
874 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
875 if (fe
->ops
.i2c_gate_ctrl
) {
876 fe
->ops
.i2c_gate_ctrl(fe
, 1);
877 if (dev
->original_set_high_voltage
)
878 res
= dev
->original_set_high_voltage(fe
, arg
);
879 fe
->ops
.i2c_gate_ctrl(fe
, 0);
884 static int md8800_set_voltage2(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
886 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
887 u8 wbuf
[2] = { 0x1f, 00 };
889 struct i2c_msg msg
[] = { { .addr
= 0x08, .flags
= 0, .buf
= wbuf
, .len
= 1 },
890 { .addr
= 0x08, .flags
= I2C_M_RD
, .buf
= &rbuf
, .len
= 1 } };
892 if (i2c_transfer(&dev
->i2c_adap
, msg
, 2) != 2)
894 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
895 if (voltage
== SEC_VOLTAGE_18
)
896 wbuf
[1] = rbuf
| 0x10;
898 wbuf
[1] = rbuf
& 0xef;
900 i2c_transfer(&dev
->i2c_adap
, msg
, 1);
904 static int md8800_set_high_voltage2(struct dvb_frontend
*fe
, long arg
)
906 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
907 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__
);
911 /* ==================================================================
912 * nxt200x based ATSC cards, helper functions
915 static struct nxt200x_config avertvhda180
= {
916 .demod_address
= 0x0a,
919 static struct nxt200x_config kworldatsc110
= {
920 .demod_address
= 0x0a,
923 /* ==================================================================
927 static int dvb_init(struct saa7134_dev
*dev
)
930 int attach_xc3028
= 0;
932 /* init struct videobuf_dvb */
933 dev
->ts
.nr_bufs
= 32;
934 dev
->ts
.nr_packets
= 32*4;
935 dev
->dvb
.name
= dev
->name
;
936 videobuf_queue_sg_init(&dev
->dvb
.dvbq
, &saa7134_ts_qops
,
937 &dev
->pci
->dev
, &dev
->slock
,
938 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
939 V4L2_FIELD_ALTERNATE
,
940 sizeof(struct saa7134_buf
),
943 switch (dev
->board
) {
944 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
945 dprintk("pinnacle 300i dvb setup\n");
946 dev
->dvb
.frontend
= dvb_attach(mt352_attach
, &pinnacle_300i
,
948 if (dev
->dvb
.frontend
) {
949 dev
->dvb
.frontend
->ops
.tuner_ops
.set_params
= mt352_pinnacle_tuner_set_params
;
952 case SAA7134_BOARD_AVERMEDIA_777
:
953 case SAA7134_BOARD_AVERMEDIA_A16AR
:
954 dprintk("avertv 777 dvb setup\n");
955 dev
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_777
,
957 if (dev
->dvb
.frontend
) {
958 dvb_attach(simple_tuner_attach
, dev
->dvb
.frontend
,
959 &dev
->i2c_adap
, 0x61,
960 TUNER_PHILIPS_TD1316
);
963 case SAA7134_BOARD_AVERMEDIA_A16D
:
964 dprintk("avertv A16D dvb setup\n");
965 dev
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_16d
,
969 case SAA7134_BOARD_MD7134
:
970 dev
->dvb
.frontend
= dvb_attach(tda10046_attach
,
973 if (dev
->dvb
.frontend
) {
974 dvb_attach(simple_tuner_attach
, dev
->dvb
.frontend
,
975 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
976 TUNER_PHILIPS_FMD1216ME_MK3
);
979 case SAA7134_BOARD_PHILIPS_TOUGH
:
980 dev
->dvb
.frontend
= dvb_attach(tda10046_attach
,
981 &philips_tu1216_60_config
,
983 if (dev
->dvb
.frontend
) {
984 dev
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
985 dev
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
988 case SAA7134_BOARD_FLYDVBTDUO
:
989 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS
:
990 configure_tda827x_fe(dev
, &tda827x_lifeview_config
, &tda827x_cfg_0
);
992 case SAA7134_BOARD_PHILIPS_EUROPA
:
993 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
994 dev
->dvb
.frontend
= dvb_attach(tda10046_attach
,
995 &philips_europa_config
,
997 if (dev
->dvb
.frontend
) {
998 dev
->original_demod_sleep
= dev
->dvb
.frontend
->ops
.sleep
;
999 dev
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1000 dev
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1001 dev
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1002 dev
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1005 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
1006 dev
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1007 &philips_tu1216_61_config
,
1009 if (dev
->dvb
.frontend
) {
1010 dev
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1011 dev
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1014 case SAA7134_BOARD_KWORLD_DVBT_210
:
1015 configure_tda827x_fe(dev
, &kworld_dvb_t_210_config
, &tda827x_cfg_2
);
1017 case SAA7134_BOARD_PHILIPS_TIGER
:
1018 configure_tda827x_fe(dev
, &philips_tiger_config
, &tda827x_cfg_0
);
1020 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
1021 configure_tda827x_fe(dev
, &pinnacle_pctv_310i_config
, &tda827x_cfg_1
);
1023 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
1024 configure_tda827x_fe(dev
, &hauppauge_hvr_1110_config
, &tda827x_cfg_1
);
1026 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
1027 configure_tda827x_fe(dev
, &asus_p7131_dual_config
, &tda827x_cfg_0
);
1029 case SAA7134_BOARD_FLYDVBT_LR301
:
1030 configure_tda827x_fe(dev
, &tda827x_lifeview_config
, &tda827x_cfg_0
);
1032 case SAA7134_BOARD_FLYDVB_TRIO
:
1033 if(! use_frontend
) { /* terrestrial */
1034 configure_tda827x_fe(dev
, &lifeview_trio_config
, &tda827x_cfg_0
);
1035 } else { /* satellite */
1036 dev
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
, &dev
->i2c_adap
);
1037 if (dev
->dvb
.frontend
) {
1038 if (dvb_attach(tda826x_attach
, dev
->dvb
.frontend
, 0x63,
1039 &dev
->i2c_adap
, 0) == NULL
) {
1040 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__
);
1042 if (dvb_attach(isl6421_attach
, dev
->dvb
.frontend
, &dev
->i2c_adap
,
1043 0x08, 0, 0) == NULL
) {
1044 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__
);
1049 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331
:
1050 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS
:
1051 dev
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1052 &ads_tech_duo_config
,
1054 if (dev
->dvb
.frontend
) {
1055 if (dvb_attach(tda827x_attach
,dev
->dvb
.frontend
,
1056 ads_tech_duo_config
.tuner_address
, &dev
->i2c_adap
,
1057 &ads_duo_cfg
) == NULL
) {
1058 wprintk("no tda827x tuner found at addr: %02x\n",
1059 ads_tech_duo_config
.tuner_address
);
1063 case SAA7134_BOARD_TEVION_DVBT_220RF
:
1064 configure_tda827x_fe(dev
, &tevion_dvbt220rf_config
, &tda827x_cfg_0
);
1066 case SAA7134_BOARD_MEDION_MD8800_QUADRO
:
1067 if (!use_frontend
) { /* terrestrial */
1068 configure_tda827x_fe(dev
, &md8800_dvbt_config
, &tda827x_cfg_0
);
1069 } else { /* satellite */
1070 dev
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1071 &flydvbs
, &dev
->i2c_adap
);
1072 if (dev
->dvb
.frontend
) {
1073 struct dvb_frontend
*fe
= dev
->dvb
.frontend
;
1074 u8 dev_id
= dev
->eedata
[2];
1076 struct i2c_msg msg
= {.addr
= 0x08, .flags
= 0, .len
= 1};
1078 if (dvb_attach(tda826x_attach
, dev
->dvb
.frontend
,
1079 0x60, &dev
->i2c_adap
, 0) == NULL
)
1080 wprintk("%s: Medion Quadro, no tda826x "
1081 "found !\n", __func__
);
1082 if (dev_id
!= 0x08) {
1083 /* we need to open the i2c gate (we know it exists) */
1084 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1085 if (dvb_attach(isl6405_attach
, fe
,
1086 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
)
1087 wprintk("%s: Medion Quadro, no ISL6405 "
1088 "found !\n", __func__
);
1089 if (dev_id
== 0x07) {
1090 /* fire up the 2nd section of the LNB supply since
1091 we can't do this from the other section */
1093 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1095 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1096 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1097 fe
->ops
.set_voltage
= md8800_set_voltage
;
1098 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1099 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1101 fe
->ops
.set_voltage
= md8800_set_voltage2
;
1102 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage2
;
1107 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
1108 dev
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &avertvhda180
,
1110 if (dev
->dvb
.frontend
) {
1111 dvb_attach(dvb_pll_attach
, dev
->dvb
.frontend
, 0x61,
1112 NULL
, DVB_PLL_TDHU2
);
1115 case SAA7134_BOARD_KWORLD_ATSC110
:
1116 dev
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &kworldatsc110
,
1118 if (dev
->dvb
.frontend
) {
1119 dvb_attach(simple_tuner_attach
, dev
->dvb
.frontend
,
1120 &dev
->i2c_adap
, 0x61,
1121 TUNER_PHILIPS_TUV1236D
);
1124 case SAA7134_BOARD_FLYDVBS_LR300
:
1125 dev
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1127 if (dev
->dvb
.frontend
) {
1128 if (dvb_attach(tda826x_attach
, dev
->dvb
.frontend
, 0x60,
1129 &dev
->i2c_adap
, 0) == NULL
) {
1130 wprintk("%s: No tda826x found!\n", __func__
);
1132 if (dvb_attach(isl6421_attach
, dev
->dvb
.frontend
,
1133 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1134 wprintk("%s: No ISL6421 found!\n", __func__
);
1138 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID
:
1139 dev
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1142 if (dev
->dvb
.frontend
) {
1143 dev
->original_demod_sleep
= dev
->dvb
.frontend
->ops
.sleep
;
1144 dev
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1146 dvb_attach(simple_tuner_attach
, dev
->dvb
.frontend
,
1147 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1148 TUNER_PHILIPS_FMD1216ME_MK3
);
1151 case SAA7134_BOARD_VIDEOMATE_DVBT_200A
:
1152 dev
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1153 &philips_europa_config
,
1155 if (dev
->dvb
.frontend
) {
1156 dev
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_td1316_tuner_init
;
1157 dev
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1160 case SAA7134_BOARD_CINERGY_HT_PCMCIA
:
1161 configure_tda827x_fe(dev
, &cinergy_ht_config
, &tda827x_cfg_0
);
1163 case SAA7134_BOARD_CINERGY_HT_PCI
:
1164 configure_tda827x_fe(dev
, &cinergy_ht_pci_config
, &tda827x_cfg_0
);
1166 case SAA7134_BOARD_PHILIPS_TIGER_S
:
1167 configure_tda827x_fe(dev
, &philips_tiger_s_config
, &tda827x_cfg_2
);
1169 case SAA7134_BOARD_ASUS_P7131_4871
:
1170 configure_tda827x_fe(dev
, &asus_p7131_4871_config
, &tda827x_cfg_2
);
1172 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
1173 configure_tda827x_fe(dev
, &asus_p7131_hybrid_lna_config
, &tda827x_cfg_2
);
1175 case SAA7134_BOARD_AVERMEDIA_SUPER_007
:
1176 configure_tda827x_fe(dev
, &avermedia_super_007_config
, &tda827x_cfg_0
);
1178 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056
:
1179 configure_tda827x_fe(dev
, &twinhan_dtv_dvb_3056_config
, &tda827x_cfg_2_sw42
);
1181 case SAA7134_BOARD_PHILIPS_SNAKE
:
1182 dev
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1184 if (dev
->dvb
.frontend
) {
1185 if (dvb_attach(tda826x_attach
, dev
->dvb
.frontend
, 0x60,
1186 &dev
->i2c_adap
, 0) == NULL
)
1187 wprintk("%s: No tda826x found!\n", __func__
);
1188 if (dvb_attach(lnbp21_attach
, dev
->dvb
.frontend
,
1189 &dev
->i2c_adap
, 0, 0) == NULL
)
1190 wprintk("%s: No lnbp21 found!\n", __func__
);
1193 case SAA7134_BOARD_CREATIX_CTX953
:
1194 configure_tda827x_fe(dev
, &md8800_dvbt_config
, &tda827x_cfg_0
);
1196 case SAA7134_BOARD_MSI_TVANYWHERE_AD11
:
1197 configure_tda827x_fe(dev
, &philips_tiger_s_config
, &tda827x_cfg_2
);
1199 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
1200 dev
->dvb
.frontend
= dvb_attach(mt352_attach
,
1201 &avermedia_e506r_mt352_dev
,
1205 case SAA7134_BOARD_MD7134_BRIDGE_2
:
1206 dev
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1207 &flydvbs
, &dev
->i2c_adap
);
1208 if (dev
->dvb
.frontend
) {
1209 struct dvb_frontend
*fe
;
1210 if (dvb_attach(dvb_pll_attach
, dev
->dvb
.frontend
, 0x60,
1211 &dev
->i2c_adap
, DVB_PLL_PHILIPS_SD1878_TDA8261
) == NULL
)
1212 wprintk("%s: MD7134 DVB-S, no SD1878 "
1213 "found !\n", __func__
);
1214 /* we need to open the i2c gate (we know it exists) */
1215 fe
= dev
->dvb
.frontend
;
1216 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1217 if (dvb_attach(isl6405_attach
, fe
,
1218 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
)
1219 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1220 "found !\n", __func__
);
1221 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1222 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1223 fe
->ops
.set_voltage
= md8800_set_voltage
;
1224 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1225 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1229 wprintk("Huh? unknown DVB card?\n");
1233 if (attach_xc3028
) {
1234 struct dvb_frontend
*fe
;
1235 struct xc2028_config cfg
= {
1236 .i2c_adap
= &dev
->i2c_adap
,
1240 if (!dev
->dvb
.frontend
)
1243 fe
= dvb_attach(xc2028_attach
, dev
->dvb
.frontend
, &cfg
);
1245 printk(KERN_ERR
"%s/2: xc3028 attach failed\n",
1247 dvb_frontend_detach(dev
->dvb
.frontend
);
1248 dvb_unregister_frontend(dev
->dvb
.frontend
);
1249 dev
->dvb
.frontend
= NULL
;
1254 if (NULL
== dev
->dvb
.frontend
) {
1255 printk(KERN_ERR
"%s/dvb: frontend initialization failed\n", dev
->name
);
1259 /* register everything else */
1260 ret
= videobuf_dvb_register(&dev
->dvb
, THIS_MODULE
, dev
, &dev
->pci
->dev
);
1262 /* this sequence is necessary to make the tda1004x load its firmware
1263 * and to enter analog mode of hybrid boards
1266 if (dev
->dvb
.frontend
->ops
.init
)
1267 dev
->dvb
.frontend
->ops
.init(dev
->dvb
.frontend
);
1268 if (dev
->dvb
.frontend
->ops
.sleep
)
1269 dev
->dvb
.frontend
->ops
.sleep(dev
->dvb
.frontend
);
1270 if (dev
->dvb
.frontend
->ops
.tuner_ops
.sleep
)
1271 dev
->dvb
.frontend
->ops
.tuner_ops
.sleep(dev
->dvb
.frontend
);
1276 static int dvb_fini(struct saa7134_dev
*dev
)
1278 /* FIXME: I suspect that this code is bogus, since the entry for
1279 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1280 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1282 if (dev
->board
== SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
) {
1283 struct v4l2_priv_tun_config tda9887_cfg
;
1284 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
1286 tda9887_cfg
.tuner
= TUNER_TDA9887
;
1287 tda9887_cfg
.priv
= &on
;
1289 /* otherwise we don't detect the tuner on next insmod */
1290 saa7134_i2c_call_clients(dev
, TUNER_SET_CONFIG
, &tda9887_cfg
);
1291 } else if (dev
->board
== SAA7134_BOARD_MEDION_MD8800_QUADRO
) {
1292 if ((dev
->eedata
[2] == 0x07) && use_frontend
) {
1293 /* turn off the 2nd lnb supply */
1295 struct i2c_msg msg
= {.addr
= 0x08, .buf
= &data
, .flags
= 0, .len
= 1};
1296 struct dvb_frontend
*fe
;
1297 fe
= dev
->dvb
.frontend
;
1298 if (fe
->ops
.i2c_gate_ctrl
) {
1299 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1300 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1301 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1305 videobuf_dvb_unregister(&dev
->dvb
);
1309 static struct saa7134_mpeg_ops dvb_ops
= {
1310 .type
= SAA7134_MPEG_DVB
,
1315 static int __init
dvb_register(void)
1317 return saa7134_ts_register(&dvb_ops
);
1320 static void __exit
dvb_unregister(void)
1322 saa7134_ts_unregister(&dvb_ops
);
1325 module_init(dvb_register
);
1326 module_exit(dvb_unregister
);
1328 /* ------------------------------------------------------------------ */