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
) {
562 case 1: pr_debug("setting GPIO21 to 0 (TV antenna?)\n");
563 saa7134_set_gpio(dev
, 21, 0);
565 case 2: pr_debug("setting GPIO21 to 1 (Radio antenna?)\n");
566 saa7134_set_gpio(dev
, 21, 1);
572 static int philips_tda827x_tuner_sleep(struct dvb_frontend
*fe
)
574 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
575 struct tda1004x_state
*state
= fe
->demodulator_priv
;
577 switch (state
->config
->antenna_switch
) {
579 case 1: pr_debug("setting GPIO21 to 1 (Radio antenna?)\n");
580 saa7134_set_gpio(dev
, 21, 1);
582 case 2: pr_debug("setting GPIO21 to 0 (TV antenna?)\n");
583 saa7134_set_gpio(dev
, 21, 0);
589 static int configure_tda827x_fe(struct saa7134_dev
*dev
,
590 struct tda1004x_config
*cdec_conf
,
591 struct tda827x_config
*tuner_conf
)
593 struct vb2_dvb_frontend
*fe0
;
595 /* Get the first frontend */
596 fe0
= vb2_dvb_get_frontend(&dev
->frontends
, 1);
601 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
, cdec_conf
, &dev
->i2c_adap
);
602 if (fe0
->dvb
.frontend
) {
603 if (cdec_conf
->i2c_gate
)
604 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= tda8290_i2c_gate_ctrl
;
605 if (dvb_attach(tda827x_attach
, fe0
->dvb
.frontend
,
606 cdec_conf
->tuner_address
,
607 &dev
->i2c_adap
, tuner_conf
))
610 pr_warn("no tda827x tuner found at addr: %02x\n",
611 cdec_conf
->tuner_address
);
616 /* ------------------------------------------------------------------ */
618 static struct tda827x_config tda827x_cfg_0
= {
619 .init
= philips_tda827x_tuner_init
,
620 .sleep
= philips_tda827x_tuner_sleep
,
625 static struct tda827x_config tda827x_cfg_1
= {
626 .init
= philips_tda827x_tuner_init
,
627 .sleep
= philips_tda827x_tuner_sleep
,
632 static struct tda827x_config tda827x_cfg_2
= {
633 .init
= philips_tda827x_tuner_init
,
634 .sleep
= philips_tda827x_tuner_sleep
,
639 static struct tda827x_config tda827x_cfg_2_sw42
= {
640 .init
= philips_tda827x_tuner_init
,
641 .sleep
= philips_tda827x_tuner_sleep
,
646 /* ------------------------------------------------------------------ */
648 static struct tda1004x_config tda827x_lifeview_config
= {
649 .demod_address
= 0x08,
652 .xtal_freq
= TDA10046_XTAL_16M
,
653 .agc_config
= TDA10046_AGC_TDA827X
,
654 .gpio_config
= TDA10046_GP11_I
,
655 .if_freq
= TDA10046_FREQ_045
,
656 .tuner_address
= 0x60,
657 .request_firmware
= philips_tda1004x_request_firmware
660 static struct tda1004x_config philips_tiger_config
= {
661 .demod_address
= 0x08,
664 .xtal_freq
= TDA10046_XTAL_16M
,
665 .agc_config
= TDA10046_AGC_TDA827X
,
666 .gpio_config
= TDA10046_GP11_I
,
667 .if_freq
= TDA10046_FREQ_045
,
669 .tuner_address
= 0x61,
671 .request_firmware
= philips_tda1004x_request_firmware
674 static struct tda1004x_config cinergy_ht_config
= {
675 .demod_address
= 0x08,
678 .xtal_freq
= TDA10046_XTAL_16M
,
679 .agc_config
= TDA10046_AGC_TDA827X
,
680 .gpio_config
= TDA10046_GP01_I
,
681 .if_freq
= TDA10046_FREQ_045
,
683 .tuner_address
= 0x61,
684 .request_firmware
= philips_tda1004x_request_firmware
687 static struct tda1004x_config cinergy_ht_pci_config
= {
688 .demod_address
= 0x08,
691 .xtal_freq
= TDA10046_XTAL_16M
,
692 .agc_config
= TDA10046_AGC_TDA827X
,
693 .gpio_config
= TDA10046_GP01_I
,
694 .if_freq
= TDA10046_FREQ_045
,
696 .tuner_address
= 0x60,
697 .request_firmware
= philips_tda1004x_request_firmware
700 static struct tda1004x_config philips_tiger_s_config
= {
701 .demod_address
= 0x08,
704 .xtal_freq
= TDA10046_XTAL_16M
,
705 .agc_config
= TDA10046_AGC_TDA827X
,
706 .gpio_config
= TDA10046_GP01_I
,
707 .if_freq
= TDA10046_FREQ_045
,
709 .tuner_address
= 0x61,
711 .request_firmware
= philips_tda1004x_request_firmware
714 static struct tda1004x_config pinnacle_pctv_310i_config
= {
715 .demod_address
= 0x08,
718 .xtal_freq
= TDA10046_XTAL_16M
,
719 .agc_config
= TDA10046_AGC_TDA827X
,
720 .gpio_config
= TDA10046_GP11_I
,
721 .if_freq
= TDA10046_FREQ_045
,
723 .tuner_address
= 0x61,
724 .request_firmware
= philips_tda1004x_request_firmware
727 static struct tda1004x_config hauppauge_hvr_1110_config
= {
728 .demod_address
= 0x08,
731 .xtal_freq
= TDA10046_XTAL_16M
,
732 .agc_config
= TDA10046_AGC_TDA827X
,
733 .gpio_config
= TDA10046_GP11_I
,
734 .if_freq
= TDA10046_FREQ_045
,
736 .tuner_address
= 0x61,
737 .request_firmware
= philips_tda1004x_request_firmware
740 static struct tda1004x_config asus_p7131_dual_config
= {
741 .demod_address
= 0x08,
744 .xtal_freq
= TDA10046_XTAL_16M
,
745 .agc_config
= TDA10046_AGC_TDA827X
,
746 .gpio_config
= TDA10046_GP11_I
,
747 .if_freq
= TDA10046_FREQ_045
,
749 .tuner_address
= 0x61,
751 .request_firmware
= philips_tda1004x_request_firmware
754 static struct tda1004x_config lifeview_trio_config
= {
755 .demod_address
= 0x09,
758 .xtal_freq
= TDA10046_XTAL_16M
,
759 .agc_config
= TDA10046_AGC_TDA827X
,
760 .gpio_config
= TDA10046_GP00_I
,
761 .if_freq
= TDA10046_FREQ_045
,
762 .tuner_address
= 0x60,
763 .request_firmware
= philips_tda1004x_request_firmware
766 static struct tda1004x_config tevion_dvbt220rf_config
= {
767 .demod_address
= 0x08,
770 .xtal_freq
= TDA10046_XTAL_16M
,
771 .agc_config
= TDA10046_AGC_TDA827X
,
772 .gpio_config
= TDA10046_GP11_I
,
773 .if_freq
= TDA10046_FREQ_045
,
774 .tuner_address
= 0x60,
775 .request_firmware
= philips_tda1004x_request_firmware
778 static struct tda1004x_config md8800_dvbt_config
= {
779 .demod_address
= 0x08,
782 .xtal_freq
= TDA10046_XTAL_16M
,
783 .agc_config
= TDA10046_AGC_TDA827X
,
784 .gpio_config
= TDA10046_GP01_I
,
785 .if_freq
= TDA10046_FREQ_045
,
787 .tuner_address
= 0x60,
788 .request_firmware
= philips_tda1004x_request_firmware
791 static struct tda1004x_config asus_p7131_4871_config
= {
792 .demod_address
= 0x08,
795 .xtal_freq
= TDA10046_XTAL_16M
,
796 .agc_config
= TDA10046_AGC_TDA827X
,
797 .gpio_config
= TDA10046_GP01_I
,
798 .if_freq
= TDA10046_FREQ_045
,
800 .tuner_address
= 0x61,
802 .request_firmware
= philips_tda1004x_request_firmware
805 static struct tda1004x_config asus_p7131_hybrid_lna_config
= {
806 .demod_address
= 0x08,
809 .xtal_freq
= TDA10046_XTAL_16M
,
810 .agc_config
= TDA10046_AGC_TDA827X
,
811 .gpio_config
= TDA10046_GP11_I
,
812 .if_freq
= TDA10046_FREQ_045
,
814 .tuner_address
= 0x61,
816 .request_firmware
= philips_tda1004x_request_firmware
819 static struct tda1004x_config kworld_dvb_t_210_config
= {
820 .demod_address
= 0x08,
823 .xtal_freq
= TDA10046_XTAL_16M
,
824 .agc_config
= TDA10046_AGC_TDA827X
,
825 .gpio_config
= TDA10046_GP11_I
,
826 .if_freq
= TDA10046_FREQ_045
,
828 .tuner_address
= 0x61,
830 .request_firmware
= philips_tda1004x_request_firmware
833 static struct tda1004x_config avermedia_super_007_config
= {
834 .demod_address
= 0x08,
837 .xtal_freq
= TDA10046_XTAL_16M
,
838 .agc_config
= TDA10046_AGC_TDA827X
,
839 .gpio_config
= TDA10046_GP01_I
,
840 .if_freq
= TDA10046_FREQ_045
,
842 .tuner_address
= 0x60,
844 .request_firmware
= philips_tda1004x_request_firmware
847 static struct tda1004x_config twinhan_dtv_dvb_3056_config
= {
848 .demod_address
= 0x08,
851 .xtal_freq
= TDA10046_XTAL_16M
,
852 .agc_config
= TDA10046_AGC_TDA827X
,
853 .gpio_config
= TDA10046_GP01_I
,
854 .if_freq
= TDA10046_FREQ_045
,
856 .tuner_address
= 0x61,
858 .request_firmware
= philips_tda1004x_request_firmware
861 static struct tda1004x_config asus_tiger_3in1_config
= {
862 .demod_address
= 0x0b,
865 .xtal_freq
= TDA10046_XTAL_16M
,
866 .agc_config
= TDA10046_AGC_TDA827X
,
867 .gpio_config
= TDA10046_GP11_I
,
868 .if_freq
= TDA10046_FREQ_045
,
870 .tuner_address
= 0x61,
872 .request_firmware
= philips_tda1004x_request_firmware
875 static struct tda1004x_config asus_ps3_100_config
= {
876 .demod_address
= 0x0b,
879 .xtal_freq
= TDA10046_XTAL_16M
,
880 .agc_config
= TDA10046_AGC_TDA827X
,
881 .gpio_config
= TDA10046_GP11_I
,
882 .if_freq
= TDA10046_FREQ_045
,
884 .tuner_address
= 0x61,
886 .request_firmware
= philips_tda1004x_request_firmware
889 /* ------------------------------------------------------------------
890 * special case: this card uses saa713x GPIO22 for the mode switch
893 static int ads_duo_tuner_init(struct dvb_frontend
*fe
)
895 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
896 philips_tda827x_tuner_init(fe
);
897 /* route TDA8275a AGC input to the channel decoder */
898 saa7134_set_gpio(dev
, 22, 1);
902 static int ads_duo_tuner_sleep(struct dvb_frontend
*fe
)
904 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
905 /* route TDA8275a AGC input to the analog IF chip*/
906 saa7134_set_gpio(dev
, 22, 0);
907 philips_tda827x_tuner_sleep(fe
);
911 static struct tda827x_config ads_duo_cfg
= {
912 .init
= ads_duo_tuner_init
,
913 .sleep
= ads_duo_tuner_sleep
,
917 static struct tda1004x_config ads_tech_duo_config
= {
918 .demod_address
= 0x08,
921 .xtal_freq
= TDA10046_XTAL_16M
,
922 .agc_config
= TDA10046_AGC_TDA827X
,
923 .gpio_config
= TDA10046_GP00_I
,
924 .if_freq
= TDA10046_FREQ_045
,
925 .tuner_address
= 0x61,
926 .request_firmware
= philips_tda1004x_request_firmware
929 static struct zl10353_config behold_h6_config
= {
930 .demod_address
= 0x1e>>1,
933 .disable_i2c_gate_ctrl
= 1,
936 static struct xc5000_config behold_x7_tunerconfig
= {
937 .i2c_address
= 0xc2>>1,
939 .radio_input
= XC5000_RADIO_FM1
,
942 static struct zl10353_config behold_x7_config
= {
943 .demod_address
= 0x1e>>1,
947 .disable_i2c_gate_ctrl
= 1,
950 static struct zl10353_config videomate_t750_zl10353_config
= {
951 .demod_address
= 0x0f,
954 .disable_i2c_gate_ctrl
= 1,
957 static struct qt1010_config videomate_t750_qt1010_config
= {
962 /* ==================================================================
963 * tda10086 based DVB-S cards, helper functions
966 static struct tda10086_config flydvbs
= {
967 .demod_address
= 0x0e,
970 .xtal_freq
= TDA10086_XTAL_16M
,
973 static struct tda10086_config sd1878_4m
= {
974 .demod_address
= 0x0e,
977 .xtal_freq
= TDA10086_XTAL_4M
,
980 /* ------------------------------------------------------------------
981 * special case: lnb supply is connected to the gated i2c
984 static int md8800_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
987 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
988 if (fe
->ops
.i2c_gate_ctrl
) {
989 fe
->ops
.i2c_gate_ctrl(fe
, 1);
990 if (dev
->original_set_voltage
)
991 res
= dev
->original_set_voltage(fe
, voltage
);
992 fe
->ops
.i2c_gate_ctrl(fe
, 0);
997 static int md8800_set_high_voltage(struct dvb_frontend
*fe
, long arg
)
1000 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
1001 if (fe
->ops
.i2c_gate_ctrl
) {
1002 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1003 if (dev
->original_set_high_voltage
)
1004 res
= dev
->original_set_high_voltage(fe
, arg
);
1005 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1010 static int md8800_set_voltage2(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
1012 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
1013 u8 wbuf
[2] = { 0x1f, 00 };
1015 struct i2c_msg msg
[] = { { .addr
= 0x08, .flags
= 0, .buf
= wbuf
, .len
= 1 },
1016 { .addr
= 0x08, .flags
= I2C_M_RD
, .buf
= &rbuf
, .len
= 1 } };
1018 if (i2c_transfer(&dev
->i2c_adap
, msg
, 2) != 2)
1020 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1021 if (voltage
== SEC_VOLTAGE_18
)
1022 wbuf
[1] = rbuf
| 0x10;
1024 wbuf
[1] = rbuf
& 0xef;
1026 i2c_transfer(&dev
->i2c_adap
, msg
, 1);
1030 static int md8800_set_high_voltage2(struct dvb_frontend
*fe
, long arg
)
1032 pr_warn("%s: sorry can't set high LNB supply voltage from here\n", __func__
);
1036 /* ==================================================================
1037 * nxt200x based ATSC cards, helper functions
1040 static struct nxt200x_config avertvhda180
= {
1041 .demod_address
= 0x0a,
1044 static struct nxt200x_config kworldatsc110
= {
1045 .demod_address
= 0x0a,
1048 /* ------------------------------------------------------------------ */
1050 static struct mt312_config avertv_a700_mt312
= {
1051 .demod_address
= 0x0e,
1052 .voltage_inverted
= 1,
1055 static struct zl10036_config avertv_a700_tuner
= {
1056 .tuner_address
= 0x60,
1059 static struct mt312_config zl10313_compro_s350_config
= {
1060 .demod_address
= 0x0e,
1063 static struct mt312_config zl10313_avermedia_a706_config
= {
1064 .demod_address
= 0x0e,
1067 static struct lgdt3305_config hcw_lgdt3305_config
= {
1069 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
1070 .tpclk_edge
= LGDT3305_TPCLK_RISING_EDGE
,
1071 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
1073 .spectral_inversion
= 1,
1078 static struct tda10048_config hcw_tda10048_config
= {
1079 .demod_address
= 0x10 >> 1,
1080 .output_mode
= TDA10048_SERIAL_OUTPUT
,
1081 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1082 .inversion
= TDA10048_INVERSION_ON
,
1083 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1084 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1085 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1086 .clk_freq_khz
= TDA10048_CLK_16000
,
1087 .disable_gate_access
= 1,
1090 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
1091 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
1092 .if_lvl
= 1, .rfagc_top
= 0x58, },
1093 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
1094 .if_lvl
= 1, .rfagc_top
= 0x58, },
1097 static struct tda18271_config hcw_tda18271_config
= {
1098 .std_map
= &hauppauge_tda18271_std_map
,
1099 .gate
= TDA18271_GATE_ANALOG
,
1101 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1104 static struct tda829x_config tda829x_no_probe
= {
1105 .probe_tuner
= TDA829X_DONT_PROBE
,
1108 static struct tda10048_config zolid_tda10048_config
= {
1109 .demod_address
= 0x10 >> 1,
1110 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1111 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1112 .inversion
= TDA10048_INVERSION_ON
,
1113 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1114 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
1115 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
1116 .clk_freq_khz
= TDA10048_CLK_16000
,
1117 .disable_gate_access
= 1,
1120 static struct tda18271_config zolid_tda18271_config
= {
1121 .gate
= TDA18271_GATE_ANALOG
,
1124 static struct tda10048_config dtv1000s_tda10048_config
= {
1125 .demod_address
= 0x10 >> 1,
1126 .output_mode
= TDA10048_PARALLEL_OUTPUT
,
1127 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
1128 .inversion
= TDA10048_INVERSION_ON
,
1129 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
1130 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
1131 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
1132 .clk_freq_khz
= TDA10048_CLK_16000
,
1133 .disable_gate_access
= 1,
1136 static struct tda18271_std_map dtv1000s_tda18271_std_map
= {
1137 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
1138 .if_lvl
= 1, .rfagc_top
= 0x37, },
1139 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
1140 .if_lvl
= 1, .rfagc_top
= 0x37, },
1141 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
1142 .if_lvl
= 1, .rfagc_top
= 0x37, },
1145 static struct tda18271_config dtv1000s_tda18271_config
= {
1146 .std_map
= &dtv1000s_tda18271_std_map
,
1147 .gate
= TDA18271_GATE_ANALOG
,
1150 static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config
= {
1151 .prod
= LGS8GXX_PROD_LGS8G75
,
1152 .demod_address
= 0x1d,
1156 .if_clk_freq
= 30400, /* 30.4 MHz */
1157 .if_freq
= 4000, /* 4.00 MHz */
1161 .adc_vpp
= 3, /* 2.0 Vpp */
1165 static struct tda18271_config prohdtv_pro2_tda18271_config
= {
1166 .gate
= TDA18271_GATE_ANALOG
,
1167 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1170 static struct tda18271_std_map kworld_tda18271_std_map
= {
1171 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 3,
1172 .if_lvl
= 6, .rfagc_top
= 0x37 },
1173 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
1174 .if_lvl
= 6, .rfagc_top
= 0x37 },
1177 static struct tda18271_config kworld_pc150u_tda18271_config
= {
1178 .std_map
= &kworld_tda18271_std_map
,
1179 .gate
= TDA18271_GATE_ANALOG
,
1180 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1181 .config
= 3, /* Use tuner callback for AGC */
1182 .rf_cal_on_startup
= 1
1185 static struct s5h1411_config kworld_s5h1411_config
= {
1186 .output_mode
= S5H1411_PARALLEL_OUTPUT
,
1187 .gpio
= S5H1411_GPIO_OFF
,
1188 .qam_if
= S5H1411_IF_4000
,
1189 .vsb_if
= S5H1411_IF_3250
,
1190 .inversion
= S5H1411_INVERSION_ON
,
1191 .status_mode
= S5H1411_DEMODLOCKING
,
1193 S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
1197 /* ==================================================================
1201 static int dvb_init(struct saa7134_dev
*dev
)
1204 int attach_xc3028
= 0;
1205 struct vb2_dvb_frontend
*fe0
;
1206 struct vb2_queue
*q
;
1208 /* FIXME: add support for multi-frontend */
1209 mutex_init(&dev
->frontends
.lock
);
1210 INIT_LIST_HEAD(&dev
->frontends
.felist
);
1212 pr_info("%s() allocating 1 frontend\n", __func__
);
1213 fe0
= vb2_dvb_alloc_frontend(&dev
->frontends
, 1);
1215 pr_err("%s() failed to alloc\n", __func__
);
1219 /* init struct vb2_dvb */
1220 dev
->ts
.nr_bufs
= 32;
1221 dev
->ts
.nr_packets
= 32*4;
1222 fe0
->dvb
.name
= dev
->name
;
1224 q
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
1225 q
->io_modes
= VB2_MMAP
| VB2_READ
;
1226 q
->drv_priv
= &dev
->ts_q
;
1227 q
->ops
= &saa7134_ts_qops
;
1228 q
->mem_ops
= &vb2_dma_sg_memops
;
1229 q
->buf_struct_size
= sizeof(struct saa7134_buf
);
1230 q
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
;
1231 q
->lock
= &dev
->lock
;
1232 ret
= vb2_queue_init(q
);
1234 vb2_dvb_dealloc_frontends(&dev
->frontends
);
1238 switch (dev
->board
) {
1239 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
1240 pr_debug("pinnacle 300i dvb setup\n");
1241 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &pinnacle_300i
,
1243 if (fe0
->dvb
.frontend
) {
1244 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= mt352_pinnacle_tuner_set_params
;
1247 case SAA7134_BOARD_AVERMEDIA_777
:
1248 case SAA7134_BOARD_AVERMEDIA_A16AR
:
1249 pr_debug("avertv 777 dvb setup\n");
1250 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
, &avermedia_777
,
1252 if (fe0
->dvb
.frontend
) {
1253 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1254 &dev
->i2c_adap
, 0x61,
1255 TUNER_PHILIPS_TD1316
);
1258 case SAA7134_BOARD_AVERMEDIA_A16D
:
1259 pr_debug("AverMedia A16D dvb setup\n");
1260 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1261 &avermedia_xc3028_mt352_dev
,
1265 case SAA7134_BOARD_MD7134
:
1266 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1269 if (fe0
->dvb
.frontend
) {
1270 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1271 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1272 TUNER_PHILIPS_FMD1216ME_MK3
);
1275 case SAA7134_BOARD_PHILIPS_TOUGH
:
1276 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1277 &philips_tu1216_60_config
,
1279 if (fe0
->dvb
.frontend
) {
1280 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1281 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1284 case SAA7134_BOARD_FLYDVBTDUO
:
1285 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS
:
1286 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1287 &tda827x_cfg_0
) < 0)
1288 goto detach_frontend
;
1290 case SAA7134_BOARD_PHILIPS_EUROPA
:
1291 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
1292 case SAA7134_BOARD_ASUS_EUROPA_HYBRID
:
1293 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1294 &philips_europa_config
,
1296 if (fe0
->dvb
.frontend
) {
1297 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1298 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1299 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1300 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1301 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1304 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000
:
1305 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1306 &technotrend_budget_t3000_config
,
1308 if (fe0
->dvb
.frontend
) {
1309 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1310 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1311 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_europa_tuner_init
;
1312 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
= philips_europa_tuner_sleep
;
1313 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1316 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
1317 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1318 &philips_tu1216_61_config
,
1320 if (fe0
->dvb
.frontend
) {
1321 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_tu1216_init
;
1322 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_tda6651_pll_set
;
1325 case SAA7134_BOARD_KWORLD_DVBT_210
:
1326 if (configure_tda827x_fe(dev
, &kworld_dvb_t_210_config
,
1327 &tda827x_cfg_2
) < 0)
1328 goto detach_frontend
;
1330 case SAA7134_BOARD_HAUPPAUGE_HVR1120
:
1331 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1332 &hcw_tda10048_config
,
1334 if (fe0
->dvb
.frontend
!= NULL
) {
1335 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1336 &dev
->i2c_adap
, 0x4b,
1338 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1339 0x60, &dev
->i2c_adap
,
1340 &hcw_tda18271_config
);
1343 case SAA7134_BOARD_PHILIPS_TIGER
:
1344 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1345 &tda827x_cfg_0
) < 0)
1346 goto detach_frontend
;
1348 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
1349 if (configure_tda827x_fe(dev
, &pinnacle_pctv_310i_config
,
1350 &tda827x_cfg_1
) < 0)
1351 goto detach_frontend
;
1353 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
1354 if (configure_tda827x_fe(dev
, &hauppauge_hvr_1110_config
,
1355 &tda827x_cfg_1
) < 0)
1356 goto detach_frontend
;
1358 case SAA7134_BOARD_HAUPPAUGE_HVR1150
:
1359 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1360 &hcw_lgdt3305_config
,
1362 if (fe0
->dvb
.frontend
) {
1363 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1364 &dev
->i2c_adap
, 0x4b,
1366 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1367 0x60, &dev
->i2c_adap
,
1368 &hcw_tda18271_config
);
1371 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
1372 if (configure_tda827x_fe(dev
, &asus_p7131_dual_config
,
1373 &tda827x_cfg_0
) < 0)
1374 goto detach_frontend
;
1376 case SAA7134_BOARD_FLYDVBT_LR301
:
1377 if (configure_tda827x_fe(dev
, &tda827x_lifeview_config
,
1378 &tda827x_cfg_0
) < 0)
1379 goto detach_frontend
;
1381 case SAA7134_BOARD_FLYDVB_TRIO
:
1382 if (!use_frontend
) { /* terrestrial */
1383 if (configure_tda827x_fe(dev
, &lifeview_trio_config
,
1384 &tda827x_cfg_0
) < 0)
1385 goto detach_frontend
;
1386 } else { /* satellite */
1387 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
, &dev
->i2c_adap
);
1388 if (fe0
->dvb
.frontend
) {
1389 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x63,
1390 &dev
->i2c_adap
, 0) == NULL
) {
1391 pr_warn("%s: Lifeview Trio, No tda826x found!\n", __func__
);
1392 goto detach_frontend
;
1394 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1396 0x08, 0, 0, false) == NULL
) {
1397 pr_warn("%s: Lifeview Trio, No ISL6421 found!\n", __func__
);
1398 goto detach_frontend
;
1403 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331
:
1404 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS
:
1405 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1406 &ads_tech_duo_config
,
1408 if (fe0
->dvb
.frontend
) {
1409 if (dvb_attach(tda827x_attach
,fe0
->dvb
.frontend
,
1410 ads_tech_duo_config
.tuner_address
, &dev
->i2c_adap
,
1411 &ads_duo_cfg
) == NULL
) {
1412 pr_warn("no tda827x tuner found at addr: %02x\n",
1413 ads_tech_duo_config
.tuner_address
);
1414 goto detach_frontend
;
1417 pr_warn("failed to attach tda10046\n");
1419 case SAA7134_BOARD_TEVION_DVBT_220RF
:
1420 if (configure_tda827x_fe(dev
, &tevion_dvbt220rf_config
,
1421 &tda827x_cfg_0
) < 0)
1422 goto detach_frontend
;
1424 case SAA7134_BOARD_MEDION_MD8800_QUADRO
:
1425 if (!use_frontend
) { /* terrestrial */
1426 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1427 &tda827x_cfg_0
) < 0)
1428 goto detach_frontend
;
1429 } else { /* satellite */
1430 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1431 &flydvbs
, &dev
->i2c_adap
);
1432 if (fe0
->dvb
.frontend
) {
1433 struct dvb_frontend
*fe
= fe0
->dvb
.frontend
;
1434 u8 dev_id
= dev
->eedata
[2];
1436 struct i2c_msg msg
= {.addr
= 0x08, .flags
= 0, .len
= 1};
1438 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
,
1439 0x60, &dev
->i2c_adap
, 0) == NULL
) {
1440 pr_warn("%s: Medion Quadro, no tda826x "
1441 "found !\n", __func__
);
1442 goto detach_frontend
;
1444 if (dev_id
!= 0x08) {
1445 /* we need to open the i2c gate (we know it exists) */
1446 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1447 if (dvb_attach(isl6405_attach
, fe
,
1448 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1449 pr_warn("%s: Medion Quadro, no ISL6405 "
1450 "found !\n", __func__
);
1451 goto detach_frontend
;
1453 if (dev_id
== 0x07) {
1454 /* fire up the 2nd section of the LNB supply since
1455 we can't do this from the other section */
1457 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1459 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1460 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1461 fe
->ops
.set_voltage
= md8800_set_voltage
;
1462 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1463 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1465 fe
->ops
.set_voltage
= md8800_set_voltage2
;
1466 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage2
;
1471 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
1472 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &avertvhda180
,
1474 if (fe0
->dvb
.frontend
)
1475 dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x61,
1476 NULL
, DVB_PLL_TDHU2
);
1478 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI
:
1479 case SAA7134_BOARD_KWORLD_ATSC110
:
1480 fe0
->dvb
.frontend
= dvb_attach(nxt200x_attach
, &kworldatsc110
,
1482 if (fe0
->dvb
.frontend
)
1483 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1484 &dev
->i2c_adap
, 0x61,
1485 TUNER_PHILIPS_TUV1236D
);
1487 case SAA7134_BOARD_KWORLD_PC150U
:
1488 saa7134_set_gpio(dev
, 18, 1); /* Switch to digital mode */
1489 saa7134_tuner_callback(dev
, 0,
1490 TDA18271_CALLBACK_CMD_AGC_ENABLE
, 1);
1491 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1492 &kworld_s5h1411_config
,
1494 if (fe0
->dvb
.frontend
!= NULL
) {
1495 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1496 &dev
->i2c_adap
, 0x4b,
1498 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1499 0x60, &dev
->i2c_adap
,
1500 &kworld_pc150u_tda18271_config
);
1503 case SAA7134_BOARD_FLYDVBS_LR300
:
1504 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1506 if (fe0
->dvb
.frontend
) {
1507 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1508 &dev
->i2c_adap
, 0) == NULL
) {
1509 pr_warn("%s: No tda826x found!\n", __func__
);
1510 goto detach_frontend
;
1512 if (dvb_attach(isl6421_attach
, fe0
->dvb
.frontend
,
1514 0x08, 0, 0, false) == NULL
) {
1515 pr_warn("%s: No ISL6421 found!\n", __func__
);
1516 goto detach_frontend
;
1520 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID
:
1521 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1524 if (fe0
->dvb
.frontend
) {
1525 dev
->original_demod_sleep
= fe0
->dvb
.frontend
->ops
.sleep
;
1526 fe0
->dvb
.frontend
->ops
.sleep
= philips_europa_demod_sleep
;
1528 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1529 &dev
->i2c_adap
, medion_cardbus
.tuner_address
,
1530 TUNER_PHILIPS_FMD1216ME_MK3
);
1533 case SAA7134_BOARD_VIDEOMATE_DVBT_200A
:
1534 fe0
->dvb
.frontend
= dvb_attach(tda10046_attach
,
1535 &philips_europa_config
,
1537 if (fe0
->dvb
.frontend
) {
1538 fe0
->dvb
.frontend
->ops
.tuner_ops
.init
= philips_td1316_tuner_init
;
1539 fe0
->dvb
.frontend
->ops
.tuner_ops
.set_params
= philips_td1316_tuner_set_params
;
1542 case SAA7134_BOARD_CINERGY_HT_PCMCIA
:
1543 if (configure_tda827x_fe(dev
, &cinergy_ht_config
,
1544 &tda827x_cfg_0
) < 0)
1545 goto detach_frontend
;
1547 case SAA7134_BOARD_CINERGY_HT_PCI
:
1548 if (configure_tda827x_fe(dev
, &cinergy_ht_pci_config
,
1549 &tda827x_cfg_0
) < 0)
1550 goto detach_frontend
;
1552 case SAA7134_BOARD_PHILIPS_TIGER_S
:
1553 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1554 &tda827x_cfg_2
) < 0)
1555 goto detach_frontend
;
1557 case SAA7134_BOARD_ASUS_P7131_4871
:
1558 if (configure_tda827x_fe(dev
, &asus_p7131_4871_config
,
1559 &tda827x_cfg_2
) < 0)
1560 goto detach_frontend
;
1562 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
1563 if (configure_tda827x_fe(dev
, &asus_p7131_hybrid_lna_config
,
1564 &tda827x_cfg_2
) < 0)
1565 goto detach_frontend
;
1567 case SAA7134_BOARD_AVERMEDIA_SUPER_007
:
1568 if (configure_tda827x_fe(dev
, &avermedia_super_007_config
,
1569 &tda827x_cfg_0
) < 0)
1570 goto detach_frontend
;
1572 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056
:
1573 if (configure_tda827x_fe(dev
, &twinhan_dtv_dvb_3056_config
,
1574 &tda827x_cfg_2_sw42
) < 0)
1575 goto detach_frontend
;
1577 case SAA7134_BOARD_PHILIPS_SNAKE
:
1578 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
, &flydvbs
,
1580 if (fe0
->dvb
.frontend
) {
1581 if (dvb_attach(tda826x_attach
, fe0
->dvb
.frontend
, 0x60,
1582 &dev
->i2c_adap
, 0) == NULL
) {
1583 pr_warn("%s: No tda826x found!\n", __func__
);
1584 goto detach_frontend
;
1586 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1587 &dev
->i2c_adap
, 0, 0) == NULL
) {
1588 pr_warn("%s: No lnbp21 found!\n", __func__
);
1589 goto detach_frontend
;
1593 case SAA7134_BOARD_CREATIX_CTX953
:
1594 if (configure_tda827x_fe(dev
, &md8800_dvbt_config
,
1595 &tda827x_cfg_0
) < 0)
1596 goto detach_frontend
;
1598 case SAA7134_BOARD_MSI_TVANYWHERE_AD11
:
1599 if (configure_tda827x_fe(dev
, &philips_tiger_s_config
,
1600 &tda827x_cfg_2
) < 0)
1601 goto detach_frontend
;
1603 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
1604 pr_debug("AverMedia E506R dvb setup\n");
1605 saa7134_set_gpio(dev
, 25, 0);
1607 saa7134_set_gpio(dev
, 25, 1);
1608 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1609 &avermedia_xc3028_mt352_dev
,
1613 case SAA7134_BOARD_MD7134_BRIDGE_2
:
1614 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1615 &sd1878_4m
, &dev
->i2c_adap
);
1616 if (fe0
->dvb
.frontend
) {
1617 struct dvb_frontend
*fe
;
1618 if (dvb_attach(dvb_pll_attach
, fe0
->dvb
.frontend
, 0x60,
1619 &dev
->i2c_adap
, DVB_PLL_PHILIPS_SD1878_TDA8261
) == NULL
) {
1620 pr_warn("%s: MD7134 DVB-S, no SD1878 "
1621 "found !\n", __func__
);
1622 goto detach_frontend
;
1624 /* we need to open the i2c gate (we know it exists) */
1625 fe
= fe0
->dvb
.frontend
;
1626 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1627 if (dvb_attach(isl6405_attach
, fe
,
1628 &dev
->i2c_adap
, 0x08, 0, 0) == NULL
) {
1629 pr_warn("%s: MD7134 DVB-S, no ISL6405 "
1630 "found !\n", __func__
);
1631 goto detach_frontend
;
1633 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1634 dev
->original_set_voltage
= fe
->ops
.set_voltage
;
1635 fe
->ops
.set_voltage
= md8800_set_voltage
;
1636 dev
->original_set_high_voltage
= fe
->ops
.enable_high_lnb_voltage
;
1637 fe
->ops
.enable_high_lnb_voltage
= md8800_set_high_voltage
;
1640 case SAA7134_BOARD_AVERMEDIA_M103
:
1641 saa7134_set_gpio(dev
, 25, 0);
1643 saa7134_set_gpio(dev
, 25, 1);
1644 fe0
->dvb
.frontend
= dvb_attach(mt352_attach
,
1645 &avermedia_xc3028_mt352_dev
,
1649 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1
:
1650 if (!use_frontend
) { /* terrestrial */
1651 if (configure_tda827x_fe(dev
, &asus_tiger_3in1_config
,
1652 &tda827x_cfg_2
) < 0)
1653 goto detach_frontend
;
1654 } else { /* satellite */
1655 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1656 &flydvbs
, &dev
->i2c_adap
);
1657 if (fe0
->dvb
.frontend
) {
1658 if (dvb_attach(tda826x_attach
,
1659 fe0
->dvb
.frontend
, 0x60,
1660 &dev
->i2c_adap
, 0) == NULL
) {
1661 pr_warn("%s: Asus Tiger 3in1, no "
1662 "tda826x found!\n", __func__
);
1663 goto detach_frontend
;
1665 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1666 &dev
->i2c_adap
, 0, 0) == NULL
) {
1667 pr_warn("%s: Asus Tiger 3in1, no lnbp21"
1668 " found!\n", __func__
);
1669 goto detach_frontend
;
1674 case SAA7134_BOARD_ASUSTeK_PS3_100
:
1675 if (!use_frontend
) { /* terrestrial */
1676 if (configure_tda827x_fe(dev
, &asus_ps3_100_config
,
1677 &tda827x_cfg_2
) < 0)
1678 goto detach_frontend
;
1679 } else { /* satellite */
1680 fe0
->dvb
.frontend
= dvb_attach(tda10086_attach
,
1681 &flydvbs
, &dev
->i2c_adap
);
1682 if (fe0
->dvb
.frontend
) {
1683 if (dvb_attach(tda826x_attach
,
1684 fe0
->dvb
.frontend
, 0x60,
1685 &dev
->i2c_adap
, 0) == NULL
) {
1686 pr_warn("%s: Asus My Cinema PS3-100, no "
1687 "tda826x found!\n", __func__
);
1688 goto detach_frontend
;
1690 if (dvb_attach(lnbp21_attach
, fe0
->dvb
.frontend
,
1691 &dev
->i2c_adap
, 0, 0) == NULL
) {
1692 pr_warn("%s: Asus My Cinema PS3-100, no lnbp21"
1693 " found!\n", __func__
);
1694 goto detach_frontend
;
1699 case SAA7134_BOARD_ASUSTeK_TIGER
:
1700 if (configure_tda827x_fe(dev
, &philips_tiger_config
,
1701 &tda827x_cfg_0
) < 0)
1702 goto detach_frontend
;
1704 case SAA7134_BOARD_BEHOLD_H6
:
1705 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1708 if (fe0
->dvb
.frontend
) {
1709 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1710 &dev
->i2c_adap
, 0x61,
1711 TUNER_PHILIPS_FMD1216MEX_MK3
);
1714 case SAA7134_BOARD_BEHOLD_X7
:
1715 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1718 if (fe0
->dvb
.frontend
) {
1719 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1720 &dev
->i2c_adap
, &behold_x7_tunerconfig
);
1723 case SAA7134_BOARD_BEHOLD_H7
:
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_AVERMEDIA_A700_PRO
:
1733 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID
:
1734 /* Zarlink ZL10313 */
1735 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1736 &avertv_a700_mt312
, &dev
->i2c_adap
);
1737 if (fe0
->dvb
.frontend
) {
1738 if (dvb_attach(zl10036_attach
, fe0
->dvb
.frontend
,
1739 &avertv_a700_tuner
, &dev
->i2c_adap
) == NULL
) {
1740 pr_warn("%s: No zl10036 found!\n",
1745 case SAA7134_BOARD_VIDEOMATE_S350
:
1746 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1747 &zl10313_compro_s350_config
, &dev
->i2c_adap
);
1748 if (fe0
->dvb
.frontend
)
1749 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1750 0x60, &dev
->i2c_adap
) == NULL
)
1751 pr_warn("%s: No zl10039 found!\n",
1755 case SAA7134_BOARD_VIDEOMATE_T750
:
1756 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1757 &videomate_t750_zl10353_config
,
1759 if (fe0
->dvb
.frontend
!= NULL
) {
1760 if (dvb_attach(qt1010_attach
,
1763 &videomate_t750_qt1010_config
) == NULL
)
1764 pr_warn("error attaching QT1010\n");
1767 case SAA7134_BOARD_ZOLID_HYBRID_PCI
:
1768 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1769 &zolid_tda10048_config
,
1771 if (fe0
->dvb
.frontend
!= NULL
) {
1772 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1773 &dev
->i2c_adap
, 0x4b,
1775 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1776 0x60, &dev
->i2c_adap
,
1777 &zolid_tda18271_config
);
1780 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S
:
1781 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1782 &dtv1000s_tda10048_config
,
1784 if (fe0
->dvb
.frontend
!= NULL
) {
1785 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1786 &dev
->i2c_adap
, 0x4b,
1788 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1789 0x60, &dev
->i2c_adap
,
1790 &dtv1000s_tda18271_config
);
1793 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG
:
1794 /* Switch to digital mode */
1795 saa7134_tuner_callback(dev
, 0,
1796 TDA18271_CALLBACK_CMD_AGC_ENABLE
, 1);
1797 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1798 &kworld_mb86a20s_config
,
1800 if (fe0
->dvb
.frontend
!= NULL
) {
1801 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1802 &dev
->i2c_adap
, 0x4b,
1804 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= kworld_sbtvd_gate_ctrl
;
1805 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1806 0x60, &dev
->i2c_adap
,
1807 &kworld_tda18271_config
);
1810 /* mb86a20s need to use the I2C gateway */
1812 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2
:
1813 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1814 &prohdtv_pro2_lgs8g75_config
,
1816 if (fe0
->dvb
.frontend
!= NULL
) {
1817 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1818 &dev
->i2c_adap
, 0x4b,
1820 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1821 0x60, &dev
->i2c_adap
,
1822 &prohdtv_pro2_tda18271_config
);
1825 case SAA7134_BOARD_AVERMEDIA_A706
:
1826 /* Enable all DVB-S devices now */
1827 /* CE5039 DVB-S tuner SLEEP pin low */
1828 saa7134_set_gpio(dev
, 23, 0);
1829 /* CE6313 DVB-S demod SLEEP pin low */
1830 saa7134_set_gpio(dev
, 9, 0);
1831 /* CE6313 DVB-S demod RESET# pin high */
1832 saa7134_set_gpio(dev
, 25, 1);
1834 fe0
->dvb
.frontend
= dvb_attach(mt312_attach
,
1835 &zl10313_avermedia_a706_config
, &dev
->i2c_adap
);
1836 if (fe0
->dvb
.frontend
) {
1837 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1838 if (dvb_attach(zl10039_attach
, fe0
->dvb
.frontend
,
1839 0x60, &dev
->i2c_adap
) == NULL
)
1840 pr_warn("%s: No zl10039 found!\n",
1845 pr_warn("Huh? unknown DVB card?\n");
1849 if (attach_xc3028
) {
1850 struct dvb_frontend
*fe
;
1851 struct xc2028_config cfg
= {
1852 .i2c_adap
= &dev
->i2c_adap
,
1856 if (!fe0
->dvb
.frontend
)
1857 goto detach_frontend
;
1859 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
, &cfg
);
1861 pr_err("%s/2: xc3028 attach failed\n",
1863 goto detach_frontend
;
1867 if (NULL
== fe0
->dvb
.frontend
) {
1868 pr_err("%s/dvb: frontend initialization failed\n", dev
->name
);
1869 goto detach_frontend
;
1871 /* define general-purpose callback pointer */
1872 fe0
->dvb
.frontend
->callback
= saa7134_tuner_callback
;
1874 /* register everything else */
1875 ret
= vb2_dvb_register_bus(&dev
->frontends
, THIS_MODULE
, dev
,
1876 &dev
->pci
->dev
, adapter_nr
, 0);
1878 /* this sequence is necessary to make the tda1004x load its firmware
1879 * and to enter analog mode of hybrid boards
1882 if (fe0
->dvb
.frontend
->ops
.init
)
1883 fe0
->dvb
.frontend
->ops
.init(fe0
->dvb
.frontend
);
1884 if (fe0
->dvb
.frontend
->ops
.sleep
)
1885 fe0
->dvb
.frontend
->ops
.sleep(fe0
->dvb
.frontend
);
1886 if (fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep
)
1887 fe0
->dvb
.frontend
->ops
.tuner_ops
.sleep(fe0
->dvb
.frontend
);
1892 vb2_dvb_dealloc_frontends(&dev
->frontends
);
1893 vb2_queue_release(&fe0
->dvb
.dvbq
);
1897 static int dvb_fini(struct saa7134_dev
*dev
)
1899 struct vb2_dvb_frontend
*fe0
;
1901 /* Get the first frontend */
1902 fe0
= vb2_dvb_get_frontend(&dev
->frontends
, 1);
1906 /* FIXME: I suspect that this code is bogus, since the entry for
1907 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1908 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1910 if (dev
->board
== SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
) {
1911 struct v4l2_priv_tun_config tda9887_cfg
;
1912 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
1914 tda9887_cfg
.tuner
= TUNER_TDA9887
;
1915 tda9887_cfg
.priv
= &on
;
1917 /* otherwise we don't detect the tuner on next insmod */
1918 saa_call_all(dev
, tuner
, s_config
, &tda9887_cfg
);
1919 } else if (dev
->board
== SAA7134_BOARD_MEDION_MD8800_QUADRO
) {
1920 if ((dev
->eedata
[2] == 0x07) && use_frontend
) {
1921 /* turn off the 2nd lnb supply */
1923 struct i2c_msg msg
= {.addr
= 0x08, .buf
= &data
, .flags
= 0, .len
= 1};
1924 struct dvb_frontend
*fe
;
1925 fe
= fe0
->dvb
.frontend
;
1926 if (fe
->ops
.i2c_gate_ctrl
) {
1927 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1928 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
1929 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1933 vb2_dvb_unregister_bus(&dev
->frontends
);
1934 vb2_queue_release(&fe0
->dvb
.dvbq
);
1938 static struct saa7134_mpeg_ops dvb_ops
= {
1939 .type
= SAA7134_MPEG_DVB
,
1944 static int __init
dvb_register(void)
1946 return saa7134_ts_register(&dvb_ops
);
1949 static void __exit
dvb_unregister(void)
1951 saa7134_ts_unregister(&dvb_ops
);
1954 module_init(dvb_register
);
1955 module_exit(dvb_unregister
);