2 * driver for the SAA7146 based AV110 cards (like the Fujitsu-Siemens DVB)
3 * av7110.c: initialization and demux stuff
5 * Copyright (C) 1999-2002 Ralph Metzler
6 * & Marcus Metzler for convergence integrated media GmbH
8 * originally based on code by:
9 * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
29 * the project's page is at http://www.linuxtv.org/dvb/
33 #include <linux/config.h>
34 #include <linux/module.h>
35 #include <linux/kmod.h>
36 #include <linux/delay.h>
38 #include <linux/timer.h>
39 #include <linux/poll.h>
40 #include <linux/byteorder/swabb.h>
41 #include <linux/smp_lock.h>
43 #include <linux/kernel.h>
44 #include <linux/moduleparam.h>
45 #include <linux/sched.h>
46 #include <linux/types.h>
47 #include <linux/fcntl.h>
48 #include <linux/interrupt.h>
49 #include <linux/string.h>
50 #include <linux/pci.h>
51 #include <linux/vmalloc.h>
52 #include <linux/firmware.h>
53 #include <linux/crc32.h>
54 #include <linux/i2c.h>
56 #include <asm/system.h>
57 #include <asm/semaphore.h>
59 #include <linux/dvb/frontend.h>
61 #include "dvb_frontend.h"
63 #include "ttpci-eeprom.h"
65 #include "av7110_hw.h"
66 #include "av7110_av.h"
67 #include "av7110_ca.h"
68 #include "av7110_ipack.h"
72 #define TS_BUFLEN (TS_WIDTH*TS_HEIGHT)
73 #define TS_MAX_PACKETS (TS_BUFLEN/TS_SIZE)
78 static int vidmode = CVBS_RGB_OUT;
80 static int adac = DVB_ADAC_TI;
81 static int hw_sections;
83 static int volume = 255;
84 static int budgetpatch = 0;
86 module_param_named(debug, av7110_debug, int, 0644);
87 MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)");
88 module_param(vidmode, int, 0444);
89 MODULE_PARM_DESC(vidmode,"analog video out: 0 off, 1 CVBS+RGB (default), 2 CVBS+YC, 3 YC");
90 module_param(pids_off, int, 0444);
91 MODULE_PARM_DESC(pids_off,"clear video/audio/PCR PID filters when demux is closed");
92 module_param(adac, int, 0444);
93 MODULE_PARM_DESC(adac,"audio DAC type: 0 TI, 1 CRYSTAL, 2 MSP (use if autodetection fails)");
94 module_param(hw_sections, int, 0444);
95 MODULE_PARM_DESC(hw_sections, "0 use software section filter, 1 use hardware");
96 module_param(rgb_on, int, 0444);
97 MODULE_PARM_DESC(rgb_on, "For Siemens DVB-C cards only: Enable RGB control"
98 " signal on SCART pin 16 to switch SCART video mode from CVBS to RGB");
99 module_param(volume, int, 0444);
100 MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)");
101 module_param(budgetpatch, int, 0444);
102 MODULE_PARM_DESC(budgetpatch, "use budget-patch hardware modification: default 0 (0 no, 1 autodetect, 2 always)");
104 static void restart_feeds(struct av7110 *av7110);
106 static int av7110_num = 0;
108 #define FE_FUNC_OVERRIDE(fe_func, av7110_copy, av7110_func) \
110 if (fe_func != NULL) { \
111 av7110_copy = fe_func; \
112 fe_func = av7110_func; \
117 static void init_av7110_av(struct av7110 *av7110)
120 struct saa7146_dev *dev = av7110->dev;
122 /* set internal volume control to maximum */
123 av7110->adac_type = DVB_ADAC_TI;
124 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
126 printk("dvb-ttpci:cannot set internal volume to maximum:%d\n",ret);
128 ret = av7710_set_video_mode(av7110, vidmode);
130 printk("dvb-ttpci:cannot set video mode:%d\n",ret);
132 /* handle different card types */
133 /* remaining inits according to card and frontend type */
134 av7110->analog_tuner_flags = 0;
135 av7110->current_input = 0;
136 if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) {
137 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n",
138 av7110->dvb_adapter.num);
139 av7110->adac_type = DVB_ADAC_CRYSTAL;
140 i2c_writereg(av7110, 0x20, 0x01, 0xd2);
141 i2c_writereg(av7110, 0x20, 0x02, 0x49);
142 i2c_writereg(av7110, 0x20, 0x03, 0x00);
143 i2c_writereg(av7110, 0x20, 0x04, 0x00);
146 * some special handling for the Siemens DVB-C cards...
148 } else if (0 == av7110_init_analog_module(av7110)) {
151 else if (dev->pci->subsystem_vendor == 0x110a) {
152 printk("dvb-ttpci: DVB-C w/o analog module @ card %d detected\n",
153 av7110->dvb_adapter.num);
154 av7110->adac_type = DVB_ADAC_NONE;
157 av7110->adac_type = adac;
158 printk("dvb-ttpci: adac type set to %d @ card %d\n",
159 av7110->dvb_adapter.num, av7110->adac_type);
162 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) {
163 // switch DVB SCART on
164 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
166 printk("dvb-ttpci:cannot switch on SCART(Main):%d\n",ret);
167 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
169 printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret);
171 ((av7110->dev->pci->subsystem_vendor == 0x110a) ||
172 (av7110->dev->pci->subsystem_vendor == 0x13c2)) &&
173 (av7110->dev->pci->subsystem_device == 0x0000)) {
174 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
175 //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8
179 if (dev->pci->subsystem_vendor == 0x13c2 && dev->pci->subsystem_device == 0x000e)
180 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, SpdifSwitch, 1, 0); // SPDIF on
182 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
184 printk("dvb-ttpci:cannot set volume :%d\n",ret);
187 static void recover_arm(struct av7110 *av7110)
189 dprintk(4, "%p\n",av7110);
191 av7110_bootarm(av7110);
193 restart_feeds(av7110);
194 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, av7110->ir_config);
197 static void arm_error(struct av7110 *av7110)
199 dprintk(4, "%p\n",av7110);
201 av7110->arm_errors++;
202 av7110->arm_ready = 0;
206 static void av7110_arm_sync(struct av7110 *av7110)
208 av7110->arm_rmmod = 1;
209 wake_up_interruptible(&av7110->arm_wait);
211 while (av7110->arm_thread)
215 static int arm_thread(void *data)
217 struct av7110 *av7110 = data;
221 dprintk(4, "%p\n",av7110);
224 daemonize("arm_mon");
225 sigfillset(¤t->blocked);
228 av7110->arm_thread = current;
231 timeout = wait_event_interruptible_timeout(av7110->arm_wait,
232 av7110->arm_rmmod, 5 * HZ);
233 if (-ERESTARTSYS == timeout || av7110->arm_rmmod) {
234 /* got signal or told to quit*/
238 if (!av7110->arm_ready)
241 if (down_interruptible(&av7110->dcomlock))
244 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2);
245 up(&av7110->dcomlock);
247 if (newloops == av7110->arm_loops) {
248 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
249 av7110->dvb_adapter.num);
252 av7710_set_video_mode(av7110, vidmode);
254 init_av7110_av(av7110);
256 if (down_interruptible(&av7110->dcomlock))
259 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1;
260 up(&av7110->dcomlock);
262 av7110->arm_loops = newloops;
265 av7110->arm_thread = NULL;
270 /****************************************************************************
272 ****************************************************************************/
274 static int DvbDmxFilterCallback(u8 *buffer1, size_t buffer1_len,
275 u8 *buffer2, size_t buffer2_len,
276 struct dvb_demux_filter *dvbdmxfilter,
277 enum dmx_success success,
278 struct av7110 *av7110)
280 if (!dvbdmxfilter->feed->demux->dmx.frontend)
282 if (dvbdmxfilter->feed->demux->dmx.frontend->source == DMX_MEMORY_FE)
285 switch (dvbdmxfilter->type) {
287 if ((((buffer1[1] << 8) | buffer1[2]) & 0xfff) + 3 != buffer1_len)
289 if (dvbdmxfilter->doneq) {
290 struct dmx_section_filter *filter = &dvbdmxfilter->filter;
294 for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
295 xor = filter->filter_value[i] ^ buffer1[i];
296 neq |= dvbdmxfilter->maskandnotmode[i] & xor;
301 return dvbdmxfilter->feed->cb.sec(buffer1, buffer1_len,
302 buffer2, buffer2_len,
303 &dvbdmxfilter->filter,
306 if (!(dvbdmxfilter->feed->ts_type & TS_PACKET))
308 if (dvbdmxfilter->feed->ts_type & TS_PAYLOAD_ONLY)
309 return dvbdmxfilter->feed->cb.ts(buffer1, buffer1_len,
310 buffer2, buffer2_len,
311 &dvbdmxfilter->feed->feed.ts,
314 av7110_p2t_write(buffer1, buffer1_len,
315 dvbdmxfilter->feed->pid,
316 &av7110->p2t_filter[dvbdmxfilter->index]);
323 //#define DEBUG_TIMING
324 static inline void print_time(char *s)
328 do_gettimeofday(&tv);
329 printk("%s: %d.%d\n", s, (int)tv.tv_sec, (int)tv.tv_usec);
335 static inline void start_debi_dma(struct av7110 *av7110, int dir,
336 unsigned long addr, unsigned int len)
338 dprintk(8, "%c %08lx %u\n", dir == DEBI_READ ? 'R' : 'W', addr, len);
339 if (saa7146_wait_for_debi_done(av7110->dev, 0)) {
340 printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __FUNCTION__);
344 SAA7146_ISR_CLEAR(av7110->dev, MASK_19); /* for good measure */
345 SAA7146_IER_ENABLE(av7110->dev, MASK_19);
347 len = 5; /* we want a real DEBI DMA */
348 if (dir == DEBI_WRITE)
349 iwdebi(av7110, DEBISWAB, addr, 0, (len + 3) & ~3);
351 irdebi(av7110, DEBISWAB, addr, 0, len);
354 static void debiirq(unsigned long data)
356 struct av7110 *av7110 = (struct av7110 *) data;
357 int type = av7110->debitype;
358 int handle = (type >> 8) & 0x1f;
359 unsigned int xfer = 0;
362 dprintk(4, "type 0x%04x\n", type);
365 printk("DEBI irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
366 jiffies, saa7146_read(av7110->dev, PSR),
367 saa7146_read(av7110->dev, SSR));
370 av7110->debitype = -1;
372 switch (type & 0xff) {
375 dvb_dmx_swfilter_packets(&av7110->demux,
376 (const u8 *) av7110->debi_virt,
377 av7110->debilen / 188);
381 case DATA_PES_RECORD:
382 if (av7110->demux.recording)
383 av7110_record_cb(&av7110->p2t[handle],
384 (u8 *) av7110->debi_virt,
392 if (av7110->handle2filter[handle])
393 DvbDmxFilterCallback((u8 *)av7110->debi_virt,
394 av7110->debilen, NULL, 0,
395 av7110->handle2filter[handle],
402 u8 *data = av7110->debi_virt;
404 if ((data[0] < 2) && data[2] == 0xff) {
407 flags |= CA_CI_MODULE_PRESENT;
409 flags |= CA_CI_MODULE_READY;
410 av7110->ci_slot[data[0]].flags = flags;
412 ci_get_data(&av7110->ci_rbuffer,
419 case DATA_COMMON_INTERFACE:
420 CI_handle(av7110, (u8 *)av7110->debi_virt, av7110->debilen);
425 printk("av7110%d: ", av7110->num);
426 printk("%02x ", *(u8 *)av7110->debi_virt);
427 printk("%02x ", *(1+(u8 *)av7110->debi_virt));
428 for (i = 2; i < av7110->debilen; i++)
429 printk("%02x ", (*(i+(unsigned char *)av7110->debi_virt)));
430 for (i = 2; i < av7110->debilen; i++)
431 printk("%c", chtrans(*(i+(unsigned char *)av7110->debi_virt)));
439 case DATA_DEBUG_MESSAGE:
440 ((s8*)av7110->debi_virt)[Reserved_SIZE - 1] = 0;
441 printk("%s\n", (s8 *) av7110->debi_virt);
446 dprintk(4, "debi DATA_CI_PUT\n");
448 dprintk(4, "debi DATA_MPEG_PLAY\n");
450 dprintk(4, "debi DATA_BMP_LOAD\n");
457 spin_lock(&av7110->debilock);
459 iwdebi(av7110, DEBINOSWAP, xfer, 0, 2);
460 ARM_ClearMailBox(av7110);
461 spin_unlock(&av7110->debilock);
464 /* irq from av7110 firmware writing the mailbox register in the DPRAM */
465 static void gpioirq(unsigned long data)
467 struct av7110 *av7110 = (struct av7110 *) data;
471 if (av7110->debitype != -1)
472 /* we shouldn't get any irq while a debi xfer is running */
473 printk("dvb-ttpci: GPIO0 irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
474 jiffies, saa7146_read(av7110->dev, PSR),
475 saa7146_read(av7110->dev, SSR));
477 if (saa7146_wait_for_debi_done(av7110->dev, 0)) {
478 printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __FUNCTION__);
479 BUG(); /* maybe we should try resetting the debi? */
482 spin_lock(&av7110->debilock);
483 ARM_ClearIrq(av7110);
485 /* see what the av7110 wants */
486 av7110->debitype = irdebi(av7110, DEBINOSWAP, IRQ_STATE, 0, 2);
487 av7110->debilen = irdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
488 rxbuf = irdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
489 txbuf = irdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
490 len = (av7110->debilen + 3) & ~3;
493 dprintk(8, "GPIO0 irq 0x%04x %d\n", av7110->debitype, av7110->debilen);
495 switch (av7110->debitype & 0xff) {
501 case DATA_MPEG_VIDEO_EVENT:
504 struct video_event event;
506 av7110->video_size.w = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_WIDTH, 0, 2);
507 h_ar = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_HEIGHT_AR, 0, 2);
509 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
510 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
512 av7110->video_size.h = h_ar & 0xfff;
513 dprintk(8, "GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n",
514 av7110->video_size.w,
515 av7110->video_size.h,
516 av7110->video_size.aspect_ratio);
518 event.type = VIDEO_EVENT_SIZE_CHANGED;
519 event.u.size.w = av7110->video_size.w;
520 event.u.size.h = av7110->video_size.h;
521 switch ((h_ar >> 12) & 0xf)
524 av7110->video_size.aspect_ratio = VIDEO_FORMAT_16_9;
525 event.u.size.aspect_ratio = VIDEO_FORMAT_16_9;
526 av7110->videostate.video_format = VIDEO_FORMAT_16_9;
529 av7110->video_size.aspect_ratio = VIDEO_FORMAT_221_1;
530 event.u.size.aspect_ratio = VIDEO_FORMAT_221_1;
531 av7110->videostate.video_format = VIDEO_FORMAT_221_1;
534 av7110->video_size.aspect_ratio = VIDEO_FORMAT_4_3;
535 event.u.size.aspect_ratio = VIDEO_FORMAT_4_3;
536 av7110->videostate.video_format = VIDEO_FORMAT_4_3;
538 dvb_video_add_event(av7110, &event);
545 struct dvb_ringbuffer *cibuf = &av7110->ci_wbuffer;
547 avail = dvb_ringbuffer_avail(cibuf);
549 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
550 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
551 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
554 len = DVB_RINGBUFFER_PEEK(cibuf, 0) << 8;
555 len |= DVB_RINGBUFFER_PEEK(cibuf, 1);
556 if (avail < len + 2) {
557 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
558 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
559 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
562 DVB_RINGBUFFER_SKIP(cibuf, 2);
564 dvb_ringbuffer_read(cibuf, av7110->debi_virt, len, 0);
566 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
567 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
568 dprintk(8, "DMA: CI\n");
569 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE + txbuf, len);
570 spin_unlock(&av7110->debilock);
571 wake_up(&cibuf->queue);
576 if (!av7110->playing) {
577 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
578 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
579 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
583 if (av7110->debitype & 0x100) {
584 spin_lock(&av7110->aout.lock);
585 len = av7110_pes_play(av7110->debi_virt, &av7110->aout, 2048);
586 spin_unlock(&av7110->aout.lock);
588 if (len <= 0 && (av7110->debitype & 0x200)
589 &&av7110->videostate.play_state != VIDEO_FREEZED) {
590 spin_lock(&av7110->avout.lock);
591 len = av7110_pes_play(av7110->debi_virt, &av7110->avout, 2048);
592 spin_unlock(&av7110->avout.lock);
595 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
596 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
597 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
600 dprintk(8, "GPIO0 PES_PLAY len=%04x\n", len);
601 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
602 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
603 dprintk(8, "DMA: MPEG_PLAY\n");
604 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE + txbuf, len);
605 spin_unlock(&av7110->debilock);
609 len = av7110->debilen;
610 dprintk(8, "gpio DATA_BMP_LOAD len %d\n", len);
612 av7110->bmp_state = BMP_LOADED;
613 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
614 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
615 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
616 wake_up(&av7110->bmpq);
617 dprintk(8, "gpio DATA_BMP_LOAD done\n");
620 if (len > av7110->bmplen)
621 len = av7110->bmplen;
624 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
625 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
626 memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len);
628 av7110->bmplen -= len;
629 dprintk(8, "gpio DATA_BMP_LOAD DMA len %d\n", len);
630 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE+txbuf, len);
631 spin_unlock(&av7110->debilock);
635 case DATA_COMMON_INTERFACE:
639 if (!len || len > 4 * 1024) {
640 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
646 case DATA_PES_RECORD:
647 dprintk(8, "DMA: TS_REC etc.\n");
648 start_debi_dma(av7110, DEBI_READ, DPRAM_BASE+rxbuf, len);
649 spin_unlock(&av7110->debilock);
652 case DATA_DEBUG_MESSAGE:
653 if (!len || len > 0xff) {
654 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
657 start_debi_dma(av7110, DEBI_READ, Reserved, len);
658 spin_unlock(&av7110->debilock);
662 if (av7110->ir_handler)
663 av7110->ir_handler(av7110,
664 swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4)));
665 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
669 printk("dvb-ttpci: gpioirq unknown type=%d len=%d\n",
670 av7110->debitype, av7110->debilen);
673 av7110->debitype = -1;
674 ARM_ClearMailBox(av7110);
675 spin_unlock(&av7110->debilock);
679 #ifdef CONFIG_DVB_AV7110_OSD
680 static int dvb_osd_ioctl(struct inode *inode, struct file *file,
681 unsigned int cmd, void *parg)
683 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
684 struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
686 dprintk(4, "%p\n", av7110);
688 if (cmd == OSD_SEND_CMD)
689 return av7110_osd_cmd(av7110, (osd_cmd_t *) parg);
690 if (cmd == OSD_GET_CAPABILITY)
691 return av7110_osd_capability(av7110, (osd_cap_t *) parg);
697 static struct file_operations dvb_osd_fops = {
698 .owner = THIS_MODULE,
699 .ioctl = dvb_generic_ioctl,
700 .open = dvb_generic_open,
701 .release = dvb_generic_release,
704 static struct dvb_device dvbdev_osd = {
708 .fops = &dvb_osd_fops,
709 .kernel_ioctl = dvb_osd_ioctl,
711 #endif /* CONFIG_DVB_AV7110_OSD */
714 static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
715 u16 subpid, u16 pcrpid)
717 dprintk(4, "%p\n", av7110);
719 if (vpid == 0x1fff || apid == 0x1fff ||
720 ttpid == 0x1fff || subpid == 0x1fff || pcrpid == 0x1fff) {
721 vpid = apid = ttpid = subpid = pcrpid = 0;
722 av7110->pids[DMX_PES_VIDEO] = 0;
723 av7110->pids[DMX_PES_AUDIO] = 0;
724 av7110->pids[DMX_PES_TELETEXT] = 0;
725 av7110->pids[DMX_PES_PCR] = 0;
728 return av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, MultiPID, 5,
729 pcrpid, vpid, apid, ttpid, subpid);
732 int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
733 u16 subpid, u16 pcrpid)
736 dprintk(4, "%p\n", av7110);
738 if (down_interruptible(&av7110->pid_mutex))
741 if (!(vpid & 0x8000))
742 av7110->pids[DMX_PES_VIDEO] = vpid;
743 if (!(apid & 0x8000))
744 av7110->pids[DMX_PES_AUDIO] = apid;
745 if (!(ttpid & 0x8000))
746 av7110->pids[DMX_PES_TELETEXT] = ttpid;
747 if (!(pcrpid & 0x8000))
748 av7110->pids[DMX_PES_PCR] = pcrpid;
750 av7110->pids[DMX_PES_SUBTITLE] = 0;
752 if (av7110->fe_synced) {
753 pcrpid = av7110->pids[DMX_PES_PCR];
754 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
757 up(&av7110->pid_mutex);
762 /******************************************************************************
763 * hardware filter functions
764 ******************************************************************************/
766 static int StartHWFilter(struct dvb_demux_filter *dvbdmxfilter)
768 struct dvb_demux_feed *dvbdmxfeed = dvbdmxfilter->feed;
769 struct av7110 *av7110 = (struct av7110 *) dvbdmxfeed->demux->priv;
773 // u16 mode = 0x0320;
776 dprintk(4, "%p\n", av7110);
778 if (dvbdmxfilter->type == DMX_TYPE_SEC) {
780 buf[4] = (dvbdmxfilter->filter.filter_value[0] << 8) |
781 dvbdmxfilter->maskandmode[0];
782 for (i = 3; i < 18; i++)
784 (dvbdmxfilter->filter.filter_value[i] << 8) |
785 dvbdmxfilter->maskandmode[i];
788 } else if ((dvbdmxfeed->ts_type & TS_PACKET) &&
789 !(dvbdmxfeed->ts_type & TS_PAYLOAD_ONLY)) {
790 av7110_p2t_init(&av7110->p2t_filter[dvbdmxfilter->index], dvbdmxfeed);
793 buf[0] = (COMTYPE_PID_FILTER << 8) + AddPIDFilter;
795 buf[2] = dvbdmxfeed->pid;
798 ret = av7110_fw_request(av7110, buf, 20, &handle, 1);
799 if (ret != 0 || handle >= 32) {
800 printk("dvb-ttpci: %s error buf %04x %04x %04x %04x "
801 "ret %d handle %04x\n",
802 __FUNCTION__, buf[0], buf[1], buf[2], buf[3],
804 dvbdmxfilter->hw_handle = 0xffff;
810 av7110->handle2filter[handle] = dvbdmxfilter;
811 dvbdmxfilter->hw_handle = handle;
816 static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter)
818 struct av7110 *av7110 = (struct av7110 *) dvbdmxfilter->feed->demux->priv;
824 dprintk(4, "%p\n", av7110);
826 handle = dvbdmxfilter->hw_handle;
828 printk("%s tried to stop invalid filter %04x, filter type = %x\n",
829 __FUNCTION__, handle, dvbdmxfilter->type);
833 av7110->handle2filter[handle] = NULL;
835 buf[0] = (COMTYPE_PID_FILTER << 8) + DelPIDFilter;
838 ret = av7110_fw_request(av7110, buf, 3, answ, 2);
839 if (ret != 0 || answ[1] != handle) {
840 printk("dvb-ttpci: %s error cmd %04x %04x %04x ret %x "
841 "resp %04x %04x pid %d\n",
842 __FUNCTION__, buf[0], buf[1], buf[2], ret,
843 answ[0], answ[1], dvbdmxfilter->feed->pid);
851 static int dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed)
853 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
854 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv;
855 u16 *pid = dvbdmx->pids, npids[5];
859 dprintk(4, "%p\n", av7110);
861 npids[0] = npids[1] = npids[2] = npids[3] = npids[4] = 0xffff;
862 i = dvbdmxfeed->pes_type;
863 npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
864 if ((i == 2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) {
866 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
868 ret = StartHWFilter(dvbdmxfeed->filter);
871 if (dvbdmxfeed->pes_type <= 2 || dvbdmxfeed->pes_type == 4) {
872 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
877 if (dvbdmxfeed->pes_type < 2 && npids[0])
878 if (av7110->fe_synced)
880 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
885 if ((dvbdmxfeed->ts_type & TS_PACKET)) {
886 if (dvbdmxfeed->pes_type == 0 && !(dvbdmx->pids[0] & 0x8000))
887 ret = av7110_av_start_record(av7110, RP_AUDIO, dvbdmxfeed);
888 if (dvbdmxfeed->pes_type == 1 && !(dvbdmx->pids[1] & 0x8000))
889 ret = av7110_av_start_record(av7110, RP_VIDEO, dvbdmxfeed);
894 static int dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed)
896 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
897 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv;
898 u16 *pid = dvbdmx->pids, npids[5];
903 dprintk(4, "%p\n", av7110);
905 if (dvbdmxfeed->pes_type <= 1) {
906 ret = av7110_av_stop(av7110, dvbdmxfeed->pes_type ? RP_VIDEO : RP_AUDIO);
909 if (!av7110->rec_mode)
910 dvbdmx->recording = 0;
911 if (!av7110->playing)
914 npids[0] = npids[1] = npids[2] = npids[3] = npids[4] = 0xffff;
915 i = dvbdmxfeed->pes_type;
918 if (dvbdmxfeed->ts_type & TS_PACKET)
919 ret = StopHWFilter(dvbdmxfeed->filter);
927 npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
931 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
935 static int av7110_start_feed(struct dvb_demux_feed *feed)
937 struct dvb_demux *demux = feed->demux;
938 struct av7110 *av7110 = demux->priv;
941 dprintk(4, "%p\n", av7110);
943 if (!demux->dmx.frontend)
946 if (feed->pid > 0x1fff)
949 if (feed->type == DMX_TYPE_TS) {
950 if ((feed->ts_type & TS_DECODER) &&
951 (feed->pes_type < DMX_TS_PES_OTHER)) {
952 switch (demux->dmx.frontend->source) {
954 if (feed->ts_type & TS_DECODER)
955 if (feed->pes_type < 2 &&
956 !(demux->pids[0] & 0x8000) &&
957 !(demux->pids[1] & 0x8000)) {
958 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
959 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
960 ret = av7110_av_start_play(av7110,RP_AV);
966 ret = dvb_feed_start_pid(feed);
969 } else if ((feed->ts_type & TS_PACKET) &&
970 (demux->dmx.frontend->source != DMX_MEMORY_FE)) {
971 ret = StartHWFilter(feed->filter);
975 else if (feed->type == DMX_TYPE_SEC) {
978 for (i = 0; i < demux->filternum; i++) {
979 if (demux->filter[i].state != DMX_STATE_READY)
981 if (demux->filter[i].type != DMX_TYPE_SEC)
983 if (demux->filter[i].filter.parent != &feed->feed.sec)
985 demux->filter[i].state = DMX_STATE_GO;
986 if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
987 ret = StartHWFilter(&demux->filter[i]);
998 static int av7110_stop_feed(struct dvb_demux_feed *feed)
1000 struct dvb_demux *demux = feed->demux;
1001 struct av7110 *av7110 = demux->priv;
1003 dprintk(4, "%p\n", av7110);
1005 if (feed->type == DMX_TYPE_TS) {
1006 if (feed->ts_type & TS_DECODER) {
1007 if (feed->pes_type >= DMX_TS_PES_OTHER ||
1008 !demux->pesfilter[feed->pes_type])
1010 demux->pids[feed->pes_type] |= 0x8000;
1011 demux->pesfilter[feed->pes_type] = NULL;
1013 if (feed->ts_type & TS_DECODER &&
1014 feed->pes_type < DMX_TS_PES_OTHER) {
1015 ret = dvb_feed_stop_pid(feed);
1017 if ((feed->ts_type & TS_PACKET) &&
1018 (demux->dmx.frontend->source != DMX_MEMORY_FE))
1019 ret = StopHWFilter(feed->filter);
1022 if (!ret && feed->type == DMX_TYPE_SEC) {
1023 for (i = 0; i<demux->filternum; i++) {
1024 if (demux->filter[i].state == DMX_STATE_GO &&
1025 demux->filter[i].filter.parent == &feed->feed.sec) {
1026 demux->filter[i].state = DMX_STATE_READY;
1027 if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
1028 rc = StopHWFilter(&demux->filter[i]);
1031 /* keep going, stop as many filters as possible */
1041 static void restart_feeds(struct av7110 *av7110)
1043 struct dvb_demux *dvbdmx = &av7110->demux;
1044 struct dvb_demux_feed *feed;
1048 dprintk(4, "%p\n", av7110);
1050 mode = av7110->playing;
1051 av7110->playing = 0;
1052 av7110->rec_mode = 0;
1054 for (i = 0; i < dvbdmx->filternum; i++) {
1055 feed = &dvbdmx->feed[i];
1056 if (feed->state == DMX_STATE_GO)
1057 av7110_start_feed(feed);
1061 av7110_av_start_play(av7110, mode);
1064 static int dvb_get_stc(struct dmx_demux *demux, unsigned int num,
1065 uint64_t *stc, unsigned int *base)
1069 u16 tag = ((COMTYPE_REQUEST << 8) + ReqSTC);
1070 struct dvb_demux *dvbdemux;
1071 struct av7110 *av7110;
1073 /* pointer casting paranoia... */
1076 dvbdemux = (struct dvb_demux *) demux->priv;
1079 av7110 = (struct av7110 *) dvbdemux->priv;
1081 dprintk(4, "%p\n", av7110);
1086 ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4);
1088 printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__);
1091 dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n",
1092 fwstc[0], fwstc[1], fwstc[2], fwstc[3]);
1094 *stc = (((uint64_t) ((fwstc[3] & 0x8000) >> 15)) << 32) |
1095 (((uint64_t) fwstc[1]) << 16) | ((uint64_t) fwstc[0]);
1098 dprintk(4, "stc = %lu\n", (unsigned long)*stc);
1104 /******************************************************************************
1105 * SEC device file operations
1106 ******************************************************************************/
1109 static int av7110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
1111 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1115 return Set22K(av7110, 1);
1118 return Set22K(av7110, 0);
1125 static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe,
1126 struct dvb_diseqc_master_cmd* cmd)
1128 struct av7110* av7110 = fe->dvb->priv;
1130 return av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1);
1133 static int av7110_diseqc_send_burst(struct dvb_frontend* fe,
1134 fe_sec_mini_cmd_t minicmd)
1136 struct av7110* av7110 = fe->dvb->priv;
1138 return av7110_diseqc_send(av7110, 0, NULL, minicmd);
1141 /* simplified code from budget-core.c */
1142 static int stop_ts_capture(struct av7110 *budget)
1144 dprintk(2, "budget: %p\n", budget);
1146 if (--budget->feeding1)
1147 return budget->feeding1;
1148 saa7146_write(budget->dev, MC1, MASK_20); /* DMA3 off */
1149 SAA7146_IER_DISABLE(budget->dev, MASK_10);
1150 SAA7146_ISR_CLEAR(budget->dev, MASK_10);
1154 static int start_ts_capture(struct av7110 *budget)
1156 dprintk(2, "budget: %p\n", budget);
1158 if (budget->feeding1)
1159 return ++budget->feeding1;
1160 memset(budget->grabbing, 0x00, TS_HEIGHT * TS_WIDTH);
1163 SAA7146_IER_ENABLE(budget->dev, MASK_10); /* VPE */
1164 saa7146_write(budget->dev, MC1, (MASK_04 | MASK_20)); /* DMA3 on */
1165 return ++budget->feeding1;
1168 static int budget_start_feed(struct dvb_demux_feed *feed)
1170 struct dvb_demux *demux = feed->demux;
1171 struct av7110 *budget = (struct av7110 *) demux->priv;
1174 dprintk(2, "av7110: %p\n", budget);
1176 spin_lock(&budget->feedlock1);
1177 feed->pusi_seen = 0; /* have a clean section start */
1178 status = start_ts_capture(budget);
1179 spin_unlock(&budget->feedlock1);
1183 static int budget_stop_feed(struct dvb_demux_feed *feed)
1185 struct dvb_demux *demux = feed->demux;
1186 struct av7110 *budget = (struct av7110 *) demux->priv;
1189 dprintk(2, "budget: %p\n", budget);
1191 spin_lock(&budget->feedlock1);
1192 status = stop_ts_capture(budget);
1193 spin_unlock(&budget->feedlock1);
1197 static void vpeirq(unsigned long data)
1199 struct av7110 *budget = (struct av7110 *) data;
1200 u8 *mem = (u8 *) (budget->grabbing);
1201 u32 olddma = budget->ttbp;
1202 u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
1205 printk("av7110.c: vpeirq() called while budgetpatch disabled!"
1206 " check saa7146 IER register\n");
1209 /* nearest lower position divisible by 188 */
1210 newdma -= newdma % 188;
1212 if (newdma >= TS_BUFLEN)
1215 budget->ttbp = newdma;
1217 if (!budget->feeding1 || (newdma == olddma))
1221 /* track rps1 activity */
1222 printk("vpeirq: %02x Event Counter 1 0x%04x\n",
1224 saa7146_read(budget->dev, EC1R) & 0x3fff);
1227 if (newdma > olddma)
1228 /* no wraparound, dump olddma..newdma */
1229 dvb_dmx_swfilter_packets(&budget->demux1, mem + olddma, (newdma - olddma) / 188);
1231 /* wraparound, dump olddma..buflen and 0..newdma */
1232 dvb_dmx_swfilter_packets(&budget->demux1, mem + olddma, (TS_BUFLEN - olddma) / 188);
1233 dvb_dmx_swfilter_packets(&budget->demux1, mem, newdma / 188);
1237 static int av7110_register(struct av7110 *av7110)
1240 struct dvb_demux *dvbdemux = &av7110->demux;
1241 struct dvb_demux *dvbdemux1 = &av7110->demux1;
1243 dprintk(4, "%p\n", av7110);
1245 if (av7110->registered)
1248 av7110->registered = 1;
1250 dvbdemux->priv = (void *) av7110;
1252 for (i = 0; i < 32; i++)
1253 av7110->handle2filter[i] = NULL;
1255 dvbdemux->filternum = 32;
1256 dvbdemux->feednum = 32;
1257 dvbdemux->start_feed = av7110_start_feed;
1258 dvbdemux->stop_feed = av7110_stop_feed;
1259 dvbdemux->write_to_decoder = av7110_write_to_decoder;
1260 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
1261 DMX_MEMORY_BASED_FILTERING);
1263 dvb_dmx_init(&av7110->demux);
1264 av7110->demux.dmx.get_stc = dvb_get_stc;
1266 av7110->dmxdev.filternum = 32;
1267 av7110->dmxdev.demux = &dvbdemux->dmx;
1268 av7110->dmxdev.capabilities = 0;
1270 dvb_dmxdev_init(&av7110->dmxdev, &av7110->dvb_adapter);
1272 av7110->hw_frontend.source = DMX_FRONTEND_0;
1274 ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
1279 av7110->mem_frontend.source = DMX_MEMORY_FE;
1281 ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
1286 ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx,
1287 &av7110->hw_frontend);
1291 av7110_av_register(av7110);
1292 av7110_ca_register(av7110);
1294 #ifdef CONFIG_DVB_AV7110_OSD
1295 dvb_register_device(&av7110->dvb_adapter, &av7110->osd_dev,
1296 &dvbdev_osd, av7110, DVB_DEVICE_OSD);
1299 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx);
1302 /* initialize software demux1 without its own frontend
1303 * demux1 hardware is connected to frontend0 of demux0
1305 dvbdemux1->priv = (void *) av7110;
1307 dvbdemux1->filternum = 256;
1308 dvbdemux1->feednum = 256;
1309 dvbdemux1->start_feed = budget_start_feed;
1310 dvbdemux1->stop_feed = budget_stop_feed;
1311 dvbdemux1->write_to_decoder = NULL;
1313 dvbdemux1->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
1314 DMX_MEMORY_BASED_FILTERING);
1316 dvb_dmx_init(&av7110->demux1);
1318 av7110->dmxdev1.filternum = 256;
1319 av7110->dmxdev1.demux = &dvbdemux1->dmx;
1320 av7110->dmxdev1.capabilities = 0;
1322 dvb_dmxdev_init(&av7110->dmxdev1, &av7110->dvb_adapter);
1324 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx);
1325 printk("dvb-ttpci: additional demux1 for budget-patch registered\n");
1331 static void dvb_unregister(struct av7110 *av7110)
1333 struct dvb_demux *dvbdemux = &av7110->demux;
1334 struct dvb_demux *dvbdemux1 = &av7110->demux1;
1336 dprintk(4, "%p\n", av7110);
1338 if (!av7110->registered)
1342 dvb_net_release(&av7110->dvb_net1);
1343 dvbdemux->dmx.close(&dvbdemux1->dmx);
1344 dvb_dmxdev_release(&av7110->dmxdev1);
1345 dvb_dmx_release(&av7110->demux1);
1348 dvb_net_release(&av7110->dvb_net);
1350 dvbdemux->dmx.close(&dvbdemux->dmx);
1351 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
1352 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
1354 dvb_dmxdev_release(&av7110->dmxdev);
1355 dvb_dmx_release(&av7110->demux);
1357 if (av7110->fe != NULL)
1358 dvb_unregister_frontend(av7110->fe);
1359 dvb_unregister_device(av7110->osd_dev);
1360 av7110_av_unregister(av7110);
1361 av7110_ca_unregister(av7110);
1365 /****************************************************************************
1366 * I2C client commands
1367 ****************************************************************************/
1369 int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val)
1371 u8 msg[2] = { reg, val };
1372 struct i2c_msg msgs;
1378 return i2c_transfer(&av7110->i2c_adap, &msgs, 1);
1382 u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg)
1386 struct i2c_msg msgs[2];
1389 msgs[1].flags = I2C_M_RD;
1390 msgs[0].addr = msgs[1].addr = id / 2;
1392 msgs[0].len = 1; msgs[1].len = 1;
1393 msgs[0].buf = mm1; msgs[1].buf = mm2;
1394 i2c_transfer(&av7110->i2c_adap, msgs, 2);
1400 /****************************************************************************
1402 ****************************************************************************/
1405 static int check_firmware(struct av7110* av7110)
1407 u32 crc = 0, len = 0;
1410 /* check for firmware magic */
1411 ptr = av7110->bin_fw;
1412 if (ptr[0] != 'A' || ptr[1] != 'V' ||
1413 ptr[2] != 'F' || ptr[3] != 'W') {
1414 printk("dvb-ttpci: this is not an av7110 firmware\n");
1419 /* check dpram file */
1420 crc = ntohl(*(u32*) ptr);
1422 len = ntohl(*(u32*) ptr);
1425 printk("dvb-ttpci: dpram file is way to big.\n");
1428 if (crc != crc32_le(0, ptr, len)) {
1429 printk("dvb-ttpci: crc32 of dpram file does not match.\n");
1432 av7110->bin_dpram = ptr;
1433 av7110->size_dpram = len;
1436 /* check root file */
1437 crc = ntohl(*(u32*) ptr);
1439 len = ntohl(*(u32*) ptr);
1442 if (len <= 200000 || len >= 300000 ||
1443 len > ((av7110->bin_fw + av7110->size_fw) - ptr)) {
1444 printk("dvb-ttpci: root file has strange size (%d). aborting.\n", len);
1447 if( crc != crc32_le(0, ptr, len)) {
1448 printk("dvb-ttpci: crc32 of root file does not match.\n");
1451 av7110->bin_root = ptr;
1452 av7110->size_root = len;
1456 #ifdef CONFIG_DVB_AV7110_FIRMWARE_FILE
1457 #include "av7110_firm.h"
1458 static void put_firmware(struct av7110* av7110)
1460 av7110->bin_fw = NULL;
1463 static inline int get_firmware(struct av7110* av7110)
1465 av7110->bin_fw = dvb_ttpci_fw;
1466 av7110->size_fw = sizeof(dvb_ttpci_fw);
1467 return check_firmware(av7110);
1470 static void put_firmware(struct av7110* av7110)
1472 vfree(av7110->bin_fw);
1475 static int get_firmware(struct av7110* av7110)
1478 const struct firmware *fw;
1480 /* request the av7110 firmware, this will block until someone uploads it */
1481 ret = request_firmware(&fw, "dvb-ttpci-01.fw", &av7110->dev->pci->dev);
1483 if (ret == -ENOENT) {
1484 printk(KERN_ERR "dvb-ttpci: could not load firmware,"
1485 " file not found: dvb-ttpci-01.fw\n");
1486 printk(KERN_ERR "dvb-ttpci: usually this should be in"
1487 " /usr/lib/hotplug/firmware\n");
1488 printk(KERN_ERR "dvb-ttpci: and can be downloaded here"
1489 " http://www.linuxtv.org/download/dvb/firmware/\n");
1491 printk(KERN_ERR "dvb-ttpci: cannot request firmware"
1492 " (error %i)\n", ret);
1496 if (fw->size <= 200000) {
1497 printk("dvb-ttpci: this firmware is way too small.\n");
1498 release_firmware(fw);
1502 /* check if the firmware is available */
1503 av7110->bin_fw = (unsigned char *) vmalloc(fw->size);
1504 if (NULL == av7110->bin_fw) {
1505 dprintk(1, "out of memory\n");
1506 release_firmware(fw);
1510 memcpy(av7110->bin_fw, fw->data, fw->size);
1511 av7110->size_fw = fw->size;
1512 if ((ret = check_firmware(av7110)))
1513 vfree(av7110->bin_fw);
1515 release_firmware(fw);
1521 static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1523 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1526 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
1527 u32 div = (params->frequency + 479500) / 125;
1529 if (params->frequency > 2000000) pwr = 3;
1530 else if (params->frequency > 1800000) pwr = 2;
1531 else if (params->frequency > 1600000) pwr = 1;
1532 else if (params->frequency > 1200000) pwr = 0;
1533 else if (params->frequency >= 1100000) pwr = 1;
1536 buf[0] = (div >> 8) & 0x7f;
1537 buf[1] = div & 0xff;
1538 buf[2] = ((div & 0x18000) >> 10) | 0x95;
1539 buf[3] = (pwr << 6) | 0x30;
1541 // NOTE: since we're using a prescaler of 2, we set the
1542 // divisor frequency to 62.5kHz and divide by 125 above
1544 if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
1549 static struct ves1x93_config alps_bsrv2_config = {
1550 .demod_address = 0x08,
1553 .pll_set = alps_bsrv2_pll_set,
1557 static u8 alps_bsru6_inittab[] = {
1561 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
1562 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
1563 0x06, 0x40, /* DAC not used, set to high impendance mode */
1564 0x07, 0x00, /* DAC LSB */
1565 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
1566 0x09, 0x00, /* FIFO */
1567 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
1568 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
1569 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
1570 0x10, 0x3f, // AGC2 0x3d
1573 0x15, 0xc9, // lock detector threshold
1584 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
1585 0x29, 0x1e, // 1/2 threshold
1586 0x2a, 0x14, // 2/3 threshold
1587 0x2b, 0x0f, // 3/4 threshold
1588 0x2c, 0x09, // 5/6 threshold
1589 0x2d, 0x05, // 7/8 threshold
1591 0x31, 0x1f, // test all FECs
1592 0x32, 0x19, // viterbi and synchro search
1593 0x33, 0xfc, // rs control
1594 0x34, 0x93, // error control
1599 static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
1604 if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
1605 else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
1606 else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
1607 else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
1608 else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
1609 else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
1611 stv0299_writereg(fe, 0x13, aclk);
1612 stv0299_writereg(fe, 0x14, bclk);
1613 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
1614 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
1615 stv0299_writereg(fe, 0x21, (ratio ) & 0xf0);
1620 static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
1625 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1627 if ((params->frequency < 950000) || (params->frequency > 2150000))
1630 div = (params->frequency + (125 - 1)) / 125; // round correctly
1631 data[0] = (div >> 8) & 0x7f;
1632 data[1] = div & 0xff;
1633 data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
1636 if (params->frequency > 1530000) data[3] = 0xc0;
1638 ret = i2c_transfer(i2c, &msg, 1);
1644 static struct stv0299_config alps_bsru6_config = {
1646 .demod_address = 0x68,
1647 .inittab = alps_bsru6_inittab,
1651 .lock_output = STV0229_LOCKOUTPUT_1,
1652 .volt13_op0_op1 = STV0299_VOLT13_OP1,
1653 .min_delay_ms = 100,
1654 .set_symbol_rate = alps_bsru6_set_symbol_rate,
1655 .pll_set = alps_bsru6_pll_set,
1659 static u8 alps_bsbe1_inittab[] = {
1663 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
1664 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
1665 0x06, 0x40, /* DAC not used, set to high impendance mode */
1666 0x07, 0x00, /* DAC LSB */
1667 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
1668 0x09, 0x00, /* FIFO */
1669 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
1670 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
1671 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
1672 0x10, 0x3f, // AGC2 0x3d
1675 0x15, 0xc9, // lock detector threshold
1686 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
1687 0x29, 0x1e, // 1/2 threshold
1688 0x2a, 0x14, // 2/3 threshold
1689 0x2b, 0x0f, // 3/4 threshold
1690 0x2c, 0x09, // 5/6 threshold
1691 0x2d, 0x05, // 7/8 threshold
1693 0x31, 0x1f, // test all FECs
1694 0x32, 0x19, // viterbi and synchro search
1695 0x33, 0xfc, // rs control
1696 0x34, 0x93, // error control
1701 static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
1706 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1708 if ((params->frequency < 950000) || (params->frequency > 2150000))
1711 div = (params->frequency + (125 - 1)) / 125; // round correctly
1712 data[0] = (div >> 8) & 0x7f;
1713 data[1] = div & 0xff;
1714 data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
1715 data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
1717 ret = i2c_transfer(i2c, &msg, 1);
1718 return (ret != 1) ? -EIO : 0;
1721 static struct stv0299_config alps_bsbe1_config = {
1722 .demod_address = 0x68,
1723 .inittab = alps_bsbe1_inittab,
1727 .min_delay_ms = 100,
1728 .set_symbol_rate = alps_bsru6_set_symbol_rate,
1729 .pll_set = alps_bsbe1_pll_set,
1732 static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
1734 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1737 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) };
1740 case SEC_VOLTAGE_OFF:
1743 case SEC_VOLTAGE_13:
1746 case SEC_VOLTAGE_18:
1753 ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
1754 return (ret != 1) ? -EIO : 0;
1758 static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1760 struct av7110* av7110 = fe->dvb->priv;
1763 struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
1765 div = (params->frequency + 35937500 + 31250) / 62500;
1767 data[0] = (div >> 8) & 0x7f;
1768 data[1] = div & 0xff;
1769 data[2] = 0x85 | ((div >> 10) & 0x60);
1770 data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81);
1772 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1777 static struct ves1820_config alps_tdbe2_config = {
1778 .demod_address = 0x09,
1781 .selagc = VES1820_SELAGC_SIGNAMPERR,
1782 .pll_set = alps_tdbe2_pll_set,
1788 static int grundig_29504_451_pll_set(struct dvb_frontend* fe,
1789 struct dvb_frontend_parameters* params)
1791 struct av7110* av7110 = fe->dvb->priv;
1794 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1796 div = params->frequency / 125;
1797 data[0] = (div >> 8) & 0x7f;
1798 data[1] = div & 0xff;
1802 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1807 static struct tda8083_config grundig_29504_451_config = {
1808 .demod_address = 0x68,
1809 .pll_set = grundig_29504_451_pll_set,
1814 static int philips_cd1516_pll_set(struct dvb_frontend* fe,
1815 struct dvb_frontend_parameters* params)
1817 struct av7110* av7110 = fe->dvb->priv;
1819 u32 f = params->frequency;
1821 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1823 div = (f + 36125000 + 31250) / 62500;
1825 data[0] = (div >> 8) & 0x7f;
1826 data[1] = div & 0xff;
1828 data[3] = (f < 174000000 ? 0xa1 : f < 470000000 ? 0x92 : 0x34);
1830 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1835 static struct ves1820_config philips_cd1516_config = {
1836 .demod_address = 0x09,
1839 .selagc = VES1820_SELAGC_SIGNAMPERR,
1840 .pll_set = philips_cd1516_pll_set,
1845 static int alps_tdlb7_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1847 struct av7110* av7110 = fe->dvb->priv;
1850 struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = sizeof(data) };
1852 div = (params->frequency + 36200000) / 166666;
1854 if (params->frequency <= 782000000)
1859 data[0] = (div >> 8) & 0x7f;
1860 data[1] = div & 0xff;
1864 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1869 static int alps_tdlb7_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
1871 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1873 return request_firmware(fw, name, &av7110->dev->pci->dev);
1876 static struct sp8870_config alps_tdlb7_config = {
1878 .demod_address = 0x71,
1879 .pll_set = alps_tdlb7_pll_set,
1880 .request_firmware = alps_tdlb7_request_firmware,
1884 static u8 nexusca_stv0297_inittab[] = {
1977 static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1979 struct av7110* av7110 = fe->dvb->priv;
1982 struct i2c_msg msg = { .addr = 0x63, .flags = 0, .buf = data, .len = sizeof(data) };
1983 struct i2c_msg readmsg = { .addr = 0x63, .flags = I2C_M_RD, .buf = data, .len = 1 };
1986 div = (params->frequency + 36150000 + 31250) / 62500;
1988 data[0] = (div >> 8) & 0x7f;
1989 data[1] = div & 0xff;
1992 if (params->frequency < 45000000)
1994 else if (params->frequency < 137000000)
1996 else if (params->frequency < 403000000)
1998 else if (params->frequency < 860000000)
2003 stv0297_enable_plli2c(fe);
2004 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1) {
2005 printk("nexusca: pll transfer failed!\n");
2009 // wait for PLL lock
2010 for(i = 0; i < 20; i++) {
2012 stv0297_enable_plli2c(fe);
2013 if (i2c_transfer(&av7110->i2c_adap, &readmsg, 1) == 1)
2014 if (data[0] & 0x40) break;
2021 static struct stv0297_config nexusca_stv0297_config = {
2023 .demod_address = 0x1C,
2024 .inittab = nexusca_stv0297_inittab,
2026 .pll_set = nexusca_stv0297_pll_set,
2031 static int grundig_29504_401_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
2033 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
2035 u8 cfg, cpump, band_select;
2037 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
2039 div = (36125000 + params->frequency) / 166666;
2043 if (params->frequency < 175000000) cpump = 2;
2044 else if (params->frequency < 390000000) cpump = 1;
2045 else if (params->frequency < 470000000) cpump = 2;
2046 else if (params->frequency < 750000000) cpump = 1;
2049 if (params->frequency < 175000000) band_select = 0x0e;
2050 else if (params->frequency < 470000000) band_select = 0x05;
2051 else band_select = 0x03;
2053 data[0] = (div >> 8) & 0x7f;
2054 data[1] = div & 0xff;
2055 data[2] = ((div >> 10) & 0x60) | cfg;
2056 data[3] = (cpump << 6) | band_select;
2058 if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) return -EIO;
2062 static struct l64781_config grundig_29504_401_config = {
2063 .demod_address = 0x55,
2064 .pll_set = grundig_29504_401_pll_set,
2069 static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
2072 int synced = (status & FE_HAS_LOCK) ? 1 : 0;
2074 av7110->fe_status = status;
2076 if (av7110->fe_synced == synced)
2079 if (av7110->playing)
2082 if (down_interruptible(&av7110->pid_mutex))
2083 return -ERESTARTSYS;
2086 ret = SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO],
2087 av7110->pids[DMX_PES_AUDIO],
2088 av7110->pids[DMX_PES_TELETEXT], 0,
2089 av7110->pids[DMX_PES_PCR]);
2091 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
2093 ret = SetPIDs(av7110, 0, 0, 0, 0, 0);
2095 ret = av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0);
2097 ret = av7110_wait_msgstate(av7110, GPMQBusy);
2102 av7110->fe_synced = synced;
2104 up(&av7110->pid_mutex);
2108 static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
2110 struct av7110* av7110 = fe->dvb->priv;
2112 int ret = av7110_fe_lock_fix(av7110, 0);
2114 ret = av7110->fe_set_frontend(fe, params);
2118 static int av7110_fe_init(struct dvb_frontend* fe)
2120 struct av7110* av7110 = fe->dvb->priv;
2122 int ret = av7110_fe_lock_fix(av7110, 0);
2124 ret = av7110->fe_init(fe);
2128 static int av7110_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
2130 struct av7110* av7110 = fe->dvb->priv;
2132 /* call the real implementation */
2133 int ret = av7110->fe_read_status(fe, status);
2135 if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK))
2136 ret = av7110_fe_lock_fix(av7110, *status);
2140 static int av7110_fe_diseqc_reset_overload(struct dvb_frontend* fe)
2142 struct av7110* av7110 = fe->dvb->priv;
2144 int ret = av7110_fe_lock_fix(av7110, 0);
2146 ret = av7110->fe_diseqc_reset_overload(fe);
2150 static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
2151 struct dvb_diseqc_master_cmd* cmd)
2153 struct av7110* av7110 = fe->dvb->priv;
2155 int ret = av7110_fe_lock_fix(av7110, 0);
2157 ret = av7110->fe_diseqc_send_master_cmd(fe, cmd);
2161 static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
2163 struct av7110* av7110 = fe->dvb->priv;
2165 int ret = av7110_fe_lock_fix(av7110, 0);
2167 ret = av7110->fe_diseqc_send_burst(fe, minicmd);
2171 static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
2173 struct av7110* av7110 = fe->dvb->priv;
2175 int ret = av7110_fe_lock_fix(av7110, 0);
2177 ret = av7110->fe_set_tone(fe, tone);
2181 static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
2183 struct av7110* av7110 = fe->dvb->priv;
2185 int ret = av7110_fe_lock_fix(av7110, 0);
2187 ret = av7110->fe_set_voltage(fe, voltage);
2191 static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned int cmd)
2193 struct av7110* av7110 = fe->dvb->priv;
2195 int ret = av7110_fe_lock_fix(av7110, 0);
2197 ret = av7110->fe_dishnetwork_send_legacy_command(fe, cmd);
2201 static u8 read_pwm(struct av7110* av7110)
2205 struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
2206 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
2208 if ((i2c_transfer(&av7110->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
2214 static int frontend_init(struct av7110 *av7110)
2218 if (av7110->dev->pci->subsystem_vendor == 0x110a) {
2219 switch(av7110->dev->pci->subsystem_device) {
2220 case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??))
2221 av7110->fe = ves1820_attach(&philips_cd1516_config,
2222 &av7110->i2c_adap, read_pwm(av7110));
2226 } else if (av7110->dev->pci->subsystem_vendor == 0x13c2) {
2227 switch(av7110->dev->pci->subsystem_device) {
2228 case 0x0000: // Hauppauge/TT WinTV DVB-S rev1.X
2229 case 0x0003: // Hauppauge/TT WinTV Nexus-S Rev 2.X
2230 case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE
2232 // try the ALPS BSRV2 first of all
2233 av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap);
2235 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2236 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2237 av7110->fe->ops->set_tone = av7110_set_tone;
2241 // try the ALPS BSRU6 now
2242 av7110->fe = stv0299_attach(&alps_bsru6_config, &av7110->i2c_adap);
2244 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2245 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2246 av7110->fe->ops->set_tone = av7110_set_tone;
2250 // Try the grundig 29504-451
2251 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap);
2253 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2254 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2255 av7110->fe->ops->set_tone = av7110_set_tone;
2259 /* Try DVB-C cards */
2260 switch(av7110->dev->pci->subsystem_device) {
2262 /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */
2263 av7110->fe = ves1820_attach(&philips_cd1516_config, &av7110->i2c_adap,
2267 /* Haupauge DVB-C 2.1 VES1820/ALPS TDBE2 */
2268 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap,
2274 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
2277 av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap);
2280 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
2282 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
2285 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */
2286 /* Grundig 29504-451 */
2287 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap);
2289 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2290 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2291 av7110->fe->ops->set_tone = av7110_set_tone;
2295 case 0x0008: // Hauppauge/TT DVB-T
2297 av7110->fe = l64781_attach(&grundig_29504_401_config, &av7110->i2c_adap);
2300 case 0x000A: // Hauppauge/TT Nexus-CA rev1.X
2302 av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap);
2304 /* set TDA9819 into DVB mode */
2305 saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9198 pin9(STD)
2306 saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9198 pin30(VIF)
2308 /* tuner on this needs a slower i2c bus speed */
2309 av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
2314 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */
2316 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap);
2318 av7110->fe->ops->set_voltage = lnbp21_set_voltage;
2324 /* FIXME: propagate the failure code from the lower layers */
2326 printk("dvb-ttpci: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
2327 av7110->dev->pci->vendor,
2328 av7110->dev->pci->device,
2329 av7110->dev->pci->subsystem_vendor,
2330 av7110->dev->pci->subsystem_device);
2332 FE_FUNC_OVERRIDE(av7110->fe->ops->init, av7110->fe_init, av7110_fe_init);
2333 FE_FUNC_OVERRIDE(av7110->fe->ops->read_status, av7110->fe_read_status, av7110_fe_read_status);
2334 FE_FUNC_OVERRIDE(av7110->fe->ops->diseqc_reset_overload, av7110->fe_diseqc_reset_overload, av7110_fe_diseqc_reset_overload);
2335 FE_FUNC_OVERRIDE(av7110->fe->ops->diseqc_send_master_cmd, av7110->fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd);
2336 FE_FUNC_OVERRIDE(av7110->fe->ops->diseqc_send_burst, av7110->fe_diseqc_send_burst, av7110_fe_diseqc_send_burst);
2337 FE_FUNC_OVERRIDE(av7110->fe->ops->set_tone, av7110->fe_set_tone, av7110_fe_set_tone);
2338 FE_FUNC_OVERRIDE(av7110->fe->ops->set_voltage, av7110->fe_set_voltage, av7110_fe_set_voltage;)
2339 FE_FUNC_OVERRIDE(av7110->fe->ops->dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command);
2340 FE_FUNC_OVERRIDE(av7110->fe->ops->set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend);
2342 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe);
2344 printk("av7110: Frontend registration failed!\n");
2345 if (av7110->fe->ops->release)
2346 av7110->fe->ops->release(av7110->fe);
2353 /* Budgetpatch note:
2354 * Original hardware design by Roberto Deza:
2355 * There is a DVB_Wiki at
2356 * http://212.227.36.83/linuxtv/wiki/index.php/Main_Page
2357 * where is described this 'DVB TT Budget Patch', on Card Modding:
2358 * http://212.227.36.83/linuxtv/wiki/index.php/DVB_TT_Budget_Patch
2359 * On the short description there is also a link to a external file,
2360 * with more details:
2361 * http://perso.wanadoo.es/jesussolano/Ttf_tsc1.zip
2363 * New software triggering design by Emard that works on
2364 * original Roberto Deza's hardware:
2366 * rps1 code for budgetpatch will copy internal HS event to GPIO3 pin.
2367 * GPIO3 is in budget-patch hardware connectd to port B VSYNC
2368 * HS is an internal event of 7146, accessible with RPS
2369 * and temporarily raised high every n lines
2370 * (n in defined in the RPS_THRESH1 counter threshold)
2371 * I think HS is raised high on the beginning of the n-th line
2372 * and remains high until this n-th line that triggered
2373 * it is completely received. When the receiption of n-th line
2374 * ends, HS is lowered.
2376 * To transmit data over DMA, 7146 needs changing state at
2377 * port B VSYNC pin. Any changing of port B VSYNC will
2378 * cause some DMA data transfer, with more or less packets loss.
2379 * It depends on the phase and frequency of VSYNC and
2380 * the way of 7146 is instructed to trigger on port B (defined
2381 * in DD1_INIT register, 3rd nibble from the right valid
2382 * numbers are 0-7, see datasheet)
2384 * The correct triggering can minimize packet loss,
2385 * dvbtraffic should give this stable bandwidths:
2386 * 22k transponder = 33814 kbit/s
2387 * 27.5k transponder = 38045 kbit/s
2388 * by experiment it is found that the best results
2389 * (stable bandwidths and almost no packet loss)
2390 * are obtained using DD1_INIT triggering number 2
2391 * (Va at rising edge of VS Fa = HS x VS-failing forced toggle)
2392 * and a VSYNC phase that occurs in the middle of DMA transfer
2393 * (about byte 188*512=96256 in the DMA window).
2395 * Phase of HS is still not clear to me how to control,
2396 * It just happens to be so. It can be seen if one enables
2397 * RPS_IRQ and print Event Counter 1 in vpeirq(). Every
2398 * time RPS_INTERRUPT is called, the Event Counter 1 will
2399 * increment. That's how the 7146 is programmed to do event
2400 * counting in this budget-patch.c
2401 * I *think* HPS setting has something to do with the phase
2402 * of HS but I cant be 100% sure in that.
2404 * hardware debug note: a working budget card (including budget patch)
2405 * with vpeirq() interrupt setup in mode "0x90" (every 64K) will
2406 * generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
2407 * and that means 3*25=75 Hz of interrupt freqency, as seen by
2408 * watch cat /proc/interrupts
2410 * If this frequency is 3x lower (and data received in the DMA
2411 * buffer don't start with 0x47, but in the middle of packets,
2412 * whose lengths appear to be like 188 292 188 104 etc.
2413 * this means VSYNC line is not connected in the hardware.
2414 * (check soldering pcb and pins)
2415 * The same behaviour of missing VSYNC can be duplicated on budget
2416 * cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
2418 static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data *pci_ext)
2420 const int length = TS_WIDTH * TS_HEIGHT;
2421 struct pci_dev *pdev = dev->pci;
2422 struct av7110 *av7110;
2425 dprintk(4, "dev: %p\n", dev);
2427 /* Set RPS_IRQ to 1 to track rps1 activity.
2428 * Enabling this won't send any interrupt to PC CPU.
2432 if (budgetpatch == 1) {
2434 /* autodetect the presence of budget patch
2435 * this only works if saa7146 has been recently
2436 * reset with with MASK_31 to MC1
2438 * will wait for VBI_B event (vertical blank at port B)
2439 * and will reset GPIO3 after VBI_B is detected.
2440 * (GPIO3 should be raised high by CPU to
2441 * test if GPIO3 will generate vertical blank signal
2442 * in budget patch GPIO3 is connected to VSYNC_B
2446 saa7146_write(dev, MC1, MASK_31);
2447 /* autodetection success seems to be time-dependend after reset */
2449 /* Fix VSYNC level */
2450 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
2451 /* set vsync_b triggering */
2452 saa7146_write(dev, DD1_STREAM_B, 0);
2453 /* port B VSYNC at rising edge */
2454 saa7146_write(dev, DD1_INIT, 0x00000200);
2455 saa7146_write(dev, BRS_CTRL, 0x00000000); // VBI
2456 saa7146_write(dev, MC2,
2457 1 * (MASK_08 | MASK_24) | // BRS control
2458 0 * (MASK_09 | MASK_25) | // a
2459 1 * (MASK_10 | MASK_26) | // b
2460 0 * (MASK_06 | MASK_22) | // HPS_CTRL1
2461 0 * (MASK_05 | MASK_21) | // HPS_CTRL2
2462 0 * (MASK_01 | MASK_15) // DEBI
2465 /* start writing RPS1 code from beginning */
2468 saa7146_write(dev, MC1, MASK_29);
2469 /* RPS1 timeout disable */
2470 saa7146_write(dev, RPS_TOV1, 0);
2471 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_VBI_B));
2472 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
2473 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
2474 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
2476 /* issue RPS1 interrupt to increment counter */
2477 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
2479 WRITE_RPS1(cpu_to_le32(CMD_STOP));
2480 /* Jump to begin of RPS program as safety measure (p37) */
2481 WRITE_RPS1(cpu_to_le32(CMD_JUMP));
2482 WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
2485 /* set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
2486 * use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
2487 * use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
2489 saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
2490 /* set event counter 1 treshold to maximum allowed value (rEC p55) */
2491 saa7146_write(dev, ECT1R, 0x3fff );
2493 /* Set RPS1 Address register to point to RPS code (r108 p42) */
2494 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
2495 /* Enable RPS1, (rFC p33) */
2496 saa7146_write(dev, MC1, (MASK_13 | MASK_29 ));
2499 /* now send VSYNC_B to rps1 by rising GPIO3 */
2500 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
2502 /* if rps1 responded by lowering the GPIO3,
2503 * then we have budgetpatch hardware
2505 if ((saa7146_read(dev, GPIO_CTRL) & 0x10000000) == 0) {
2507 printk("dvb-ttpci: BUDGET-PATCH DETECTED.\n");
2510 saa7146_write(dev, MC1, ( MASK_29 ));
2512 printk("dvb-ttpci: Event Counter 1 0x%04x\n", saa7146_read(dev, EC1R) & 0x3fff );
2516 /* prepare the av7110 device struct */
2517 av7110 = kmalloc(sizeof(struct av7110), GFP_KERNEL);
2519 dprintk(1, "out of memory\n");
2523 memset(av7110, 0, sizeof(struct av7110));
2525 av7110->card_name = (char*) pci_ext->ext_priv;
2527 dev->ext_priv = av7110;
2529 ret = get_firmware(av7110);
2533 ret = dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name,
2536 goto err_put_firmware_1;
2538 /* the Siemens DVB needs this if you want to have the i2c chips
2539 get recognized before the main driver is fully loaded */
2540 saa7146_write(dev, GPIO_CTRL, 0x500000);
2542 #ifdef I2C_ADAP_CLASS_TV_DIGITAL
2543 av7110->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
2545 av7110->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
2547 strlcpy(av7110->i2c_adap.name, pci_ext->ext_priv, sizeof(av7110->i2c_adap.name));
2549 saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */
2551 ret = i2c_add_adapter(&av7110->i2c_adap);
2553 goto err_dvb_unregister_adapter_2;
2555 ttpci_eeprom_parse_mac(&av7110->i2c_adap,
2556 av7110->dvb_adapter.proposed_mac);
2560 spin_lock_init(&av7110->feedlock1);
2561 av7110->grabbing = saa7146_vmalloc_build_pgtable(pdev, length,
2563 if (!av7110->grabbing)
2566 saa7146_write(dev, PCI_BT_V1, 0x1c1f101f);
2567 saa7146_write(dev, BCS_CTRL, 0x80400040);
2568 /* set dd1 stream a & b */
2569 saa7146_write(dev, DD1_STREAM_B, 0x00000000);
2570 saa7146_write(dev, DD1_INIT, 0x03000200);
2571 saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
2572 saa7146_write(dev, BRS_CTRL, 0x60000000);
2573 saa7146_write(dev, BASE_ODD3, 0);
2574 saa7146_write(dev, BASE_EVEN3, 0);
2575 saa7146_write(dev, PROT_ADDR3, TS_WIDTH * TS_HEIGHT);
2576 saa7146_write(dev, BASE_PAGE3, av7110->pt.dma | ME1 | 0x90);
2578 saa7146_write(dev, PITCH3, TS_WIDTH);
2579 saa7146_write(dev, NUM_LINE_BYTE3, (TS_HEIGHT << 16) | TS_WIDTH);
2582 saa7146_write(dev, MC2, 0x077c077c);
2583 saa7146_write(dev, GPIO_CTRL, 0x000000);
2585 /* set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
2586 * use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
2587 * use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
2589 saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
2590 /* set event counter 1 treshold to maximum allowed value (rEC p55) */
2591 saa7146_write(dev, ECT1R, 0x3fff );
2593 /* Setup BUDGETPATCH MAIN RPS1 "program" (p35) */
2596 /* Wait Source Line Counter Threshold (p36) */
2597 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_HS));
2598 /* Set GPIO3=1 (p42) */
2599 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
2600 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
2601 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTHI<<24));
2603 /* issue RPS1 interrupt */
2604 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
2606 /* Wait reset Source Line Counter Threshold (p36) */
2607 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS));
2608 /* Set GPIO3=0 (p42) */
2609 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
2610 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
2611 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
2613 /* issue RPS1 interrupt */
2614 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
2616 /* Jump to begin of RPS program (p37) */
2617 WRITE_RPS1(cpu_to_le32(CMD_JUMP));
2618 WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
2620 /* Fix VSYNC level */
2621 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
2622 /* Set RPS1 Address register to point to RPS code (r108 p42) */
2623 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
2624 /* Set Source Line Counter Threshold, using BRS (rCC p43)
2625 * It generates HS event every TS_HEIGHT lines
2626 * this is related to TS_WIDTH set in register
2627 * NUM_LINE_BYTE3. If NUM_LINE_BYTE low 16 bits
2628 * are set to TS_WIDTH bytes (TS_WIDTH=2*188),
2629 * then RPS_THRESH1 should be set to trigger
2630 * every TS_HEIGHT (512) lines.
2632 saa7146_write(dev, RPS_THRESH1, (TS_HEIGHT*1) | MASK_12 );
2634 /* Enable RPS1 (rFC p33) */
2635 saa7146_write(dev, MC1, (MASK_13 | MASK_29));
2637 /* end of budgetpatch register initialization */
2638 tasklet_init (&av7110->vpe_tasklet, vpeirq, (unsigned long) av7110);
2640 saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
2641 saa7146_write(dev, BCS_CTRL, 0x80400040);
2643 /* set dd1 stream a & b */
2644 saa7146_write(dev, DD1_STREAM_B, 0x00000000);
2645 saa7146_write(dev, DD1_INIT, 0x03000000);
2646 saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
2649 saa7146_write(dev, MC2, 0x077c077c);
2650 saa7146_write(dev, GPIO_CTRL, 0x000000);
2653 tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110);
2654 tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110);
2656 sema_init(&av7110->pid_mutex, 1);
2658 /* locks for data transfers from/to AV7110 */
2659 spin_lock_init(&av7110->debilock);
2660 sema_init(&av7110->dcomlock, 1);
2661 av7110->debitype = -1;
2663 /* default OSD window */
2665 sema_init(&av7110->osd_sema, 1);
2667 /* ARM "watchdog" */
2668 init_waitqueue_head(&av7110->arm_wait);
2669 av7110->arm_thread = NULL;
2671 /* allocate and init buffers */
2672 av7110->debi_virt = pci_alloc_consistent(pdev, 8192, &av7110->debi_bus);
2673 if (!av7110->debi_virt)
2674 goto err_saa71466_vfree_4;
2677 av7110->iobuf = vmalloc(AVOUTLEN+AOUTLEN+BMPLEN+4*IPACKS);
2679 goto err_pci_free_5;
2681 ret = av7110_av_init(av7110);
2683 goto err_iobuf_vfree_6;
2685 /* init BMP buffer */
2686 av7110->bmpbuf = av7110->iobuf+AVOUTLEN+AOUTLEN;
2687 init_waitqueue_head(&av7110->bmpq);
2689 ret = av7110_ca_init(av7110);
2691 goto err_av7110_av_exit_7;
2693 /* load firmware into AV7110 cards */
2694 ret = av7110_bootarm(av7110);
2696 goto err_av7110_ca_exit_8;
2698 ret = av7110_firmversion(av7110);
2700 goto err_stop_arm_9;
2702 if (FW_VERSION(av7110->arm_app)<0x2501)
2703 printk ("dvb-ttpci: Warning, firmware version 0x%04x is too old. "
2704 "System might be unstable!\n", FW_VERSION(av7110->arm_app));
2706 ret = kernel_thread(arm_thread, (void *) av7110, 0);
2708 goto err_stop_arm_9;
2710 /* set initial volume in mixer struct */
2711 av7110->mixer.volume_left = volume;
2712 av7110->mixer.volume_right = volume;
2714 init_av7110_av(av7110);
2716 ret = av7110_register(av7110);
2718 goto err_arm_thread_stop_10;
2720 /* special case DVB-C: these cards have an analog tuner
2721 plus need some special handling, so we have separate
2722 saa7146_ext_vv data for these... */
2723 ret = av7110_init_v4l(av7110);
2725 goto err_av7110_unregister_11;
2727 av7110->dvb_adapter.priv = av7110;
2728 ret = frontend_init(av7110);
2730 goto err_av7110_exit_v4l_12;
2732 #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
2733 av7110_ir_init(av7110);
2735 printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num);
2740 err_av7110_exit_v4l_12:
2741 av7110_exit_v4l(av7110);
2742 err_av7110_unregister_11:
2743 dvb_unregister(av7110);
2744 err_arm_thread_stop_10:
2745 av7110_arm_sync(av7110);
2747 /* Nothing to do. Rejoice. */
2748 err_av7110_ca_exit_8:
2749 av7110_ca_exit(av7110);
2750 err_av7110_av_exit_7:
2751 av7110_av_exit(av7110);
2753 vfree(av7110->iobuf);
2755 pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus);
2756 err_saa71466_vfree_4:
2757 if (!av7110->grabbing)
2758 saa7146_pgtable_free(pdev, &av7110->pt);
2760 i2c_del_adapter(&av7110->i2c_adap);
2761 err_dvb_unregister_adapter_2:
2762 dvb_unregister_adapter(&av7110->dvb_adapter);
2764 put_firmware(av7110);
2770 static int av7110_detach(struct saa7146_dev* saa)
2772 struct av7110 *av7110 = saa->ext_priv;
2773 dprintk(4, "%p\n", av7110);
2775 #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
2776 av7110_ir_exit(av7110);
2780 saa7146_write(saa, MC1, MASK_29);
2781 /* VSYNC LOW (inactive) */
2782 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
2783 saa7146_write(saa, MC1, MASK_20); /* DMA3 off */
2784 SAA7146_IER_DISABLE(saa, MASK_10);
2785 SAA7146_ISR_CLEAR(saa, MASK_10);
2787 tasklet_kill(&av7110->vpe_tasklet);
2788 saa7146_pgtable_free(saa->pci, &av7110->pt);
2790 av7110_exit_v4l(av7110);
2792 av7110_arm_sync(av7110);
2794 tasklet_kill(&av7110->debi_tasklet);
2795 tasklet_kill(&av7110->gpio_tasklet);
2797 dvb_unregister(av7110);
2799 SAA7146_IER_DISABLE(saa, MASK_19 | MASK_03);
2800 SAA7146_ISR_CLEAR(saa, MASK_19 | MASK_03);
2802 av7110_ca_exit(av7110);
2803 av7110_av_exit(av7110);
2805 vfree(av7110->iobuf);
2806 pci_free_consistent(saa->pci, 8192, av7110->debi_virt,
2809 i2c_del_adapter(&av7110->i2c_adap);
2811 dvb_unregister_adapter (&av7110->dvb_adapter);
2815 put_firmware(av7110);
2819 saa->ext_priv = NULL;
2825 static void av7110_irq(struct saa7146_dev* dev, u32 *isr)
2827 struct av7110 *av7110 = dev->ext_priv;
2829 //print_time("av7110_irq");
2831 /* Note: Don't try to handle the DEBI error irq (MASK_18), in
2832 * intel mode the timeout is asserted all the time...
2835 if (*isr & MASK_19) {
2836 //printk("av7110_irq: DEBI\n");
2837 /* Note 1: The DEBI irq is level triggered: We must enable it
2838 * only after we started a DMA xfer, and disable it here
2839 * immediately, or it will be signalled all the time while
2841 * Note 2: You would think that an irq which is masked is
2842 * not signalled by the hardware. Not so for the SAA7146:
2843 * An irq is signalled as long as the corresponding bit
2844 * in the ISR is set, and disabling irqs just prevents the
2845 * hardware from setting the ISR bit. This means a) that we
2846 * must clear the ISR *after* disabling the irq (which is why
2847 * we must do it here even though saa7146_core did it already),
2848 * and b) that if we were to disable an edge triggered irq
2849 * (like the gpio irqs sadly are) temporarily we would likely
2850 * loose some. This sucks :-(
2852 SAA7146_IER_DISABLE(av7110->dev, MASK_19);
2853 SAA7146_ISR_CLEAR(av7110->dev, MASK_19);
2854 tasklet_schedule(&av7110->debi_tasklet);
2857 if (*isr & MASK_03) {
2858 //printk("av7110_irq: GPIO\n");
2859 tasklet_schedule(&av7110->gpio_tasklet);
2862 if ((*isr & MASK_10) && budgetpatch)
2863 tasklet_schedule(&av7110->vpe_tasklet);
2867 static struct saa7146_extension av7110_extension;
2869 #define MAKE_AV7110_INFO(x_var,x_name) \
2870 static struct saa7146_pci_extension_data x_var = { \
2871 .ext_priv = x_name, \
2872 .ext = &av7110_extension }
2874 MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C");
2875 MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X");
2876 MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X");
2877 MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X");
2878 MAKE_AV7110_INFO(tts_2_X, "Technotrend/Hauppauge WinTV Nexus-S rev2.X");
2879 MAKE_AV7110_INFO(tts_2_3, "Technotrend/Hauppauge WinTV Nexus-S rev2.3");
2880 MAKE_AV7110_INFO(tts_1_3se, "Technotrend/Hauppauge WinTV DVB-S rev1.3 SE");
2881 MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T");
2882 MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C");
2883 MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6");
2885 static struct pci_device_id pci_tbl[] = {
2886 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
2887 MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000),
2888 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001),
2889 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002),
2890 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003),
2891 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006),
2892 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008),
2893 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
2894 MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e),
2895 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
2897 /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte
2898 /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1
2899 /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0009), UNDEFINED CARD */ // TT/Hauppauge WinTV Nexus-CA v????
2906 MODULE_DEVICE_TABLE(pci, pci_tbl);
2909 static struct saa7146_extension av7110_extension = {
2911 .flags = SAA7146_I2C_SHORT_DELAY,
2913 .module = THIS_MODULE,
2914 .pci_tbl = &pci_tbl[0],
2915 .attach = av7110_attach,
2916 .detach = av7110_detach,
2918 .irq_mask = MASK_19 | MASK_03 | MASK_10,
2919 .irq_func = av7110_irq,
2923 static int __init av7110_init(void)
2926 retval = saa7146_register_extension(&av7110_extension);
2931 static void __exit av7110_exit(void)
2933 saa7146_unregister_extension(&av7110_extension);
2936 module_init(av7110_init);
2937 module_exit(av7110_exit);
2939 MODULE_DESCRIPTION("driver for the SAA7146 based AV110 PCI DVB cards by "
2940 "Siemens, Technotrend, Hauppauge");
2941 MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others");
2942 MODULE_LICENSE("GPL");