V4L/DVB (7224): Initial DVB-S support for MD8800 /CTX948
[safe/jmp/linux-2.6] / drivers / media / video / saa7134 / saa7134-dvb.c
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/slab.h>
28 #include <linux/delay.h>
29 #include <linux/kthread.h>
30 #include <linux/suspend.h>
31
32 #include "saa7134-reg.h"
33 #include "saa7134.h"
34 #include <media/v4l2-common.h>
35 #include "dvb-pll.h"
36
37 #include "mt352.h"
38 #include "mt352_priv.h" /* FIXME */
39 #include "tda1004x.h"
40 #include "nxt200x.h"
41
42 #include "tda10086.h"
43 #include "tda826x.h"
44 #include "tda827x.h"
45 #include "isl6421.h"
46 #include "isl6405.h"
47
48 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
49 MODULE_LICENSE("GPL");
50
51 static unsigned int antenna_pwr;
52
53 module_param(antenna_pwr, int, 0444);
54 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
55
56 static int use_frontend;
57 module_param(use_frontend, int, 0644);
58 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
59
60 static int debug;
61 module_param(debug, int, 0644);
62 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
63
64 #define dprintk(fmt, arg...)    do { if (debug) \
65         printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
66
67 /* Print a warning */
68 #define wprintk(fmt, arg...) \
69         printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
70
71 /* ------------------------------------------------------------------
72  * mt352 based DVB-T cards
73  */
74
75 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
76 {
77         u32 ok;
78
79         if (!on) {
80                 saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
81                 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
82                 return 0;
83         }
84
85         saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
86         saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
87         udelay(10);
88
89         saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 28));
90         saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
91         udelay(10);
92         saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 28));
93         udelay(10);
94         ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
95         dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
96
97         if (!ok)
98                 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
99         return ok;
100 }
101
102 static int mt352_pinnacle_init(struct dvb_frontend* fe)
103 {
104         static u8 clock_config []  = { CLOCK_CTL,  0x3d, 0x28 };
105         static u8 reset []         = { RESET,      0x80 };
106         static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
107         static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
108         static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
109         static u8 fsm_ctl_cfg[]    = { 0x7b,       0x04 };
110         static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x0f };
111         static u8 scan_ctl_cfg []  = { SCAN_CTL,   0x0d };
112         static u8 irq_cfg []       = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
113         struct saa7134_dev *dev= fe->dvb->priv;
114
115         dprintk("%s called\n", __FUNCTION__);
116
117         mt352_write(fe, clock_config,   sizeof(clock_config));
118         udelay(200);
119         mt352_write(fe, reset,          sizeof(reset));
120         mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
121         mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
122         mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
123         mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
124
125         mt352_write(fe, fsm_ctl_cfg,    sizeof(fsm_ctl_cfg));
126         mt352_write(fe, scan_ctl_cfg,   sizeof(scan_ctl_cfg));
127         mt352_write(fe, irq_cfg,        sizeof(irq_cfg));
128
129         return 0;
130 }
131
132 static int mt352_aver777_init(struct dvb_frontend* fe)
133 {
134         static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x2d };
135         static u8 reset []         = { RESET,      0x80 };
136         static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
137         static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
138         static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
139
140         mt352_write(fe, clock_config,   sizeof(clock_config));
141         udelay(200);
142         mt352_write(fe, reset,          sizeof(reset));
143         mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
144         mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
145         mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
146
147         return 0;
148 }
149
150 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
151                                            struct dvb_frontend_parameters* params)
152 {
153         u8 off[] = { 0x00, 0xf1};
154         u8 on[]  = { 0x00, 0x71};
155         struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
156
157         struct saa7134_dev *dev = fe->dvb->priv;
158         struct v4l2_frequency f;
159
160         /* set frequency (mt2050) */
161         f.tuner     = 0;
162         f.type      = V4L2_TUNER_DIGITAL_TV;
163         f.frequency = params->frequency / 1000 * 16 / 1000;
164         if (fe->ops.i2c_gate_ctrl)
165                 fe->ops.i2c_gate_ctrl(fe, 1);
166         i2c_transfer(&dev->i2c_adap, &msg, 1);
167         saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
168         msg.buf = on;
169         if (fe->ops.i2c_gate_ctrl)
170                 fe->ops.i2c_gate_ctrl(fe, 1);
171         i2c_transfer(&dev->i2c_adap, &msg, 1);
172
173         pinnacle_antenna_pwr(dev, antenna_pwr);
174
175         /* mt352 setup */
176         return mt352_pinnacle_init(fe);
177 }
178
179 static struct mt352_config pinnacle_300i = {
180         .demod_address = 0x3c >> 1,
181         .adc_clock     = 20333,
182         .if2           = 36150,
183         .no_tuner      = 1,
184         .demod_init    = mt352_pinnacle_init,
185 };
186
187 static struct mt352_config avermedia_777 = {
188         .demod_address = 0xf,
189         .demod_init    = mt352_aver777_init,
190 };
191
192 /* ==================================================================
193  * tda1004x based DVB-T cards, helper functions
194  */
195
196 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
197                                            const struct firmware **fw, char *name)
198 {
199         struct saa7134_dev *dev = fe->dvb->priv;
200         return request_firmware(fw, name, &dev->pci->dev);
201 }
202
203 /* ------------------------------------------------------------------
204  * these tuners are tu1216, td1316(a)
205  */
206
207 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
208 {
209         struct saa7134_dev *dev = fe->dvb->priv;
210         struct tda1004x_state *state = fe->demodulator_priv;
211         u8 addr = state->config->tuner_address;
212         u8 tuner_buf[4];
213         struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
214                         sizeof(tuner_buf) };
215         int tuner_frequency = 0;
216         u8 band, cp, filter;
217
218         /* determine charge pump */
219         tuner_frequency = params->frequency + 36166000;
220         if (tuner_frequency < 87000000)
221                 return -EINVAL;
222         else if (tuner_frequency < 130000000)
223                 cp = 3;
224         else if (tuner_frequency < 160000000)
225                 cp = 5;
226         else if (tuner_frequency < 200000000)
227                 cp = 6;
228         else if (tuner_frequency < 290000000)
229                 cp = 3;
230         else if (tuner_frequency < 420000000)
231                 cp = 5;
232         else if (tuner_frequency < 480000000)
233                 cp = 6;
234         else if (tuner_frequency < 620000000)
235                 cp = 3;
236         else if (tuner_frequency < 830000000)
237                 cp = 5;
238         else if (tuner_frequency < 895000000)
239                 cp = 7;
240         else
241                 return -EINVAL;
242
243         /* determine band */
244         if (params->frequency < 49000000)
245                 return -EINVAL;
246         else if (params->frequency < 161000000)
247                 band = 1;
248         else if (params->frequency < 444000000)
249                 band = 2;
250         else if (params->frequency < 861000000)
251                 band = 4;
252         else
253                 return -EINVAL;
254
255         /* setup PLL filter */
256         switch (params->u.ofdm.bandwidth) {
257         case BANDWIDTH_6_MHZ:
258                 filter = 0;
259                 break;
260
261         case BANDWIDTH_7_MHZ:
262                 filter = 0;
263                 break;
264
265         case BANDWIDTH_8_MHZ:
266                 filter = 1;
267                 break;
268
269         default:
270                 return -EINVAL;
271         }
272
273         /* calculate divisor
274          * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
275          */
276         tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
277
278         /* setup tuner buffer */
279         tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
280         tuner_buf[1] = tuner_frequency & 0xff;
281         tuner_buf[2] = 0xca;
282         tuner_buf[3] = (cp << 5) | (filter << 3) | band;
283
284         if (fe->ops.i2c_gate_ctrl)
285                 fe->ops.i2c_gate_ctrl(fe, 1);
286         if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
287                 wprintk("could not write to tuner at addr: 0x%02x\n",
288                         addr << 1);
289                 return -EIO;
290         }
291         msleep(1);
292         return 0;
293 }
294
295 static int philips_tu1216_init(struct dvb_frontend *fe)
296 {
297         struct saa7134_dev *dev = fe->dvb->priv;
298         struct tda1004x_state *state = fe->demodulator_priv;
299         u8 addr = state->config->tuner_address;
300         static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
301         struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
302
303         /* setup PLL configuration */
304         if (fe->ops.i2c_gate_ctrl)
305                 fe->ops.i2c_gate_ctrl(fe, 1);
306         if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
307                 return -EIO;
308         msleep(1);
309
310         return 0;
311 }
312
313 /* ------------------------------------------------------------------ */
314
315 static struct tda1004x_config philips_tu1216_60_config = {
316         .demod_address = 0x8,
317         .invert        = 1,
318         .invert_oclk   = 0,
319         .xtal_freq     = TDA10046_XTAL_4M,
320         .agc_config    = TDA10046_AGC_DEFAULT,
321         .if_freq       = TDA10046_FREQ_3617,
322         .tuner_address = 0x60,
323         .request_firmware = philips_tda1004x_request_firmware
324 };
325
326 static struct tda1004x_config philips_tu1216_61_config = {
327
328         .demod_address = 0x8,
329         .invert        = 1,
330         .invert_oclk   = 0,
331         .xtal_freq     = TDA10046_XTAL_4M,
332         .agc_config    = TDA10046_AGC_DEFAULT,
333         .if_freq       = TDA10046_FREQ_3617,
334         .tuner_address = 0x61,
335         .request_firmware = philips_tda1004x_request_firmware
336 };
337
338 /* ------------------------------------------------------------------ */
339
340 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
341 {
342         struct saa7134_dev *dev = fe->dvb->priv;
343         struct tda1004x_state *state = fe->demodulator_priv;
344         u8 addr = state->config->tuner_address;
345         static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
346         struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
347
348         /* setup PLL configuration */
349         if (fe->ops.i2c_gate_ctrl)
350                 fe->ops.i2c_gate_ctrl(fe, 1);
351         if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
352                 return -EIO;
353         return 0;
354 }
355
356 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
357 {
358         return philips_tda6651_pll_set(fe, params);
359 }
360
361 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
362 {
363         struct saa7134_dev *dev = fe->dvb->priv;
364         struct tda1004x_state *state = fe->demodulator_priv;
365         u8 addr = state->config->tuner_address;
366         static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
367         struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
368
369         /* switch the tuner to analog mode */
370         if (fe->ops.i2c_gate_ctrl)
371                 fe->ops.i2c_gate_ctrl(fe, 1);
372         if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
373                 return -EIO;
374         return 0;
375 }
376
377 /* ------------------------------------------------------------------ */
378
379 static int philips_europa_tuner_init(struct dvb_frontend *fe)
380 {
381         struct saa7134_dev *dev = fe->dvb->priv;
382         static u8 msg[] = { 0x00, 0x40};
383         struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
384
385
386         if (philips_td1316_tuner_init(fe))
387                 return -EIO;
388         msleep(1);
389         if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
390                 return -EIO;
391
392         return 0;
393 }
394
395 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
396 {
397         struct saa7134_dev *dev = fe->dvb->priv;
398
399         static u8 msg[] = { 0x00, 0x14 };
400         struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
401
402         if (philips_td1316_tuner_sleep(fe))
403                 return -EIO;
404
405         /* switch the board to analog mode */
406         if (fe->ops.i2c_gate_ctrl)
407                 fe->ops.i2c_gate_ctrl(fe, 1);
408         i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
409         return 0;
410 }
411
412 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
413 {
414         struct saa7134_dev *dev = fe->dvb->priv;
415
416         if (dev->original_demod_sleep)
417                 dev->original_demod_sleep(fe);
418         fe->ops.i2c_gate_ctrl(fe, 1);
419         return 0;
420 }
421
422 static struct tda1004x_config philips_europa_config = {
423
424         .demod_address = 0x8,
425         .invert        = 0,
426         .invert_oclk   = 0,
427         .xtal_freq     = TDA10046_XTAL_4M,
428         .agc_config    = TDA10046_AGC_IFO_AUTO_POS,
429         .if_freq       = TDA10046_FREQ_052,
430         .tuner_address = 0x61,
431         .request_firmware = philips_tda1004x_request_firmware
432 };
433
434 /* ------------------------------------------------------------------ */
435
436 static struct tda1004x_config medion_cardbus = {
437         .demod_address = 0x08,
438         .invert        = 1,
439         .invert_oclk   = 0,
440         .xtal_freq     = TDA10046_XTAL_16M,
441         .agc_config    = TDA10046_AGC_IFO_AUTO_NEG,
442         .if_freq       = TDA10046_FREQ_3613,
443         .tuner_address = 0x61,
444         .request_firmware = philips_tda1004x_request_firmware
445 };
446
447 /* ------------------------------------------------------------------
448  * tda 1004x based cards with philips silicon tuner
449  */
450
451 static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
452 {
453         struct saa7134_dev *dev = fe->dvb->priv;
454         struct tda1004x_state *state = fe->demodulator_priv;
455         u8 addr = state->config->i2c_gate;
456         u8 config = state->config->tuner_config;
457         u8 GP00_CF[] = {0x20, 0x01};
458         u8 GP00_LEV[] = {0x22, 0x00};
459
460         struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
461         if (config) {
462                 if (high) {
463                         dprintk("setting LNA to high gain\n");
464                 } else {
465                         dprintk("setting LNA to low gain\n");
466                 }
467         }
468         switch (config) {
469         case 0: /* no LNA */
470                 break;
471         case 1: /* switch is GPIO 0 of tda8290 */
472         case 2:
473                 /* turn Vsync off */
474                 saa7134_set_gpio(dev, 22, 0);
475                 GP00_LEV[1] = high ? 0 : 1;
476                 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
477                         wprintk("could not access tda8290 at addr: 0x%02x\n",
478                                 addr << 1);
479                         return;
480                 }
481                 msg.buf = GP00_LEV;
482                 if (config == 2)
483                         GP00_LEV[1] = high ? 1 : 0;
484                 i2c_transfer(&dev->i2c_adap, &msg, 1);
485                 break;
486         case 3: /* switch with GPIO of saa713x */
487                 saa7134_set_gpio(dev, 22, high);
488                 break;
489         }
490 }
491
492 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
493 {
494         struct tda1004x_state *state = fe->demodulator_priv;
495
496         u8 addr = state->config->i2c_gate;
497         static u8 tda8290_close[] = { 0x21, 0xc0};
498         static u8 tda8290_open[]  = { 0x21, 0x80};
499         struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
500         if (enable) {
501                 tda8290_msg.buf = tda8290_close;
502         } else {
503                 tda8290_msg.buf = tda8290_open;
504         }
505         if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
506                 struct saa7134_dev *dev = fe->dvb->priv;
507                 wprintk("could not access tda8290 I2C gate\n");
508                 return -EIO;
509         }
510         msleep(20);
511         return 0;
512 }
513
514 /* ------------------------------------------------------------------ */
515
516 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
517 {
518         struct saa7134_dev *dev = fe->dvb->priv;
519         struct tda1004x_state *state = fe->demodulator_priv;
520
521         switch (state->config->antenna_switch) {
522         case 0: break;
523         case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
524                 saa7134_set_gpio(dev, 21, 0);
525                 break;
526         case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
527                 saa7134_set_gpio(dev, 21, 1);
528                 break;
529         }
530         return 0;
531 }
532
533 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
534 {
535         struct saa7134_dev *dev = fe->dvb->priv;
536         struct tda1004x_state *state = fe->demodulator_priv;
537
538         switch (state->config->antenna_switch) {
539         case 0: break;
540         case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
541                 saa7134_set_gpio(dev, 21, 1);
542                 break;
543         case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
544                 saa7134_set_gpio(dev, 21, 0);
545                 break;
546         }
547         return 0;
548 }
549
550 static struct tda827x_config tda827x_cfg = {
551         .lna_gain = philips_tda827x_lna_gain,
552         .init = philips_tda827x_tuner_init,
553         .sleep = philips_tda827x_tuner_sleep
554 };
555
556 static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
557 {
558         dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
559         if (dev->dvb.frontend) {
560                 if (tda_conf->i2c_gate)
561                         dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
562                 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
563                                                 &dev->i2c_adap,&tda827x_cfg) == NULL) {
564                         wprintk("no tda827x tuner found at addr: %02x\n",
565                                 tda_conf->tuner_address);
566                 }
567         }
568 }
569
570 /* ------------------------------------------------------------------ */
571
572 static struct tda1004x_config tda827x_lifeview_config = {
573         .demod_address = 0x08,
574         .invert        = 1,
575         .invert_oclk   = 0,
576         .xtal_freq     = TDA10046_XTAL_16M,
577         .agc_config    = TDA10046_AGC_TDA827X,
578         .gpio_config   = TDA10046_GP11_I,
579         .if_freq       = TDA10046_FREQ_045,
580         .tuner_address = 0x60,
581         .request_firmware = philips_tda1004x_request_firmware
582 };
583
584 static struct tda1004x_config philips_tiger_config = {
585         .demod_address = 0x08,
586         .invert        = 1,
587         .invert_oclk   = 0,
588         .xtal_freq     = TDA10046_XTAL_16M,
589         .agc_config    = TDA10046_AGC_TDA827X,
590         .gpio_config   = TDA10046_GP11_I,
591         .if_freq       = TDA10046_FREQ_045,
592         .i2c_gate      = 0x4b,
593         .tuner_address = 0x61,
594         .tuner_config  = 0,
595         .antenna_switch= 1,
596         .request_firmware = philips_tda1004x_request_firmware
597 };
598
599 static struct tda1004x_config cinergy_ht_config = {
600         .demod_address = 0x08,
601         .invert        = 1,
602         .invert_oclk   = 0,
603         .xtal_freq     = TDA10046_XTAL_16M,
604         .agc_config    = TDA10046_AGC_TDA827X,
605         .gpio_config   = TDA10046_GP01_I,
606         .if_freq       = TDA10046_FREQ_045,
607         .i2c_gate      = 0x4b,
608         .tuner_address = 0x61,
609         .tuner_config  = 0,
610         .request_firmware = philips_tda1004x_request_firmware
611 };
612
613 static struct tda1004x_config cinergy_ht_pci_config = {
614         .demod_address = 0x08,
615         .invert        = 1,
616         .invert_oclk   = 0,
617         .xtal_freq     = TDA10046_XTAL_16M,
618         .agc_config    = TDA10046_AGC_TDA827X,
619         .gpio_config   = TDA10046_GP01_I,
620         .if_freq       = TDA10046_FREQ_045,
621         .i2c_gate      = 0x4b,
622         .tuner_address = 0x60,
623         .tuner_config  = 0,
624         .request_firmware = philips_tda1004x_request_firmware
625 };
626
627 static struct tda1004x_config philips_tiger_s_config = {
628         .demod_address = 0x08,
629         .invert        = 1,
630         .invert_oclk   = 0,
631         .xtal_freq     = TDA10046_XTAL_16M,
632         .agc_config    = TDA10046_AGC_TDA827X,
633         .gpio_config   = TDA10046_GP01_I,
634         .if_freq       = TDA10046_FREQ_045,
635         .i2c_gate      = 0x4b,
636         .tuner_address = 0x61,
637         .tuner_config  = 2,
638         .antenna_switch= 1,
639         .request_firmware = philips_tda1004x_request_firmware
640 };
641
642 static struct tda1004x_config pinnacle_pctv_310i_config = {
643         .demod_address = 0x08,
644         .invert        = 1,
645         .invert_oclk   = 0,
646         .xtal_freq     = TDA10046_XTAL_16M,
647         .agc_config    = TDA10046_AGC_TDA827X,
648         .gpio_config   = TDA10046_GP11_I,
649         .if_freq       = TDA10046_FREQ_045,
650         .i2c_gate      = 0x4b,
651         .tuner_address = 0x61,
652         .tuner_config  = 1,
653         .request_firmware = philips_tda1004x_request_firmware
654 };
655
656 static struct tda1004x_config hauppauge_hvr_1110_config = {
657         .demod_address = 0x08,
658         .invert        = 1,
659         .invert_oclk   = 0,
660         .xtal_freq     = TDA10046_XTAL_16M,
661         .agc_config    = TDA10046_AGC_TDA827X,
662         .gpio_config   = TDA10046_GP11_I,
663         .if_freq       = TDA10046_FREQ_045,
664         .i2c_gate      = 0x4b,
665         .tuner_address = 0x61,
666         .tuner_config  = 1,
667         .request_firmware = philips_tda1004x_request_firmware
668 };
669
670 static struct tda1004x_config asus_p7131_dual_config = {
671         .demod_address = 0x08,
672         .invert        = 1,
673         .invert_oclk   = 0,
674         .xtal_freq     = TDA10046_XTAL_16M,
675         .agc_config    = TDA10046_AGC_TDA827X,
676         .gpio_config   = TDA10046_GP11_I,
677         .if_freq       = TDA10046_FREQ_045,
678         .i2c_gate      = 0x4b,
679         .tuner_address = 0x61,
680         .tuner_config  = 0,
681         .antenna_switch= 2,
682         .request_firmware = philips_tda1004x_request_firmware
683 };
684
685 static struct tda1004x_config lifeview_trio_config = {
686         .demod_address = 0x09,
687         .invert        = 1,
688         .invert_oclk   = 0,
689         .xtal_freq     = TDA10046_XTAL_16M,
690         .agc_config    = TDA10046_AGC_TDA827X,
691         .gpio_config   = TDA10046_GP00_I,
692         .if_freq       = TDA10046_FREQ_045,
693         .tuner_address = 0x60,
694         .request_firmware = philips_tda1004x_request_firmware
695 };
696
697 static struct tda1004x_config tevion_dvbt220rf_config = {
698         .demod_address = 0x08,
699         .invert        = 1,
700         .invert_oclk   = 0,
701         .xtal_freq     = TDA10046_XTAL_16M,
702         .agc_config    = TDA10046_AGC_TDA827X,
703         .gpio_config   = TDA10046_GP11_I,
704         .if_freq       = TDA10046_FREQ_045,
705         .tuner_address = 0x60,
706         .request_firmware = philips_tda1004x_request_firmware
707 };
708
709 static struct tda1004x_config md8800_dvbt_config = {
710         .demod_address = 0x08,
711         .invert        = 1,
712         .invert_oclk   = 0,
713         .xtal_freq     = TDA10046_XTAL_16M,
714         .agc_config    = TDA10046_AGC_TDA827X,
715         .gpio_config   = TDA10046_GP01_I,
716         .if_freq       = TDA10046_FREQ_045,
717         .i2c_gate      = 0x4b,
718         .tuner_address = 0x60,
719         .tuner_config  = 0,
720         .request_firmware = philips_tda1004x_request_firmware
721 };
722
723 static struct tda1004x_config asus_p7131_4871_config = {
724         .demod_address = 0x08,
725         .invert        = 1,
726         .invert_oclk   = 0,
727         .xtal_freq     = TDA10046_XTAL_16M,
728         .agc_config    = TDA10046_AGC_TDA827X,
729         .gpio_config   = TDA10046_GP01_I,
730         .if_freq       = TDA10046_FREQ_045,
731         .i2c_gate      = 0x4b,
732         .tuner_address = 0x61,
733         .tuner_config  = 2,
734         .antenna_switch= 2,
735         .request_firmware = philips_tda1004x_request_firmware
736 };
737
738 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
739         .demod_address = 0x08,
740         .invert        = 1,
741         .invert_oclk   = 0,
742         .xtal_freq     = TDA10046_XTAL_16M,
743         .agc_config    = TDA10046_AGC_TDA827X,
744         .gpio_config   = TDA10046_GP11_I,
745         .if_freq       = TDA10046_FREQ_045,
746         .i2c_gate      = 0x4b,
747         .tuner_address = 0x61,
748         .tuner_config  = 2,
749         .antenna_switch= 2,
750         .request_firmware = philips_tda1004x_request_firmware
751 };
752
753 static struct tda1004x_config kworld_dvb_t_210_config = {
754         .demod_address = 0x08,
755         .invert        = 1,
756         .invert_oclk   = 0,
757         .xtal_freq     = TDA10046_XTAL_16M,
758         .agc_config    = TDA10046_AGC_TDA827X,
759         .gpio_config   = TDA10046_GP11_I,
760         .if_freq       = TDA10046_FREQ_045,
761         .i2c_gate      = 0x4b,
762         .tuner_address = 0x61,
763         .tuner_config  = 2,
764         .antenna_switch= 1,
765         .request_firmware = philips_tda1004x_request_firmware
766 };
767
768 static struct tda1004x_config avermedia_super_007_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_GP01_I,
775         .if_freq       = TDA10046_FREQ_045,
776         .i2c_gate      = 0x4b,
777         .tuner_address = 0x60,
778         .tuner_config  = 0,
779         .antenna_switch= 1,
780         .request_firmware = philips_tda1004x_request_firmware
781 };
782
783 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
784         .demod_address = 0x08,
785         .invert        = 1,
786         .invert_oclk   = 0,
787         .xtal_freq     = TDA10046_XTAL_16M,
788         .agc_config    = TDA10046_AGC_TDA827X,
789         .gpio_config   = TDA10046_GP01_I,
790         .if_freq       = TDA10046_FREQ_045,
791         .i2c_gate      = 0x42,
792         .tuner_address = 0x61,
793         .tuner_config  = 2,
794         .antenna_switch = 1,
795         .request_firmware = philips_tda1004x_request_firmware
796 };
797
798 /* ------------------------------------------------------------------
799  * special case: this card uses saa713x GPIO22 for the mode switch
800  */
801
802 static int ads_duo_tuner_init(struct dvb_frontend *fe)
803 {
804         struct saa7134_dev *dev = fe->dvb->priv;
805         philips_tda827x_tuner_init(fe);
806         /* route TDA8275a AGC input to the channel decoder */
807         saa7134_set_gpio(dev, 22, 1);
808         return 0;
809 }
810
811 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
812 {
813         struct saa7134_dev *dev = fe->dvb->priv;
814         /* route TDA8275a AGC input to the analog IF chip*/
815         saa7134_set_gpio(dev, 22, 0);
816         philips_tda827x_tuner_sleep(fe);
817         return 0;
818 }
819
820 static struct tda827x_config ads_duo_cfg = {
821         .lna_gain = philips_tda827x_lna_gain,
822         .init = ads_duo_tuner_init,
823         .sleep = ads_duo_tuner_sleep
824 };
825
826 static struct tda1004x_config ads_tech_duo_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_GP00_I,
833         .if_freq       = TDA10046_FREQ_045,
834         .tuner_address = 0x61,
835         .request_firmware = philips_tda1004x_request_firmware
836 };
837
838 /* ==================================================================
839  * tda10086 based DVB-S cards, helper functions
840  */
841
842 static struct tda10086_config flydvbs = {
843         .demod_address = 0x0e,
844         .invert = 0,
845         .diseqc_tone = 0,
846 };
847
848 /* ==================================================================
849  * nxt200x based ATSC cards, helper functions
850  */
851
852 static struct nxt200x_config avertvhda180 = {
853         .demod_address    = 0x0a,
854 };
855
856 static struct nxt200x_config kworldatsc110 = {
857         .demod_address    = 0x0a,
858 };
859
860 /* ==================================================================
861  * Core code
862  */
863
864 static int dvb_init(struct saa7134_dev *dev)
865 {
866         int ret;
867         /* init struct videobuf_dvb */
868         dev->ts.nr_bufs    = 32;
869         dev->ts.nr_packets = 32*4;
870         dev->dvb.name = dev->name;
871         videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops,
872                             dev->pci, &dev->slock,
873                             V4L2_BUF_TYPE_VIDEO_CAPTURE,
874                             V4L2_FIELD_ALTERNATE,
875                             sizeof(struct saa7134_buf),
876                             dev);
877
878         switch (dev->board) {
879         case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
880                 dprintk("pinnacle 300i dvb setup\n");
881                 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
882                                                &dev->i2c_adap);
883                 if (dev->dvb.frontend) {
884                         dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
885                 }
886                 break;
887         case SAA7134_BOARD_AVERMEDIA_777:
888         case SAA7134_BOARD_AVERMEDIA_A16AR:
889                 dprintk("avertv 777 dvb setup\n");
890                 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
891                                                &dev->i2c_adap);
892                 if (dev->dvb.frontend) {
893                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
894                                    NULL, DVB_PLL_PHILIPS_TD1316);
895                 }
896                 break;
897         case SAA7134_BOARD_MD7134:
898                 dev->dvb.frontend = dvb_attach(tda10046_attach,
899                                                &medion_cardbus,
900                                                &dev->i2c_adap);
901                 if (dev->dvb.frontend) {
902                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
903                                    &dev->i2c_adap, DVB_PLL_FMD1216ME);
904                 }
905                 break;
906         case SAA7134_BOARD_PHILIPS_TOUGH:
907                 dev->dvb.frontend = dvb_attach(tda10046_attach,
908                                                &philips_tu1216_60_config,
909                                                &dev->i2c_adap);
910                 if (dev->dvb.frontend) {
911                         dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
912                         dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
913                 }
914                 break;
915         case SAA7134_BOARD_FLYDVBTDUO:
916         case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
917                 configure_tda827x_fe(dev, &tda827x_lifeview_config);
918                 break;
919         case SAA7134_BOARD_PHILIPS_EUROPA:
920         case SAA7134_BOARD_VIDEOMATE_DVBT_300:
921                 dev->dvb.frontend = dvb_attach(tda10046_attach,
922                                                &philips_europa_config,
923                                                &dev->i2c_adap);
924                 if (dev->dvb.frontend) {
925                         dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
926                         dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
927                         dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
928                         dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
929                         dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
930                 }
931                 break;
932         case SAA7134_BOARD_VIDEOMATE_DVBT_200:
933                 dev->dvb.frontend = dvb_attach(tda10046_attach,
934                                                &philips_tu1216_61_config,
935                                                &dev->i2c_adap);
936                 if (dev->dvb.frontend) {
937                         dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
938                         dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
939                 }
940                 break;
941         case SAA7134_BOARD_KWORLD_DVBT_210:
942                 configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
943                 break;
944         case SAA7134_BOARD_PHILIPS_TIGER:
945                 configure_tda827x_fe(dev, &philips_tiger_config);
946                 break;
947         case SAA7134_BOARD_PINNACLE_PCTV_310i:
948                 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
949                 break;
950         case SAA7134_BOARD_HAUPPAUGE_HVR1110:
951                 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
952                 break;
953         case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
954                 configure_tda827x_fe(dev, &asus_p7131_dual_config);
955                 break;
956         case SAA7134_BOARD_FLYDVBT_LR301:
957                 configure_tda827x_fe(dev, &tda827x_lifeview_config);
958                 break;
959         case SAA7134_BOARD_FLYDVB_TRIO:
960                 if(! use_frontend) {    /* terrestrial */
961                         configure_tda827x_fe(dev, &lifeview_trio_config);
962                 } else {                /* satellite */
963                         dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
964                         if (dev->dvb.frontend) {
965                                 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
966                                                                         &dev->i2c_adap, 0) == NULL) {
967                                         wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
968                                 }
969                                 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
970                                                                                 0x08, 0, 0) == NULL) {
971                                         wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
972                                 }
973                         }
974                 }
975                 break;
976         case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
977         case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
978                 dev->dvb.frontend = dvb_attach(tda10046_attach,
979                                                &ads_tech_duo_config,
980                                                &dev->i2c_adap);
981                 if (dev->dvb.frontend) {
982                         if (dvb_attach(tda827x_attach,dev->dvb.frontend,
983                                    ads_tech_duo_config.tuner_address,
984                                    &dev->i2c_adap,&ads_duo_cfg) == NULL) {
985                                 wprintk("no tda827x tuner found at addr: %02x\n",
986                                         ads_tech_duo_config.tuner_address);
987                         }
988                 }
989                 break;
990         case SAA7134_BOARD_TEVION_DVBT_220RF:
991                 configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
992                 break;
993         case SAA7134_BOARD_MEDION_MD8800_QUADRO:
994                 if (!use_frontend) {     /* terrestrial */
995                         configure_tda827x_fe(dev, &md8800_dvbt_config);
996                 } else {        /* satellite */
997                         dev->dvb.frontend = dvb_attach(tda10086_attach,
998                                                         &flydvbs, &dev->i2c_adap);
999                         if (dev->dvb.frontend) {
1000                                 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1001                                                 0x60, &dev->i2c_adap, 0) == NULL)
1002                                         wprintk("%s: Medion Quadro, no tda826x "
1003                                                 "found !\n", __FUNCTION__);
1004                                 if (dvb_attach(isl6405_attach, dev->dvb.frontend,
1005                                                 &dev->i2c_adap, 0x08, 0, 0) == NULL)
1006                                         wprintk("%s: Medion Quadro, no ISL6405 "
1007                                                 "found !\n", __FUNCTION__);
1008                         }
1009                 }
1010                 break;
1011         case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1012                 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1013                                                &dev->i2c_adap);
1014                 if (dev->dvb.frontend) {
1015                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1016                                    NULL, DVB_PLL_TDHU2);
1017                 }
1018                 break;
1019         case SAA7134_BOARD_KWORLD_ATSC110:
1020                 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1021                                                &dev->i2c_adap);
1022                 if (dev->dvb.frontend) {
1023                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1024                                    NULL, DVB_PLL_TUV1236D);
1025                 }
1026                 break;
1027         case SAA7134_BOARD_FLYDVBS_LR300:
1028                 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1029                                                &dev->i2c_adap);
1030                 if (dev->dvb.frontend) {
1031                         if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1032                                        &dev->i2c_adap, 0) == NULL) {
1033                                 wprintk("%s: No tda826x found!\n", __FUNCTION__);
1034                         }
1035                         if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1036                                        &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1037                                 wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
1038                         }
1039                 }
1040                 break;
1041         case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1042                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1043                                                &medion_cardbus,
1044                                                &dev->i2c_adap);
1045                 if (dev->dvb.frontend) {
1046                         dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1047                         dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1048
1049                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
1050                                    &dev->i2c_adap, DVB_PLL_FMD1216ME);
1051                 }
1052                 break;
1053         case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1054                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1055                                 &philips_europa_config,
1056                                 &dev->i2c_adap);
1057                 if (dev->dvb.frontend) {
1058                         dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1059                         dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1060                 }
1061                 break;
1062         case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1063                 configure_tda827x_fe(dev, &cinergy_ht_config);
1064                 break;
1065         case SAA7134_BOARD_CINERGY_HT_PCI:
1066                 configure_tda827x_fe(dev, &cinergy_ht_pci_config);
1067                 break;
1068         case SAA7134_BOARD_PHILIPS_TIGER_S:
1069                 configure_tda827x_fe(dev, &philips_tiger_s_config);
1070                 break;
1071         case SAA7134_BOARD_ASUS_P7131_4871:
1072                 configure_tda827x_fe(dev, &asus_p7131_4871_config);
1073                 break;
1074         case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1075                 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
1076                 break;
1077         case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1078                 configure_tda827x_fe(dev, &avermedia_super_007_config);
1079                 break;
1080         case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1081                 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
1082                 break;
1083         default:
1084                 wprintk("Huh? unknown DVB card?\n");
1085                 break;
1086         }
1087
1088         if (NULL == dev->dvb.frontend) {
1089                 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1090                 return -1;
1091         }
1092
1093         /* register everything else */
1094         ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1095
1096         /* this sequence is necessary to make the tda1004x load its firmware
1097          * and to enter analog mode of hybrid boards
1098          */
1099         if (!ret) {
1100                 if (dev->dvb.frontend->ops.init)
1101                         dev->dvb.frontend->ops.init(dev->dvb.frontend);
1102                 if (dev->dvb.frontend->ops.sleep)
1103                         dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
1104                 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1105                         dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1106         }
1107         return ret;
1108 }
1109
1110 static int dvb_fini(struct saa7134_dev *dev)
1111 {
1112         /* FIXME: I suspect that this code is bogus, since the entry for
1113            Pinnacle 300I DVB-T PAL already defines the proper init to allow
1114            the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1115          */
1116         if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1117                 struct v4l2_priv_tun_config tda9887_cfg;
1118                 static int on  = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1119
1120                 tda9887_cfg.tuner = TUNER_TDA9887;
1121                 tda9887_cfg.priv  = &on;
1122
1123                 /* otherwise we don't detect the tuner on next insmod */
1124                 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
1125         }
1126
1127         videobuf_dvb_unregister(&dev->dvb);
1128         return 0;
1129 }
1130
1131 static struct saa7134_mpeg_ops dvb_ops = {
1132         .type          = SAA7134_MPEG_DVB,
1133         .init          = dvb_init,
1134         .fini          = dvb_fini,
1135 };
1136
1137 static int __init dvb_register(void)
1138 {
1139         return saa7134_ts_register(&dvb_ops);
1140 }
1141
1142 static void __exit dvb_unregister(void)
1143 {
1144         saa7134_ts_unregister(&dvb_ops);
1145 }
1146
1147 module_init(dvb_register);
1148 module_exit(dvb_unregister);
1149
1150 /* ------------------------------------------------------------------ */
1151 /*
1152  * Local variables:
1153  * c-basic-offset: 8
1154  * End:
1155  */