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