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