• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/media/video/saa7134/
1/*
2 *
3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
4 *
5 *  Extended 3 / 2005 by Hartmut Hackmann to support various
6 *  cards with the tda10046 DVB-T channel decoder
7 *
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.
12 *
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.
17 *
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.
21 */
22
23#include <linux/init.h>
24#include <linux/list.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/delay.h>
28#include <linux/kthread.h>
29#include <linux/suspend.h>
30
31#include "saa7134-reg.h"
32#include "saa7134.h"
33#include <media/v4l2-common.h>
34#include "dvb-pll.h"
35#include <dvb_frontend.h>
36
37#include "mt352.h"
38#include "mt352_priv.h"
39#include "tda1004x.h"
40#include "nxt200x.h"
41#include "tuner-xc2028.h"
42#include "xc5000.h"
43
44#include "tda10086.h"
45#include "tda826x.h"
46#include "tda827x.h"
47#include "isl6421.h"
48#include "isl6405.h"
49#include "lnbp21.h"
50#include "tuner-simple.h"
51#include "tda10048.h"
52#include "tda18271.h"
53#include "lgdt3305.h"
54#include "tda8290.h"
55
56#include "zl10353.h"
57
58#include "zl10036.h"
59#include "zl10039.h"
60#include "mt312.h"
61
62MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
63MODULE_LICENSE("GPL");
64
65static unsigned int antenna_pwr;
66
67module_param(antenna_pwr, int, 0444);
68MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
69
70static int use_frontend;
71module_param(use_frontend, int, 0644);
72MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
73
74static int debug;
75module_param(debug, int, 0644);
76MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
77
78DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
79
80#define dprintk(fmt, arg...)	do { if (debug) \
81	printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
82
83/* Print a warning */
84#define wprintk(fmt, arg...) \
85	printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
86
87/* ------------------------------------------------------------------
88 * mt352 based DVB-T cards
89 */
90
91static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
92{
93	u32 ok;
94
95	if (!on) {
96		saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
97		saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
98		return 0;
99	}
100
101	saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
102	saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
103	udelay(10);
104
105	saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 28));
106	saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
107	udelay(10);
108	saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 28));
109	udelay(10);
110	ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
111	dprintk("%s %s\n", __func__, ok ? "on" : "off");
112
113	if (!ok)
114		saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
115	return ok;
116}
117
118static int mt352_pinnacle_init(struct dvb_frontend* fe)
119{
120	static u8 clock_config []  = { CLOCK_CTL,  0x3d, 0x28 };
121	static u8 reset []         = { RESET,      0x80 };
122	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
123	static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
124	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
125	static u8 fsm_ctl_cfg[]    = { 0x7b,       0x04 };
126	static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x0f };
127	static u8 scan_ctl_cfg []  = { SCAN_CTL,   0x0d };
128	static u8 irq_cfg []       = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
129	struct saa7134_dev *dev= fe->dvb->priv;
130
131	dprintk("%s called\n", __func__);
132
133	mt352_write(fe, clock_config,   sizeof(clock_config));
134	udelay(200);
135	mt352_write(fe, reset,          sizeof(reset));
136	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
137	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
138	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
139	mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
140
141	mt352_write(fe, fsm_ctl_cfg,    sizeof(fsm_ctl_cfg));
142	mt352_write(fe, scan_ctl_cfg,   sizeof(scan_ctl_cfg));
143	mt352_write(fe, irq_cfg,        sizeof(irq_cfg));
144
145	return 0;
146}
147
148static int mt352_aver777_init(struct dvb_frontend* fe)
149{
150	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x2d };
151	static u8 reset []         = { RESET,      0x80 };
152	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
153	static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
154	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
155
156	mt352_write(fe, clock_config,   sizeof(clock_config));
157	udelay(200);
158	mt352_write(fe, reset,          sizeof(reset));
159	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
160	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
161	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
162
163	return 0;
164}
165
166static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
167{
168	static u8 clock_config []  = { CLOCK_CTL, 0x38, 0x2d };
169	static u8 reset []         = { RESET, 0x80 };
170	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
171	static u8 agc_cfg []       = { AGC_TARGET, 0xe };
172	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
173
174	mt352_write(fe, clock_config,   sizeof(clock_config));
175	udelay(200);
176	mt352_write(fe, reset,          sizeof(reset));
177	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
178	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
179	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
180	return 0;
181}
182
183static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
184					   struct dvb_frontend_parameters* params)
185{
186	u8 off[] = { 0x00, 0xf1};
187	u8 on[]  = { 0x00, 0x71};
188	struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
189
190	struct saa7134_dev *dev = fe->dvb->priv;
191	struct v4l2_frequency f;
192
193	/* set frequency (mt2050) */
194	f.tuner     = 0;
195	f.type      = V4L2_TUNER_DIGITAL_TV;
196	f.frequency = params->frequency / 1000 * 16 / 1000;
197	if (fe->ops.i2c_gate_ctrl)
198		fe->ops.i2c_gate_ctrl(fe, 1);
199	i2c_transfer(&dev->i2c_adap, &msg, 1);
200	saa_call_all(dev, tuner, s_frequency, &f);
201	msg.buf = on;
202	if (fe->ops.i2c_gate_ctrl)
203		fe->ops.i2c_gate_ctrl(fe, 1);
204	i2c_transfer(&dev->i2c_adap, &msg, 1);
205
206	pinnacle_antenna_pwr(dev, antenna_pwr);
207
208	/* mt352 setup */
209	return mt352_pinnacle_init(fe);
210}
211
212static struct mt352_config pinnacle_300i = {
213	.demod_address = 0x3c >> 1,
214	.adc_clock     = 20333,
215	.if2           = 36150,
216	.no_tuner      = 1,
217	.demod_init    = mt352_pinnacle_init,
218};
219
220static struct mt352_config avermedia_777 = {
221	.demod_address = 0xf,
222	.demod_init    = mt352_aver777_init,
223};
224
225static struct mt352_config avermedia_xc3028_mt352_dev = {
226	.demod_address   = (0x1e >> 1),
227	.no_tuner        = 1,
228	.demod_init      = mt352_avermedia_xc3028_init,
229};
230
231/* ==================================================================
232 * tda1004x based DVB-T cards, helper functions
233 */
234
235static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
236					   const struct firmware **fw, char *name)
237{
238	struct saa7134_dev *dev = fe->dvb->priv;
239	return request_firmware(fw, name, &dev->pci->dev);
240}
241
242/* ------------------------------------------------------------------
243 * these tuners are tu1216, td1316(a)
244 */
245
246static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
247{
248	struct saa7134_dev *dev = fe->dvb->priv;
249	struct tda1004x_state *state = fe->demodulator_priv;
250	u8 addr = state->config->tuner_address;
251	u8 tuner_buf[4];
252	struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
253			sizeof(tuner_buf) };
254	int tuner_frequency = 0;
255	u8 band, cp, filter;
256
257	/* determine charge pump */
258	tuner_frequency = params->frequency + 36166000;
259	if (tuner_frequency < 87000000)
260		return -EINVAL;
261	else if (tuner_frequency < 130000000)
262		cp = 3;
263	else if (tuner_frequency < 160000000)
264		cp = 5;
265	else if (tuner_frequency < 200000000)
266		cp = 6;
267	else if (tuner_frequency < 290000000)
268		cp = 3;
269	else if (tuner_frequency < 420000000)
270		cp = 5;
271	else if (tuner_frequency < 480000000)
272		cp = 6;
273	else if (tuner_frequency < 620000000)
274		cp = 3;
275	else if (tuner_frequency < 830000000)
276		cp = 5;
277	else if (tuner_frequency < 895000000)
278		cp = 7;
279	else
280		return -EINVAL;
281
282	/* determine band */
283	if (params->frequency < 49000000)
284		return -EINVAL;
285	else if (params->frequency < 161000000)
286		band = 1;
287	else if (params->frequency < 444000000)
288		band = 2;
289	else if (params->frequency < 861000000)
290		band = 4;
291	else
292		return -EINVAL;
293
294	/* setup PLL filter */
295	switch (params->u.ofdm.bandwidth) {
296	case BANDWIDTH_6_MHZ:
297		filter = 0;
298		break;
299
300	case BANDWIDTH_7_MHZ:
301		filter = 0;
302		break;
303
304	case BANDWIDTH_8_MHZ:
305		filter = 1;
306		break;
307
308	default:
309		return -EINVAL;
310	}
311
312	/* calculate divisor
313	 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
314	 */
315	tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
316
317	/* setup tuner buffer */
318	tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
319	tuner_buf[1] = tuner_frequency & 0xff;
320	tuner_buf[2] = 0xca;
321	tuner_buf[3] = (cp << 5) | (filter << 3) | band;
322
323	if (fe->ops.i2c_gate_ctrl)
324		fe->ops.i2c_gate_ctrl(fe, 1);
325	if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
326		wprintk("could not write to tuner at addr: 0x%02x\n",
327			addr << 1);
328		return -EIO;
329	}
330	msleep(1);
331	return 0;
332}
333
334static int philips_tu1216_init(struct dvb_frontend *fe)
335{
336	struct saa7134_dev *dev = fe->dvb->priv;
337	struct tda1004x_state *state = fe->demodulator_priv;
338	u8 addr = state->config->tuner_address;
339	static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
340	struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
341
342	/* setup PLL configuration */
343	if (fe->ops.i2c_gate_ctrl)
344		fe->ops.i2c_gate_ctrl(fe, 1);
345	if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
346		return -EIO;
347	msleep(1);
348
349	return 0;
350}
351
352/* ------------------------------------------------------------------ */
353
354static struct tda1004x_config philips_tu1216_60_config = {
355	.demod_address = 0x8,
356	.invert        = 1,
357	.invert_oclk   = 0,
358	.xtal_freq     = TDA10046_XTAL_4M,
359	.agc_config    = TDA10046_AGC_DEFAULT,
360	.if_freq       = TDA10046_FREQ_3617,
361	.tuner_address = 0x60,
362	.request_firmware = philips_tda1004x_request_firmware
363};
364
365static struct tda1004x_config philips_tu1216_61_config = {
366
367	.demod_address = 0x8,
368	.invert        = 1,
369	.invert_oclk   = 0,
370	.xtal_freq     = TDA10046_XTAL_4M,
371	.agc_config    = TDA10046_AGC_DEFAULT,
372	.if_freq       = TDA10046_FREQ_3617,
373	.tuner_address = 0x61,
374	.request_firmware = philips_tda1004x_request_firmware
375};
376
377/* ------------------------------------------------------------------ */
378
379static int philips_td1316_tuner_init(struct dvb_frontend *fe)
380{
381	struct saa7134_dev *dev = fe->dvb->priv;
382	struct tda1004x_state *state = fe->demodulator_priv;
383	u8 addr = state->config->tuner_address;
384	static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
385	struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
386
387	/* setup PLL configuration */
388	if (fe->ops.i2c_gate_ctrl)
389		fe->ops.i2c_gate_ctrl(fe, 1);
390	if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
391		return -EIO;
392	return 0;
393}
394
395static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
396{
397	return philips_tda6651_pll_set(fe, params);
398}
399
400static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
401{
402	struct saa7134_dev *dev = fe->dvb->priv;
403	struct tda1004x_state *state = fe->demodulator_priv;
404	u8 addr = state->config->tuner_address;
405	static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
406	struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
407
408	/* switch the tuner to analog mode */
409	if (fe->ops.i2c_gate_ctrl)
410		fe->ops.i2c_gate_ctrl(fe, 1);
411	if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
412		return -EIO;
413	return 0;
414}
415
416/* ------------------------------------------------------------------ */
417
418static int philips_europa_tuner_init(struct dvb_frontend *fe)
419{
420	struct saa7134_dev *dev = fe->dvb->priv;
421	static u8 msg[] = { 0x00, 0x40};
422	struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
423
424
425	if (philips_td1316_tuner_init(fe))
426		return -EIO;
427	msleep(1);
428	if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
429		return -EIO;
430
431	return 0;
432}
433
434static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
435{
436	struct saa7134_dev *dev = fe->dvb->priv;
437
438	static u8 msg[] = { 0x00, 0x14 };
439	struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
440
441	if (philips_td1316_tuner_sleep(fe))
442		return -EIO;
443
444	/* switch the board to analog mode */
445	if (fe->ops.i2c_gate_ctrl)
446		fe->ops.i2c_gate_ctrl(fe, 1);
447	i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
448	return 0;
449}
450
451static int philips_europa_demod_sleep(struct dvb_frontend *fe)
452{
453	struct saa7134_dev *dev = fe->dvb->priv;
454
455	if (dev->original_demod_sleep)
456		dev->original_demod_sleep(fe);
457	fe->ops.i2c_gate_ctrl(fe, 1);
458	return 0;
459}
460
461static struct tda1004x_config philips_europa_config = {
462
463	.demod_address = 0x8,
464	.invert        = 0,
465	.invert_oclk   = 0,
466	.xtal_freq     = TDA10046_XTAL_4M,
467	.agc_config    = TDA10046_AGC_IFO_AUTO_POS,
468	.if_freq       = TDA10046_FREQ_052,
469	.tuner_address = 0x61,
470	.request_firmware = philips_tda1004x_request_firmware
471};
472
473static struct tda1004x_config medion_cardbus = {
474	.demod_address = 0x08,
475	.invert        = 1,
476	.invert_oclk   = 0,
477	.xtal_freq     = TDA10046_XTAL_16M,
478	.agc_config    = TDA10046_AGC_IFO_AUTO_NEG,
479	.if_freq       = TDA10046_FREQ_3613,
480	.tuner_address = 0x61,
481	.request_firmware = philips_tda1004x_request_firmware
482};
483
484static struct tda1004x_config technotrend_budget_t3000_config = {
485	.demod_address = 0x8,
486	.invert        = 1,
487	.invert_oclk   = 0,
488	.xtal_freq     = TDA10046_XTAL_4M,
489	.agc_config    = TDA10046_AGC_DEFAULT,
490	.if_freq       = TDA10046_FREQ_3617,
491	.tuner_address = 0x63,
492	.request_firmware = philips_tda1004x_request_firmware
493};
494
495/* ------------------------------------------------------------------
496 * tda 1004x based cards with philips silicon tuner
497 */
498
499static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
500{
501	struct tda1004x_state *state = fe->demodulator_priv;
502
503	u8 addr = state->config->i2c_gate;
504	static u8 tda8290_close[] = { 0x21, 0xc0};
505	static u8 tda8290_open[]  = { 0x21, 0x80};
506	struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
507	if (enable) {
508		tda8290_msg.buf = tda8290_close;
509	} else {
510		tda8290_msg.buf = tda8290_open;
511	}
512	if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
513		struct saa7134_dev *dev = fe->dvb->priv;
514		wprintk("could not access tda8290 I2C gate\n");
515		return -EIO;
516	}
517	msleep(20);
518	return 0;
519}
520
521static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
522{
523	struct saa7134_dev *dev = fe->dvb->priv;
524	struct tda1004x_state *state = fe->demodulator_priv;
525
526	switch (state->config->antenna_switch) {
527	case 0: break;
528	case 1:	dprintk("setting GPIO21 to 0 (TV antenna?)\n");
529		saa7134_set_gpio(dev, 21, 0);
530		break;
531	case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
532		saa7134_set_gpio(dev, 21, 1);
533		break;
534	}
535	return 0;
536}
537
538static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
539{
540	struct saa7134_dev *dev = fe->dvb->priv;
541	struct tda1004x_state *state = fe->demodulator_priv;
542
543	switch (state->config->antenna_switch) {
544	case 0: break;
545	case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
546		saa7134_set_gpio(dev, 21, 1);
547		break;
548	case 2:	dprintk("setting GPIO21 to 0 (TV antenna?)\n");
549		saa7134_set_gpio(dev, 21, 0);
550		break;
551	}
552	return 0;
553}
554
555static int configure_tda827x_fe(struct saa7134_dev *dev,
556				struct tda1004x_config *cdec_conf,
557				struct tda827x_config *tuner_conf)
558{
559	struct videobuf_dvb_frontend *fe0;
560
561	/* Get the first frontend */
562	fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
563
564	fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
565	if (fe0->dvb.frontend) {
566		if (cdec_conf->i2c_gate)
567			fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
568		if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
569			       cdec_conf->tuner_address,
570			       &dev->i2c_adap, tuner_conf))
571			return 0;
572
573		wprintk("no tda827x tuner found at addr: %02x\n",
574				cdec_conf->tuner_address);
575	}
576	return -EINVAL;
577}
578
579/* ------------------------------------------------------------------ */
580
581static struct tda827x_config tda827x_cfg_0 = {
582	.init = philips_tda827x_tuner_init,
583	.sleep = philips_tda827x_tuner_sleep,
584	.config = 0,
585	.switch_addr = 0
586};
587
588static struct tda827x_config tda827x_cfg_1 = {
589	.init = philips_tda827x_tuner_init,
590	.sleep = philips_tda827x_tuner_sleep,
591	.config = 1,
592	.switch_addr = 0x4b
593};
594
595static struct tda827x_config tda827x_cfg_2 = {
596	.init = philips_tda827x_tuner_init,
597	.sleep = philips_tda827x_tuner_sleep,
598	.config = 2,
599	.switch_addr = 0x4b
600};
601
602static struct tda827x_config tda827x_cfg_2_sw42 = {
603	.init = philips_tda827x_tuner_init,
604	.sleep = philips_tda827x_tuner_sleep,
605	.config = 2,
606	.switch_addr = 0x42
607};
608
609/* ------------------------------------------------------------------ */
610
611static struct tda1004x_config tda827x_lifeview_config = {
612	.demod_address = 0x08,
613	.invert        = 1,
614	.invert_oclk   = 0,
615	.xtal_freq     = TDA10046_XTAL_16M,
616	.agc_config    = TDA10046_AGC_TDA827X,
617	.gpio_config   = TDA10046_GP11_I,
618	.if_freq       = TDA10046_FREQ_045,
619	.tuner_address = 0x60,
620	.request_firmware = philips_tda1004x_request_firmware
621};
622
623static struct tda1004x_config philips_tiger_config = {
624	.demod_address = 0x08,
625	.invert        = 1,
626	.invert_oclk   = 0,
627	.xtal_freq     = TDA10046_XTAL_16M,
628	.agc_config    = TDA10046_AGC_TDA827X,
629	.gpio_config   = TDA10046_GP11_I,
630	.if_freq       = TDA10046_FREQ_045,
631	.i2c_gate      = 0x4b,
632	.tuner_address = 0x61,
633	.antenna_switch= 1,
634	.request_firmware = philips_tda1004x_request_firmware
635};
636
637static struct tda1004x_config cinergy_ht_config = {
638	.demod_address = 0x08,
639	.invert        = 1,
640	.invert_oclk   = 0,
641	.xtal_freq     = TDA10046_XTAL_16M,
642	.agc_config    = TDA10046_AGC_TDA827X,
643	.gpio_config   = TDA10046_GP01_I,
644	.if_freq       = TDA10046_FREQ_045,
645	.i2c_gate      = 0x4b,
646	.tuner_address = 0x61,
647	.request_firmware = philips_tda1004x_request_firmware
648};
649
650static struct tda1004x_config cinergy_ht_pci_config = {
651	.demod_address = 0x08,
652	.invert        = 1,
653	.invert_oclk   = 0,
654	.xtal_freq     = TDA10046_XTAL_16M,
655	.agc_config    = TDA10046_AGC_TDA827X,
656	.gpio_config   = TDA10046_GP01_I,
657	.if_freq       = TDA10046_FREQ_045,
658	.i2c_gate      = 0x4b,
659	.tuner_address = 0x60,
660	.request_firmware = philips_tda1004x_request_firmware
661};
662
663static struct tda1004x_config philips_tiger_s_config = {
664	.demod_address = 0x08,
665	.invert        = 1,
666	.invert_oclk   = 0,
667	.xtal_freq     = TDA10046_XTAL_16M,
668	.agc_config    = TDA10046_AGC_TDA827X,
669	.gpio_config   = TDA10046_GP01_I,
670	.if_freq       = TDA10046_FREQ_045,
671	.i2c_gate      = 0x4b,
672	.tuner_address = 0x61,
673	.antenna_switch= 1,
674	.request_firmware = philips_tda1004x_request_firmware
675};
676
677static struct tda1004x_config pinnacle_pctv_310i_config = {
678	.demod_address = 0x08,
679	.invert        = 1,
680	.invert_oclk   = 0,
681	.xtal_freq     = TDA10046_XTAL_16M,
682	.agc_config    = TDA10046_AGC_TDA827X,
683	.gpio_config   = TDA10046_GP11_I,
684	.if_freq       = TDA10046_FREQ_045,
685	.i2c_gate      = 0x4b,
686	.tuner_address = 0x61,
687	.request_firmware = philips_tda1004x_request_firmware
688};
689
690static struct tda1004x_config hauppauge_hvr_1110_config = {
691	.demod_address = 0x08,
692	.invert        = 1,
693	.invert_oclk   = 0,
694	.xtal_freq     = TDA10046_XTAL_16M,
695	.agc_config    = TDA10046_AGC_TDA827X,
696	.gpio_config   = TDA10046_GP11_I,
697	.if_freq       = TDA10046_FREQ_045,
698	.i2c_gate      = 0x4b,
699	.tuner_address = 0x61,
700	.request_firmware = philips_tda1004x_request_firmware
701};
702
703static struct tda1004x_config asus_p7131_dual_config = {
704	.demod_address = 0x08,
705	.invert        = 1,
706	.invert_oclk   = 0,
707	.xtal_freq     = TDA10046_XTAL_16M,
708	.agc_config    = TDA10046_AGC_TDA827X,
709	.gpio_config   = TDA10046_GP11_I,
710	.if_freq       = TDA10046_FREQ_045,
711	.i2c_gate      = 0x4b,
712	.tuner_address = 0x61,
713	.antenna_switch= 2,
714	.request_firmware = philips_tda1004x_request_firmware
715};
716
717static struct tda1004x_config lifeview_trio_config = {
718	.demod_address = 0x09,
719	.invert        = 1,
720	.invert_oclk   = 0,
721	.xtal_freq     = TDA10046_XTAL_16M,
722	.agc_config    = TDA10046_AGC_TDA827X,
723	.gpio_config   = TDA10046_GP00_I,
724	.if_freq       = TDA10046_FREQ_045,
725	.tuner_address = 0x60,
726	.request_firmware = philips_tda1004x_request_firmware
727};
728
729static struct tda1004x_config tevion_dvbt220rf_config = {
730	.demod_address = 0x08,
731	.invert        = 1,
732	.invert_oclk   = 0,
733	.xtal_freq     = TDA10046_XTAL_16M,
734	.agc_config    = TDA10046_AGC_TDA827X,
735	.gpio_config   = TDA10046_GP11_I,
736	.if_freq       = TDA10046_FREQ_045,
737	.tuner_address = 0x60,
738	.request_firmware = philips_tda1004x_request_firmware
739};
740
741static struct tda1004x_config md8800_dvbt_config = {
742	.demod_address = 0x08,
743	.invert        = 1,
744	.invert_oclk   = 0,
745	.xtal_freq     = TDA10046_XTAL_16M,
746	.agc_config    = TDA10046_AGC_TDA827X,
747	.gpio_config   = TDA10046_GP01_I,
748	.if_freq       = TDA10046_FREQ_045,
749	.i2c_gate      = 0x4b,
750	.tuner_address = 0x60,
751	.request_firmware = philips_tda1004x_request_firmware
752};
753
754static struct tda1004x_config asus_p7131_4871_config = {
755	.demod_address = 0x08,
756	.invert        = 1,
757	.invert_oclk   = 0,
758	.xtal_freq     = TDA10046_XTAL_16M,
759	.agc_config    = TDA10046_AGC_TDA827X,
760	.gpio_config   = TDA10046_GP01_I,
761	.if_freq       = TDA10046_FREQ_045,
762	.i2c_gate      = 0x4b,
763	.tuner_address = 0x61,
764	.antenna_switch= 2,
765	.request_firmware = philips_tda1004x_request_firmware
766};
767
768static struct tda1004x_config asus_p7131_hybrid_lna_config = {
769	.demod_address = 0x08,
770	.invert        = 1,
771	.invert_oclk   = 0,
772	.xtal_freq     = TDA10046_XTAL_16M,
773	.agc_config    = TDA10046_AGC_TDA827X,
774	.gpio_config   = TDA10046_GP11_I,
775	.if_freq       = TDA10046_FREQ_045,
776	.i2c_gate      = 0x4b,
777	.tuner_address = 0x61,
778	.antenna_switch= 2,
779	.request_firmware = philips_tda1004x_request_firmware
780};
781
782static struct tda1004x_config kworld_dvb_t_210_config = {
783	.demod_address = 0x08,
784	.invert        = 1,
785	.invert_oclk   = 0,
786	.xtal_freq     = TDA10046_XTAL_16M,
787	.agc_config    = TDA10046_AGC_TDA827X,
788	.gpio_config   = TDA10046_GP11_I,
789	.if_freq       = TDA10046_FREQ_045,
790	.i2c_gate      = 0x4b,
791	.tuner_address = 0x61,
792	.antenna_switch= 1,
793	.request_firmware = philips_tda1004x_request_firmware
794};
795
796static struct tda1004x_config avermedia_super_007_config = {
797	.demod_address = 0x08,
798	.invert        = 1,
799	.invert_oclk   = 0,
800	.xtal_freq     = TDA10046_XTAL_16M,
801	.agc_config    = TDA10046_AGC_TDA827X,
802	.gpio_config   = TDA10046_GP01_I,
803	.if_freq       = TDA10046_FREQ_045,
804	.i2c_gate      = 0x4b,
805	.tuner_address = 0x60,
806	.antenna_switch= 1,
807	.request_firmware = philips_tda1004x_request_firmware
808};
809
810static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
811	.demod_address = 0x08,
812	.invert        = 1,
813	.invert_oclk   = 0,
814	.xtal_freq     = TDA10046_XTAL_16M,
815	.agc_config    = TDA10046_AGC_TDA827X,
816	.gpio_config   = TDA10046_GP01_I,
817	.if_freq       = TDA10046_FREQ_045,
818	.i2c_gate      = 0x42,
819	.tuner_address = 0x61,
820	.antenna_switch = 1,
821	.request_firmware = philips_tda1004x_request_firmware
822};
823
824static struct tda1004x_config asus_tiger_3in1_config = {
825	.demod_address = 0x0b,
826	.invert        = 1,
827	.invert_oclk   = 0,
828	.xtal_freq     = TDA10046_XTAL_16M,
829	.agc_config    = TDA10046_AGC_TDA827X,
830	.gpio_config   = TDA10046_GP11_I,
831	.if_freq       = TDA10046_FREQ_045,
832	.i2c_gate      = 0x4b,
833	.tuner_address = 0x61,
834	.antenna_switch = 1,
835	.request_firmware = philips_tda1004x_request_firmware
836};
837
838/* ------------------------------------------------------------------
839 * special case: this card uses saa713x GPIO22 for the mode switch
840 */
841
842static int ads_duo_tuner_init(struct dvb_frontend *fe)
843{
844	struct saa7134_dev *dev = fe->dvb->priv;
845	philips_tda827x_tuner_init(fe);
846	/* route TDA8275a AGC input to the channel decoder */
847	saa7134_set_gpio(dev, 22, 1);
848	return 0;
849}
850
851static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
852{
853	struct saa7134_dev *dev = fe->dvb->priv;
854	/* route TDA8275a AGC input to the analog IF chip*/
855	saa7134_set_gpio(dev, 22, 0);
856	philips_tda827x_tuner_sleep(fe);
857	return 0;
858}
859
860static struct tda827x_config ads_duo_cfg = {
861	.init = ads_duo_tuner_init,
862	.sleep = ads_duo_tuner_sleep,
863	.config = 0
864};
865
866static struct tda1004x_config ads_tech_duo_config = {
867	.demod_address = 0x08,
868	.invert        = 1,
869	.invert_oclk   = 0,
870	.xtal_freq     = TDA10046_XTAL_16M,
871	.agc_config    = TDA10046_AGC_TDA827X,
872	.gpio_config   = TDA10046_GP00_I,
873	.if_freq       = TDA10046_FREQ_045,
874	.tuner_address = 0x61,
875	.request_firmware = philips_tda1004x_request_firmware
876};
877
878static struct zl10353_config behold_h6_config = {
879	.demod_address = 0x1e>>1,
880	.no_tuner      = 1,
881	.parallel_ts   = 1,
882	.disable_i2c_gate_ctrl = 1,
883};
884
885static struct xc5000_config behold_x7_tunerconfig = {
886	.i2c_address      = 0xc2>>1,
887	.if_khz           = 4560,
888	.radio_input      = XC5000_RADIO_FM1,
889};
890
891static struct zl10353_config behold_x7_config = {
892	.demod_address = 0x1e>>1,
893	.if2           = 45600,
894	.no_tuner      = 1,
895	.parallel_ts   = 1,
896	.disable_i2c_gate_ctrl = 1,
897};
898
899/* ==================================================================
900 * tda10086 based DVB-S cards, helper functions
901 */
902
903static struct tda10086_config flydvbs = {
904	.demod_address = 0x0e,
905	.invert = 0,
906	.diseqc_tone = 0,
907	.xtal_freq = TDA10086_XTAL_16M,
908};
909
910static struct tda10086_config sd1878_4m = {
911	.demod_address = 0x0e,
912	.invert = 0,
913	.diseqc_tone = 0,
914	.xtal_freq = TDA10086_XTAL_4M,
915};
916
917/* ------------------------------------------------------------------
918 * special case: lnb supply is connected to the gated i2c
919 */
920
921static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
922{
923	int res = -EIO;
924	struct saa7134_dev *dev = fe->dvb->priv;
925	if (fe->ops.i2c_gate_ctrl) {
926		fe->ops.i2c_gate_ctrl(fe, 1);
927		if (dev->original_set_voltage)
928			res = dev->original_set_voltage(fe, voltage);
929		fe->ops.i2c_gate_ctrl(fe, 0);
930	}
931	return res;
932};
933
934static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
935{
936	int res = -EIO;
937	struct saa7134_dev *dev = fe->dvb->priv;
938	if (fe->ops.i2c_gate_ctrl) {
939		fe->ops.i2c_gate_ctrl(fe, 1);
940		if (dev->original_set_high_voltage)
941			res = dev->original_set_high_voltage(fe, arg);
942		fe->ops.i2c_gate_ctrl(fe, 0);
943	}
944	return res;
945};
946
947static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
948{
949	struct saa7134_dev *dev = fe->dvb->priv;
950	u8 wbuf[2] = { 0x1f, 00 };
951	u8 rbuf;
952	struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
953				 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
954
955	if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
956		return -EIO;
957	/* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
958	if (voltage == SEC_VOLTAGE_18)
959		wbuf[1] = rbuf | 0x10;
960	else
961		wbuf[1] = rbuf & 0xef;
962	msg[0].len = 2;
963	i2c_transfer(&dev->i2c_adap, msg, 1);
964	return 0;
965}
966
967static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
968{
969	struct saa7134_dev *dev = fe->dvb->priv;
970	wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
971	return -EIO;
972}
973
974/* ==================================================================
975 * nxt200x based ATSC cards, helper functions
976 */
977
978static struct nxt200x_config avertvhda180 = {
979	.demod_address    = 0x0a,
980};
981
982static struct nxt200x_config kworldatsc110 = {
983	.demod_address    = 0x0a,
984};
985
986/* ------------------------------------------------------------------ */
987
988static struct mt312_config avertv_a700_mt312 = {
989	.demod_address = 0x0e,
990	.voltage_inverted = 1,
991};
992
993static struct zl10036_config avertv_a700_tuner = {
994	.tuner_address = 0x60,
995};
996
997static struct mt312_config zl10313_compro_s350_config = {
998	.demod_address = 0x0e,
999};
1000
1001static struct lgdt3305_config hcw_lgdt3305_config = {
1002	.i2c_addr           = 0x0e,
1003	.mpeg_mode          = LGDT3305_MPEG_SERIAL,
1004	.tpclk_edge         = LGDT3305_TPCLK_RISING_EDGE,
1005	.tpvalid_polarity   = LGDT3305_TP_VALID_HIGH,
1006	.deny_i2c_rptr      = 1,
1007	.spectral_inversion = 1,
1008	.qam_if_khz         = 4000,
1009	.vsb_if_khz         = 3250,
1010};
1011
1012static struct tda10048_config hcw_tda10048_config = {
1013	.demod_address    = 0x10 >> 1,
1014	.output_mode      = TDA10048_SERIAL_OUTPUT,
1015	.fwbulkwritelen   = TDA10048_BULKWRITE_200,
1016	.inversion        = TDA10048_INVERSION_ON,
1017	.dtv6_if_freq_khz = TDA10048_IF_3300,
1018	.dtv7_if_freq_khz = TDA10048_IF_3500,
1019	.dtv8_if_freq_khz = TDA10048_IF_4000,
1020	.clk_freq_khz     = TDA10048_CLK_16000,
1021	.disable_gate_access = 1,
1022};
1023
1024static struct tda18271_std_map hauppauge_tda18271_std_map = {
1025	.atsc_6   = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1026		      .if_lvl = 1, .rfagc_top = 0x58, },
1027	.qam_6    = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1028		      .if_lvl = 1, .rfagc_top = 0x58, },
1029};
1030
1031static struct tda18271_config hcw_tda18271_config = {
1032	.std_map = &hauppauge_tda18271_std_map,
1033	.gate    = TDA18271_GATE_ANALOG,
1034	.config  = 3,
1035	.output_opt = TDA18271_OUTPUT_LT_OFF,
1036};
1037
1038static struct tda829x_config tda829x_no_probe = {
1039	.probe_tuner = TDA829X_DONT_PROBE,
1040};
1041
1042static struct tda10048_config zolid_tda10048_config = {
1043	.demod_address    = 0x10 >> 1,
1044	.output_mode      = TDA10048_PARALLEL_OUTPUT,
1045	.fwbulkwritelen   = TDA10048_BULKWRITE_200,
1046	.inversion        = TDA10048_INVERSION_ON,
1047	.dtv6_if_freq_khz = TDA10048_IF_3300,
1048	.dtv7_if_freq_khz = TDA10048_IF_3500,
1049	.dtv8_if_freq_khz = TDA10048_IF_4000,
1050	.clk_freq_khz     = TDA10048_CLK_16000,
1051	.disable_gate_access = 1,
1052};
1053
1054static struct tda18271_config zolid_tda18271_config = {
1055	.gate    = TDA18271_GATE_ANALOG,
1056};
1057
1058static struct tda10048_config dtv1000s_tda10048_config = {
1059	.demod_address    = 0x10 >> 1,
1060	.output_mode      = TDA10048_PARALLEL_OUTPUT,
1061	.fwbulkwritelen   = TDA10048_BULKWRITE_200,
1062	.inversion        = TDA10048_INVERSION_ON,
1063	.dtv6_if_freq_khz = TDA10048_IF_3300,
1064	.dtv7_if_freq_khz = TDA10048_IF_3800,
1065	.dtv8_if_freq_khz = TDA10048_IF_4300,
1066	.clk_freq_khz     = TDA10048_CLK_16000,
1067	.disable_gate_access = 1,
1068};
1069
1070static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1071	.dvbt_6   = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1072		      .if_lvl = 1, .rfagc_top = 0x37, },
1073	.dvbt_7   = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1074		      .if_lvl = 1, .rfagc_top = 0x37, },
1075	.dvbt_8   = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1076		      .if_lvl = 1, .rfagc_top = 0x37, },
1077};
1078
1079static struct tda18271_config dtv1000s_tda18271_config = {
1080	.std_map = &dtv1000s_tda18271_std_map,
1081	.gate    = TDA18271_GATE_ANALOG,
1082};
1083
1084/* ==================================================================
1085 * Core code
1086 */
1087
1088static int dvb_init(struct saa7134_dev *dev)
1089{
1090	int ret;
1091	int attach_xc3028 = 0;
1092	struct videobuf_dvb_frontend *fe0;
1093
1094	mutex_init(&dev->frontends.lock);
1095	INIT_LIST_HEAD(&dev->frontends.felist);
1096
1097	printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
1098	fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1099	if (!fe0) {
1100		printk(KERN_ERR "%s() failed to alloc\n", __func__);
1101		return -ENOMEM;
1102	}
1103
1104	/* init struct videobuf_dvb */
1105	dev->ts.nr_bufs    = 32;
1106	dev->ts.nr_packets = 32*4;
1107	fe0->dvb.name = dev->name;
1108	videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
1109			    &dev->pci->dev, &dev->slock,
1110			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
1111			    V4L2_FIELD_ALTERNATE,
1112			    sizeof(struct saa7134_buf),
1113			    dev);
1114
1115	switch (dev->board) {
1116	case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1117		dprintk("pinnacle 300i dvb setup\n");
1118		fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1119					       &dev->i2c_adap);
1120		if (fe0->dvb.frontend) {
1121			fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1122		}
1123		break;
1124	case SAA7134_BOARD_AVERMEDIA_777:
1125	case SAA7134_BOARD_AVERMEDIA_A16AR:
1126		dprintk("avertv 777 dvb setup\n");
1127		fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1128					       &dev->i2c_adap);
1129		if (fe0->dvb.frontend) {
1130			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1131				   &dev->i2c_adap, 0x61,
1132				   TUNER_PHILIPS_TD1316);
1133		}
1134		break;
1135	case SAA7134_BOARD_AVERMEDIA_A16D:
1136		dprintk("AverMedia A16D dvb setup\n");
1137		fe0->dvb.frontend = dvb_attach(mt352_attach,
1138						&avermedia_xc3028_mt352_dev,
1139						&dev->i2c_adap);
1140		attach_xc3028 = 1;
1141		break;
1142	case SAA7134_BOARD_MD7134:
1143		fe0->dvb.frontend = dvb_attach(tda10046_attach,
1144					       &medion_cardbus,
1145					       &dev->i2c_adap);
1146		if (fe0->dvb.frontend) {
1147			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1148				   &dev->i2c_adap, medion_cardbus.tuner_address,
1149				   TUNER_PHILIPS_FMD1216ME_MK3);
1150		}
1151		break;
1152	case SAA7134_BOARD_PHILIPS_TOUGH:
1153		fe0->dvb.frontend = dvb_attach(tda10046_attach,
1154					       &philips_tu1216_60_config,
1155					       &dev->i2c_adap);
1156		if (fe0->dvb.frontend) {
1157			fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1158			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1159		}
1160		break;
1161	case SAA7134_BOARD_FLYDVBTDUO:
1162	case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1163		if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1164					 &tda827x_cfg_0) < 0)
1165			goto dettach_frontend;
1166		break;
1167	case SAA7134_BOARD_PHILIPS_EUROPA:
1168	case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1169	case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
1170		fe0->dvb.frontend = dvb_attach(tda10046_attach,
1171					       &philips_europa_config,
1172					       &dev->i2c_adap);
1173		if (fe0->dvb.frontend) {
1174			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1175			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1176			fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1177			fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1178			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1179		}
1180		break;
1181	case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1182		fe0->dvb.frontend = dvb_attach(tda10046_attach,
1183					       &technotrend_budget_t3000_config,
1184					       &dev->i2c_adap);
1185		if (fe0->dvb.frontend) {
1186			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1187			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1188			fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1189			fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1190			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1191		}
1192		break;
1193	case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1194		fe0->dvb.frontend = dvb_attach(tda10046_attach,
1195					       &philips_tu1216_61_config,
1196					       &dev->i2c_adap);
1197		if (fe0->dvb.frontend) {
1198			fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1199			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1200		}
1201		break;
1202	case SAA7134_BOARD_KWORLD_DVBT_210:
1203		if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1204					 &tda827x_cfg_2) < 0)
1205			goto dettach_frontend;
1206		break;
1207	case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1208		fe0->dvb.frontend = dvb_attach(tda10048_attach,
1209					       &hcw_tda10048_config,
1210					       &dev->i2c_adap);
1211		if (fe0->dvb.frontend != NULL) {
1212			dvb_attach(tda829x_attach, fe0->dvb.frontend,
1213				   &dev->i2c_adap, 0x4b,
1214				   &tda829x_no_probe);
1215			dvb_attach(tda18271_attach, fe0->dvb.frontend,
1216				   0x60, &dev->i2c_adap,
1217				   &hcw_tda18271_config);
1218		}
1219		break;
1220	case SAA7134_BOARD_PHILIPS_TIGER:
1221		if (configure_tda827x_fe(dev, &philips_tiger_config,
1222					 &tda827x_cfg_0) < 0)
1223			goto dettach_frontend;
1224		break;
1225	case SAA7134_BOARD_PINNACLE_PCTV_310i:
1226		if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1227					 &tda827x_cfg_1) < 0)
1228			goto dettach_frontend;
1229		break;
1230	case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1231		if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1232					 &tda827x_cfg_1) < 0)
1233			goto dettach_frontend;
1234		break;
1235	case SAA7134_BOARD_HAUPPAUGE_HVR1150:
1236		fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1237					       &hcw_lgdt3305_config,
1238					       &dev->i2c_adap);
1239		if (fe0->dvb.frontend) {
1240			dvb_attach(tda829x_attach, fe0->dvb.frontend,
1241				   &dev->i2c_adap, 0x4b,
1242				   &tda829x_no_probe);
1243			dvb_attach(tda18271_attach, fe0->dvb.frontend,
1244				   0x60, &dev->i2c_adap,
1245				   &hcw_tda18271_config);
1246		}
1247		break;
1248	case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1249		if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1250					 &tda827x_cfg_0) < 0)
1251			goto dettach_frontend;
1252		break;
1253	case SAA7134_BOARD_FLYDVBT_LR301:
1254		if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1255					 &tda827x_cfg_0) < 0)
1256			goto dettach_frontend;
1257		break;
1258	case SAA7134_BOARD_FLYDVB_TRIO:
1259		if (!use_frontend) {	/* terrestrial */
1260			if (configure_tda827x_fe(dev, &lifeview_trio_config,
1261						 &tda827x_cfg_0) < 0)
1262				goto dettach_frontend;
1263		} else {  		/* satellite */
1264			fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1265			if (fe0->dvb.frontend) {
1266				if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1267									&dev->i2c_adap, 0) == NULL) {
1268					wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1269					goto dettach_frontend;
1270				}
1271				if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1272										0x08, 0, 0) == NULL) {
1273					wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1274					goto dettach_frontend;
1275				}
1276			}
1277		}
1278		break;
1279	case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1280	case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1281		fe0->dvb.frontend = dvb_attach(tda10046_attach,
1282					       &ads_tech_duo_config,
1283					       &dev->i2c_adap);
1284		if (fe0->dvb.frontend) {
1285			if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1286				   ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1287								&ads_duo_cfg) == NULL) {
1288				wprintk("no tda827x tuner found at addr: %02x\n",
1289					ads_tech_duo_config.tuner_address);
1290				goto dettach_frontend;
1291			}
1292		} else
1293			wprintk("failed to attach tda10046\n");
1294		break;
1295	case SAA7134_BOARD_TEVION_DVBT_220RF:
1296		if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1297					 &tda827x_cfg_0) < 0)
1298			goto dettach_frontend;
1299		break;
1300	case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1301		if (!use_frontend) {     /* terrestrial */
1302			if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1303						 &tda827x_cfg_0) < 0)
1304				goto dettach_frontend;
1305		} else {        /* satellite */
1306			fe0->dvb.frontend = dvb_attach(tda10086_attach,
1307							&flydvbs, &dev->i2c_adap);
1308			if (fe0->dvb.frontend) {
1309				struct dvb_frontend *fe = fe0->dvb.frontend;
1310				u8 dev_id = dev->eedata[2];
1311				u8 data = 0xc4;
1312				struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1313
1314				if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1315						0x60, &dev->i2c_adap, 0) == NULL) {
1316					wprintk("%s: Medion Quadro, no tda826x "
1317						"found !\n", __func__);
1318					goto dettach_frontend;
1319				}
1320				if (dev_id != 0x08) {
1321					/* we need to open the i2c gate (we know it exists) */
1322					fe->ops.i2c_gate_ctrl(fe, 1);
1323					if (dvb_attach(isl6405_attach, fe,
1324							&dev->i2c_adap, 0x08, 0, 0) == NULL) {
1325						wprintk("%s: Medion Quadro, no ISL6405 "
1326							"found !\n", __func__);
1327						goto dettach_frontend;
1328					}
1329					if (dev_id == 0x07) {
1330						/* fire up the 2nd section of the LNB supply since
1331						   we can't do this from the other section */
1332						msg.buf = &data;
1333						i2c_transfer(&dev->i2c_adap, &msg, 1);
1334					}
1335					fe->ops.i2c_gate_ctrl(fe, 0);
1336					dev->original_set_voltage = fe->ops.set_voltage;
1337					fe->ops.set_voltage = md8800_set_voltage;
1338					dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1339					fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1340				} else {
1341					fe->ops.set_voltage = md8800_set_voltage2;
1342					fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1343				}
1344			}
1345		}
1346		break;
1347	case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1348		fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1349					       &dev->i2c_adap);
1350		if (fe0->dvb.frontend)
1351			dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1352				   NULL, DVB_PLL_TDHU2);
1353		break;
1354	case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1355	case SAA7134_BOARD_KWORLD_ATSC110:
1356		fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1357					       &dev->i2c_adap);
1358		if (fe0->dvb.frontend)
1359			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1360				   &dev->i2c_adap, 0x61,
1361				   TUNER_PHILIPS_TUV1236D);
1362		break;
1363	case SAA7134_BOARD_FLYDVBS_LR300:
1364		fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1365					       &dev->i2c_adap);
1366		if (fe0->dvb.frontend) {
1367			if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1368				       &dev->i2c_adap, 0) == NULL) {
1369				wprintk("%s: No tda826x found!\n", __func__);
1370				goto dettach_frontend;
1371			}
1372			if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
1373				       &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1374				wprintk("%s: No ISL6421 found!\n", __func__);
1375				goto dettach_frontend;
1376			}
1377		}
1378		break;
1379	case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1380		fe0->dvb.frontend = dvb_attach(tda10046_attach,
1381					       &medion_cardbus,
1382					       &dev->i2c_adap);
1383		if (fe0->dvb.frontend) {
1384			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1385			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1386
1387			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1388				   &dev->i2c_adap, medion_cardbus.tuner_address,
1389				   TUNER_PHILIPS_FMD1216ME_MK3);
1390		}
1391		break;
1392	case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1393		fe0->dvb.frontend = dvb_attach(tda10046_attach,
1394				&philips_europa_config,
1395				&dev->i2c_adap);
1396		if (fe0->dvb.frontend) {
1397			fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1398			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1399		}
1400		break;
1401	case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1402		if (configure_tda827x_fe(dev, &cinergy_ht_config,
1403					 &tda827x_cfg_0) < 0)
1404			goto dettach_frontend;
1405		break;
1406	case SAA7134_BOARD_CINERGY_HT_PCI:
1407		if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1408					 &tda827x_cfg_0) < 0)
1409			goto dettach_frontend;
1410		break;
1411	case SAA7134_BOARD_PHILIPS_TIGER_S:
1412		if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1413					 &tda827x_cfg_2) < 0)
1414			goto dettach_frontend;
1415		break;
1416	case SAA7134_BOARD_ASUS_P7131_4871:
1417		if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1418					 &tda827x_cfg_2) < 0)
1419			goto dettach_frontend;
1420		break;
1421	case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1422		if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1423					 &tda827x_cfg_2) < 0)
1424			goto dettach_frontend;
1425		break;
1426	case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1427		if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1428					 &tda827x_cfg_0) < 0)
1429			goto dettach_frontend;
1430		break;
1431	case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1432		if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1433					 &tda827x_cfg_2_sw42) < 0)
1434			goto dettach_frontend;
1435		break;
1436	case SAA7134_BOARD_PHILIPS_SNAKE:
1437		fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1438						&dev->i2c_adap);
1439		if (fe0->dvb.frontend) {
1440			if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1441					&dev->i2c_adap, 0) == NULL) {
1442				wprintk("%s: No tda826x found!\n", __func__);
1443				goto dettach_frontend;
1444			}
1445			if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1446					&dev->i2c_adap, 0, 0) == NULL) {
1447				wprintk("%s: No lnbp21 found!\n", __func__);
1448				goto dettach_frontend;
1449			}
1450		}
1451		break;
1452	case SAA7134_BOARD_CREATIX_CTX953:
1453		if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1454					 &tda827x_cfg_0) < 0)
1455			goto dettach_frontend;
1456		break;
1457	case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1458		if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1459					 &tda827x_cfg_2) < 0)
1460			goto dettach_frontend;
1461		break;
1462	case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1463		dprintk("AverMedia E506R dvb setup\n");
1464		saa7134_set_gpio(dev, 25, 0);
1465		msleep(10);
1466		saa7134_set_gpio(dev, 25, 1);
1467		fe0->dvb.frontend = dvb_attach(mt352_attach,
1468						&avermedia_xc3028_mt352_dev,
1469						&dev->i2c_adap);
1470		attach_xc3028 = 1;
1471		break;
1472	case SAA7134_BOARD_MD7134_BRIDGE_2:
1473		fe0->dvb.frontend = dvb_attach(tda10086_attach,
1474						&sd1878_4m, &dev->i2c_adap);
1475		if (fe0->dvb.frontend) {
1476			struct dvb_frontend *fe;
1477			if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1478				  &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1479				wprintk("%s: MD7134 DVB-S, no SD1878 "
1480					"found !\n", __func__);
1481				goto dettach_frontend;
1482			}
1483			/* we need to open the i2c gate (we know it exists) */
1484			fe = fe0->dvb.frontend;
1485			fe->ops.i2c_gate_ctrl(fe, 1);
1486			if (dvb_attach(isl6405_attach, fe,
1487					&dev->i2c_adap, 0x08, 0, 0) == NULL) {
1488				wprintk("%s: MD7134 DVB-S, no ISL6405 "
1489					"found !\n", __func__);
1490				goto dettach_frontend;
1491			}
1492			fe->ops.i2c_gate_ctrl(fe, 0);
1493			dev->original_set_voltage = fe->ops.set_voltage;
1494			fe->ops.set_voltage = md8800_set_voltage;
1495			dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1496			fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1497		}
1498		break;
1499	case SAA7134_BOARD_AVERMEDIA_M103:
1500		saa7134_set_gpio(dev, 25, 0);
1501		msleep(10);
1502		saa7134_set_gpio(dev, 25, 1);
1503		fe0->dvb.frontend = dvb_attach(mt352_attach,
1504						&avermedia_xc3028_mt352_dev,
1505						&dev->i2c_adap);
1506		attach_xc3028 = 1;
1507		break;
1508	case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1509		if (!use_frontend) {     /* terrestrial */
1510			if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1511							&tda827x_cfg_2) < 0)
1512				goto dettach_frontend;
1513		} else {  		/* satellite */
1514			fe0->dvb.frontend = dvb_attach(tda10086_attach,
1515						&flydvbs, &dev->i2c_adap);
1516			if (fe0->dvb.frontend) {
1517				if (dvb_attach(tda826x_attach,
1518						fe0->dvb.frontend, 0x60,
1519						&dev->i2c_adap, 0) == NULL) {
1520					wprintk("%s: Asus Tiger 3in1, no "
1521						"tda826x found!\n", __func__);
1522					goto dettach_frontend;
1523				}
1524				if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1525						&dev->i2c_adap, 0, 0) == NULL) {
1526					wprintk("%s: Asus Tiger 3in1, no lnbp21"
1527						" found!\n", __func__);
1528					goto dettach_frontend;
1529				}
1530			}
1531		}
1532		break;
1533	case SAA7134_BOARD_ASUSTeK_TIGER:
1534		if (configure_tda827x_fe(dev, &philips_tiger_config,
1535					 &tda827x_cfg_0) < 0)
1536			goto dettach_frontend;
1537		break;
1538	case SAA7134_BOARD_BEHOLD_H6:
1539		fe0->dvb.frontend = dvb_attach(zl10353_attach,
1540						&behold_h6_config,
1541						&dev->i2c_adap);
1542		if (fe0->dvb.frontend) {
1543			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1544				   &dev->i2c_adap, 0x61,
1545				   TUNER_PHILIPS_FMD1216MEX_MK3);
1546		}
1547		break;
1548	case SAA7134_BOARD_BEHOLD_X7:
1549		fe0->dvb.frontend = dvb_attach(zl10353_attach,
1550						&behold_x7_config,
1551						&dev->i2c_adap);
1552		if (fe0->dvb.frontend) {
1553			dvb_attach(xc5000_attach, fe0->dvb.frontend,
1554				   &dev->i2c_adap, &behold_x7_tunerconfig);
1555		}
1556		break;
1557	case SAA7134_BOARD_BEHOLD_H7:
1558		fe0->dvb.frontend = dvb_attach(zl10353_attach,
1559						&behold_x7_config,
1560						&dev->i2c_adap);
1561		if (fe0->dvb.frontend) {
1562			dvb_attach(xc5000_attach, fe0->dvb.frontend,
1563				   &dev->i2c_adap, &behold_x7_tunerconfig);
1564		}
1565		break;
1566	case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1567	case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1568		/* Zarlink ZL10313 */
1569		fe0->dvb.frontend = dvb_attach(mt312_attach,
1570			&avertv_a700_mt312, &dev->i2c_adap);
1571		if (fe0->dvb.frontend) {
1572			if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1573					&avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1574				wprintk("%s: No zl10036 found!\n",
1575					__func__);
1576			}
1577		}
1578		break;
1579	case SAA7134_BOARD_VIDEOMATE_S350:
1580		fe0->dvb.frontend = dvb_attach(mt312_attach,
1581				&zl10313_compro_s350_config, &dev->i2c_adap);
1582		if (fe0->dvb.frontend)
1583			if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1584					0x60, &dev->i2c_adap) == NULL)
1585				wprintk("%s: No zl10039 found!\n",
1586					__func__);
1587
1588		break;
1589	case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1590		fe0->dvb.frontend = dvb_attach(tda10048_attach,
1591					       &zolid_tda10048_config,
1592					       &dev->i2c_adap);
1593		if (fe0->dvb.frontend != NULL) {
1594			dvb_attach(tda829x_attach, fe0->dvb.frontend,
1595				   &dev->i2c_adap, 0x4b,
1596				   &tda829x_no_probe);
1597			dvb_attach(tda18271_attach, fe0->dvb.frontend,
1598				   0x60, &dev->i2c_adap,
1599				   &zolid_tda18271_config);
1600		}
1601		break;
1602	case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1603		fe0->dvb.frontend = dvb_attach(tda10048_attach,
1604					       &dtv1000s_tda10048_config,
1605					       &dev->i2c_adap);
1606		if (fe0->dvb.frontend != NULL) {
1607			dvb_attach(tda829x_attach, fe0->dvb.frontend,
1608				   &dev->i2c_adap, 0x4b,
1609				   &tda829x_no_probe);
1610			dvb_attach(tda18271_attach, fe0->dvb.frontend,
1611				   0x60, &dev->i2c_adap,
1612				   &dtv1000s_tda18271_config);
1613		}
1614		break;
1615	default:
1616		wprintk("Huh? unknown DVB card?\n");
1617		break;
1618	}
1619
1620	if (attach_xc3028) {
1621		struct dvb_frontend *fe;
1622		struct xc2028_config cfg = {
1623			.i2c_adap  = &dev->i2c_adap,
1624			.i2c_addr  = 0x61,
1625		};
1626
1627		if (!fe0->dvb.frontend)
1628			goto dettach_frontend;
1629
1630		fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1631		if (!fe) {
1632			printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1633			       dev->name);
1634			goto dettach_frontend;
1635		}
1636	}
1637
1638	if (NULL == fe0->dvb.frontend) {
1639		printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1640		goto dettach_frontend;
1641	}
1642	/* define general-purpose callback pointer */
1643	fe0->dvb.frontend->callback = saa7134_tuner_callback;
1644
1645	/* register everything else */
1646	ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1647					&dev->pci->dev, adapter_nr, 0, NULL);
1648
1649	/* this sequence is necessary to make the tda1004x load its firmware
1650	 * and to enter analog mode of hybrid boards
1651	 */
1652	if (!ret) {
1653		if (fe0->dvb.frontend->ops.init)
1654			fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1655		if (fe0->dvb.frontend->ops.sleep)
1656			fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1657		if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1658			fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1659	}
1660	return ret;
1661
1662dettach_frontend:
1663	videobuf_dvb_dealloc_frontends(&dev->frontends);
1664	return -EINVAL;
1665}
1666
1667static int dvb_fini(struct saa7134_dev *dev)
1668{
1669	struct videobuf_dvb_frontend *fe0;
1670
1671	/* Get the first frontend */
1672	fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1673	if (!fe0)
1674		return -EINVAL;
1675
1676	if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1677		struct v4l2_priv_tun_config tda9887_cfg;
1678		static int on  = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1679
1680		tda9887_cfg.tuner = TUNER_TDA9887;
1681		tda9887_cfg.priv  = &on;
1682
1683		/* otherwise we don't detect the tuner on next insmod */
1684		saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1685	} else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1686		if ((dev->eedata[2] == 0x07) && use_frontend) {
1687			/* turn off the 2nd lnb supply */
1688			u8 data = 0x80;
1689			struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1690			struct dvb_frontend *fe;
1691			fe = fe0->dvb.frontend;
1692			if (fe->ops.i2c_gate_ctrl) {
1693				fe->ops.i2c_gate_ctrl(fe, 1);
1694				i2c_transfer(&dev->i2c_adap, &msg, 1);
1695				fe->ops.i2c_gate_ctrl(fe, 0);
1696			}
1697		}
1698	}
1699	videobuf_dvb_unregister_bus(&dev->frontends);
1700	return 0;
1701}
1702
1703static struct saa7134_mpeg_ops dvb_ops = {
1704	.type          = SAA7134_MPEG_DVB,
1705	.init          = dvb_init,
1706	.fini          = dvb_fini,
1707};
1708
1709static int __init dvb_register(void)
1710{
1711	return saa7134_ts_register(&dvb_ops);
1712}
1713
1714static void __exit dvb_unregister(void)
1715{
1716	saa7134_ts_unregister(&dvb_ops);
1717}
1718
1719module_init(dvb_register);
1720module_exit(dvb_unregister);
1721
1722/* ------------------------------------------------------------------ */
1723/*
1724 * Local variables:
1725 * c-basic-offset: 8
1726 * End:
1727 */
1728