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.
24 #include "saa7134-reg.h"
26 #include <linux/init.h>
27 #include <linux/list.h>
28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/delay.h>
31 #include <linux/kthread.h>
32 #include <linux/suspend.h>
34 #include <media/v4l2-common.h>
36 #include <dvb_frontend.h>
39 #include "mt352_priv.h" /* FIXME */
42 #include "tuner-xc2028.h"
51 #include "tuner-simple.h"
67 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
68 MODULE_LICENSE("GPL");
70 static unsigned int antenna_pwr
;
72 module_param(antenna_pwr
, int, 0444);
73 MODULE_PARM_DESC(antenna_pwr
,"enable antenna power (Pinnacle 300i)");
75 static int use_frontend
;
76 module_param(use_frontend
, int, 0644);
77 MODULE_PARM_DESC(use_frontend
,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
79 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
81 /* ------------------------------------------------------------------
82 * mt352 based DVB-T cards
85 static int pinnacle_antenna_pwr(struct saa7134_dev
*dev
, int on
)
90 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
91 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
95 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
96 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
99 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 28));
100 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
102 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
104 ok
= saa_readl(SAA7134_GPIO_GPSTATUS0
) & (1 << 27);
105 pr_debug("%s %s\n", __func__
, ok
? "on" : "off");
108 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
112 static int mt352_pinnacle_init(struct dvb_frontend
* fe
)
114 static u8 clock_config
[] = { CLOCK_CTL
, 0x3d, 0x28 };
115 static u8 reset
[] = { RESET
, 0x80 };
116 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
117 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
118 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x31 };
119 static u8 fsm_ctl_cfg
[] = { 0x7b, 0x04 };
120 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x0f };
121 static u8 scan_ctl_cfg
[] = { SCAN_CTL
, 0x0d };
122 static u8 irq_cfg
[] = { INTERRUPT_EN_0
, 0x00, 0x00, 0x00, 0x00 };
124 pr_debug("%s called\n", __func__
);
126 mt352_write(fe
, clock_config
, sizeof(clock_config
));
128 mt352_write(fe
, reset
, sizeof(reset
));
129 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
130 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
131 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
132 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
134 mt352_write(fe
, fsm_ctl_cfg
, sizeof(fsm_ctl_cfg
));
135 mt352_write(fe
, scan_ctl_cfg
, sizeof(scan_ctl_cfg
));
136 mt352_write(fe
, irq_cfg
, sizeof(irq_cfg
));
141 static int mt352_aver777_init(struct dvb_frontend
* fe
)
143 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
144 static u8 reset
[] = { RESET
, 0x80 };
145 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
146 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
147 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
149 mt352_write(fe
, clock_config
, sizeof(clock_config
));
151 mt352_write(fe
, reset
, sizeof(reset
));
152 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
153 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
154 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
159 static int mt352_avermedia_xc3028_init(struct dvb_frontend
*fe
)
161 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x2d };
162 static u8 reset
[] = { RESET
, 0x80 };
163 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
164 static u8 agc_cfg
[] = { AGC_TARGET
, 0xe };
165 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x33 };
167 mt352_write(fe
, clock_config
, sizeof(clock_config
));
169 mt352_write(fe
, reset
, sizeof(reset
));
170 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
171 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
172 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
176 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend
*fe
)
178 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
179 u8 off
[] = { 0x00, 0xf1};
180 u8 on
[] = { 0x00, 0x71};
181 struct i2c_msg msg
= {.addr
=0x43, .flags
=0, .buf
=off
, .len
= sizeof(off
)};
183 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
184 struct v4l2_frequency f
;
186 /* set frequency (mt2050) */
188 f
.type
= V4L2_TUNER_DIGITAL_TV
;
189 f
.frequency
= c
->frequency
/ 1000 * 16 / 1000;
190 if (fe
->ops
.i2c_gate_ctrl
)
191 fe
->ops
.i2c_gate_ctrl(fe
, 1);
192 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
193 saa_call_all(dev
, tuner
, s_frequency
, &f
);
195 if (fe
->ops
.i2c_gate_ctrl
)
196 fe
->ops
.i2c_gate_ctrl(fe
, 1);
197 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
199 pinnacle_antenna_pwr(dev
, antenna_pwr
);
202 return mt352_pinnacle_init(fe
);
205 static struct mt352_config pinnacle_300i
= {
206 .demod_address
= 0x3c >> 1,
210 .demod_init
= mt352_pinnacle_init
,
213 static struct mt352_config avermedia_777
= {
214 .demod_address
= 0xf,
215 .demod_init
= mt352_aver777_init
,
218 static struct mt352_config avermedia_xc3028_mt352_dev
= {
219 .demod_address
= (0x1e >> 1),
221 .demod_init
= mt352_avermedia_xc3028_init
,
224 static struct tda18271_std_map mb86a20s_tda18271_std_map
= {
225 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
226 .if_lvl
= 7, .rfagc_top
= 0x37, },
229 static struct tda18271_config kworld_tda18271_config
= {
230 .std_map
= &mb86a20s_tda18271_std_map
,
231 .gate
= TDA18271_GATE_DIGITAL
,
232 .config
= 3, /* Use tuner callback for AGC */
236 static const struct mb86a20s_config kworld_mb86a20s_config
= {
237 .demod_address
= 0x10,
240 static int kworld_sbtvd_gate_ctrl(struct dvb_frontend
* fe
, int enable
)
242 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
244 unsigned char initmsg
[] = {0x45, 0x97};
245 unsigned char msg_enable
[] = {0x45, 0xc1};
246 unsigned char msg_disable
[] = {0x45, 0x81};
247 struct i2c_msg msg
= {.addr
= 0x4b, .flags
= 0, .buf
= initmsg
, .len
= 2};
249 if (i2c_transfer(&dev
->i2c_adap
, &msg
, 1) != 1) {
250 pr_warn("could not access the I2C gate\n");
254 msg
.buf
= msg_enable
;
256 msg
.buf
= msg_disable
;
257 if (i2c_transfer(&dev
->i2c_adap
, &msg
, 1) != 1) {
258 pr_warn("could not access the I2C gate\n");
265 /* ==================================================================
266 * tda1004x based DVB-T cards, helper functions
269 static int philips_tda1004x_request_firmware(struct dvb_frontend
*fe
,
270 const struct firmware
**fw
, char *name
)
272 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
273 return request_firmware(fw
, name
, &dev
->pci
->dev
);
276 /* ------------------------------------------------------------------
277 * these tuners are tu1216, td1316(a)
280 static int philips_tda6651_pll_set(struct dvb_frontend
*fe
)
282 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
283 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
284 struct tda1004x_state
*state
= fe
->demodulator_priv
;
285 u8 addr
= state
->config
->tuner_address
;
287 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tuner_buf
,.len
=
289 int tuner_frequency
= 0;
292 /* determine charge pump */
293 tuner_frequency
= c
->frequency
+ 36166000;
294 if (tuner_frequency
< 87000000)
296 else if (tuner_frequency
< 130000000)
298 else if (tuner_frequency
< 160000000)
300 else if (tuner_frequency
< 200000000)
302 else if (tuner_frequency
< 290000000)
304 else if (tuner_frequency
< 420000000)
306 else if (tuner_frequency
< 480000000)
308 else if (tuner_frequency
< 620000000)
310 else if (tuner_frequency
< 830000000)
312 else if (tuner_frequency
< 895000000)
318 if (c
->frequency
< 49000000)
320 else if (c
->frequency
< 161000000)
322 else if (c
->frequency
< 444000000)
324 else if (c
->frequency
< 861000000)
329 /* setup PLL filter */
330 switch (c
->bandwidth_hz
) {
348 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
350 tuner_frequency
= (((c
->frequency
/ 1000) * 6) + 217496) / 1000;
352 /* setup tuner buffer */
353 tuner_buf
[0] = (tuner_frequency
>> 8) & 0x7f;
354 tuner_buf
[1] = tuner_frequency
& 0xff;
356 tuner_buf
[3] = (cp
<< 5) | (filter
<< 3) | band
;
358 if (fe
->ops
.i2c_gate_ctrl
)
359 fe
->ops
.i2c_gate_ctrl(fe
, 1);
360 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1) {
361 pr_warn("could not write to tuner at addr: 0x%02x\n",
369 static int philips_tu1216_init(struct dvb_frontend
*fe
)
371 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
372 struct tda1004x_state
*state
= fe
->demodulator_priv
;
373 u8 addr
= state
->config
->tuner_address
;
374 static u8 tu1216_init
[] = { 0x0b, 0xf5, 0x85, 0xab };
375 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tu1216_init
,.len
= sizeof(tu1216_init
) };
377 /* setup PLL configuration */
378 if (fe
->ops
.i2c_gate_ctrl
)
379 fe
->ops
.i2c_gate_ctrl(fe
, 1);
380 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
387 /* ------------------------------------------------------------------ */
389 static struct tda1004x_config philips_tu1216_60_config
= {
390 .demod_address
= 0x8,
393 .xtal_freq
= TDA10046_XTAL_4M
,
394 .agc_config
= TDA10046_AGC_DEFAULT
,
395 .if_freq
= TDA10046_FREQ_3617
,
396 .tuner_address
= 0x60,
397 .request_firmware
= philips_tda1004x_request_firmware
400 static struct tda1004x_config philips_tu1216_61_config
= {
402 .demod_address
= 0x8,
405 .xtal_freq
= TDA10046_XTAL_4M
,
406 .agc_config
= TDA10046_AGC_DEFAULT
,
407 .if_freq
= TDA10046_FREQ_3617
,
408 .tuner_address
= 0x61,
409 .request_firmware
= philips_tda1004x_request_firmware
412 /* ------------------------------------------------------------------ */
414 static int philips_td1316_tuner_init(struct dvb_frontend
*fe
)
416 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
417 struct tda1004x_state
*state
= fe
->demodulator_priv
;
418 u8 addr
= state
->config
->tuner_address
;
419 static u8 msg
[] = { 0x0b, 0xf5, 0x86, 0xab };
420 struct i2c_msg init_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
422 /* setup PLL configuration */
423 if (fe
->ops
.i2c_gate_ctrl
)
424 fe
->ops
.i2c_gate_ctrl(fe
, 1);
425 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
430 static int philips_td1316_tuner_set_params(struct dvb_frontend
*fe
)
432 return philips_tda6651_pll_set(fe
);
435 static int philips_td1316_tuner_sleep(struct dvb_frontend
*fe
)
437 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
438 struct tda1004x_state
*state
= fe
->demodulator_priv
;
439 u8 addr
= state
->config
->tuner_address
;
440 static u8 msg
[] = { 0x0b, 0xdc, 0x86, 0xa4 };
441 struct i2c_msg analog_msg
= {.addr
= addr
,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
443 /* switch the tuner to analog mode */
444 if (fe
->ops
.i2c_gate_ctrl
)
445 fe
->ops
.i2c_gate_ctrl(fe
, 1);
446 if (i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1) != 1)
451 /* ------------------------------------------------------------------ */
453 static int philips_europa_tuner_init(struct dvb_frontend
*fe
)
455 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
456 static u8 msg
[] = { 0x00, 0x40};
457 struct i2c_msg init_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
460 if (philips_td1316_tuner_init(fe
))
463 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
469 static int philips_europa_tuner_sleep(struct dvb_frontend
*fe
)
471 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
473 static u8 msg
[] = { 0x00, 0x14 };
474 struct i2c_msg analog_msg
= {.addr
= 0x43,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
476 if (philips_td1316_tuner_sleep(fe
))
479 /* switch the board to analog mode */
480 if (fe
->ops
.i2c_gate_ctrl
)
481 fe
->ops
.i2c_gate_ctrl(fe
, 1);
482 i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1);
486 static int philips_europa_demod_sleep(struct dvb_frontend
*fe
)
488 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
490 if (dev
->original_demod_sleep
)
491 dev
->original_demod_sleep(fe
);
492 fe
->ops
.i2c_gate_ctrl(fe
, 1);
496 static struct tda1004x_config philips_europa_config
= {
498 .demod_address
= 0x8,
501 .xtal_freq
= TDA10046_XTAL_4M
,
502 .agc_config
= TDA10046_AGC_IFO_AUTO_POS
,
503 .if_freq
= TDA10046_FREQ_052
,
504 .tuner_address
= 0x61,
505 .request_firmware
= philips_tda1004x_request_firmware
508 static struct tda1004x_config medion_cardbus
= {
509 .demod_address
= 0x08,
512 .xtal_freq
= TDA10046_XTAL_16M
,
513 .agc_config
= TDA10046_AGC_IFO_AUTO_NEG
,
514 .if_freq
= TDA10046_FREQ_3613
,
515 .tuner_address
= 0x61,
516 .request_firmware
= philips_tda1004x_request_firmware
519 static struct tda1004x_config technotrend_budget_t3000_config
= {
520 .demod_address
= 0x8,
523 .xtal_freq
= TDA10046_XTAL_4M
,
524 .agc_config
= TDA10046_AGC_DEFAULT
,
525 .if_freq
= TDA10046_FREQ_3617
,
526 .tuner_address
= 0x63,
527 .request_firmware
= philips_tda1004x_request_firmware
530 /* ------------------------------------------------------------------
531 * tda 1004x based cards with philips silicon tuner
534 static int tda8290_i2c_gate_ctrl( struct dvb_frontend
* fe
, int enable
)
536 struct tda1004x_state
*state
= fe
->demodulator_priv
;
538 u8 addr
= state
->config
->i2c_gate
;
539 static u8 tda8290_close
[] = { 0x21, 0xc0};
540 static u8 tda8290_open
[] = { 0x21, 0x80};
541 struct i2c_msg tda8290_msg
= {.addr
= addr
,.flags
= 0, .len
= 2};
543 tda8290_msg
.buf
= tda8290_close
;
545 tda8290_msg
.buf
= tda8290_open
;
547 if (i2c_transfer(state
->i2c
, &tda8290_msg
, 1) != 1) {
548 pr_warn("could not access tda8290 I2C gate\n");
555 static int philips_tda827x_tuner_init(struct dvb_frontend
*fe
)
557 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
558 struct tda1004x_state
*state
= fe
->demodulator_priv
;
560 switch (state
->config
->antenna_switch
) {
564 pr_debug("setting GPIO21 to 0 (TV antenna?)\n");
565 saa7134_set_gpio(dev
, 21, 0);
568 pr_debug("setting GPIO21 to 1 (Radio antenna?)\n");
569 saa7134_set_gpio(dev
, 21, 1);
575 static int philips_tda827x_tuner_sleep(struct dvb_frontend
*fe
)
577 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
578 struct tda1004x_state
*state
= fe
->demodulator_priv
;
580 switch (state
->config
->antenna_switch
) {
584 pr_debug("setting GPIO21 to 1 (Radio antenna?)\n");
585 saa7134_set_gpio(dev
, 21, 1);
588 pr_debug("setting GPIO21 to 0 (TV antenna?)\n");
589 saa7134_set_gpio(dev
, 21, 0);
595 static int configure_tda827x_fe(struct saa7134_dev
*dev
,
596 struct tda1004x_config
*cdec_conf
,
597 struct tda827x_config
*tuner_conf
)
599 struct vb2_dvb_frontend
*fe0
;
601 /* Get the first frontend */
602 fe0
= vb2_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 pr_warn("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 static struct tda1004x_config asus_ps3_100_config
= {
882 .demod_address
= 0x0b,
885 .xtal_freq
= TDA10046_XTAL_16M
,
886 .agc_config
= TDA10046_AGC_TDA827X
,
887 .gpio_config
= TDA10046_GP11_I
,
888 .if_freq
= TDA10046_FREQ_045
,
890 .tuner_address
= 0x61,
892 .request_firmware
= philips_tda1004x_request_firmware
895 /* ------------------------------------------------------------------
896 * special case: this card uses saa713x GPIO22 for the mode switch
899 static int ads_duo_tuner_init(struct dvb_frontend
*fe
)
901 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
902 philips_tda827x_tuner_init(fe
);
903 /* route TDA8275a AGC input to the channel decoder */
904 saa7134_set_gpio(dev
, 22, 1);
908 static int ads_duo_tuner_sleep(struct dvb_frontend
*fe
)
910 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
911 /* route TDA8275a AGC input to the analog IF chip*/
912 saa7134_set_gpio(dev
, 22, 0);
913 philips_tda827x_tuner_sleep(fe
);
917 static struct tda827x_config ads_duo_cfg
= {
918 .init
= ads_duo_tuner_init
,
919 .sleep
= ads_duo_tuner_sleep
,
923 static struct tda1004x_config ads_tech_duo_config
= {
924 .demod_address
= 0x08,
927 .xtal_freq
= TDA10046_XTAL_16M
,
928 .agc_config
= TDA10046_AGC_TDA827X
,
929 .gpio_config
= TDA10046_GP00_I
,
930 .if_freq
= TDA10046_FREQ_045
,
931 .tuner_address
= 0x61,
932 .request_firmware
= philips_tda1004x_request_firmware
935 static struct zl10353_config behold_h6_config
= {
936 .demod_address
= 0x1e>>1,
939 .disable_i2c_gate_ctrl
= 1,
942 static struct xc5000_config behold_x7_tunerconfig
= {
943 .i2c_address
= 0xc2>>1,
945 .radio_input
= XC5000_RADIO_FM1
,
948 static struct zl10353_config behold_x7_config
= {
949 .demod_address
= 0x1e>>1,
953 .disable_i2c_gate_ctrl
= 1,
956 static struct zl10353_config videomate_t750_zl10353_config
= {
957 .demod_address
= 0x0f,
960 .disable_i2c_gate_ctrl
= 1,
963 static struct qt1010_config videomate_t750_qt1010_config
= {
968 /* ==================================================================
969 * tda10086 based DVB-S cards, helper functions
972 static struct tda10086_config flydvbs
= {
973 .demod_address
= 0x0e,
976 .xtal_freq
= TDA10086_XTAL_16M
,
979 static struct tda10086_config sd1878_4m
= {
980 .demod_address
= 0x0e,
983 .xtal_freq
= TDA10086_XTAL_4M
,
986 /* ------------------------------------------------------------------
987 * special case: lnb supply is connected to the gated i2c
990 static int md8800_set_voltage(struct dvb_frontend
*fe
,
991 enum fe_sec_voltage voltage
)
994 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
995 if (fe
->ops
.i2c_gate_ctrl
) {
996 fe
->ops
.i2c_gate_ctrl(fe
, 1);
997 if (dev
->original_set_voltage
)
998 res
= dev
->original_set_voltage(fe
, voltage
);
999 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1004 static int md8800_set_high_voltage(struct dvb_frontend
*fe
, long arg
)
1007 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
1008 if (fe
->ops
.i2c_gate_ctrl
) {
1009 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1010 if (dev
->original_set_high_voltage
)
1011 res
= dev
->original_set_high_voltage(fe
, arg
);
1012 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1017 static int md8800_set_voltage2(struct dvb_frontend
*fe
,
1018 enum fe_sec_voltage voltage
)
1020 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
1021 u8 wbuf
[2] = { 0x1f, 00 };
1023 struct i2c_msg msg
[] = { { .addr
= 0x08, .flags
= 0, .buf
= wbuf
, .len
= 1 },
1024 { .addr
= 0x08, .flags
= I2C_M_RD
, .buf
= &rbuf
, .len
= 1 } };
1026 if (i2c_transfer(&dev
->i2c_adap
, msg
, 2) != 2)
1028 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1029 if (voltage
== SEC_VOLTAGE_18
)
1030 wbuf
[1] = rbuf
| 0x10;
1032 wbuf
[1] = rbuf
& 0xef;
1034 i2c_transfer(&dev
->i2c_adap
, msg
, 1);
1038 static int md8800_set_high_voltage2(struct dvb_frontend
*fe
, long arg
)
1040 pr_warn("%s: sorry can't set high LNB supply voltage from here\n",
1045 /* ==================================================================
1046 * nxt200x based ATSC cards, helper functions
1049 static struct nxt200x_config avertvhda180
= {
1050 .demod_address
= 0x0a,
1053 static struct nxt200x_config kworldatsc110
= {
1054 .demod_address
= 0x0a,
1057 /* ------------------------------------------------------------------ */
1059 static struct mt312_config avertv_a700_mt312
= {
1060 .demod_address
= 0x0e,
1061 .voltage_inverted
= 1,
1064 static struct zl10036_config avertv_a700_tuner
= {
1065 .tuner_address
= 0x60,
1068 static struct mt312_config zl10313_compro_s350_config
= {
1069 .demod_address
= 0x0e,
1072 static struct mt312_config zl10313_avermedia_a706_config
= {
1073 .demod_address
= 0x0e,
1076 static struct lgdt3305_config hcw_lgdt3305_config
= {
1078 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
1079 .tpclk_edge
= LGDT3305_TPCLK_RISING_EDGE
,
1080 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
1082 .spectral_inversion
= 1,
1087 static struct tda10048_config hcw_tda10048_config
= {
1088 .demod_address
= 0x10 >> 1,
1089 .output_mode
= TDA10048_SERIAL_OUTPUT
,
1090 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1091 .inversion
= TDA10048_INVERSION_ON
,
1092 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1093 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1094 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1095 .clk_freq_khz
= TDA10048_CLK_16000
,
1096 .disable_gate_access
= 1,
1099 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
1100 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
1101 .if_lvl
= 1, .rfagc_top
= 0x58, },
1102 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
1103 .if_lvl
= 1, .rfagc_top
= 0x58, },
1106 static struct tda18271_config hcw_tda18271_config
= {
1107 .std_map
= &hauppauge_tda18271_std_map
,
1108 .gate
= TDA18271_GATE_ANALOG
,
1110 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1113 static struct tda829x_config tda829x_no_probe
= {
1114 .probe_tuner
= TDA829X_DONT_PROBE
,
1117 static struct tda10048_config zolid_tda10048_config
= {
1118 .demod_address
= 0x10 >> 1,
1119 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1120 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1121 .inversion
= TDA10048_INVERSION_ON
,
1122 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1123 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1124 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1125 .clk_freq_khz
= TDA10048_CLK_16000
,
1126 .disable_gate_access
= 1,
1129 static struct tda18271_config zolid_tda18271_config
= {
1130 .gate
= TDA18271_GATE_ANALOG
,
1133 static struct tda10048_config dtv1000s_tda10048_config
= {
1134 .demod_address
= 0x10 >> 1,
1135 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1136 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1137 .inversion
= TDA10048_INVERSION_ON
,
1138 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1139 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
1140 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
1141 .clk_freq_khz
= TDA10048_CLK_16000
,
1142 .disable_gate_access
= 1,
1145 static struct tda18271_std_map dtv1000s_tda18271_std_map
= {
1146 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
1147 .if_lvl
= 1, .rfagc_top
= 0x37, },
1148 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
1149 .if_lvl
= 1, .rfagc_top
= 0x37, },
1150 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
1151 .if_lvl
= 1, .rfagc_top
= 0x37, },
1154 static struct tda18271_config dtv1000s_tda18271_config
= {
1155 .std_map
= &dtv1000s_tda18271_std_map
,
1156 .gate
= TDA18271_GATE_ANALOG
,
1159 static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config
= {
1160 .prod
= LGS8GXX_PROD_LGS8G75
,
1161 .demod_address
= 0x1d,
1165 .if_clk_freq
= 30400, /* 30.4 MHz */
1166 .if_freq
= 4000, /* 4.00 MHz */
1170 .adc_vpp
= 3, /* 2.0 Vpp */
1174 static struct tda18271_config prohdtv_pro2_tda18271_config
= {
1175 .gate
= TDA18271_GATE_ANALOG
,
1176 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1179 static struct tda18271_std_map kworld_tda18271_std_map
= {
1180 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 3,
1181 .if_lvl
= 6, .rfagc_top
= 0x37 },
1182 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
1183 .if_lvl
= 6, .rfagc_top
= 0x37 },
1186 static struct tda18271_config kworld_pc150u_tda18271_config
= {
1187 .std_map
= &kworld_tda18271_std_map
,
1188 .gate
= TDA18271_GATE_ANALOG
,
1189 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1190 .config
= 3, /* Use tuner callback for AGC */
1191 .rf_cal_on_startup
= 1
1194 static struct s5h1411_config kworld_s5h1411_config
= {
1195 .output_mode
= S5H1411_PARALLEL_OUTPUT
,
1196 .gpio
= S5H1411_GPIO_OFF
,
1197 .qam_if
= S5H1411_IF_4000
,
1198 .vsb_if
= S5H1411_IF_3250
,
1199 .inversion
= S5H1411_INVERSION_ON
,
1200 .status_mode
= S5H1411_DEMODLOCKING
,
1202 S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
1206 /* ==================================================================
1210 static int dvb_init(struct saa7134_dev
*dev
)
1213 int attach_xc3028
= 0;
1214 struct vb2_dvb_frontend
*fe0
;
1215 struct vb2_queue
*q
;
1217 /* FIXME: add support for multi-frontend */
1218 mutex_init(&dev
->frontends
.lock
);
1219 INIT_LIST_HEAD(&dev
->frontends
.felist
);
1221 pr_info("%s() allocating 1 frontend\n", __func__
);
1222 fe0
= vb2_dvb_alloc_frontend(&dev
->frontends
, 1);
1224 pr_err("%s() failed to alloc\n", __func__
);
1228 /* init struct vb2_dvb */
1229 dev
->ts
.nr_bufs
= 32;
1230 dev
->ts
.nr_packets
= 32*4;
1231 fe0
->dvb
.name
= dev
->name
;
1233 q
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
1234 q
->io_modes
= VB2_MMAP
| VB2_READ
;
1235 q
->drv_priv
= &dev
->ts_q
;
1236 q
->ops
= &saa7134_ts_qops
;
1237 q
->mem_ops
= &vb2_dma_sg_memops
;
1238 q
->buf_struct_size
= sizeof(struct saa7134_buf
);
1239 q
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
;
1240 q
->lock
= &dev
->lock
;
1241 q
->dev
= &dev
->pci
->dev
;
1242 ret
= vb2_queue_init(q
);
1244 vb2_dvb_dealloc_frontends(&dev
->frontends
);
1248 switch (dev
->board
) {
1249 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
1250 pr_debug("pinnacle 300i dvb setup\n");
1251 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &pinnacle_300i
,
1253 if (fe0
->dvb
.frontend
) {
1254 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= mt352_pinnacle_tuner_set_params
;
1257 case SAA7134_BOARD_AVERMEDIA_777
:
1258 case SAA7134_BOARD_AVERMEDIA_A16AR
:
1259 pr_debug("avertv 777 dvb setup\n");
1260 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_777
,
1262 if (fe0
->dvb
.frontend
) {
1263 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1264 &dev
->i2c_adap
, 0x61,
1265 TUNER_PHILIPS_TD1316
);
1268 case SAA7134_BOARD_AVERMEDIA_A16D
:
1269 pr_debug("AverMedia A16D dvb setup\n");
1270 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1271 &avermedia_xc3028_mt352_dev
,
1275 case SAA7134_BOARD_MD7134
:
1276 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1279 if (fe0
->dvb
.frontend
) {
1280 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1281 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1282 TUNER_PHILIPS_FMD1216ME_MK3
);
1285 case SAA7134_BOARD_PHILIPS_TOUGH
:
1286 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1287 &philips_tu1216_60_config
,
1289 if (fe0
->dvb
.frontend
) {
1290 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1291 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1294 case SAA7134_BOARD_FLYDVBTDUO
:
1295 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS
:
1296 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1297 &tda827x_cfg_0
) < 0)
1298 goto detach_frontend
;
1300 case SAA7134_BOARD_PHILIPS_EUROPA
:
1301 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
1302 case SAA7134_BOARD_ASUS_EUROPA_HYBRID
:
1303 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1304 &philips_europa_config
,
1306 if (fe0
->dvb
.frontend
) {
1307 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1308 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1309 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1310 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1311 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1314 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000
:
1315 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1316 &technotrend_budget_t3000_config
,
1318 if (fe0
->dvb
.frontend
) {
1319 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1320 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1321 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1322 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1323 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1326 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
1327 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1328 &philips_tu1216_61_config
,
1330 if (fe0
->dvb
.frontend
) {
1331 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1332 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1335 case SAA7134_BOARD_KWORLD_DVBT_210
:
1336 if (configure_tda827x_fe(dev
, &kworld_dvb_t_210_config
,
1337 &tda827x_cfg_2
) < 0)
1338 goto detach_frontend
;
1340 case SAA7134_BOARD_HAUPPAUGE_HVR1120
:
1341 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1342 &hcw_tda10048_config
,
1344 if (fe0
->dvb
.frontend
!= NULL
) {
1345 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1346 &dev
->i2c_adap
, 0x4b,
1348 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1349 0x60, &dev
->i2c_adap
,
1350 &hcw_tda18271_config
);
1353 case SAA7134_BOARD_PHILIPS_TIGER
:
1354 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1355 &tda827x_cfg_0
) < 0)
1356 goto detach_frontend
;
1358 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
1359 if (configure_tda827x_fe(dev
, &pinnacle_pctv_310i_config
,
1360 &tda827x_cfg_1
) < 0)
1361 goto detach_frontend
;
1363 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
1364 if (configure_tda827x_fe(dev
, &hauppauge_hvr_1110_config
,
1365 &tda827x_cfg_1
) < 0)
1366 goto detach_frontend
;
1368 case SAA7134_BOARD_HAUPPAUGE_HVR1150
:
1369 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1370 &hcw_lgdt3305_config
,
1372 if (fe0
->dvb
.frontend
) {
1373 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1374 &dev
->i2c_adap
, 0x4b,
1376 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1377 0x60, &dev
->i2c_adap
,
1378 &hcw_tda18271_config
);
1381 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
1382 if (configure_tda827x_fe(dev
, &asus_p7131_dual_config
,
1383 &tda827x_cfg_0
) < 0)
1384 goto detach_frontend
;
1386 case SAA7134_BOARD_FLYDVBT_LR301
:
1387 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1388 &tda827x_cfg_0
) < 0)
1389 goto detach_frontend
;
1391 case SAA7134_BOARD_FLYDVB_TRIO
:
1392 if (!use_frontend
) { /* terrestrial */
1393 if (configure_tda827x_fe(dev
, &lifeview_trio_config
,
1394 &tda827x_cfg_0
) < 0)
1395 goto detach_frontend
;
1396 } else { /* satellite */
1397 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
, &dev
->i2c_adap
);
1398 if (fe0
->dvb
.frontend
) {
1399 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x63,
1400 &dev
->i2c_adap
, 0) == NULL
) {
1401 pr_warn("%s: Lifeview Trio, No tda826x found!\n",
1403 goto detach_frontend
;
1405 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1407 0x08, 0, 0, false) == NULL
) {
1408 pr_warn("%s: Lifeview Trio, No ISL6421 found!\n",
1410 goto detach_frontend
;
1415 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331
:
1416 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS
:
1417 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1418 &ads_tech_duo_config
,
1420 if (fe0
->dvb
.frontend
) {
1421 if (dvb_attach(tda827x_attach
,fe0
->dvb
.frontend
,
1422 ads_tech_duo_config
.tuner_address
, &dev
->i2c_adap
,
1423 &ads_duo_cfg
) == NULL
) {
1424 pr_warn("no tda827x tuner found at addr: %02x\n",
1425 ads_tech_duo_config
.tuner_address
);
1426 goto detach_frontend
;
1429 pr_warn("failed to attach tda10046\n");
1431 case SAA7134_BOARD_TEVION_DVBT_220RF
:
1432 if (configure_tda827x_fe(dev
, &tevion_dvbt220rf_config
,
1433 &tda827x_cfg_0
) < 0)
1434 goto detach_frontend
;
1436 case SAA7134_BOARD_MEDION_MD8800_QUADRO
:
1437 if (!use_frontend
) { /* terrestrial */
1438 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1439 &tda827x_cfg_0
) < 0)
1440 goto detach_frontend
;
1441 } else { /* satellite */
1442 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1443 &flydvbs
, &dev
->i2c_adap
);
1444 if (fe0
->dvb
.frontend
) {
1445 struct dvb_frontend
*fe
= fe0
->dvb
.frontend
;
1446 u8 dev_id
= dev
->eedata
[2];
1448 struct i2c_msg msg
= {.addr
= 0x08, .flags
= 0, .len
= 1};
1450 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
,
1451 0x60, &dev
->i2c_adap
, 0) == NULL
) {
1452 pr_warn("%s: Medion Quadro, no tda826x found !\n",
1454 goto detach_frontend
;
1456 if (dev_id
!= 0x08) {
1457 /* we need to open the i2c gate (we know it exists) */
1458 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1459 if (dvb_attach(isl6405_attach
, fe
,
1460 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1461 pr_warn("%s: Medion Quadro, no ISL6405 found !\n",
1463 goto detach_frontend
;
1465 if (dev_id
== 0x07) {
1466 /* fire up the 2nd section of the LNB supply since
1467 we can't do this from the other section */
1469 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1471 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1472 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1473 fe
->ops
.set_voltage
= md8800_set_voltage
;
1474 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1475 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1477 fe
->ops
.set_voltage
= md8800_set_voltage2
;
1478 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage2
;
1483 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
1484 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &avertvhda180
,
1486 if (fe0
->dvb
.frontend
)
1487 dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x61,
1488 NULL
, DVB_PLL_TDHU2
);
1490 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI
:
1491 case SAA7134_BOARD_KWORLD_ATSC110
:
1492 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &kworldatsc110
,
1494 if (fe0
->dvb
.frontend
)
1495 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1496 &dev
->i2c_adap
, 0x61,
1497 TUNER_PHILIPS_TUV1236D
);
1499 case SAA7134_BOARD_KWORLD_PC150U
:
1500 saa7134_set_gpio(dev
, 18, 1); /* Switch to digital mode */
1501 saa7134_tuner_callback(dev
, 0,
1502 TDA18271_CALLBACK_CMD_AGC_ENABLE
, 1);
1503 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1504 &kworld_s5h1411_config
,
1506 if (fe0
->dvb
.frontend
!= NULL
) {
1507 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1508 &dev
->i2c_adap
, 0x4b,
1510 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1511 0x60, &dev
->i2c_adap
,
1512 &kworld_pc150u_tda18271_config
);
1515 case SAA7134_BOARD_FLYDVBS_LR300
:
1516 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1518 if (fe0
->dvb
.frontend
) {
1519 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1520 &dev
->i2c_adap
, 0) == NULL
) {
1521 pr_warn("%s: No tda826x found!\n", __func__
);
1522 goto detach_frontend
;
1524 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1526 0x08, 0, 0, false) == NULL
) {
1527 pr_warn("%s: No ISL6421 found!\n", __func__
);
1528 goto detach_frontend
;
1532 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID
:
1533 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1536 if (fe0
->dvb
.frontend
) {
1537 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1538 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1540 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1541 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1542 TUNER_PHILIPS_FMD1216ME_MK3
);
1545 case SAA7134_BOARD_VIDEOMATE_DVBT_200A
:
1546 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1547 &philips_europa_config
,
1549 if (fe0
->dvb
.frontend
) {
1550 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_td1316_tuner_init
;
1551 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1554 case SAA7134_BOARD_CINERGY_HT_PCMCIA
:
1555 if (configure_tda827x_fe(dev
, &cinergy_ht_config
,
1556 &tda827x_cfg_0
) < 0)
1557 goto detach_frontend
;
1559 case SAA7134_BOARD_CINERGY_HT_PCI
:
1560 if (configure_tda827x_fe(dev
, &cinergy_ht_pci_config
,
1561 &tda827x_cfg_0
) < 0)
1562 goto detach_frontend
;
1564 case SAA7134_BOARD_PHILIPS_TIGER_S
:
1565 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1566 &tda827x_cfg_2
) < 0)
1567 goto detach_frontend
;
1569 case SAA7134_BOARD_ASUS_P7131_4871
:
1570 if (configure_tda827x_fe(dev
, &asus_p7131_4871_config
,
1571 &tda827x_cfg_2
) < 0)
1572 goto detach_frontend
;
1574 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
1575 if (configure_tda827x_fe(dev
, &asus_p7131_hybrid_lna_config
,
1576 &tda827x_cfg_2
) < 0)
1577 goto detach_frontend
;
1579 case SAA7134_BOARD_AVERMEDIA_SUPER_007
:
1580 if (configure_tda827x_fe(dev
, &avermedia_super_007_config
,
1581 &tda827x_cfg_0
) < 0)
1582 goto detach_frontend
;
1584 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056
:
1585 if (configure_tda827x_fe(dev
, &twinhan_dtv_dvb_3056_config
,
1586 &tda827x_cfg_2_sw42
) < 0)
1587 goto detach_frontend
;
1589 case SAA7134_BOARD_PHILIPS_SNAKE
:
1590 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1592 if (fe0
->dvb
.frontend
) {
1593 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1594 &dev
->i2c_adap
, 0) == NULL
) {
1595 pr_warn("%s: No tda826x found!\n", __func__
);
1596 goto detach_frontend
;
1598 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1599 &dev
->i2c_adap
, 0, 0) == NULL
) {
1600 pr_warn("%s: No lnbp21 found!\n", __func__
);
1601 goto detach_frontend
;
1605 case SAA7134_BOARD_CREATIX_CTX953
:
1606 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1607 &tda827x_cfg_0
) < 0)
1608 goto detach_frontend
;
1610 case SAA7134_BOARD_MSI_TVANYWHERE_AD11
:
1611 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1612 &tda827x_cfg_2
) < 0)
1613 goto detach_frontend
;
1615 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
1616 pr_debug("AverMedia E506R dvb setup\n");
1617 saa7134_set_gpio(dev
, 25, 0);
1619 saa7134_set_gpio(dev
, 25, 1);
1620 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1621 &avermedia_xc3028_mt352_dev
,
1625 case SAA7134_BOARD_MD7134_BRIDGE_2
:
1626 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1627 &sd1878_4m
, &dev
->i2c_adap
);
1628 if (fe0
->dvb
.frontend
) {
1629 struct dvb_frontend
*fe
;
1630 if (dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1631 &dev
->i2c_adap
, DVB_PLL_PHILIPS_SD1878_TDA8261
) == NULL
) {
1632 pr_warn("%s: MD7134 DVB-S, no SD1878 found !\n",
1634 goto detach_frontend
;
1636 /* we need to open the i2c gate (we know it exists) */
1637 fe
= fe0
->dvb
.frontend
;
1638 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1639 if (dvb_attach(isl6405_attach
, fe
,
1640 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1641 pr_warn("%s: MD7134 DVB-S, no ISL6405 found !\n",
1643 goto detach_frontend
;
1645 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1646 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1647 fe
->ops
.set_voltage
= md8800_set_voltage
;
1648 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1649 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1652 case SAA7134_BOARD_AVERMEDIA_M103
:
1653 saa7134_set_gpio(dev
, 25, 0);
1655 saa7134_set_gpio(dev
, 25, 1);
1656 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1657 &avermedia_xc3028_mt352_dev
,
1661 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1
:
1662 if (!use_frontend
) { /* terrestrial */
1663 if (configure_tda827x_fe(dev
, &asus_tiger_3in1_config
,
1664 &tda827x_cfg_2
) < 0)
1665 goto detach_frontend
;
1666 } else { /* satellite */
1667 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1668 &flydvbs
, &dev
->i2c_adap
);
1669 if (fe0
->dvb
.frontend
) {
1670 if (dvb_attach(tda826x_attach
,
1671 fe0
->dvb
.frontend
, 0x60,
1672 &dev
->i2c_adap
, 0) == NULL
) {
1673 pr_warn("%s: Asus Tiger 3in1, no tda826x found!\n",
1675 goto detach_frontend
;
1677 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1678 &dev
->i2c_adap
, 0, 0) == NULL
) {
1679 pr_warn("%s: Asus Tiger 3in1, no lnbp21 found!\n",
1681 goto detach_frontend
;
1686 case SAA7134_BOARD_ASUSTeK_PS3_100
:
1687 if (!use_frontend
) { /* terrestrial */
1688 if (configure_tda827x_fe(dev
, &asus_ps3_100_config
,
1689 &tda827x_cfg_2
) < 0)
1690 goto detach_frontend
;
1691 } else { /* satellite */
1692 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1693 &flydvbs
, &dev
->i2c_adap
);
1694 if (fe0
->dvb
.frontend
) {
1695 if (dvb_attach(tda826x_attach
,
1696 fe0
->dvb
.frontend
, 0x60,
1697 &dev
->i2c_adap
, 0) == NULL
) {
1698 pr_warn("%s: Asus My Cinema PS3-100, no tda826x found!\n",
1700 goto detach_frontend
;
1702 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1703 &dev
->i2c_adap
, 0, 0) == NULL
) {
1704 pr_warn("%s: Asus My Cinema PS3-100, no lnbp21 found!\n",
1706 goto detach_frontend
;
1711 case SAA7134_BOARD_ASUSTeK_TIGER
:
1712 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1713 &tda827x_cfg_0
) < 0)
1714 goto detach_frontend
;
1716 case SAA7134_BOARD_BEHOLD_H6
:
1717 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1720 if (fe0
->dvb
.frontend
) {
1721 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1722 &dev
->i2c_adap
, 0x61,
1723 TUNER_PHILIPS_FMD1216MEX_MK3
);
1726 case SAA7134_BOARD_BEHOLD_X7
:
1727 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1730 if (fe0
->dvb
.frontend
) {
1731 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1732 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1735 case SAA7134_BOARD_BEHOLD_H7
:
1736 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1739 if (fe0
->dvb
.frontend
) {
1740 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1741 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1744 case SAA7134_BOARD_AVERMEDIA_A700_PRO
:
1745 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID
:
1746 /* Zarlink ZL10313 */
1747 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1748 &avertv_a700_mt312
, &dev
->i2c_adap
);
1749 if (fe0
->dvb
.frontend
) {
1750 if (dvb_attach(zl10036_attach
, fe0
->dvb
.frontend
,
1751 &avertv_a700_tuner
, &dev
->i2c_adap
) == NULL
) {
1752 pr_warn("%s: No zl10036 found!\n",
1757 case SAA7134_BOARD_VIDEOMATE_S350
:
1758 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1759 &zl10313_compro_s350_config
, &dev
->i2c_adap
);
1760 if (fe0
->dvb
.frontend
)
1761 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1762 0x60, &dev
->i2c_adap
) == NULL
)
1763 pr_warn("%s: No zl10039 found!\n",
1767 case SAA7134_BOARD_VIDEOMATE_T750
:
1768 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1769 &videomate_t750_zl10353_config
,
1771 if (fe0
->dvb
.frontend
!= NULL
) {
1772 if (dvb_attach(qt1010_attach
,
1775 &videomate_t750_qt1010_config
) == NULL
)
1776 pr_warn("error attaching QT1010\n");
1779 case SAA7134_BOARD_ZOLID_HYBRID_PCI
:
1780 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1781 &zolid_tda10048_config
,
1783 if (fe0
->dvb
.frontend
!= NULL
) {
1784 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1785 &dev
->i2c_adap
, 0x4b,
1787 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1788 0x60, &dev
->i2c_adap
,
1789 &zolid_tda18271_config
);
1792 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S
:
1793 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1794 &dtv1000s_tda10048_config
,
1796 if (fe0
->dvb
.frontend
!= NULL
) {
1797 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1798 &dev
->i2c_adap
, 0x4b,
1800 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1801 0x60, &dev
->i2c_adap
,
1802 &dtv1000s_tda18271_config
);
1805 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG
:
1806 /* Switch to digital mode */
1807 saa7134_tuner_callback(dev
, 0,
1808 TDA18271_CALLBACK_CMD_AGC_ENABLE
, 1);
1809 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1810 &kworld_mb86a20s_config
,
1812 if (fe0
->dvb
.frontend
!= NULL
) {
1813 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1814 &dev
->i2c_adap
, 0x4b,
1816 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= kworld_sbtvd_gate_ctrl
;
1817 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1818 0x60, &dev
->i2c_adap
,
1819 &kworld_tda18271_config
);
1822 /* mb86a20s need to use the I2C gateway */
1824 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2
:
1825 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1826 &prohdtv_pro2_lgs8g75_config
,
1828 if (fe0
->dvb
.frontend
!= NULL
) {
1829 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1830 &dev
->i2c_adap
, 0x4b,
1832 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1833 0x60, &dev
->i2c_adap
,
1834 &prohdtv_pro2_tda18271_config
);
1837 case SAA7134_BOARD_AVERMEDIA_A706
:
1838 /* Enable all DVB-S devices now */
1839 /* CE5039 DVB-S tuner SLEEP pin low */
1840 saa7134_set_gpio(dev
, 23, 0);
1841 /* CE6313 DVB-S demod SLEEP pin low */
1842 saa7134_set_gpio(dev
, 9, 0);
1843 /* CE6313 DVB-S demod RESET# pin high */
1844 saa7134_set_gpio(dev
, 25, 1);
1846 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1847 &zl10313_avermedia_a706_config
, &dev
->i2c_adap
);
1848 if (fe0
->dvb
.frontend
) {
1849 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1850 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1851 0x60, &dev
->i2c_adap
) == NULL
)
1852 pr_warn("%s: No zl10039 found!\n",
1857 pr_warn("Huh? unknown DVB card?\n");
1861 if (attach_xc3028
) {
1862 struct dvb_frontend
*fe
;
1863 struct xc2028_config cfg
= {
1864 .i2c_adap
= &dev
->i2c_adap
,
1868 if (!fe0
->dvb
.frontend
)
1869 goto detach_frontend
;
1871 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
1873 pr_err("%s/2: xc3028 attach failed\n",
1875 goto detach_frontend
;
1879 if (NULL
== fe0
->dvb
.frontend
) {
1880 pr_err("%s/dvb: frontend initialization failed\n", dev
->name
);
1881 goto detach_frontend
;
1883 /* define general-purpose callback pointer */
1884 fe0
->dvb
.frontend
->callback
= saa7134_tuner_callback
;
1886 /* register everything else */
1887 #ifndef CONFIG_MEDIA_CONTROLLER_DVB
1888 ret
= vb2_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1889 &dev
->pci
->dev
, NULL
,
1892 ret
= vb2_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1893 &dev
->pci
->dev
, dev
->media_dev
,
1897 /* this sequence is necessary to make the tda1004x load its firmware
1898 * and to enter analog mode of hybrid boards
1901 if (fe0
->dvb
.frontend
->ops
.init
)
1902 fe0
->dvb
.frontend
->ops
.init(fe0
->dvb
.frontend
);
1903 if (fe0
->dvb
.frontend
->ops
.sleep
)
1904 fe0
->dvb
.frontend
->ops
.sleep(fe0
->dvb
.frontend
);
1905 if (fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
)
1906 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep(fe0
->dvb
.frontend
);
1911 vb2_dvb_dealloc_frontends(&dev
->frontends
);
1912 vb2_queue_release(&fe0
->dvb
.dvbq
);
1916 static int dvb_fini(struct saa7134_dev
*dev
)
1918 struct vb2_dvb_frontend
*fe0
;
1920 /* Get the first frontend */
1921 fe0
= vb2_dvb_get_frontend(&dev
->frontends
, 1);
1925 /* FIXME: I suspect that this code is bogus, since the entry for
1926 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1927 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1929 if (dev
->board
== SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
) {
1930 struct v4l2_priv_tun_config tda9887_cfg
;
1931 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
1933 tda9887_cfg
.tuner
= TUNER_TDA9887
;
1934 tda9887_cfg
.priv
= &on
;
1936 /* otherwise we don't detect the tuner on next insmod */
1937 saa_call_all(dev
, tuner
, s_config
, &tda9887_cfg
);
1938 } else if (dev
->board
== SAA7134_BOARD_MEDION_MD8800_QUADRO
) {
1939 if ((dev
->eedata
[2] == 0x07) && use_frontend
) {
1940 /* turn off the 2nd lnb supply */
1942 struct i2c_msg msg
= {.addr
= 0x08, .buf
= &data
, .flags
= 0, .len
= 1};
1943 struct dvb_frontend
*fe
;
1944 fe
= fe0
->dvb
.frontend
;
1945 if (fe
->ops
.i2c_gate_ctrl
) {
1946 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1947 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1948 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1952 vb2_dvb_unregister_bus(&dev
->frontends
);
1953 vb2_queue_release(&fe0
->dvb
.dvbq
);
1957 static struct saa7134_mpeg_ops dvb_ops
= {
1958 .type
= SAA7134_MPEG_DVB
,
1963 static int __init
dvb_register(void)
1965 return saa7134_ts_register(&dvb_ops
);
1968 static void __exit
dvb_unregister(void)
1970 saa7134_ts_unregister(&dvb_ops
);
1973 module_init(dvb_register
);
1974 module_exit(dvb_unregister
);