2 * Bt8xx based DVB adapter driver
4 * Copyright (C) 2002,2003 Florian Schirmer <jolt@tuxbox.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/bitops.h>
23 #include <linux/module.h>
24 #include <linux/moduleparam.h>
25 #include <linux/init.h>
26 #include <linux/device.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/i2c.h>
33 #include "dvb_demux.h"
34 #include "dvb_frontend.h"
36 #include "dvb-bt8xx.h"
42 module_param(debug, int, 0644);
43 MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
45 #define dprintk( args... ) \
47 if (debug) printk(KERN_DEBUG args); \
50 static void dvb_bt8xx_task(unsigned long data)
52 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data;
54 //printk("%d ", card->bt->finished_block);
56 while (card->bt->last_block != card->bt->finished_block) {
57 (card->bt->TS_Size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter)
59 &card->bt->buf_cpu[card->bt->last_block *
60 card->bt->block_bytes],
61 card->bt->block_bytes);
62 card->bt->last_block = (card->bt->last_block + 1) %
63 card->bt->block_count;
67 static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed)
69 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
70 struct dvb_bt8xx_card *card = dvbdmx->priv;
73 dprintk("dvb_bt8xx: start_feed\n");
75 if (!dvbdmx->dmx.frontend)
81 if (card->nfeeds == 1)
82 bt878_start(card->bt, card->gpio_mode,
83 card->op_sync_orin, card->irq_err_ignore);
88 static int dvb_bt8xx_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
90 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
91 struct dvb_bt8xx_card *card = dvbdmx->priv;
93 dprintk("dvb_bt8xx: stop_feed\n");
95 if (!dvbdmx->dmx.frontend)
100 if (card->nfeeds == 0)
101 bt878_stop(card->bt);
107 static int is_pci_slot_eq(struct pci_dev* adev, struct pci_dev* bdev)
109 if ((adev->subsystem_vendor == bdev->subsystem_vendor) &&
110 (adev->subsystem_device == bdev->subsystem_device) &&
111 (adev->bus->number == bdev->bus->number) &&
112 (PCI_SLOT(adev->devfn) == PCI_SLOT(bdev->devfn)))
117 static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci_dev* bttv_pci_dev)
119 unsigned int card_nr;
121 /* Hmm, n squared. Hope n is small */
122 for (card_nr = 0; card_nr < bt878_num; card_nr++) {
123 if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev))
124 return &bt878[card_nr];
130 static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
132 static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 };
133 static u8 mt352_reset [] = { 0x50, 0x80 };
134 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
135 static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0x20 };
136 static u8 mt352_gpp_ctl_cfg [] = { 0x8C, 0x33 };
137 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
139 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
141 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
142 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
144 mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
145 mt352_write(fe, mt352_gpp_ctl_cfg, sizeof(mt352_gpp_ctl_cfg));
146 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
151 static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
154 unsigned char bs = 0;
155 unsigned char cp = 0;
157 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
158 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
160 if (params->frequency < 542000000) cp = 0xb4;
161 else if (params->frequency < 771000000) cp = 0xbc;
164 if (params->frequency == 0) bs = 0x03;
165 else if (params->frequency < 443250000) bs = 0x02;
168 pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address
169 pllbuf[1] = div >> 8;
170 pllbuf[2] = div & 0xff;
177 static struct mt352_config thomson_dtt7579_config = {
179 .demod_address = 0x0f,
180 .demod_init = thomson_dtt7579_demod_init,
181 .pll_set = thomson_dtt7579_pll_set,
184 static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
186 u32 freq = params->frequency;
192 u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
193 1576000,1718000,1856000,2036000,2150000};
194 u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
195 0x00102000,0x00104000,0x00108000,0x00110000,
196 0x00120000,0x00140000};
198 #define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
199 printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq);
201 /* This is really the bit driving the tuner chip cx24108 */
203 if(freq<950000) freq=950000; /* kHz */
204 if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */
206 /* decide which VCO to use for the input frequency */
207 for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++);
208 printk("cx24108 debug: select vco #%d (f=%d)\n",i,freq);
210 /* the gain values must be set by SetSymbolrate */
211 /* compute the pll divider needed, from Conexant data sheet,
212 resolved for (n*32+a), remember f(vco) is f(receive) *2 or *4,
213 depending on the divider bit. It is set to /4 on the 2 lowest
215 n=((i<=2?2:1)*freq*10L)/(XTAL/100);
216 a=n%32; n/=32; if(a==0) n--;
217 pump=(freq<(osci[i-1]+osci[i])/2);
219 ((pump?1:2)<<(14+11))|
222 /* everything is shifted left 11 bits to left-align the bits in the
223 32bit word. Output to the tuner goes MSB-aligned, after all */
224 printk("cx24108 debug: pump=%d, n=%d, a=%d\n",pump,n,a);
225 cx24110_pll_write(fe,band);
226 /* set vga and vca to their widest-band settings, as a precaution.
227 SetSymbolrate might not be called to set this up */
228 cx24110_pll_write(fe,0x500c0000);
229 cx24110_pll_write(fe,0x83f1f800);
230 cx24110_pll_write(fe,pll);
231 /* writereg(client,0x56,0x7f);*/
236 static int pinnsat_pll_init(struct dvb_frontend* fe)
242 static struct cx24110_config pctvsat_config = {
244 .demod_address = 0x55,
245 .pll_init = pinnsat_pll_init,
246 .pll_set = cx24108_pll_set,
250 static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
252 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
253 u8 cfg, cpump, band_select;
256 struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = sizeof(data) };
258 div = (36000000 + params->frequency + 83333) / 166666;
261 if (params->frequency < 175000000) cpump = 2;
262 else if (params->frequency < 390000000) cpump = 1;
263 else if (params->frequency < 470000000) cpump = 2;
264 else if (params->frequency < 750000000) cpump = 2;
267 if (params->frequency < 175000000) band_select = 0x0e;
268 else if (params->frequency < 470000000) band_select = 0x05;
269 else band_select = 0x03;
271 data[0] = (div >> 8) & 0x7f;
272 data[1] = div & 0xff;
273 data[2] = ((div >> 10) & 0x60) | cfg;
274 data[3] = cpump | band_select;
276 i2c_transfer(card->i2c_adapter, &msg, 1);
277 return (div * 166666 - 36000000);
280 static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
282 struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv;
284 return request_firmware(fw, name, &bt->bt->dev->dev);
287 static struct sp887x_config microtune_mt7202dtf_config = {
289 .demod_address = 0x70,
290 .pll_set = microtune_mt7202dtf_pll_set,
291 .request_firmware = microtune_mt7202dtf_request_firmware,
296 static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
298 static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
299 static u8 mt352_reset [] = { 0x50, 0x80 };
300 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
301 static u8 mt352_agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
302 0x00, 0xFF, 0x00, 0x40, 0x40 };
303 static u8 mt352_av771_extra[] = { 0xB5, 0x7A };
304 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
307 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
309 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
310 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
312 mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg));
314 mt352_write(fe, mt352_av771_extra,sizeof(mt352_av771_extra));
315 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
320 static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
323 unsigned char bs = 0;
324 unsigned char cp = 0;
326 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
327 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
329 if (params->frequency < 150000000) cp = 0xB4;
330 else if (params->frequency < 173000000) cp = 0xBC;
331 else if (params->frequency < 250000000) cp = 0xB4;
332 else if (params->frequency < 400000000) cp = 0xBC;
333 else if (params->frequency < 420000000) cp = 0xF4;
334 else if (params->frequency < 470000000) cp = 0xFC;
335 else if (params->frequency < 600000000) cp = 0xBC;
336 else if (params->frequency < 730000000) cp = 0xF4;
339 if (params->frequency < 150000000) bs = 0x01;
340 else if (params->frequency < 173000000) bs = 0x01;
341 else if (params->frequency < 250000000) bs = 0x02;
342 else if (params->frequency < 400000000) bs = 0x02;
343 else if (params->frequency < 420000000) bs = 0x02;
344 else if (params->frequency < 470000000) bs = 0x02;
345 else if (params->frequency < 600000000) bs = 0x08;
346 else if (params->frequency < 730000000) bs = 0x08;
349 pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
350 pllbuf[1] = div >> 8;
351 pllbuf[2] = div & 0xff;
358 static struct mt352_config advbt771_samsung_tdtc9251dh0_config = {
360 .demod_address = 0x0f,
361 .demod_init = advbt771_samsung_tdtc9251dh0_demod_init,
362 .pll_set = advbt771_samsung_tdtc9251dh0_pll_set,
366 static struct dst_config dst_config = {
368 .demod_address = 0x55,
372 static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
374 struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv;
376 return request_firmware(fw, name, &bt->bt->dev->dev);
379 static void or51211_setmode(struct dvb_frontend * fe, int mode)
381 struct dvb_bt8xx_card *bt = fe->dvb->priv;
382 bttv_write_gpio(bt->bttv_nr, 0x0002, mode); /* Reset */
386 static void or51211_reset(struct dvb_frontend * fe)
388 struct dvb_bt8xx_card *bt = fe->dvb->priv;
391 * reset is controled by GPIO-0
392 * when set to 0 causes reset and when to 1 for normal op
393 * must remain reset for 128 clock cycles on a 50Mhz clock
394 * also PRM1 PRM2 & PRM4 are controled by GPIO-1,GPIO-2 & GPIO-4
395 * We assume that the reset has be held low long enough or we
396 * have been reset by a power on. When the driver is unloaded
397 * reset set to 0 so if reloaded we have been reset.
399 /* reset & PRM1,2&4 are outputs */
400 int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F);
402 printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR "
405 bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */
407 /* Now set for normal operation */
408 bttv_write_gpio(bt->bttv_nr, 0x0001F, 0x0001);
409 /* wait for operation to begin */
413 static void or51211_sleep(struct dvb_frontend * fe)
415 struct dvb_bt8xx_card *bt = fe->dvb->priv;
416 bttv_write_gpio(bt->bttv_nr, 0x0001, 0x0000);
419 static struct or51211_config or51211_config = {
421 .demod_address = 0x15,
422 .request_firmware = or51211_request_firmware,
423 .setmode = or51211_setmode,
424 .reset = or51211_reset,
425 .sleep = or51211_sleep,
429 static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
431 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
434 struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = buf, .len = sizeof(buf) };
436 div = (params->frequency + 36166667) / 166667;
438 buf[0] = (div >> 8) & 0x7F;
441 if ((params->frequency >= 47000000) && (params->frequency < 153000000))
443 else if ((params->frequency >= 153000000) && (params->frequency < 430000000))
445 else if ((params->frequency >= 430000000) && (params->frequency < 824000000))
447 else if ((params->frequency >= 824000000) && (params->frequency < 863000000))
452 i2c_transfer(card->i2c_adapter, &msg, 1);
456 static struct nxt6000_config vp3021_alps_tded4_config = {
458 .demod_address = 0x0a,
459 .clock_inversion = 1,
460 .pll_set = vp3021_alps_tded4_pll_set,
464 static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
467 struct dst_state* state = NULL;
470 #ifdef BTTV_DVICO_DVBT_LITE
471 case BTTV_DVICO_DVBT_LITE:
472 card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter);
473 if (card->fe != NULL) {
474 card->fe->ops->info.frequency_min = 174000000;
475 card->fe->ops->info.frequency_max = 862000000;
481 #ifdef BTTV_TWINHAN_VP3021
482 case BTTV_TWINHAN_VP3021:
484 case BTTV_NEBULA_DIGITV:
486 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
487 if (card->fe != NULL) {
492 case BTTV_AVDVBT_761:
493 card->fe = sp887x_attach(µtune_mt7202dtf_config, card->i2c_adapter);
494 if (card->fe != NULL) {
499 case BTTV_AVDVBT_771:
500 card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
501 if (card->fe != NULL) {
502 card->fe->ops->info.frequency_min = 174000000;
503 card->fe->ops->info.frequency_max = 862000000;
508 case BTTV_TWINHAN_DST:
509 /* DST is not a frontend driver !!! */
510 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
512 state->config = &dst_config;
513 state->i2c = card->i2c_adapter;
514 state->bt = card->bt;
516 /* DST is not a frontend, attaching the ASIC */
517 if ((dst_attach(state, &card->dvb_adapter)) == NULL) {
518 printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__);
521 card->fe = &state->frontend;
523 /* Attach other DST peripherals if any */
524 /* Conditional Access device */
525 if (state->dst_hw_cap & DST_TYPE_HAS_CA) {
526 ret = dst_ca_attach(state, &card->dvb_adapter);
528 if (card->fe != NULL) {
533 case BTTV_PINNACLESAT:
534 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
535 if (card->fe != NULL) {
541 card->fe = or51211_attach(&or51211_config, card->i2c_adapter);
542 if (card->fe != NULL) {
548 if (card->fe == NULL) {
549 printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
550 card->bt->dev->vendor,
551 card->bt->dev->device,
552 card->bt->dev->subsystem_vendor,
553 card->bt->dev->subsystem_device);
555 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
556 printk("dvb-bt8xx: Frontend registration failed!\n");
557 if (card->fe->ops->release)
558 card->fe->ops->release(card->fe);
564 static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
568 if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name,
570 printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result);
574 card->dvb_adapter.priv = card;
576 card->bt->adapter = card->i2c_adapter;
578 memset(&card->demux, 0, sizeof(struct dvb_demux));
580 card->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING;
582 card->demux.priv = card;
583 card->demux.filternum = 256;
584 card->demux.feednum = 256;
585 card->demux.start_feed = dvb_bt8xx_start_feed;
586 card->demux.stop_feed = dvb_bt8xx_stop_feed;
587 card->demux.write_to_decoder = NULL;
589 if ((result = dvb_dmx_init(&card->demux)) < 0) {
590 printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
592 dvb_unregister_adapter(&card->dvb_adapter);
596 card->dmxdev.filternum = 256;
597 card->dmxdev.demux = &card->demux.dmx;
598 card->dmxdev.capabilities = 0;
600 if ((result = dvb_dmxdev_init(&card->dmxdev, &card->dvb_adapter)) < 0) {
601 printk("dvb_bt8xx: dvb_dmxdev_init failed (errno = %d)\n", result);
603 dvb_dmx_release(&card->demux);
604 dvb_unregister_adapter(&card->dvb_adapter);
608 card->fe_hw.source = DMX_FRONTEND_0;
610 if ((result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_hw)) < 0) {
611 printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
613 dvb_dmxdev_release(&card->dmxdev);
614 dvb_dmx_release(&card->demux);
615 dvb_unregister_adapter(&card->dvb_adapter);
619 card->fe_mem.source = DMX_MEMORY_FE;
621 if ((result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_mem)) < 0) {
622 printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
624 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
625 dvb_dmxdev_release(&card->dmxdev);
626 dvb_dmx_release(&card->demux);
627 dvb_unregister_adapter(&card->dvb_adapter);
631 if ((result = card->demux.dmx.connect_frontend(&card->demux.dmx, &card->fe_hw)) < 0) {
632 printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
634 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_mem);
635 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
636 dvb_dmxdev_release(&card->dmxdev);
637 dvb_dmx_release(&card->demux);
638 dvb_unregister_adapter(&card->dvb_adapter);
642 dvb_net_init(&card->dvb_adapter, &card->dvbnet, &card->demux.dmx);
644 tasklet_init(&card->bt->tasklet, dvb_bt8xx_task, (unsigned long) card);
646 frontend_init(card, type);
651 static int dvb_bt8xx_probe(struct device *dev)
653 struct bttv_sub_device *sub = to_bttv_sub_dev(dev);
654 struct dvb_bt8xx_card *card;
655 struct pci_dev* bttv_pci_dev;
658 if (!(card = kmalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL)))
661 memset(card, 0, sizeof(*card));
662 init_MUTEX(&card->lock);
663 card->bttv_nr = sub->core->nr;
664 strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
665 card->i2c_adapter = &sub->core->i2c_adap;
667 switch(sub->core->type)
669 case BTTV_PINNACLESAT:
670 card->gpio_mode = 0x0400c060;
671 /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
672 BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */
673 card->op_sync_orin = 0;
674 card->irq_err_ignore = 0;
677 #ifdef BTTV_DVICO_DVBT_LITE
678 case BTTV_DVICO_DVBT_LITE:
680 card->gpio_mode = 0x0400C060;
681 card->op_sync_orin = 0;
682 card->irq_err_ignore = 0;
684 * A_PWRDN DA_DPM DA_SBR DA_IOM_DA
685 * DA_APP(parallel) */
688 #ifdef BTTV_TWINHAN_VP3021
689 case BTTV_TWINHAN_VP3021:
691 case BTTV_NEBULA_DIGITV:
693 case BTTV_AVDVBT_761:
694 card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);
695 card->op_sync_orin = 0;
696 card->irq_err_ignore = 0;
697 /* A_PWRDN DA_SBR DA_APP (high speed serial) */
700 case BTTV_AVDVBT_771: //case 0x07711461:
701 card->gpio_mode = 0x0400402B;
702 card->op_sync_orin = BT878_RISC_SYNC_MASK;
703 card->irq_err_ignore = 0;
704 /* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/
707 case BTTV_TWINHAN_DST:
708 card->gpio_mode = 0x2204f2c;
709 card->op_sync_orin = BT878_RISC_SYNC_MASK;
710 card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR |
711 BT878_APPERR | BT878_AFBUS;
712 /* 25,21,14,11,10,9,8,3,2 then
714 * A_SEL=SML, DA_MLB, DA_SBR,
715 * DA_SDR=f, fifo trigger = 32 DWORDS
716 * IOM = 0 == audio A/D
717 * DPM = 0 == digital audio mode
718 * == async data parallel port
719 * then 0x33 (13 is set by start_capture)
720 * DA_APP = async data parallel port,
722 * RISC+FIFO ENABLE */
726 card->gpio_mode = 0x0100EC7B;
727 card->op_sync_orin = 0;
728 card->irq_err_ignore = 0;
732 printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n",
738 dprintk("dvb_bt8xx: identified card%d as %s\n", card->bttv_nr, card->card_name);
740 if (!(bttv_pci_dev = bttv_get_pcidev(card->bttv_nr))) {
741 printk("dvb_bt8xx: no pci device for card %d\n", card->bttv_nr);
746 if (!(card->bt = dvb_bt8xx_878_match(card->bttv_nr, bttv_pci_dev))) {
747 printk("dvb_bt8xx: unable to determine DMA core of card %d,\n",
749 printk("dvb_bt8xx: if you have the ALSA bt87x audio driver "
750 "installed, try removing it.\n");
757 init_MUTEX(&card->bt->gpio_lock);
758 card->bt->bttv_nr = sub->core->nr;
760 if ( (ret = dvb_bt8xx_load_card(card, sub->core->type)) ) {
765 dev_set_drvdata(dev, card);
769 static int dvb_bt8xx_remove(struct device *dev)
771 struct dvb_bt8xx_card *card = dev_get_drvdata(dev);
773 dprintk("dvb_bt8xx: unloading card%d\n", card->bttv_nr);
775 bt878_stop(card->bt);
776 tasklet_kill(&card->bt->tasklet);
777 dvb_net_release(&card->dvbnet);
778 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_mem);
779 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
780 dvb_dmxdev_release(&card->dmxdev);
781 dvb_dmx_release(&card->demux);
782 if (card->fe) dvb_unregister_frontend(card->fe);
783 dvb_unregister_adapter(&card->dvb_adapter);
790 static struct bttv_sub_driver driver = {
793 .probe = dvb_bt8xx_probe,
794 .remove = dvb_bt8xx_remove,
796 * .shutdown = dvb_bt8xx_shutdown,
797 * .suspend = dvb_bt8xx_suspend,
798 * .resume = dvb_bt8xx_resume,
803 static int __init dvb_bt8xx_init(void)
805 return bttv_sub_register(&driver, "dvb");
808 static void __exit dvb_bt8xx_exit(void)
810 bttv_sub_unregister(&driver);
813 module_init(dvb_bt8xx_init);
814 module_exit(dvb_bt8xx_exit);
816 MODULE_DESCRIPTION("Bt8xx based DVB adapter driver");
817 MODULE_AUTHOR("Florian Schirmer <jolt@tuxbox.org>");
818 MODULE_LICENSE("GPL");