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
, fe_sec_voltage_t voltage
)
993 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
994 if (fe
->ops
.i2c_gate_ctrl
) {
995 fe
->ops
.i2c_gate_ctrl(fe
, 1);
996 if (dev
->original_set_voltage
)
997 res
= dev
->original_set_voltage(fe
, voltage
);
998 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1003 static int md8800_set_high_voltage(struct dvb_frontend
*fe
, long arg
)
1006 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
1007 if (fe
->ops
.i2c_gate_ctrl
) {
1008 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1009 if (dev
->original_set_high_voltage
)
1010 res
= dev
->original_set_high_voltage(fe
, arg
);
1011 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1016 static int md8800_set_voltage2(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
1018 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
1019 u8 wbuf
[2] = { 0x1f, 00 };
1021 struct i2c_msg msg
[] = { { .addr
= 0x08, .flags
= 0, .buf
= wbuf
, .len
= 1 },
1022 { .addr
= 0x08, .flags
= I2C_M_RD
, .buf
= &rbuf
, .len
= 1 } };
1024 if (i2c_transfer(&dev
->i2c_adap
, msg
, 2) != 2)
1026 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1027 if (voltage
== SEC_VOLTAGE_18
)
1028 wbuf
[1] = rbuf
| 0x10;
1030 wbuf
[1] = rbuf
& 0xef;
1032 i2c_transfer(&dev
->i2c_adap
, msg
, 1);
1036 static int md8800_set_high_voltage2(struct dvb_frontend
*fe
, long arg
)
1038 pr_warn("%s: sorry can't set high LNB supply voltage from here\n",
1043 /* ==================================================================
1044 * nxt200x based ATSC cards, helper functions
1047 static struct nxt200x_config avertvhda180
= {
1048 .demod_address
= 0x0a,
1051 static struct nxt200x_config kworldatsc110
= {
1052 .demod_address
= 0x0a,
1055 /* ------------------------------------------------------------------ */
1057 static struct mt312_config avertv_a700_mt312
= {
1058 .demod_address
= 0x0e,
1059 .voltage_inverted
= 1,
1062 static struct zl10036_config avertv_a700_tuner
= {
1063 .tuner_address
= 0x60,
1066 static struct mt312_config zl10313_compro_s350_config
= {
1067 .demod_address
= 0x0e,
1070 static struct mt312_config zl10313_avermedia_a706_config
= {
1071 .demod_address
= 0x0e,
1074 static struct lgdt3305_config hcw_lgdt3305_config
= {
1076 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
1077 .tpclk_edge
= LGDT3305_TPCLK_RISING_EDGE
,
1078 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
1080 .spectral_inversion
= 1,
1085 static struct tda10048_config hcw_tda10048_config
= {
1086 .demod_address
= 0x10 >> 1,
1087 .output_mode
= TDA10048_SERIAL_OUTPUT
,
1088 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1089 .inversion
= TDA10048_INVERSION_ON
,
1090 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1091 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1092 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1093 .clk_freq_khz
= TDA10048_CLK_16000
,
1094 .disable_gate_access
= 1,
1097 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
1098 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
1099 .if_lvl
= 1, .rfagc_top
= 0x58, },
1100 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
1101 .if_lvl
= 1, .rfagc_top
= 0x58, },
1104 static struct tda18271_config hcw_tda18271_config
= {
1105 .std_map
= &hauppauge_tda18271_std_map
,
1106 .gate
= TDA18271_GATE_ANALOG
,
1108 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1111 static struct tda829x_config tda829x_no_probe
= {
1112 .probe_tuner
= TDA829X_DONT_PROBE
,
1115 static struct tda10048_config zolid_tda10048_config
= {
1116 .demod_address
= 0x10 >> 1,
1117 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1118 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1119 .inversion
= TDA10048_INVERSION_ON
,
1120 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1121 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1122 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1123 .clk_freq_khz
= TDA10048_CLK_16000
,
1124 .disable_gate_access
= 1,
1127 static struct tda18271_config zolid_tda18271_config
= {
1128 .gate
= TDA18271_GATE_ANALOG
,
1131 static struct tda10048_config dtv1000s_tda10048_config
= {
1132 .demod_address
= 0x10 >> 1,
1133 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1134 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1135 .inversion
= TDA10048_INVERSION_ON
,
1136 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1137 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
1138 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
1139 .clk_freq_khz
= TDA10048_CLK_16000
,
1140 .disable_gate_access
= 1,
1143 static struct tda18271_std_map dtv1000s_tda18271_std_map
= {
1144 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
1145 .if_lvl
= 1, .rfagc_top
= 0x37, },
1146 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
1147 .if_lvl
= 1, .rfagc_top
= 0x37, },
1148 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
1149 .if_lvl
= 1, .rfagc_top
= 0x37, },
1152 static struct tda18271_config dtv1000s_tda18271_config
= {
1153 .std_map
= &dtv1000s_tda18271_std_map
,
1154 .gate
= TDA18271_GATE_ANALOG
,
1157 static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config
= {
1158 .prod
= LGS8GXX_PROD_LGS8G75
,
1159 .demod_address
= 0x1d,
1163 .if_clk_freq
= 30400, /* 30.4 MHz */
1164 .if_freq
= 4000, /* 4.00 MHz */
1168 .adc_vpp
= 3, /* 2.0 Vpp */
1172 static struct tda18271_config prohdtv_pro2_tda18271_config
= {
1173 .gate
= TDA18271_GATE_ANALOG
,
1174 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1177 static struct tda18271_std_map kworld_tda18271_std_map
= {
1178 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 3,
1179 .if_lvl
= 6, .rfagc_top
= 0x37 },
1180 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
1181 .if_lvl
= 6, .rfagc_top
= 0x37 },
1184 static struct tda18271_config kworld_pc150u_tda18271_config
= {
1185 .std_map
= &kworld_tda18271_std_map
,
1186 .gate
= TDA18271_GATE_ANALOG
,
1187 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1188 .config
= 3, /* Use tuner callback for AGC */
1189 .rf_cal_on_startup
= 1
1192 static struct s5h1411_config kworld_s5h1411_config
= {
1193 .output_mode
= S5H1411_PARALLEL_OUTPUT
,
1194 .gpio
= S5H1411_GPIO_OFF
,
1195 .qam_if
= S5H1411_IF_4000
,
1196 .vsb_if
= S5H1411_IF_3250
,
1197 .inversion
= S5H1411_INVERSION_ON
,
1198 .status_mode
= S5H1411_DEMODLOCKING
,
1200 S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
1204 /* ==================================================================
1208 static int dvb_init(struct saa7134_dev
*dev
)
1211 int attach_xc3028
= 0;
1212 struct vb2_dvb_frontend
*fe0
;
1213 struct vb2_queue
*q
;
1215 /* FIXME: add support for multi-frontend */
1216 mutex_init(&dev
->frontends
.lock
);
1217 INIT_LIST_HEAD(&dev
->frontends
.felist
);
1219 pr_info("%s() allocating 1 frontend\n", __func__
);
1220 fe0
= vb2_dvb_alloc_frontend(&dev
->frontends
, 1);
1222 pr_err("%s() failed to alloc\n", __func__
);
1226 /* init struct vb2_dvb */
1227 dev
->ts
.nr_bufs
= 32;
1228 dev
->ts
.nr_packets
= 32*4;
1229 fe0
->dvb
.name
= dev
->name
;
1231 q
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
1232 q
->io_modes
= VB2_MMAP
| VB2_READ
;
1233 q
->drv_priv
= &dev
->ts_q
;
1234 q
->ops
= &saa7134_ts_qops
;
1235 q
->mem_ops
= &vb2_dma_sg_memops
;
1236 q
->buf_struct_size
= sizeof(struct saa7134_buf
);
1237 q
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
;
1238 q
->lock
= &dev
->lock
;
1239 ret
= vb2_queue_init(q
);
1241 vb2_dvb_dealloc_frontends(&dev
->frontends
);
1245 switch (dev
->board
) {
1246 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
1247 pr_debug("pinnacle 300i dvb setup\n");
1248 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &pinnacle_300i
,
1250 if (fe0
->dvb
.frontend
) {
1251 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= mt352_pinnacle_tuner_set_params
;
1254 case SAA7134_BOARD_AVERMEDIA_777
:
1255 case SAA7134_BOARD_AVERMEDIA_A16AR
:
1256 pr_debug("avertv 777 dvb setup\n");
1257 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_777
,
1259 if (fe0
->dvb
.frontend
) {
1260 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1261 &dev
->i2c_adap
, 0x61,
1262 TUNER_PHILIPS_TD1316
);
1265 case SAA7134_BOARD_AVERMEDIA_A16D
:
1266 pr_debug("AverMedia A16D dvb setup\n");
1267 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1268 &avermedia_xc3028_mt352_dev
,
1272 case SAA7134_BOARD_MD7134
:
1273 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1276 if (fe0
->dvb
.frontend
) {
1277 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1278 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1279 TUNER_PHILIPS_FMD1216ME_MK3
);
1282 case SAA7134_BOARD_PHILIPS_TOUGH
:
1283 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1284 &philips_tu1216_60_config
,
1286 if (fe0
->dvb
.frontend
) {
1287 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1288 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1291 case SAA7134_BOARD_FLYDVBTDUO
:
1292 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS
:
1293 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1294 &tda827x_cfg_0
) < 0)
1295 goto detach_frontend
;
1297 case SAA7134_BOARD_PHILIPS_EUROPA
:
1298 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
1299 case SAA7134_BOARD_ASUS_EUROPA_HYBRID
:
1300 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1301 &philips_europa_config
,
1303 if (fe0
->dvb
.frontend
) {
1304 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1305 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1306 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1307 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1308 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1311 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000
:
1312 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1313 &technotrend_budget_t3000_config
,
1315 if (fe0
->dvb
.frontend
) {
1316 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1317 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1318 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1319 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1320 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1323 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
1324 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1325 &philips_tu1216_61_config
,
1327 if (fe0
->dvb
.frontend
) {
1328 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1329 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1332 case SAA7134_BOARD_KWORLD_DVBT_210
:
1333 if (configure_tda827x_fe(dev
, &kworld_dvb_t_210_config
,
1334 &tda827x_cfg_2
) < 0)
1335 goto detach_frontend
;
1337 case SAA7134_BOARD_HAUPPAUGE_HVR1120
:
1338 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1339 &hcw_tda10048_config
,
1341 if (fe0
->dvb
.frontend
!= NULL
) {
1342 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1343 &dev
->i2c_adap
, 0x4b,
1345 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1346 0x60, &dev
->i2c_adap
,
1347 &hcw_tda18271_config
);
1350 case SAA7134_BOARD_PHILIPS_TIGER
:
1351 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1352 &tda827x_cfg_0
) < 0)
1353 goto detach_frontend
;
1355 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
1356 if (configure_tda827x_fe(dev
, &pinnacle_pctv_310i_config
,
1357 &tda827x_cfg_1
) < 0)
1358 goto detach_frontend
;
1360 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
1361 if (configure_tda827x_fe(dev
, &hauppauge_hvr_1110_config
,
1362 &tda827x_cfg_1
) < 0)
1363 goto detach_frontend
;
1365 case SAA7134_BOARD_HAUPPAUGE_HVR1150
:
1366 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1367 &hcw_lgdt3305_config
,
1369 if (fe0
->dvb
.frontend
) {
1370 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1371 &dev
->i2c_adap
, 0x4b,
1373 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1374 0x60, &dev
->i2c_adap
,
1375 &hcw_tda18271_config
);
1378 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
1379 if (configure_tda827x_fe(dev
, &asus_p7131_dual_config
,
1380 &tda827x_cfg_0
) < 0)
1381 goto detach_frontend
;
1383 case SAA7134_BOARD_FLYDVBT_LR301
:
1384 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1385 &tda827x_cfg_0
) < 0)
1386 goto detach_frontend
;
1388 case SAA7134_BOARD_FLYDVB_TRIO
:
1389 if (!use_frontend
) { /* terrestrial */
1390 if (configure_tda827x_fe(dev
, &lifeview_trio_config
,
1391 &tda827x_cfg_0
) < 0)
1392 goto detach_frontend
;
1393 } else { /* satellite */
1394 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
, &dev
->i2c_adap
);
1395 if (fe0
->dvb
.frontend
) {
1396 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x63,
1397 &dev
->i2c_adap
, 0) == NULL
) {
1398 pr_warn("%s: Lifeview Trio, No tda826x found!\n",
1400 goto detach_frontend
;
1402 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1404 0x08, 0, 0, false) == NULL
) {
1405 pr_warn("%s: Lifeview Trio, No ISL6421 found!\n",
1407 goto detach_frontend
;
1412 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331
:
1413 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS
:
1414 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1415 &ads_tech_duo_config
,
1417 if (fe0
->dvb
.frontend
) {
1418 if (dvb_attach(tda827x_attach
,fe0
->dvb
.frontend
,
1419 ads_tech_duo_config
.tuner_address
, &dev
->i2c_adap
,
1420 &ads_duo_cfg
) == NULL
) {
1421 pr_warn("no tda827x tuner found at addr: %02x\n",
1422 ads_tech_duo_config
.tuner_address
);
1423 goto detach_frontend
;
1426 pr_warn("failed to attach tda10046\n");
1428 case SAA7134_BOARD_TEVION_DVBT_220RF
:
1429 if (configure_tda827x_fe(dev
, &tevion_dvbt220rf_config
,
1430 &tda827x_cfg_0
) < 0)
1431 goto detach_frontend
;
1433 case SAA7134_BOARD_MEDION_MD8800_QUADRO
:
1434 if (!use_frontend
) { /* terrestrial */
1435 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1436 &tda827x_cfg_0
) < 0)
1437 goto detach_frontend
;
1438 } else { /* satellite */
1439 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1440 &flydvbs
, &dev
->i2c_adap
);
1441 if (fe0
->dvb
.frontend
) {
1442 struct dvb_frontend
*fe
= fe0
->dvb
.frontend
;
1443 u8 dev_id
= dev
->eedata
[2];
1445 struct i2c_msg msg
= {.addr
= 0x08, .flags
= 0, .len
= 1};
1447 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
,
1448 0x60, &dev
->i2c_adap
, 0) == NULL
) {
1449 pr_warn("%s: Medion Quadro, no tda826x "
1450 "found !\n", __func__
);
1451 goto detach_frontend
;
1453 if (dev_id
!= 0x08) {
1454 /* we need to open the i2c gate (we know it exists) */
1455 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1456 if (dvb_attach(isl6405_attach
, fe
,
1457 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1458 pr_warn("%s: Medion Quadro, no ISL6405 "
1459 "found !\n", __func__
);
1460 goto detach_frontend
;
1462 if (dev_id
== 0x07) {
1463 /* fire up the 2nd section of the LNB supply since
1464 we can't do this from the other section */
1466 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1468 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1469 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1470 fe
->ops
.set_voltage
= md8800_set_voltage
;
1471 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1472 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1474 fe
->ops
.set_voltage
= md8800_set_voltage2
;
1475 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage2
;
1480 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
1481 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &avertvhda180
,
1483 if (fe0
->dvb
.frontend
)
1484 dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x61,
1485 NULL
, DVB_PLL_TDHU2
);
1487 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI
:
1488 case SAA7134_BOARD_KWORLD_ATSC110
:
1489 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &kworldatsc110
,
1491 if (fe0
->dvb
.frontend
)
1492 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1493 &dev
->i2c_adap
, 0x61,
1494 TUNER_PHILIPS_TUV1236D
);
1496 case SAA7134_BOARD_KWORLD_PC150U
:
1497 saa7134_set_gpio(dev
, 18, 1); /* Switch to digital mode */
1498 saa7134_tuner_callback(dev
, 0,
1499 TDA18271_CALLBACK_CMD_AGC_ENABLE
, 1);
1500 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1501 &kworld_s5h1411_config
,
1503 if (fe0
->dvb
.frontend
!= NULL
) {
1504 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1505 &dev
->i2c_adap
, 0x4b,
1507 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1508 0x60, &dev
->i2c_adap
,
1509 &kworld_pc150u_tda18271_config
);
1512 case SAA7134_BOARD_FLYDVBS_LR300
:
1513 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1515 if (fe0
->dvb
.frontend
) {
1516 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1517 &dev
->i2c_adap
, 0) == NULL
) {
1518 pr_warn("%s: No tda826x found!\n", __func__
);
1519 goto detach_frontend
;
1521 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1523 0x08, 0, 0, false) == NULL
) {
1524 pr_warn("%s: No ISL6421 found!\n", __func__
);
1525 goto detach_frontend
;
1529 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID
:
1530 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1533 if (fe0
->dvb
.frontend
) {
1534 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1535 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1537 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1538 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1539 TUNER_PHILIPS_FMD1216ME_MK3
);
1542 case SAA7134_BOARD_VIDEOMATE_DVBT_200A
:
1543 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1544 &philips_europa_config
,
1546 if (fe0
->dvb
.frontend
) {
1547 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_td1316_tuner_init
;
1548 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1551 case SAA7134_BOARD_CINERGY_HT_PCMCIA
:
1552 if (configure_tda827x_fe(dev
, &cinergy_ht_config
,
1553 &tda827x_cfg_0
) < 0)
1554 goto detach_frontend
;
1556 case SAA7134_BOARD_CINERGY_HT_PCI
:
1557 if (configure_tda827x_fe(dev
, &cinergy_ht_pci_config
,
1558 &tda827x_cfg_0
) < 0)
1559 goto detach_frontend
;
1561 case SAA7134_BOARD_PHILIPS_TIGER_S
:
1562 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1563 &tda827x_cfg_2
) < 0)
1564 goto detach_frontend
;
1566 case SAA7134_BOARD_ASUS_P7131_4871
:
1567 if (configure_tda827x_fe(dev
, &asus_p7131_4871_config
,
1568 &tda827x_cfg_2
) < 0)
1569 goto detach_frontend
;
1571 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
1572 if (configure_tda827x_fe(dev
, &asus_p7131_hybrid_lna_config
,
1573 &tda827x_cfg_2
) < 0)
1574 goto detach_frontend
;
1576 case SAA7134_BOARD_AVERMEDIA_SUPER_007
:
1577 if (configure_tda827x_fe(dev
, &avermedia_super_007_config
,
1578 &tda827x_cfg_0
) < 0)
1579 goto detach_frontend
;
1581 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056
:
1582 if (configure_tda827x_fe(dev
, &twinhan_dtv_dvb_3056_config
,
1583 &tda827x_cfg_2_sw42
) < 0)
1584 goto detach_frontend
;
1586 case SAA7134_BOARD_PHILIPS_SNAKE
:
1587 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1589 if (fe0
->dvb
.frontend
) {
1590 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1591 &dev
->i2c_adap
, 0) == NULL
) {
1592 pr_warn("%s: No tda826x found!\n", __func__
);
1593 goto detach_frontend
;
1595 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1596 &dev
->i2c_adap
, 0, 0) == NULL
) {
1597 pr_warn("%s: No lnbp21 found!\n", __func__
);
1598 goto detach_frontend
;
1602 case SAA7134_BOARD_CREATIX_CTX953
:
1603 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1604 &tda827x_cfg_0
) < 0)
1605 goto detach_frontend
;
1607 case SAA7134_BOARD_MSI_TVANYWHERE_AD11
:
1608 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1609 &tda827x_cfg_2
) < 0)
1610 goto detach_frontend
;
1612 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
1613 pr_debug("AverMedia E506R dvb setup\n");
1614 saa7134_set_gpio(dev
, 25, 0);
1616 saa7134_set_gpio(dev
, 25, 1);
1617 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1618 &avermedia_xc3028_mt352_dev
,
1622 case SAA7134_BOARD_MD7134_BRIDGE_2
:
1623 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1624 &sd1878_4m
, &dev
->i2c_adap
);
1625 if (fe0
->dvb
.frontend
) {
1626 struct dvb_frontend
*fe
;
1627 if (dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1628 &dev
->i2c_adap
, DVB_PLL_PHILIPS_SD1878_TDA8261
) == NULL
) {
1629 pr_warn("%s: MD7134 DVB-S, no SD1878 "
1630 "found !\n", __func__
);
1631 goto detach_frontend
;
1633 /* we need to open the i2c gate (we know it exists) */
1634 fe
= fe0
->dvb
.frontend
;
1635 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1636 if (dvb_attach(isl6405_attach
, fe
,
1637 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1638 pr_warn("%s: MD7134 DVB-S, no ISL6405 "
1639 "found !\n", __func__
);
1640 goto detach_frontend
;
1642 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1643 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1644 fe
->ops
.set_voltage
= md8800_set_voltage
;
1645 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1646 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1649 case SAA7134_BOARD_AVERMEDIA_M103
:
1650 saa7134_set_gpio(dev
, 25, 0);
1652 saa7134_set_gpio(dev
, 25, 1);
1653 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1654 &avermedia_xc3028_mt352_dev
,
1658 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1
:
1659 if (!use_frontend
) { /* terrestrial */
1660 if (configure_tda827x_fe(dev
, &asus_tiger_3in1_config
,
1661 &tda827x_cfg_2
) < 0)
1662 goto detach_frontend
;
1663 } else { /* satellite */
1664 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1665 &flydvbs
, &dev
->i2c_adap
);
1666 if (fe0
->dvb
.frontend
) {
1667 if (dvb_attach(tda826x_attach
,
1668 fe0
->dvb
.frontend
, 0x60,
1669 &dev
->i2c_adap
, 0) == NULL
) {
1670 pr_warn("%s: Asus Tiger 3in1, no "
1671 "tda826x found!\n", __func__
);
1672 goto detach_frontend
;
1674 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1675 &dev
->i2c_adap
, 0, 0) == NULL
) {
1676 pr_warn("%s: Asus Tiger 3in1, no lnbp21"
1677 " found!\n", __func__
);
1678 goto detach_frontend
;
1683 case SAA7134_BOARD_ASUSTeK_PS3_100
:
1684 if (!use_frontend
) { /* terrestrial */
1685 if (configure_tda827x_fe(dev
, &asus_ps3_100_config
,
1686 &tda827x_cfg_2
) < 0)
1687 goto detach_frontend
;
1688 } else { /* satellite */
1689 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1690 &flydvbs
, &dev
->i2c_adap
);
1691 if (fe0
->dvb
.frontend
) {
1692 if (dvb_attach(tda826x_attach
,
1693 fe0
->dvb
.frontend
, 0x60,
1694 &dev
->i2c_adap
, 0) == NULL
) {
1695 pr_warn("%s: Asus My Cinema PS3-100, no "
1696 "tda826x found!\n", __func__
);
1697 goto detach_frontend
;
1699 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1700 &dev
->i2c_adap
, 0, 0) == NULL
) {
1701 pr_warn("%s: Asus My Cinema PS3-100, no lnbp21"
1702 " found!\n", __func__
);
1703 goto detach_frontend
;
1708 case SAA7134_BOARD_ASUSTeK_TIGER
:
1709 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1710 &tda827x_cfg_0
) < 0)
1711 goto detach_frontend
;
1713 case SAA7134_BOARD_BEHOLD_H6
:
1714 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1717 if (fe0
->dvb
.frontend
) {
1718 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1719 &dev
->i2c_adap
, 0x61,
1720 TUNER_PHILIPS_FMD1216MEX_MK3
);
1723 case SAA7134_BOARD_BEHOLD_X7
:
1724 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1727 if (fe0
->dvb
.frontend
) {
1728 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1729 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1732 case SAA7134_BOARD_BEHOLD_H7
:
1733 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1736 if (fe0
->dvb
.frontend
) {
1737 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1738 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1741 case SAA7134_BOARD_AVERMEDIA_A700_PRO
:
1742 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID
:
1743 /* Zarlink ZL10313 */
1744 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1745 &avertv_a700_mt312
, &dev
->i2c_adap
);
1746 if (fe0
->dvb
.frontend
) {
1747 if (dvb_attach(zl10036_attach
, fe0
->dvb
.frontend
,
1748 &avertv_a700_tuner
, &dev
->i2c_adap
) == NULL
) {
1749 pr_warn("%s: No zl10036 found!\n",
1754 case SAA7134_BOARD_VIDEOMATE_S350
:
1755 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1756 &zl10313_compro_s350_config
, &dev
->i2c_adap
);
1757 if (fe0
->dvb
.frontend
)
1758 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1759 0x60, &dev
->i2c_adap
) == NULL
)
1760 pr_warn("%s: No zl10039 found!\n",
1764 case SAA7134_BOARD_VIDEOMATE_T750
:
1765 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1766 &videomate_t750_zl10353_config
,
1768 if (fe0
->dvb
.frontend
!= NULL
) {
1769 if (dvb_attach(qt1010_attach
,
1772 &videomate_t750_qt1010_config
) == NULL
)
1773 pr_warn("error attaching QT1010\n");
1776 case SAA7134_BOARD_ZOLID_HYBRID_PCI
:
1777 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1778 &zolid_tda10048_config
,
1780 if (fe0
->dvb
.frontend
!= NULL
) {
1781 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1782 &dev
->i2c_adap
, 0x4b,
1784 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1785 0x60, &dev
->i2c_adap
,
1786 &zolid_tda18271_config
);
1789 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S
:
1790 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1791 &dtv1000s_tda10048_config
,
1793 if (fe0
->dvb
.frontend
!= NULL
) {
1794 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1795 &dev
->i2c_adap
, 0x4b,
1797 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1798 0x60, &dev
->i2c_adap
,
1799 &dtv1000s_tda18271_config
);
1802 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG
:
1803 /* Switch to digital mode */
1804 saa7134_tuner_callback(dev
, 0,
1805 TDA18271_CALLBACK_CMD_AGC_ENABLE
, 1);
1806 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1807 &kworld_mb86a20s_config
,
1809 if (fe0
->dvb
.frontend
!= NULL
) {
1810 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1811 &dev
->i2c_adap
, 0x4b,
1813 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= kworld_sbtvd_gate_ctrl
;
1814 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1815 0x60, &dev
->i2c_adap
,
1816 &kworld_tda18271_config
);
1819 /* mb86a20s need to use the I2C gateway */
1821 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2
:
1822 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1823 &prohdtv_pro2_lgs8g75_config
,
1825 if (fe0
->dvb
.frontend
!= NULL
) {
1826 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1827 &dev
->i2c_adap
, 0x4b,
1829 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1830 0x60, &dev
->i2c_adap
,
1831 &prohdtv_pro2_tda18271_config
);
1834 case SAA7134_BOARD_AVERMEDIA_A706
:
1835 /* Enable all DVB-S devices now */
1836 /* CE5039 DVB-S tuner SLEEP pin low */
1837 saa7134_set_gpio(dev
, 23, 0);
1838 /* CE6313 DVB-S demod SLEEP pin low */
1839 saa7134_set_gpio(dev
, 9, 0);
1840 /* CE6313 DVB-S demod RESET# pin high */
1841 saa7134_set_gpio(dev
, 25, 1);
1843 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1844 &zl10313_avermedia_a706_config
, &dev
->i2c_adap
);
1845 if (fe0
->dvb
.frontend
) {
1846 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1847 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1848 0x60, &dev
->i2c_adap
) == NULL
)
1849 pr_warn("%s: No zl10039 found!\n",
1854 pr_warn("Huh? unknown DVB card?\n");
1858 if (attach_xc3028
) {
1859 struct dvb_frontend
*fe
;
1860 struct xc2028_config cfg
= {
1861 .i2c_adap
= &dev
->i2c_adap
,
1865 if (!fe0
->dvb
.frontend
)
1866 goto detach_frontend
;
1868 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
1870 pr_err("%s/2: xc3028 attach failed\n",
1872 goto detach_frontend
;
1876 if (NULL
== fe0
->dvb
.frontend
) {
1877 pr_err("%s/dvb: frontend initialization failed\n", dev
->name
);
1878 goto detach_frontend
;
1880 /* define general-purpose callback pointer */
1881 fe0
->dvb
.frontend
->callback
= saa7134_tuner_callback
;
1883 /* register everything else */
1884 ret
= vb2_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1885 &dev
->pci
->dev
, adapter_nr
, 0);
1887 /* this sequence is necessary to make the tda1004x load its firmware
1888 * and to enter analog mode of hybrid boards
1891 if (fe0
->dvb
.frontend
->ops
.init
)
1892 fe0
->dvb
.frontend
->ops
.init(fe0
->dvb
.frontend
);
1893 if (fe0
->dvb
.frontend
->ops
.sleep
)
1894 fe0
->dvb
.frontend
->ops
.sleep(fe0
->dvb
.frontend
);
1895 if (fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
)
1896 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep(fe0
->dvb
.frontend
);
1901 vb2_dvb_dealloc_frontends(&dev
->frontends
);
1902 vb2_queue_release(&fe0
->dvb
.dvbq
);
1906 static int dvb_fini(struct saa7134_dev
*dev
)
1908 struct vb2_dvb_frontend
*fe0
;
1910 /* Get the first frontend */
1911 fe0
= vb2_dvb_get_frontend(&dev
->frontends
, 1);
1915 /* FIXME: I suspect that this code is bogus, since the entry for
1916 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1917 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1919 if (dev
->board
== SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
) {
1920 struct v4l2_priv_tun_config tda9887_cfg
;
1921 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
1923 tda9887_cfg
.tuner
= TUNER_TDA9887
;
1924 tda9887_cfg
.priv
= &on
;
1926 /* otherwise we don't detect the tuner on next insmod */
1927 saa_call_all(dev
, tuner
, s_config
, &tda9887_cfg
);
1928 } else if (dev
->board
== SAA7134_BOARD_MEDION_MD8800_QUADRO
) {
1929 if ((dev
->eedata
[2] == 0x07) && use_frontend
) {
1930 /* turn off the 2nd lnb supply */
1932 struct i2c_msg msg
= {.addr
= 0x08, .buf
= &data
, .flags
= 0, .len
= 1};
1933 struct dvb_frontend
*fe
;
1934 fe
= fe0
->dvb
.frontend
;
1935 if (fe
->ops
.i2c_gate_ctrl
) {
1936 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1937 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1938 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1942 vb2_dvb_unregister_bus(&dev
->frontends
);
1943 vb2_queue_release(&fe0
->dvb
.dvbq
);
1947 static struct saa7134_mpeg_ops dvb_ops
= {
1948 .type
= SAA7134_MPEG_DVB
,
1953 static int __init
dvb_register(void)
1955 return saa7134_ts_register(&dvb_ops
);
1958 static void __exit
dvb_unregister(void)
1960 saa7134_ts_unregister(&dvb_ops
);
1963 module_init(dvb_register
);
1964 module_exit(dvb_unregister
);