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/module.h>
34 #include <linux/kmod.h>
35 #include <linux/delay.h>
37 #include <linux/timer.h>
38 #include <linux/poll.h>
39 #include <linux/byteorder/swabb.h>
40 #include <linux/smp_lock.h>
42 #include <linux/kernel.h>
43 #include <linux/sched.h>
44 #include <linux/types.h>
45 #include <linux/fcntl.h>
46 #include <linux/interrupt.h>
47 #include <linux/string.h>
48 #include <linux/pci.h>
49 #include <linux/vmalloc.h>
50 #include <linux/firmware.h>
51 #include <linux/crc32.h>
52 #include <linux/i2c.h>
53 #include <linux/kthread.h>
55 #include <asm/system.h>
57 #include <linux/dvb/frontend.h>
59 #include "dvb_frontend.h"
61 #include "ttpci-eeprom.h"
63 #include "av7110_hw.h"
64 #include "av7110_av.h"
65 #include "av7110_ca.h"
66 #include "av7110_ipack.h"
74 #define TS_BUFLEN (TS_WIDTH*TS_HEIGHT)
75 #define TS_MAX_PACKETS (TS_BUFLEN/TS_SIZE)
80 static int vidmode = CVBS_RGB_OUT;
82 static int adac = DVB_ADAC_TI;
83 static int hw_sections;
85 static int volume = 255;
86 static int budgetpatch;
87 static int wss_cfg_4_3 = 0x4008;
88 static int wss_cfg_16_9 = 0x0007;
89 static int tv_standard;
91 module_param_named(debug, av7110_debug, int, 0644);
92 MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)");
93 module_param(vidmode, int, 0444);
94 MODULE_PARM_DESC(vidmode,"analog video out: 0 off, 1 CVBS+RGB (default), 2 CVBS+YC, 3 YC");
95 module_param(pids_off, int, 0444);
96 MODULE_PARM_DESC(pids_off,"clear video/audio/PCR PID filters when demux is closed");
97 module_param(adac, int, 0444);
98 MODULE_PARM_DESC(adac,"audio DAC type: 0 TI, 1 CRYSTAL, 2 MSP (use if autodetection fails)");
99 module_param(hw_sections, int, 0444);
100 MODULE_PARM_DESC(hw_sections, "0 use software section filter, 1 use hardware");
101 module_param(rgb_on, int, 0444);
102 MODULE_PARM_DESC(rgb_on, "For Siemens DVB-C cards only: Enable RGB control"
103 " signal on SCART pin 16 to switch SCART video mode from CVBS to RGB");
104 module_param(volume, int, 0444);
105 MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)");
106 module_param(budgetpatch, int, 0444);
107 MODULE_PARM_DESC(budgetpatch, "use budget-patch hardware modification: default 0 (0 no, 1 autodetect, 2 always)");
108 module_param(wss_cfg_4_3, int, 0444);
109 MODULE_PARM_DESC(wss_cfg_4_3, "WSS 4:3 - default 0x4008 - bit 15: disable, 14: burst mode, 13..0: wss data");
110 module_param(wss_cfg_16_9, int, 0444);
111 MODULE_PARM_DESC(wss_cfg_16_9, "WSS 16:9 - default 0x0007 - bit 15: disable, 14: burst mode, 13..0: wss data");
112 module_param(tv_standard, int, 0444);
113 MODULE_PARM_DESC(tv_standard, "TV standard: 0 PAL (default), 1 NTSC");
115 static void restart_feeds(struct av7110 *av7110);
117 static int av7110_num;
119 #define FE_FUNC_OVERRIDE(fe_func, av7110_copy, av7110_func) \
121 if (fe_func != NULL) { \
122 av7110_copy = fe_func; \
123 fe_func = av7110_func; \
128 static void init_av7110_av(struct av7110 *av7110)
131 struct saa7146_dev *dev = av7110->dev;
133 /* set internal volume control to maximum */
134 av7110->adac_type = DVB_ADAC_TI;
135 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
137 printk("dvb-ttpci:cannot set internal volume to maximum:%d\n",ret);
139 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetMonitorType,
140 1, (u16) av7110->display_ar);
142 printk("dvb-ttpci: unable to set aspect ratio\n");
143 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetPanScanType,
144 1, av7110->display_panscan);
146 printk("dvb-ttpci: unable to set pan scan\n");
148 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 2, wss_cfg_4_3);
150 printk("dvb-ttpci: unable to configure 4:3 wss\n");
151 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 3, wss_cfg_16_9);
153 printk("dvb-ttpci: unable to configure 16:9 wss\n");
155 ret = av7710_set_video_mode(av7110, vidmode);
157 printk("dvb-ttpci:cannot set video mode:%d\n",ret);
159 /* handle different card types */
160 /* remaining inits according to card and frontend type */
161 av7110->analog_tuner_flags = 0;
162 av7110->current_input = 0;
163 if (dev->pci->subsystem_vendor == 0x13c2 && dev->pci->subsystem_device == 0x000a)
164 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 0); // SPDIF on
165 if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) {
166 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n",
167 av7110->dvb_adapter.num);
168 av7110->adac_type = DVB_ADAC_CRYSTAL;
169 i2c_writereg(av7110, 0x20, 0x01, 0xd2);
170 i2c_writereg(av7110, 0x20, 0x02, 0x49);
171 i2c_writereg(av7110, 0x20, 0x03, 0x00);
172 i2c_writereg(av7110, 0x20, 0x04, 0x00);
175 * some special handling for the Siemens DVB-C cards...
177 } else if (0 == av7110_init_analog_module(av7110)) {
180 else if (dev->pci->subsystem_vendor == 0x110a) {
181 printk("dvb-ttpci: DVB-C w/o analog module @ card %d detected\n",
182 av7110->dvb_adapter.num);
183 av7110->adac_type = DVB_ADAC_NONE;
186 av7110->adac_type = adac;
187 printk("dvb-ttpci: adac type set to %d @ card %d\n",
188 av7110->adac_type, av7110->dvb_adapter.num);
191 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP34x0) {
192 // switch DVB SCART on
193 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
195 printk("dvb-ttpci:cannot switch on SCART(Main):%d\n",ret);
196 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
198 printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret);
200 ((av7110->dev->pci->subsystem_vendor == 0x110a) ||
201 (av7110->dev->pci->subsystem_vendor == 0x13c2)) &&
202 (av7110->dev->pci->subsystem_device == 0x0000)) {
203 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
204 //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8
208 if (dev->pci->subsystem_vendor == 0x13c2 && dev->pci->subsystem_device == 0x000e)
209 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, SpdifSwitch, 1, 0); // SPDIF on
211 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
213 printk("dvb-ttpci:cannot set volume :%d\n",ret);
216 static void recover_arm(struct av7110 *av7110)
218 dprintk(4, "%p\n",av7110);
220 av7110_bootarm(av7110);
223 init_av7110_av(av7110);
225 /* card-specific recovery */
227 av7110->recover(av7110);
229 restart_feeds(av7110);
231 #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
232 av7110_check_ir_config(av7110, true);
236 static void av7110_arm_sync(struct av7110 *av7110)
238 if (av7110->arm_thread)
239 kthread_stop(av7110->arm_thread);
241 av7110->arm_thread = NULL;
244 static int arm_thread(void *data)
246 struct av7110 *av7110 = data;
250 dprintk(4, "%p\n",av7110);
253 timeout = wait_event_interruptible_timeout(av7110->arm_wait,
254 kthread_should_stop(), 5 * HZ);
256 if (-ERESTARTSYS == timeout || kthread_should_stop()) {
257 /* got signal or told to quit*/
261 if (!av7110->arm_ready)
264 #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
265 av7110_check_ir_config(av7110, false);
268 if (mutex_lock_interruptible(&av7110->dcomlock))
270 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2);
271 mutex_unlock(&av7110->dcomlock);
273 if (newloops == av7110->arm_loops || av7110->arm_errors > 3) {
274 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
275 av7110->dvb_adapter.num);
279 if (mutex_lock_interruptible(&av7110->dcomlock))
281 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1;
282 mutex_unlock(&av7110->dcomlock);
284 av7110->arm_loops = newloops;
285 av7110->arm_errors = 0;
292 /****************************************************************************
294 ****************************************************************************/
296 static int DvbDmxFilterCallback(u8 *buffer1, size_t buffer1_len,
297 u8 *buffer2, size_t buffer2_len,
298 struct dvb_demux_filter *dvbdmxfilter,
299 enum dmx_success success,
300 struct av7110 *av7110)
302 if (!dvbdmxfilter->feed->demux->dmx.frontend)
304 if (dvbdmxfilter->feed->demux->dmx.frontend->source == DMX_MEMORY_FE)
307 switch (dvbdmxfilter->type) {
309 if ((((buffer1[1] << 8) | buffer1[2]) & 0xfff) + 3 != buffer1_len)
311 if (dvbdmxfilter->doneq) {
312 struct dmx_section_filter *filter = &dvbdmxfilter->filter;
316 for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
317 xor = filter->filter_value[i] ^ buffer1[i];
318 neq |= dvbdmxfilter->maskandnotmode[i] & xor;
323 return dvbdmxfilter->feed->cb.sec(buffer1, buffer1_len,
324 buffer2, buffer2_len,
325 &dvbdmxfilter->filter,
328 if (!(dvbdmxfilter->feed->ts_type & TS_PACKET))
330 if (dvbdmxfilter->feed->ts_type & TS_PAYLOAD_ONLY)
331 return dvbdmxfilter->feed->cb.ts(buffer1, buffer1_len,
332 buffer2, buffer2_len,
333 &dvbdmxfilter->feed->feed.ts,
336 av7110_p2t_write(buffer1, buffer1_len,
337 dvbdmxfilter->feed->pid,
338 &av7110->p2t_filter[dvbdmxfilter->index]);
345 //#define DEBUG_TIMING
346 static inline void print_time(char *s)
350 do_gettimeofday(&tv);
351 printk("%s: %d.%d\n", s, (int)tv.tv_sec, (int)tv.tv_usec);
357 static inline void start_debi_dma(struct av7110 *av7110, int dir,
358 unsigned long addr, unsigned int len)
360 dprintk(8, "%c %08lx %u\n", dir == DEBI_READ ? 'R' : 'W', addr, len);
361 if (saa7146_wait_for_debi_done(av7110->dev, 0)) {
362 printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __FUNCTION__);
366 SAA7146_ISR_CLEAR(av7110->dev, MASK_19); /* for good measure */
367 SAA7146_IER_ENABLE(av7110->dev, MASK_19);
369 len = 5; /* we want a real DEBI DMA */
370 if (dir == DEBI_WRITE)
371 iwdebi(av7110, DEBISWAB, addr, 0, (len + 3) & ~3);
373 irdebi(av7110, DEBISWAB, addr, 0, len);
376 static void debiirq(unsigned long data)
378 struct av7110 *av7110 = (struct av7110 *) data;
379 int type = av7110->debitype;
380 int handle = (type >> 8) & 0x1f;
381 unsigned int xfer = 0;
384 dprintk(4, "type 0x%04x\n", type);
387 printk("DEBI irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
388 jiffies, saa7146_read(av7110->dev, PSR),
389 saa7146_read(av7110->dev, SSR));
392 av7110->debitype = -1;
394 switch (type & 0xff) {
397 dvb_dmx_swfilter_packets(&av7110->demux,
398 (const u8 *) av7110->debi_virt,
399 av7110->debilen / 188);
403 case DATA_PES_RECORD:
404 if (av7110->demux.recording)
405 av7110_record_cb(&av7110->p2t[handle],
406 (u8 *) av7110->debi_virt,
414 if (av7110->handle2filter[handle])
415 DvbDmxFilterCallback((u8 *)av7110->debi_virt,
416 av7110->debilen, NULL, 0,
417 av7110->handle2filter[handle],
424 u8 *data = av7110->debi_virt;
426 if ((data[0] < 2) && data[2] == 0xff) {
429 flags |= CA_CI_MODULE_PRESENT;
431 flags |= CA_CI_MODULE_READY;
432 av7110->ci_slot[data[0]].flags = flags;
434 ci_get_data(&av7110->ci_rbuffer,
441 case DATA_COMMON_INTERFACE:
442 CI_handle(av7110, (u8 *)av7110->debi_virt, av7110->debilen);
447 printk("av7110%d: ", av7110->num);
448 printk("%02x ", *(u8 *)av7110->debi_virt);
449 printk("%02x ", *(1+(u8 *)av7110->debi_virt));
450 for (i = 2; i < av7110->debilen; i++)
451 printk("%02x ", (*(i+(unsigned char *)av7110->debi_virt)));
452 for (i = 2; i < av7110->debilen; i++)
453 printk("%c", chtrans(*(i+(unsigned char *)av7110->debi_virt)));
461 case DATA_DEBUG_MESSAGE:
462 ((s8*)av7110->debi_virt)[Reserved_SIZE - 1] = 0;
463 printk("%s\n", (s8 *) av7110->debi_virt);
468 dprintk(4, "debi DATA_CI_PUT\n");
470 dprintk(4, "debi DATA_MPEG_PLAY\n");
472 dprintk(4, "debi DATA_BMP_LOAD\n");
479 spin_lock(&av7110->debilock);
481 iwdebi(av7110, DEBINOSWAP, xfer, 0, 2);
482 ARM_ClearMailBox(av7110);
483 spin_unlock(&av7110->debilock);
486 /* irq from av7110 firmware writing the mailbox register in the DPRAM */
487 static void gpioirq(unsigned long data)
489 struct av7110 *av7110 = (struct av7110 *) data;
493 if (av7110->debitype != -1)
494 /* we shouldn't get any irq while a debi xfer is running */
495 printk("dvb-ttpci: GPIO0 irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
496 jiffies, saa7146_read(av7110->dev, PSR),
497 saa7146_read(av7110->dev, SSR));
499 if (saa7146_wait_for_debi_done(av7110->dev, 0)) {
500 printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __FUNCTION__);
501 BUG(); /* maybe we should try resetting the debi? */
504 spin_lock(&av7110->debilock);
505 ARM_ClearIrq(av7110);
507 /* see what the av7110 wants */
508 av7110->debitype = irdebi(av7110, DEBINOSWAP, IRQ_STATE, 0, 2);
509 av7110->debilen = irdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
510 rxbuf = irdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
511 txbuf = irdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
512 len = (av7110->debilen + 3) & ~3;
515 dprintk(8, "GPIO0 irq 0x%04x %d\n", av7110->debitype, av7110->debilen);
517 switch (av7110->debitype & 0xff) {
523 case DATA_MPEG_VIDEO_EVENT:
526 struct video_event event;
528 av7110->video_size.w = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_WIDTH, 0, 2);
529 h_ar = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_HEIGHT_AR, 0, 2);
531 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
532 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
534 av7110->video_size.h = h_ar & 0xfff;
536 event.type = VIDEO_EVENT_SIZE_CHANGED;
537 event.u.size.w = av7110->video_size.w;
538 event.u.size.h = av7110->video_size.h;
539 switch ((h_ar >> 12) & 0xf)
542 av7110->video_size.aspect_ratio = VIDEO_FORMAT_16_9;
543 event.u.size.aspect_ratio = VIDEO_FORMAT_16_9;
544 av7110->videostate.video_format = VIDEO_FORMAT_16_9;
547 av7110->video_size.aspect_ratio = VIDEO_FORMAT_221_1;
548 event.u.size.aspect_ratio = VIDEO_FORMAT_221_1;
549 av7110->videostate.video_format = VIDEO_FORMAT_221_1;
552 av7110->video_size.aspect_ratio = VIDEO_FORMAT_4_3;
553 event.u.size.aspect_ratio = VIDEO_FORMAT_4_3;
554 av7110->videostate.video_format = VIDEO_FORMAT_4_3;
557 dprintk(8, "GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n",
558 av7110->video_size.w, av7110->video_size.h,
559 av7110->video_size.aspect_ratio);
561 dvb_video_add_event(av7110, &event);
568 struct dvb_ringbuffer *cibuf = &av7110->ci_wbuffer;
570 avail = dvb_ringbuffer_avail(cibuf);
572 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
573 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
574 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
577 len = DVB_RINGBUFFER_PEEK(cibuf, 0) << 8;
578 len |= DVB_RINGBUFFER_PEEK(cibuf, 1);
579 if (avail < len + 2) {
580 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
581 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
582 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
585 DVB_RINGBUFFER_SKIP(cibuf, 2);
587 dvb_ringbuffer_read(cibuf, av7110->debi_virt, len, 0);
589 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
590 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
591 dprintk(8, "DMA: CI\n");
592 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE + txbuf, len);
593 spin_unlock(&av7110->debilock);
594 wake_up(&cibuf->queue);
599 if (!av7110->playing) {
600 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
601 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
602 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
606 if (av7110->debitype & 0x100) {
607 spin_lock(&av7110->aout.lock);
608 len = av7110_pes_play(av7110->debi_virt, &av7110->aout, 2048);
609 spin_unlock(&av7110->aout.lock);
611 if (len <= 0 && (av7110->debitype & 0x200)
612 &&av7110->videostate.play_state != VIDEO_FREEZED) {
613 spin_lock(&av7110->avout.lock);
614 len = av7110_pes_play(av7110->debi_virt, &av7110->avout, 2048);
615 spin_unlock(&av7110->avout.lock);
618 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
619 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
620 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
623 dprintk(8, "GPIO0 PES_PLAY len=%04x\n", len);
624 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
625 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
626 dprintk(8, "DMA: MPEG_PLAY\n");
627 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE + txbuf, len);
628 spin_unlock(&av7110->debilock);
632 len = av7110->debilen;
633 dprintk(8, "gpio DATA_BMP_LOAD len %d\n", len);
635 av7110->bmp_state = BMP_LOADED;
636 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
637 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
638 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
639 wake_up(&av7110->bmpq);
640 dprintk(8, "gpio DATA_BMP_LOAD done\n");
643 if (len > av7110->bmplen)
644 len = av7110->bmplen;
647 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
648 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
649 memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len);
651 av7110->bmplen -= len;
652 dprintk(8, "gpio DATA_BMP_LOAD DMA len %d\n", len);
653 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE+txbuf, len);
654 spin_unlock(&av7110->debilock);
658 case DATA_COMMON_INTERFACE:
662 if (!len || len > 4 * 1024) {
663 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
669 case DATA_PES_RECORD:
670 dprintk(8, "DMA: TS_REC etc.\n");
671 start_debi_dma(av7110, DEBI_READ, DPRAM_BASE+rxbuf, len);
672 spin_unlock(&av7110->debilock);
675 case DATA_DEBUG_MESSAGE:
676 if (!len || len > 0xff) {
677 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
680 start_debi_dma(av7110, DEBI_READ, Reserved, len);
681 spin_unlock(&av7110->debilock);
685 if (av7110->ir.ir_handler)
686 av7110->ir.ir_handler(av7110,
687 swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4)));
688 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
692 printk("dvb-ttpci: gpioirq unknown type=%d len=%d\n",
693 av7110->debitype, av7110->debilen);
696 av7110->debitype = -1;
697 ARM_ClearMailBox(av7110);
698 spin_unlock(&av7110->debilock);
702 #ifdef CONFIG_DVB_AV7110_OSD
703 static int dvb_osd_ioctl(struct inode *inode, struct file *file,
704 unsigned int cmd, void *parg)
706 struct dvb_device *dvbdev = file->private_data;
707 struct av7110 *av7110 = dvbdev->priv;
709 dprintk(4, "%p\n", av7110);
711 if (cmd == OSD_SEND_CMD)
712 return av7110_osd_cmd(av7110, (osd_cmd_t *) parg);
713 if (cmd == OSD_GET_CAPABILITY)
714 return av7110_osd_capability(av7110, (osd_cap_t *) parg);
720 static struct file_operations dvb_osd_fops = {
721 .owner = THIS_MODULE,
722 .ioctl = dvb_generic_ioctl,
723 .open = dvb_generic_open,
724 .release = dvb_generic_release,
727 static struct dvb_device dvbdev_osd = {
731 .fops = &dvb_osd_fops,
732 .kernel_ioctl = dvb_osd_ioctl,
734 #endif /* CONFIG_DVB_AV7110_OSD */
737 static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
738 u16 subpid, u16 pcrpid)
742 dprintk(4, "%p\n", av7110);
744 if (vpid == 0x1fff || apid == 0x1fff ||
745 ttpid == 0x1fff || subpid == 0x1fff || pcrpid == 0x1fff) {
746 vpid = apid = ttpid = subpid = pcrpid = 0;
747 av7110->pids[DMX_PES_VIDEO] = 0;
748 av7110->pids[DMX_PES_AUDIO] = 0;
749 av7110->pids[DMX_PES_TELETEXT] = 0;
750 av7110->pids[DMX_PES_PCR] = 0;
753 if (av7110->audiostate.bypass_mode)
756 return av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, MultiPID, 6,
757 pcrpid, vpid, apid, ttpid, subpid, aflags);
760 int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
761 u16 subpid, u16 pcrpid)
764 dprintk(4, "%p\n", av7110);
766 if (mutex_lock_interruptible(&av7110->pid_mutex))
769 if (!(vpid & 0x8000))
770 av7110->pids[DMX_PES_VIDEO] = vpid;
771 if (!(apid & 0x8000))
772 av7110->pids[DMX_PES_AUDIO] = apid;
773 if (!(ttpid & 0x8000))
774 av7110->pids[DMX_PES_TELETEXT] = ttpid;
775 if (!(pcrpid & 0x8000))
776 av7110->pids[DMX_PES_PCR] = pcrpid;
778 av7110->pids[DMX_PES_SUBTITLE] = 0;
780 if (av7110->fe_synced) {
781 pcrpid = av7110->pids[DMX_PES_PCR];
782 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
785 mutex_unlock(&av7110->pid_mutex);
790 /******************************************************************************
791 * hardware filter functions
792 ******************************************************************************/
794 static int StartHWFilter(struct dvb_demux_filter *dvbdmxfilter)
796 struct dvb_demux_feed *dvbdmxfeed = dvbdmxfilter->feed;
797 struct av7110 *av7110 = dvbdmxfeed->demux->priv;
801 // u16 mode = 0x0320;
804 dprintk(4, "%p\n", av7110);
806 if (dvbdmxfilter->type == DMX_TYPE_SEC) {
808 buf[4] = (dvbdmxfilter->filter.filter_value[0] << 8) |
809 dvbdmxfilter->maskandmode[0];
810 for (i = 3; i < 18; i++)
812 (dvbdmxfilter->filter.filter_value[i] << 8) |
813 dvbdmxfilter->maskandmode[i];
816 } else if ((dvbdmxfeed->ts_type & TS_PACKET) &&
817 !(dvbdmxfeed->ts_type & TS_PAYLOAD_ONLY)) {
818 av7110_p2t_init(&av7110->p2t_filter[dvbdmxfilter->index], dvbdmxfeed);
821 buf[0] = (COMTYPE_PID_FILTER << 8) + AddPIDFilter;
823 buf[2] = dvbdmxfeed->pid;
826 ret = av7110_fw_request(av7110, buf, 20, &handle, 1);
827 if (ret != 0 || handle >= 32) {
828 printk("dvb-ttpci: %s error buf %04x %04x %04x %04x "
829 "ret %d handle %04x\n",
830 __FUNCTION__, buf[0], buf[1], buf[2], buf[3],
832 dvbdmxfilter->hw_handle = 0xffff;
838 av7110->handle2filter[handle] = dvbdmxfilter;
839 dvbdmxfilter->hw_handle = handle;
844 static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter)
846 struct av7110 *av7110 = dvbdmxfilter->feed->demux->priv;
852 dprintk(4, "%p\n", av7110);
854 handle = dvbdmxfilter->hw_handle;
856 printk("%s tried to stop invalid filter %04x, filter type = %x\n",
857 __FUNCTION__, handle, dvbdmxfilter->type);
861 av7110->handle2filter[handle] = NULL;
863 buf[0] = (COMTYPE_PID_FILTER << 8) + DelPIDFilter;
866 ret = av7110_fw_request(av7110, buf, 3, answ, 2);
867 if (ret != 0 || answ[1] != handle) {
868 printk("dvb-ttpci: %s error cmd %04x %04x %04x ret %x "
869 "resp %04x %04x pid %d\n",
870 __FUNCTION__, buf[0], buf[1], buf[2], ret,
871 answ[0], answ[1], dvbdmxfilter->feed->pid);
879 static int dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed)
881 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
882 struct av7110 *av7110 = dvbdmx->priv;
883 u16 *pid = dvbdmx->pids, npids[5];
887 dprintk(4, "%p\n", av7110);
889 npids[0] = npids[1] = npids[2] = npids[3] = npids[4] = 0xffff;
890 i = dvbdmxfeed->pes_type;
891 npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
892 if ((i == 2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) {
894 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
896 ret = StartHWFilter(dvbdmxfeed->filter);
899 if (dvbdmxfeed->pes_type <= 2 || dvbdmxfeed->pes_type == 4) {
900 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
905 if (dvbdmxfeed->pes_type < 2 && npids[0])
906 if (av7110->fe_synced)
908 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
913 if ((dvbdmxfeed->ts_type & TS_PACKET)) {
914 if (dvbdmxfeed->pes_type == 0 && !(dvbdmx->pids[0] & 0x8000))
915 ret = av7110_av_start_record(av7110, RP_AUDIO, dvbdmxfeed);
916 if (dvbdmxfeed->pes_type == 1 && !(dvbdmx->pids[1] & 0x8000))
917 ret = av7110_av_start_record(av7110, RP_VIDEO, dvbdmxfeed);
922 static int dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed)
924 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
925 struct av7110 *av7110 = dvbdmx->priv;
926 u16 *pid = dvbdmx->pids, npids[5];
931 dprintk(4, "%p\n", av7110);
933 if (dvbdmxfeed->pes_type <= 1) {
934 ret = av7110_av_stop(av7110, dvbdmxfeed->pes_type ? RP_VIDEO : RP_AUDIO);
937 if (!av7110->rec_mode)
938 dvbdmx->recording = 0;
939 if (!av7110->playing)
942 npids[0] = npids[1] = npids[2] = npids[3] = npids[4] = 0xffff;
943 i = dvbdmxfeed->pes_type;
946 if (dvbdmxfeed->ts_type & TS_PACKET)
947 ret = StopHWFilter(dvbdmxfeed->filter);
955 npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
959 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
963 static int av7110_start_feed(struct dvb_demux_feed *feed)
965 struct dvb_demux *demux = feed->demux;
966 struct av7110 *av7110 = demux->priv;
969 dprintk(4, "%p\n", av7110);
971 if (!demux->dmx.frontend)
974 if (feed->pid > 0x1fff)
977 if (feed->type == DMX_TYPE_TS) {
978 if ((feed->ts_type & TS_DECODER) &&
979 (feed->pes_type < DMX_TS_PES_OTHER)) {
980 switch (demux->dmx.frontend->source) {
982 if (feed->ts_type & TS_DECODER)
983 if (feed->pes_type < 2 &&
984 !(demux->pids[0] & 0x8000) &&
985 !(demux->pids[1] & 0x8000)) {
986 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
987 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
988 ret = av7110_av_start_play(av7110,RP_AV);
994 ret = dvb_feed_start_pid(feed);
997 } else if ((feed->ts_type & TS_PACKET) &&
998 (demux->dmx.frontend->source != DMX_MEMORY_FE)) {
999 ret = StartHWFilter(feed->filter);
1003 else if (feed->type == DMX_TYPE_SEC) {
1006 for (i = 0; i < demux->filternum; i++) {
1007 if (demux->filter[i].state != DMX_STATE_READY)
1009 if (demux->filter[i].type != DMX_TYPE_SEC)
1011 if (demux->filter[i].filter.parent != &feed->feed.sec)
1013 demux->filter[i].state = DMX_STATE_GO;
1014 if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
1015 ret = StartHWFilter(&demux->filter[i]);
1026 static int av7110_stop_feed(struct dvb_demux_feed *feed)
1028 struct dvb_demux *demux = feed->demux;
1029 struct av7110 *av7110 = demux->priv;
1031 dprintk(4, "%p\n", av7110);
1033 if (feed->type == DMX_TYPE_TS) {
1034 if (feed->ts_type & TS_DECODER) {
1035 if (feed->pes_type >= DMX_TS_PES_OTHER ||
1036 !demux->pesfilter[feed->pes_type])
1038 demux->pids[feed->pes_type] |= 0x8000;
1039 demux->pesfilter[feed->pes_type] = NULL;
1041 if (feed->ts_type & TS_DECODER &&
1042 feed->pes_type < DMX_TS_PES_OTHER) {
1043 ret = dvb_feed_stop_pid(feed);
1045 if ((feed->ts_type & TS_PACKET) &&
1046 (demux->dmx.frontend->source != DMX_MEMORY_FE))
1047 ret = StopHWFilter(feed->filter);
1050 if (!ret && feed->type == DMX_TYPE_SEC) {
1051 for (i = 0; i<demux->filternum; i++) {
1052 if (demux->filter[i].state == DMX_STATE_GO &&
1053 demux->filter[i].filter.parent == &feed->feed.sec) {
1054 demux->filter[i].state = DMX_STATE_READY;
1055 if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
1056 rc = StopHWFilter(&demux->filter[i]);
1059 /* keep going, stop as many filters as possible */
1069 static void restart_feeds(struct av7110 *av7110)
1071 struct dvb_demux *dvbdmx = &av7110->demux;
1072 struct dvb_demux_feed *feed;
1076 dprintk(4, "%p\n", av7110);
1078 mode = av7110->playing;
1079 av7110->playing = 0;
1080 av7110->rec_mode = 0;
1082 for (i = 0; i < dvbdmx->feednum; i++) {
1083 feed = &dvbdmx->feed[i];
1084 if (feed->state == DMX_STATE_GO) {
1085 if (feed->type == DMX_TYPE_SEC) {
1086 for (j = 0; j < dvbdmx->filternum; j++) {
1087 if (dvbdmx->filter[j].type != DMX_TYPE_SEC)
1089 if (dvbdmx->filter[j].filter.parent != &feed->feed.sec)
1091 if (dvbdmx->filter[j].state == DMX_STATE_GO)
1092 dvbdmx->filter[j].state = DMX_STATE_READY;
1095 av7110_start_feed(feed);
1100 av7110_av_start_play(av7110, mode);
1103 static int dvb_get_stc(struct dmx_demux *demux, unsigned int num,
1104 uint64_t *stc, unsigned int *base)
1108 u16 tag = ((COMTYPE_REQUEST << 8) + ReqSTC);
1109 struct dvb_demux *dvbdemux;
1110 struct av7110 *av7110;
1112 /* pointer casting paranoia... */
1114 dvbdemux = demux->priv;
1116 av7110 = dvbdemux->priv;
1118 dprintk(4, "%p\n", av7110);
1123 ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4);
1125 printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__);
1128 dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n",
1129 fwstc[0], fwstc[1], fwstc[2], fwstc[3]);
1131 *stc = (((uint64_t) ((fwstc[3] & 0x8000) >> 15)) << 32) |
1132 (((uint64_t) fwstc[1]) << 16) | ((uint64_t) fwstc[0]);
1135 dprintk(4, "stc = %lu\n", (unsigned long)*stc);
1141 /******************************************************************************
1142 * SEC device file operations
1143 ******************************************************************************/
1146 static int av7110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
1148 struct av7110* av7110 = fe->dvb->priv;
1152 return Set22K(av7110, 1);
1155 return Set22K(av7110, 0);
1162 static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe,
1163 struct dvb_diseqc_master_cmd* cmd)
1165 struct av7110* av7110 = fe->dvb->priv;
1167 return av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1);
1170 static int av7110_diseqc_send_burst(struct dvb_frontend* fe,
1171 fe_sec_mini_cmd_t minicmd)
1173 struct av7110* av7110 = fe->dvb->priv;
1175 return av7110_diseqc_send(av7110, 0, NULL, minicmd);
1178 /* simplified code from budget-core.c */
1179 static int stop_ts_capture(struct av7110 *budget)
1181 dprintk(2, "budget: %p\n", budget);
1183 if (--budget->feeding1)
1184 return budget->feeding1;
1185 saa7146_write(budget->dev, MC1, MASK_20); /* DMA3 off */
1186 SAA7146_IER_DISABLE(budget->dev, MASK_10);
1187 SAA7146_ISR_CLEAR(budget->dev, MASK_10);
1191 static int start_ts_capture(struct av7110 *budget)
1193 dprintk(2, "budget: %p\n", budget);
1195 if (budget->feeding1)
1196 return ++budget->feeding1;
1197 memset(budget->grabbing, 0x00, TS_HEIGHT * TS_WIDTH);
1200 SAA7146_IER_ENABLE(budget->dev, MASK_10); /* VPE */
1201 saa7146_write(budget->dev, MC1, (MASK_04 | MASK_20)); /* DMA3 on */
1202 return ++budget->feeding1;
1205 static int budget_start_feed(struct dvb_demux_feed *feed)
1207 struct dvb_demux *demux = feed->demux;
1208 struct av7110 *budget = demux->priv;
1211 dprintk(2, "av7110: %p\n", budget);
1213 spin_lock(&budget->feedlock1);
1214 feed->pusi_seen = 0; /* have a clean section start */
1215 status = start_ts_capture(budget);
1216 spin_unlock(&budget->feedlock1);
1220 static int budget_stop_feed(struct dvb_demux_feed *feed)
1222 struct dvb_demux *demux = feed->demux;
1223 struct av7110 *budget = demux->priv;
1226 dprintk(2, "budget: %p\n", budget);
1228 spin_lock(&budget->feedlock1);
1229 status = stop_ts_capture(budget);
1230 spin_unlock(&budget->feedlock1);
1234 static void vpeirq(unsigned long data)
1236 struct av7110 *budget = (struct av7110 *) data;
1237 u8 *mem = (u8 *) (budget->grabbing);
1238 u32 olddma = budget->ttbp;
1239 u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
1242 printk("av7110.c: vpeirq() called while budgetpatch disabled!"
1243 " check saa7146 IER register\n");
1246 /* nearest lower position divisible by 188 */
1247 newdma -= newdma % 188;
1249 if (newdma >= TS_BUFLEN)
1252 budget->ttbp = newdma;
1254 if (!budget->feeding1 || (newdma == olddma))
1257 /* Ensure streamed PCI data is synced to CPU */
1258 pci_dma_sync_sg_for_cpu(budget->dev->pci, budget->pt.slist, budget->pt.nents, PCI_DMA_FROMDEVICE);
1261 /* track rps1 activity */
1262 printk("vpeirq: %02x Event Counter 1 0x%04x\n",
1264 saa7146_read(budget->dev, EC1R) & 0x3fff);
1267 if (newdma > olddma)
1268 /* no wraparound, dump olddma..newdma */
1269 dvb_dmx_swfilter_packets(&budget->demux1, mem + olddma, (newdma - olddma) / 188);
1271 /* wraparound, dump olddma..buflen and 0..newdma */
1272 dvb_dmx_swfilter_packets(&budget->demux1, mem + olddma, (TS_BUFLEN - olddma) / 188);
1273 dvb_dmx_swfilter_packets(&budget->demux1, mem, newdma / 188);
1277 static int av7110_register(struct av7110 *av7110)
1280 struct dvb_demux *dvbdemux = &av7110->demux;
1281 struct dvb_demux *dvbdemux1 = &av7110->demux1;
1283 dprintk(4, "%p\n", av7110);
1285 if (av7110->registered)
1288 av7110->registered = 1;
1290 dvbdemux->priv = (void *) av7110;
1292 for (i = 0; i < 32; i++)
1293 av7110->handle2filter[i] = NULL;
1295 dvbdemux->filternum = 32;
1296 dvbdemux->feednum = 32;
1297 dvbdemux->start_feed = av7110_start_feed;
1298 dvbdemux->stop_feed = av7110_stop_feed;
1299 dvbdemux->write_to_decoder = av7110_write_to_decoder;
1300 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
1301 DMX_MEMORY_BASED_FILTERING);
1303 dvb_dmx_init(&av7110->demux);
1304 av7110->demux.dmx.get_stc = dvb_get_stc;
1306 av7110->dmxdev.filternum = 32;
1307 av7110->dmxdev.demux = &dvbdemux->dmx;
1308 av7110->dmxdev.capabilities = 0;
1310 dvb_dmxdev_init(&av7110->dmxdev, &av7110->dvb_adapter);
1312 av7110->hw_frontend.source = DMX_FRONTEND_0;
1314 ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
1319 av7110->mem_frontend.source = DMX_MEMORY_FE;
1321 ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
1326 ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx,
1327 &av7110->hw_frontend);
1331 av7110_av_register(av7110);
1332 av7110_ca_register(av7110);
1334 #ifdef CONFIG_DVB_AV7110_OSD
1335 dvb_register_device(&av7110->dvb_adapter, &av7110->osd_dev,
1336 &dvbdev_osd, av7110, DVB_DEVICE_OSD);
1339 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx);
1342 /* initialize software demux1 without its own frontend
1343 * demux1 hardware is connected to frontend0 of demux0
1345 dvbdemux1->priv = (void *) av7110;
1347 dvbdemux1->filternum = 256;
1348 dvbdemux1->feednum = 256;
1349 dvbdemux1->start_feed = budget_start_feed;
1350 dvbdemux1->stop_feed = budget_stop_feed;
1351 dvbdemux1->write_to_decoder = NULL;
1353 dvbdemux1->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
1354 DMX_MEMORY_BASED_FILTERING);
1356 dvb_dmx_init(&av7110->demux1);
1358 av7110->dmxdev1.filternum = 256;
1359 av7110->dmxdev1.demux = &dvbdemux1->dmx;
1360 av7110->dmxdev1.capabilities = 0;
1362 dvb_dmxdev_init(&av7110->dmxdev1, &av7110->dvb_adapter);
1364 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx);
1365 printk("dvb-ttpci: additional demux1 for budget-patch registered\n");
1371 static void dvb_unregister(struct av7110 *av7110)
1373 struct dvb_demux *dvbdemux = &av7110->demux;
1374 struct dvb_demux *dvbdemux1 = &av7110->demux1;
1376 dprintk(4, "%p\n", av7110);
1378 if (!av7110->registered)
1382 dvb_net_release(&av7110->dvb_net1);
1383 dvbdemux->dmx.close(&dvbdemux1->dmx);
1384 dvb_dmxdev_release(&av7110->dmxdev1);
1385 dvb_dmx_release(&av7110->demux1);
1388 dvb_net_release(&av7110->dvb_net);
1390 dvbdemux->dmx.close(&dvbdemux->dmx);
1391 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
1392 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
1394 dvb_dmxdev_release(&av7110->dmxdev);
1395 dvb_dmx_release(&av7110->demux);
1397 if (av7110->fe != NULL) {
1398 dvb_unregister_frontend(av7110->fe);
1399 dvb_frontend_detach(av7110->fe);
1401 dvb_unregister_device(av7110->osd_dev);
1402 av7110_av_unregister(av7110);
1403 av7110_ca_unregister(av7110);
1407 /****************************************************************************
1408 * I2C client commands
1409 ****************************************************************************/
1411 int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val)
1413 u8 msg[2] = { reg, val };
1414 struct i2c_msg msgs;
1420 return i2c_transfer(&av7110->i2c_adap, &msgs, 1);
1424 u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg)
1428 struct i2c_msg msgs[2];
1431 msgs[1].flags = I2C_M_RD;
1432 msgs[0].addr = msgs[1].addr = id / 2;
1434 msgs[0].len = 1; msgs[1].len = 1;
1435 msgs[0].buf = mm1; msgs[1].buf = mm2;
1436 i2c_transfer(&av7110->i2c_adap, msgs, 2);
1442 /****************************************************************************
1444 ****************************************************************************/
1447 static int check_firmware(struct av7110* av7110)
1449 u32 crc = 0, len = 0;
1452 /* check for firmware magic */
1453 ptr = av7110->bin_fw;
1454 if (ptr[0] != 'A' || ptr[1] != 'V' ||
1455 ptr[2] != 'F' || ptr[3] != 'W') {
1456 printk("dvb-ttpci: this is not an av7110 firmware\n");
1461 /* check dpram file */
1462 crc = ntohl(*(u32*) ptr);
1464 len = ntohl(*(u32*) ptr);
1467 printk("dvb-ttpci: dpram file is way too big.\n");
1470 if (crc != crc32_le(0, ptr, len)) {
1471 printk("dvb-ttpci: crc32 of dpram file does not match.\n");
1474 av7110->bin_dpram = ptr;
1475 av7110->size_dpram = len;
1478 /* check root file */
1479 crc = ntohl(*(u32*) ptr);
1481 len = ntohl(*(u32*) ptr);
1484 if (len <= 200000 || len >= 300000 ||
1485 len > ((av7110->bin_fw + av7110->size_fw) - ptr)) {
1486 printk("dvb-ttpci: root file has strange size (%d). aborting.\n", len);
1489 if( crc != crc32_le(0, ptr, len)) {
1490 printk("dvb-ttpci: crc32 of root file does not match.\n");
1493 av7110->bin_root = ptr;
1494 av7110->size_root = len;
1498 #ifdef CONFIG_DVB_AV7110_FIRMWARE_FILE
1499 #include "av7110_firm.h"
1500 static void put_firmware(struct av7110* av7110)
1502 av7110->bin_fw = NULL;
1505 static inline int get_firmware(struct av7110* av7110)
1507 av7110->bin_fw = dvb_ttpci_fw;
1508 av7110->size_fw = sizeof(dvb_ttpci_fw);
1509 return check_firmware(av7110);
1512 static void put_firmware(struct av7110* av7110)
1514 vfree(av7110->bin_fw);
1517 static int get_firmware(struct av7110* av7110)
1520 const struct firmware *fw;
1522 /* request the av7110 firmware, this will block until someone uploads it */
1523 ret = request_firmware(&fw, "dvb-ttpci-01.fw", &av7110->dev->pci->dev);
1525 if (ret == -ENOENT) {
1526 printk(KERN_ERR "dvb-ttpci: could not load firmware,"
1527 " file not found: dvb-ttpci-01.fw\n");
1528 printk(KERN_ERR "dvb-ttpci: usually this should be in "
1529 "/usr/lib/hotplug/firmware or /lib/firmware\n");
1530 printk(KERN_ERR "dvb-ttpci: and can be downloaded from"
1531 " http://www.linuxtv.org/download/dvb/firmware/\n");
1533 printk(KERN_ERR "dvb-ttpci: cannot request firmware"
1534 " (error %i)\n", ret);
1538 if (fw->size <= 200000) {
1539 printk("dvb-ttpci: this firmware is way too small.\n");
1540 release_firmware(fw);
1544 /* check if the firmware is available */
1545 av7110->bin_fw = vmalloc(fw->size);
1546 if (NULL == av7110->bin_fw) {
1547 dprintk(1, "out of memory\n");
1548 release_firmware(fw);
1552 memcpy(av7110->bin_fw, fw->data, fw->size);
1553 av7110->size_fw = fw->size;
1554 if ((ret = check_firmware(av7110)))
1555 vfree(av7110->bin_fw);
1557 release_firmware(fw);
1563 static int alps_bsrv2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
1565 struct av7110* av7110 = fe->dvb->priv;
1568 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
1569 u32 div = (params->frequency + 479500) / 125;
1571 if (params->frequency > 2000000) pwr = 3;
1572 else if (params->frequency > 1800000) pwr = 2;
1573 else if (params->frequency > 1600000) pwr = 1;
1574 else if (params->frequency > 1200000) pwr = 0;
1575 else if (params->frequency >= 1100000) pwr = 1;
1578 buf[0] = (div >> 8) & 0x7f;
1579 buf[1] = div & 0xff;
1580 buf[2] = ((div & 0x18000) >> 10) | 0x95;
1581 buf[3] = (pwr << 6) | 0x30;
1583 // NOTE: since we're using a prescaler of 2, we set the
1584 // divisor frequency to 62.5kHz and divide by 125 above
1586 if (fe->ops.i2c_gate_ctrl)
1587 fe->ops.i2c_gate_ctrl(fe, 1);
1588 if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
1593 static struct ves1x93_config alps_bsrv2_config = {
1594 .demod_address = 0x08,
1599 static int alps_tdbe2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
1601 struct av7110* av7110 = fe->dvb->priv;
1604 struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
1606 div = (params->frequency + 35937500 + 31250) / 62500;
1608 data[0] = (div >> 8) & 0x7f;
1609 data[1] = div & 0xff;
1610 data[2] = 0x85 | ((div >> 10) & 0x60);
1611 data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81);
1613 if (fe->ops.i2c_gate_ctrl)
1614 fe->ops.i2c_gate_ctrl(fe, 1);
1615 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1620 static struct ves1820_config alps_tdbe2_config = {
1621 .demod_address = 0x09,
1624 .selagc = VES1820_SELAGC_SIGNAMPERR,
1630 static int grundig_29504_451_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
1632 struct av7110* av7110 = fe->dvb->priv;
1635 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1637 div = params->frequency / 125;
1638 data[0] = (div >> 8) & 0x7f;
1639 data[1] = div & 0xff;
1643 if (fe->ops.i2c_gate_ctrl)
1644 fe->ops.i2c_gate_ctrl(fe, 1);
1645 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1650 static struct tda8083_config grundig_29504_451_config = {
1651 .demod_address = 0x68,
1656 static int philips_cd1516_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
1658 struct av7110* av7110 = fe->dvb->priv;
1660 u32 f = params->frequency;
1662 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1664 div = (f + 36125000 + 31250) / 62500;
1666 data[0] = (div >> 8) & 0x7f;
1667 data[1] = div & 0xff;
1669 data[3] = (f < 174000000 ? 0xa1 : f < 470000000 ? 0x92 : 0x34);
1671 if (fe->ops.i2c_gate_ctrl)
1672 fe->ops.i2c_gate_ctrl(fe, 1);
1673 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1678 static struct ves1820_config philips_cd1516_config = {
1679 .demod_address = 0x09,
1682 .selagc = VES1820_SELAGC_SIGNAMPERR,
1687 static int alps_tdlb7_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
1689 struct av7110* av7110 = fe->dvb->priv;
1692 struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = sizeof(data) };
1694 div = (params->frequency + 36200000) / 166666;
1696 if (params->frequency <= 782000000)
1701 data[0] = (div >> 8) & 0x7f;
1702 data[1] = div & 0xff;
1706 if (fe->ops.i2c_gate_ctrl)
1707 fe->ops.i2c_gate_ctrl(fe, 1);
1708 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1713 static int alps_tdlb7_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
1715 #if defined(CONFIG_DVB_SP8870) || defined(CONFIG_DVB_SP8870_MODULE)
1716 struct av7110* av7110 = fe->dvb->priv;
1718 return request_firmware(fw, name, &av7110->dev->pci->dev);
1724 static struct sp8870_config alps_tdlb7_config = {
1726 .demod_address = 0x71,
1727 .request_firmware = alps_tdlb7_request_firmware,
1731 static u8 nexusca_stv0297_inittab[] = {
1824 static int nexusca_stv0297_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
1826 struct av7110* av7110 = fe->dvb->priv;
1829 struct i2c_msg msg = { .addr = 0x63, .flags = 0, .buf = data, .len = sizeof(data) };
1830 struct i2c_msg readmsg = { .addr = 0x63, .flags = I2C_M_RD, .buf = data, .len = 1 };
1833 div = (params->frequency + 36150000 + 31250) / 62500;
1835 data[0] = (div >> 8) & 0x7f;
1836 data[1] = div & 0xff;
1839 if (params->frequency < 45000000)
1841 else if (params->frequency < 137000000)
1843 else if (params->frequency < 403000000)
1845 else if (params->frequency < 860000000)
1850 if (fe->ops.i2c_gate_ctrl)
1851 fe->ops.i2c_gate_ctrl(fe, 1);
1852 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1) {
1853 printk("nexusca: pll transfer failed!\n");
1857 // wait for PLL lock
1858 for(i = 0; i < 20; i++) {
1859 if (fe->ops.i2c_gate_ctrl)
1860 fe->ops.i2c_gate_ctrl(fe, 1);
1861 if (i2c_transfer(&av7110->i2c_adap, &readmsg, 1) == 1)
1862 if (data[0] & 0x40) break;
1869 static struct stv0297_config nexusca_stv0297_config = {
1871 .demod_address = 0x1C,
1872 .inittab = nexusca_stv0297_inittab,
1874 .stop_during_read = 1,
1879 static int grundig_29504_401_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
1881 struct av7110* av7110 = fe->dvb->priv;
1883 u8 cfg, cpump, band_select;
1885 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1887 div = (36125000 + params->frequency) / 166666;
1891 if (params->frequency < 175000000) cpump = 2;
1892 else if (params->frequency < 390000000) cpump = 1;
1893 else if (params->frequency < 470000000) cpump = 2;
1894 else if (params->frequency < 750000000) cpump = 1;
1897 if (params->frequency < 175000000) band_select = 0x0e;
1898 else if (params->frequency < 470000000) band_select = 0x05;
1899 else band_select = 0x03;
1901 data[0] = (div >> 8) & 0x7f;
1902 data[1] = div & 0xff;
1903 data[2] = ((div >> 10) & 0x60) | cfg;
1904 data[3] = (cpump << 6) | band_select;
1906 if (fe->ops.i2c_gate_ctrl)
1907 fe->ops.i2c_gate_ctrl(fe, 1);
1908 if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) return -EIO;
1912 static struct l64781_config grundig_29504_401_config = {
1913 .demod_address = 0x55,
1918 static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
1921 int synced = (status & FE_HAS_LOCK) ? 1 : 0;
1923 av7110->fe_status = status;
1925 if (av7110->fe_synced == synced)
1928 if (av7110->playing) {
1929 av7110->fe_synced = synced;
1933 if (mutex_lock_interruptible(&av7110->pid_mutex))
1934 return -ERESTARTSYS;
1937 ret = SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO],
1938 av7110->pids[DMX_PES_AUDIO],
1939 av7110->pids[DMX_PES_TELETEXT], 0,
1940 av7110->pids[DMX_PES_PCR]);
1942 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
1944 ret = SetPIDs(av7110, 0, 0, 0, 0, 0);
1946 ret = av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0);
1948 ret = av7110_wait_msgstate(av7110, GPMQBusy);
1953 av7110->fe_synced = synced;
1955 mutex_unlock(&av7110->pid_mutex);
1959 static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1961 struct av7110* av7110 = fe->dvb->priv;
1963 int ret = av7110_fe_lock_fix(av7110, 0);
1965 av7110->saved_fe_params = *params;
1966 ret = av7110->fe_set_frontend(fe, params);
1971 static int av7110_fe_init(struct dvb_frontend* fe)
1973 struct av7110* av7110 = fe->dvb->priv;
1975 int ret = av7110_fe_lock_fix(av7110, 0);
1977 ret = av7110->fe_init(fe);
1981 static int av7110_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
1983 struct av7110* av7110 = fe->dvb->priv;
1985 /* call the real implementation */
1986 int ret = av7110->fe_read_status(fe, status);
1988 if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK))
1989 ret = av7110_fe_lock_fix(av7110, *status);
1993 static int av7110_fe_diseqc_reset_overload(struct dvb_frontend* fe)
1995 struct av7110* av7110 = fe->dvb->priv;
1997 int ret = av7110_fe_lock_fix(av7110, 0);
1999 ret = av7110->fe_diseqc_reset_overload(fe);
2003 static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
2004 struct dvb_diseqc_master_cmd* cmd)
2006 struct av7110* av7110 = fe->dvb->priv;
2008 int ret = av7110_fe_lock_fix(av7110, 0);
2010 av7110->saved_master_cmd = *cmd;
2011 ret = av7110->fe_diseqc_send_master_cmd(fe, cmd);
2016 static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
2018 struct av7110* av7110 = fe->dvb->priv;
2020 int ret = av7110_fe_lock_fix(av7110, 0);
2022 av7110->saved_minicmd = minicmd;
2023 ret = av7110->fe_diseqc_send_burst(fe, minicmd);
2028 static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
2030 struct av7110* av7110 = fe->dvb->priv;
2032 int ret = av7110_fe_lock_fix(av7110, 0);
2034 av7110->saved_tone = tone;
2035 ret = av7110->fe_set_tone(fe, tone);
2040 static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
2042 struct av7110* av7110 = fe->dvb->priv;
2044 int ret = av7110_fe_lock_fix(av7110, 0);
2046 av7110->saved_voltage = voltage;
2047 ret = av7110->fe_set_voltage(fe, voltage);
2052 static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned long cmd)
2054 struct av7110* av7110 = fe->dvb->priv;
2056 int ret = av7110_fe_lock_fix(av7110, 0);
2058 ret = av7110->fe_dishnetwork_send_legacy_command(fe, cmd);
2062 static void dvb_s_recover(struct av7110* av7110)
2064 av7110_fe_init(av7110->fe);
2066 av7110_fe_set_voltage(av7110->fe, av7110->saved_voltage);
2067 if (av7110->saved_master_cmd.msg_len) {
2069 av7110_fe_diseqc_send_master_cmd(av7110->fe, &av7110->saved_master_cmd);
2072 av7110_fe_diseqc_send_burst(av7110->fe, av7110->saved_minicmd);
2074 av7110_fe_set_tone(av7110->fe, av7110->saved_tone);
2076 av7110_fe_set_frontend(av7110->fe, &av7110->saved_fe_params);
2079 static u8 read_pwm(struct av7110* av7110)
2083 struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
2084 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
2086 if ((i2c_transfer(&av7110->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
2092 static int frontend_init(struct av7110 *av7110)
2096 if (av7110->dev->pci->subsystem_vendor == 0x110a) {
2097 switch(av7110->dev->pci->subsystem_device) {
2098 case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??))
2099 av7110->fe = dvb_attach(ves1820_attach, &philips_cd1516_config,
2100 &av7110->i2c_adap, read_pwm(av7110));
2102 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
2107 } else if (av7110->dev->pci->subsystem_vendor == 0x13c2) {
2108 switch(av7110->dev->pci->subsystem_device) {
2109 case 0x0000: // Hauppauge/TT WinTV DVB-S rev1.X
2110 case 0x0003: // Hauppauge/TT WinTV Nexus-S Rev 2.X
2111 case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE
2113 // try the ALPS BSRV2 first of all
2114 av7110->fe = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &av7110->i2c_adap);
2116 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
2117 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2118 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2119 av7110->fe->ops.set_tone = av7110_set_tone;
2120 av7110->recover = dvb_s_recover;
2124 // try the ALPS BSRU6 now
2125 av7110->fe = dvb_attach(stv0299_attach, &alps_bsru6_config, &av7110->i2c_adap);
2127 av7110->fe->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
2128 av7110->fe->tuner_priv = &av7110->i2c_adap;
2130 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2131 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2132 av7110->fe->ops.set_tone = av7110_set_tone;
2133 av7110->recover = dvb_s_recover;
2137 // Try the grundig 29504-451
2138 av7110->fe = dvb_attach(tda8083_attach, &grundig_29504_451_config, &av7110->i2c_adap);
2140 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
2141 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2142 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2143 av7110->fe->ops.set_tone = av7110_set_tone;
2144 av7110->recover = dvb_s_recover;
2148 /* Try DVB-C cards */
2149 switch(av7110->dev->pci->subsystem_device) {
2151 /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */
2152 av7110->fe = dvb_attach(ves1820_attach, &philips_cd1516_config, &av7110->i2c_adap,
2155 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
2159 /* Hauppauge DVB-C 2.1 VES1820/ALPS TDBE2 */
2160 av7110->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &av7110->i2c_adap,
2163 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
2169 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
2170 // try ALPS TDLB7 first, then Grundig 29504-401
2171 av7110->fe = dvb_attach(sp8870_attach, &alps_tdlb7_config, &av7110->i2c_adap);
2173 av7110->fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params;
2178 case 0x0008: // Hauppauge/TT DVB-T
2179 // Grundig 29504-401
2180 av7110->fe = dvb_attach(l64781_attach, &grundig_29504_401_config, &av7110->i2c_adap);
2182 av7110->fe->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
2185 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
2187 av7110->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
2189 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
2193 case 0x0004: // Galaxis DVB-S rev1.3
2195 av7110->fe = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &av7110->i2c_adap);
2197 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
2198 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2199 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2200 av7110->fe->ops.set_tone = av7110_set_tone;
2201 av7110->recover = dvb_s_recover;
2205 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */
2206 /* Grundig 29504-451 */
2207 av7110->fe = dvb_attach(tda8083_attach, &grundig_29504_451_config, &av7110->i2c_adap);
2209 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
2210 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2211 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2212 av7110->fe->ops.set_tone = av7110_set_tone;
2213 av7110->recover = dvb_s_recover;
2217 case 0x000A: // Hauppauge/TT Nexus-CA rev1.X
2219 av7110->fe = dvb_attach(stv0297_attach, &nexusca_stv0297_config, &av7110->i2c_adap);
2221 av7110->fe->ops.tuner_ops.set_params = nexusca_stv0297_tuner_set_params;
2223 /* set TDA9819 into DVB mode */
2224 saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD)
2225 saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF)
2227 /* tuner on this needs a slower i2c bus speed */
2228 av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
2233 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */
2235 av7110->fe = dvb_attach(stv0299_attach, &alps_bsbe1_config, &av7110->i2c_adap);
2237 av7110->fe->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
2238 av7110->fe->tuner_priv = &av7110->i2c_adap;
2240 if (dvb_attach(lnbp21_attach, av7110->fe, &av7110->i2c_adap, 0, 0) == NULL) {
2241 printk("dvb-ttpci: LNBP21 not found!\n");
2242 if (av7110->fe->ops.release)
2243 av7110->fe->ops.release(av7110->fe);
2246 av7110->fe->ops.dishnetwork_send_legacy_command = NULL;
2247 av7110->recover = dvb_s_recover;
2255 /* FIXME: propagate the failure code from the lower layers */
2257 printk("dvb-ttpci: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
2258 av7110->dev->pci->vendor,
2259 av7110->dev->pci->device,
2260 av7110->dev->pci->subsystem_vendor,
2261 av7110->dev->pci->subsystem_device);
2263 FE_FUNC_OVERRIDE(av7110->fe->ops.init, av7110->fe_init, av7110_fe_init);
2264 FE_FUNC_OVERRIDE(av7110->fe->ops.read_status, av7110->fe_read_status, av7110_fe_read_status);
2265 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_reset_overload, av7110->fe_diseqc_reset_overload, av7110_fe_diseqc_reset_overload);
2266 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_master_cmd, av7110->fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd);
2267 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_burst, av7110->fe_diseqc_send_burst, av7110_fe_diseqc_send_burst);
2268 FE_FUNC_OVERRIDE(av7110->fe->ops.set_tone, av7110->fe_set_tone, av7110_fe_set_tone);
2269 FE_FUNC_OVERRIDE(av7110->fe->ops.set_voltage, av7110->fe_set_voltage, av7110_fe_set_voltage);
2270 FE_FUNC_OVERRIDE(av7110->fe->ops.dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command);
2271 FE_FUNC_OVERRIDE(av7110->fe->ops.set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend);
2273 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe);
2275 printk("av7110: Frontend registration failed!\n");
2276 dvb_frontend_detach(av7110->fe);
2283 /* Budgetpatch note:
2284 * Original hardware design by Roberto Deza:
2285 * There is a DVB_Wiki at
2286 * http://212.227.36.83/linuxtv/wiki/index.php/Main_Page
2287 * where is described this 'DVB TT Budget Patch', on Card Modding:
2288 * http://212.227.36.83/linuxtv/wiki/index.php/DVB_TT_Budget_Patch
2289 * On the short description there is also a link to a external file,
2290 * with more details:
2291 * http://perso.wanadoo.es/jesussolano/Ttf_tsc1.zip
2293 * New software triggering design by Emard that works on
2294 * original Roberto Deza's hardware:
2296 * rps1 code for budgetpatch will copy internal HS event to GPIO3 pin.
2297 * GPIO3 is in budget-patch hardware connectd to port B VSYNC
2298 * HS is an internal event of 7146, accessible with RPS
2299 * and temporarily raised high every n lines
2300 * (n in defined in the RPS_THRESH1 counter threshold)
2301 * I think HS is raised high on the beginning of the n-th line
2302 * and remains high until this n-th line that triggered
2303 * it is completely received. When the receiption of n-th line
2304 * ends, HS is lowered.
2306 * To transmit data over DMA, 7146 needs changing state at
2307 * port B VSYNC pin. Any changing of port B VSYNC will
2308 * cause some DMA data transfer, with more or less packets loss.
2309 * It depends on the phase and frequency of VSYNC and
2310 * the way of 7146 is instructed to trigger on port B (defined
2311 * in DD1_INIT register, 3rd nibble from the right valid
2312 * numbers are 0-7, see datasheet)
2314 * The correct triggering can minimize packet loss,
2315 * dvbtraffic should give this stable bandwidths:
2316 * 22k transponder = 33814 kbit/s
2317 * 27.5k transponder = 38045 kbit/s
2318 * by experiment it is found that the best results
2319 * (stable bandwidths and almost no packet loss)
2320 * are obtained using DD1_INIT triggering number 2
2321 * (Va at rising edge of VS Fa = HS x VS-failing forced toggle)
2322 * and a VSYNC phase that occurs in the middle of DMA transfer
2323 * (about byte 188*512=96256 in the DMA window).
2325 * Phase of HS is still not clear to me how to control,
2326 * It just happens to be so. It can be seen if one enables
2327 * RPS_IRQ and print Event Counter 1 in vpeirq(). Every
2328 * time RPS_INTERRUPT is called, the Event Counter 1 will
2329 * increment. That's how the 7146 is programmed to do event
2330 * counting in this budget-patch.c
2331 * I *think* HPS setting has something to do with the phase
2332 * of HS but I cant be 100% sure in that.
2334 * hardware debug note: a working budget card (including budget patch)
2335 * with vpeirq() interrupt setup in mode "0x90" (every 64K) will
2336 * generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
2337 * and that means 3*25=75 Hz of interrupt freqency, as seen by
2338 * watch cat /proc/interrupts
2340 * If this frequency is 3x lower (and data received in the DMA
2341 * buffer don't start with 0x47, but in the middle of packets,
2342 * whose lengths appear to be like 188 292 188 104 etc.
2343 * this means VSYNC line is not connected in the hardware.
2344 * (check soldering pcb and pins)
2345 * The same behaviour of missing VSYNC can be duplicated on budget
2346 * cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
2348 static int __devinit av7110_attach(struct saa7146_dev* dev,
2349 struct saa7146_pci_extension_data *pci_ext)
2351 const int length = TS_WIDTH * TS_HEIGHT;
2352 struct pci_dev *pdev = dev->pci;
2353 struct av7110 *av7110;
2354 struct task_struct *thread;
2357 dprintk(4, "dev: %p\n", dev);
2359 /* Set RPS_IRQ to 1 to track rps1 activity.
2360 * Enabling this won't send any interrupt to PC CPU.
2364 if (budgetpatch == 1) {
2366 /* autodetect the presence of budget patch
2367 * this only works if saa7146 has been recently
2368 * reset with with MASK_31 to MC1
2370 * will wait for VBI_B event (vertical blank at port B)
2371 * and will reset GPIO3 after VBI_B is detected.
2372 * (GPIO3 should be raised high by CPU to
2373 * test if GPIO3 will generate vertical blank signal
2374 * in budget patch GPIO3 is connected to VSYNC_B
2378 saa7146_write(dev, MC1, MASK_31);
2379 /* autodetection success seems to be time-dependend after reset */
2381 /* Fix VSYNC level */
2382 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
2383 /* set vsync_b triggering */
2384 saa7146_write(dev, DD1_STREAM_B, 0);
2385 /* port B VSYNC at rising edge */
2386 saa7146_write(dev, DD1_INIT, 0x00000200);
2387 saa7146_write(dev, BRS_CTRL, 0x00000000); // VBI
2388 saa7146_write(dev, MC2,
2389 1 * (MASK_08 | MASK_24) | // BRS control
2390 0 * (MASK_09 | MASK_25) | // a
2391 1 * (MASK_10 | MASK_26) | // b
2392 0 * (MASK_06 | MASK_22) | // HPS_CTRL1
2393 0 * (MASK_05 | MASK_21) | // HPS_CTRL2
2394 0 * (MASK_01 | MASK_15) // DEBI
2397 /* start writing RPS1 code from beginning */
2400 saa7146_write(dev, MC1, MASK_29);
2401 /* RPS1 timeout disable */
2402 saa7146_write(dev, RPS_TOV1, 0);
2403 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_VBI_B));
2404 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
2405 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
2406 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
2408 /* issue RPS1 interrupt to increment counter */
2409 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
2411 WRITE_RPS1(cpu_to_le32(CMD_STOP));
2412 /* Jump to begin of RPS program as safety measure (p37) */
2413 WRITE_RPS1(cpu_to_le32(CMD_JUMP));
2414 WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
2417 /* set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
2418 * use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
2419 * use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
2421 saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
2422 /* set event counter 1 treshold to maximum allowed value (rEC p55) */
2423 saa7146_write(dev, ECT1R, 0x3fff );
2425 /* Set RPS1 Address register to point to RPS code (r108 p42) */
2426 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
2427 /* Enable RPS1, (rFC p33) */
2428 saa7146_write(dev, MC1, (MASK_13 | MASK_29 ));
2431 /* now send VSYNC_B to rps1 by rising GPIO3 */
2432 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
2434 /* if rps1 responded by lowering the GPIO3,
2435 * then we have budgetpatch hardware
2437 if ((saa7146_read(dev, GPIO_CTRL) & 0x10000000) == 0) {
2439 printk("dvb-ttpci: BUDGET-PATCH DETECTED.\n");
2442 saa7146_write(dev, MC1, ( MASK_29 ));
2444 printk("dvb-ttpci: Event Counter 1 0x%04x\n", saa7146_read(dev, EC1R) & 0x3fff );
2448 /* prepare the av7110 device struct */
2449 av7110 = kzalloc(sizeof(struct av7110), GFP_KERNEL);
2451 dprintk(1, "out of memory\n");
2455 av7110->card_name = (char*) pci_ext->ext_priv;
2457 dev->ext_priv = av7110;
2459 ret = get_firmware(av7110);
2463 ret = dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name,
2464 THIS_MODULE, &dev->pci->dev);
2466 goto err_put_firmware_1;
2468 /* the Siemens DVB needs this if you want to have the i2c chips
2469 get recognized before the main driver is fully loaded */
2470 saa7146_write(dev, GPIO_CTRL, 0x500000);
2472 #ifdef I2C_ADAP_CLASS_TV_DIGITAL
2473 av7110->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
2475 av7110->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
2477 strlcpy(av7110->i2c_adap.name, pci_ext->ext_priv, sizeof(av7110->i2c_adap.name));
2479 saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */
2481 ret = i2c_add_adapter(&av7110->i2c_adap);
2483 goto err_dvb_unregister_adapter_2;
2485 ttpci_eeprom_parse_mac(&av7110->i2c_adap,
2486 av7110->dvb_adapter.proposed_mac);
2490 spin_lock_init(&av7110->feedlock1);
2491 av7110->grabbing = saa7146_vmalloc_build_pgtable(pdev, length,
2493 if (!av7110->grabbing)
2496 saa7146_write(dev, PCI_BT_V1, 0x1c1f101f);
2497 saa7146_write(dev, BCS_CTRL, 0x80400040);
2498 /* set dd1 stream a & b */
2499 saa7146_write(dev, DD1_STREAM_B, 0x00000000);
2500 saa7146_write(dev, DD1_INIT, 0x03000200);
2501 saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
2502 saa7146_write(dev, BRS_CTRL, 0x60000000);
2503 saa7146_write(dev, BASE_ODD3, 0);
2504 saa7146_write(dev, BASE_EVEN3, 0);
2505 saa7146_write(dev, PROT_ADDR3, TS_WIDTH * TS_HEIGHT);
2506 saa7146_write(dev, BASE_PAGE3, av7110->pt.dma | ME1 | 0x90);
2508 saa7146_write(dev, PITCH3, TS_WIDTH);
2509 saa7146_write(dev, NUM_LINE_BYTE3, (TS_HEIGHT << 16) | TS_WIDTH);
2512 saa7146_write(dev, MC2, 0x077c077c);
2513 saa7146_write(dev, GPIO_CTRL, 0x000000);
2515 /* set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
2516 * use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
2517 * use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
2519 saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
2520 /* set event counter 1 treshold to maximum allowed value (rEC p55) */
2521 saa7146_write(dev, ECT1R, 0x3fff );
2523 /* Setup BUDGETPATCH MAIN RPS1 "program" (p35) */
2526 /* Wait Source Line Counter Threshold (p36) */
2527 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_HS));
2528 /* Set GPIO3=1 (p42) */
2529 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
2530 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
2531 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTHI<<24));
2533 /* issue RPS1 interrupt */
2534 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
2536 /* Wait reset Source Line Counter Threshold (p36) */
2537 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS));
2538 /* Set GPIO3=0 (p42) */
2539 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
2540 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
2541 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
2543 /* issue RPS1 interrupt */
2544 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
2546 /* Jump to begin of RPS program (p37) */
2547 WRITE_RPS1(cpu_to_le32(CMD_JUMP));
2548 WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
2550 /* Fix VSYNC level */
2551 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
2552 /* Set RPS1 Address register to point to RPS code (r108 p42) */
2553 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
2554 /* Set Source Line Counter Threshold, using BRS (rCC p43)
2555 * It generates HS event every TS_HEIGHT lines
2556 * this is related to TS_WIDTH set in register
2557 * NUM_LINE_BYTE3. If NUM_LINE_BYTE low 16 bits
2558 * are set to TS_WIDTH bytes (TS_WIDTH=2*188),
2559 * then RPS_THRESH1 should be set to trigger
2560 * every TS_HEIGHT (512) lines.
2562 saa7146_write(dev, RPS_THRESH1, (TS_HEIGHT*1) | MASK_12 );
2564 /* Enable RPS1 (rFC p33) */
2565 saa7146_write(dev, MC1, (MASK_13 | MASK_29));
2567 /* end of budgetpatch register initialization */
2568 tasklet_init (&av7110->vpe_tasklet, vpeirq, (unsigned long) av7110);
2570 saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
2571 saa7146_write(dev, BCS_CTRL, 0x80400040);
2573 /* set dd1 stream a & b */
2574 saa7146_write(dev, DD1_STREAM_B, 0x00000000);
2575 saa7146_write(dev, DD1_INIT, 0x03000000);
2576 saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
2579 saa7146_write(dev, MC2, 0x077c077c);
2580 saa7146_write(dev, GPIO_CTRL, 0x000000);
2583 tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110);
2584 tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110);
2586 mutex_init(&av7110->pid_mutex);
2588 /* locks for data transfers from/to AV7110 */
2589 spin_lock_init(&av7110->debilock);
2590 mutex_init(&av7110->dcomlock);
2591 av7110->debitype = -1;
2593 /* default OSD window */
2595 mutex_init(&av7110->osd_mutex);
2598 av7110->vidmode = tv_standard == 1 ? AV7110_VIDEO_MODE_NTSC
2599 : AV7110_VIDEO_MODE_PAL;
2601 /* ARM "watchdog" */
2602 init_waitqueue_head(&av7110->arm_wait);
2603 av7110->arm_thread = NULL;
2605 /* allocate and init buffers */
2606 av7110->debi_virt = pci_alloc_consistent(pdev, 8192, &av7110->debi_bus);
2607 if (!av7110->debi_virt)
2608 goto err_saa71466_vfree_4;
2611 av7110->iobuf = vmalloc(AVOUTLEN+AOUTLEN+BMPLEN+4*IPACKS);
2613 goto err_pci_free_5;
2615 ret = av7110_av_init(av7110);
2617 goto err_iobuf_vfree_6;
2619 /* init BMP buffer */
2620 av7110->bmpbuf = av7110->iobuf+AVOUTLEN+AOUTLEN;
2621 init_waitqueue_head(&av7110->bmpq);
2623 ret = av7110_ca_init(av7110);
2625 goto err_av7110_av_exit_7;
2627 /* load firmware into AV7110 cards */
2628 ret = av7110_bootarm(av7110);
2630 goto err_av7110_ca_exit_8;
2632 ret = av7110_firmversion(av7110);
2634 goto err_stop_arm_9;
2636 if (FW_VERSION(av7110->arm_app)<0x2501)
2637 printk ("dvb-ttpci: Warning, firmware version 0x%04x is too old. "
2638 "System might be unstable!\n", FW_VERSION(av7110->arm_app));
2640 thread = kthread_run(arm_thread, (void *) av7110, "arm_mon");
2641 if (IS_ERR(thread)) {
2642 ret = PTR_ERR(thread);
2643 goto err_stop_arm_9;
2645 av7110->arm_thread = thread;
2647 /* set initial volume in mixer struct */
2648 av7110->mixer.volume_left = volume;
2649 av7110->mixer.volume_right = volume;
2651 ret = av7110_register(av7110);
2653 goto err_arm_thread_stop_10;
2655 init_av7110_av(av7110);
2657 /* special case DVB-C: these cards have an analog tuner
2658 plus need some special handling, so we have separate
2659 saa7146_ext_vv data for these... */
2660 ret = av7110_init_v4l(av7110);
2662 goto err_av7110_unregister_11;
2664 av7110->dvb_adapter.priv = av7110;
2665 ret = frontend_init(av7110);
2667 goto err_av7110_exit_v4l_12;
2669 #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
2670 av7110_ir_init(av7110);
2672 printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num);
2677 err_av7110_exit_v4l_12:
2678 av7110_exit_v4l(av7110);
2679 err_av7110_unregister_11:
2680 dvb_unregister(av7110);
2681 err_arm_thread_stop_10:
2682 av7110_arm_sync(av7110);
2684 /* Nothing to do. Rejoice. */
2685 err_av7110_ca_exit_8:
2686 av7110_ca_exit(av7110);
2687 err_av7110_av_exit_7:
2688 av7110_av_exit(av7110);
2690 vfree(av7110->iobuf);
2692 pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus);
2693 err_saa71466_vfree_4:
2694 if (av7110->grabbing)
2695 saa7146_vfree_destroy_pgtable(pdev, av7110->grabbing, &av7110->pt);
2697 i2c_del_adapter(&av7110->i2c_adap);
2698 err_dvb_unregister_adapter_2:
2699 dvb_unregister_adapter(&av7110->dvb_adapter);
2701 put_firmware(av7110);
2707 static int __devexit av7110_detach(struct saa7146_dev* saa)
2709 struct av7110 *av7110 = saa->ext_priv;
2710 dprintk(4, "%p\n", av7110);
2712 #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
2713 av7110_ir_exit(av7110);
2717 saa7146_write(saa, MC1, MASK_29);
2718 /* VSYNC LOW (inactive) */
2719 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
2720 saa7146_write(saa, MC1, MASK_20); /* DMA3 off */
2721 SAA7146_IER_DISABLE(saa, MASK_10);
2722 SAA7146_ISR_CLEAR(saa, MASK_10);
2724 tasklet_kill(&av7110->vpe_tasklet);
2725 saa7146_vfree_destroy_pgtable(saa->pci, av7110->grabbing, &av7110->pt);
2727 av7110_exit_v4l(av7110);
2729 av7110_arm_sync(av7110);
2731 tasklet_kill(&av7110->debi_tasklet);
2732 tasklet_kill(&av7110->gpio_tasklet);
2734 dvb_unregister(av7110);
2736 SAA7146_IER_DISABLE(saa, MASK_19 | MASK_03);
2737 SAA7146_ISR_CLEAR(saa, MASK_19 | MASK_03);
2739 av7110_ca_exit(av7110);
2740 av7110_av_exit(av7110);
2742 vfree(av7110->iobuf);
2743 pci_free_consistent(saa->pci, 8192, av7110->debi_virt,
2746 i2c_del_adapter(&av7110->i2c_adap);
2748 dvb_unregister_adapter (&av7110->dvb_adapter);
2752 put_firmware(av7110);
2756 saa->ext_priv = NULL;
2762 static void av7110_irq(struct saa7146_dev* dev, u32 *isr)
2764 struct av7110 *av7110 = dev->ext_priv;
2766 //print_time("av7110_irq");
2768 /* Note: Don't try to handle the DEBI error irq (MASK_18), in
2769 * intel mode the timeout is asserted all the time...
2772 if (*isr & MASK_19) {
2773 //printk("av7110_irq: DEBI\n");
2774 /* Note 1: The DEBI irq is level triggered: We must enable it
2775 * only after we started a DMA xfer, and disable it here
2776 * immediately, or it will be signalled all the time while
2778 * Note 2: You would think that an irq which is masked is
2779 * not signalled by the hardware. Not so for the SAA7146:
2780 * An irq is signalled as long as the corresponding bit
2781 * in the ISR is set, and disabling irqs just prevents the
2782 * hardware from setting the ISR bit. This means a) that we
2783 * must clear the ISR *after* disabling the irq (which is why
2784 * we must do it here even though saa7146_core did it already),
2785 * and b) that if we were to disable an edge triggered irq
2786 * (like the gpio irqs sadly are) temporarily we would likely
2787 * loose some. This sucks :-(
2789 SAA7146_IER_DISABLE(av7110->dev, MASK_19);
2790 SAA7146_ISR_CLEAR(av7110->dev, MASK_19);
2791 tasklet_schedule(&av7110->debi_tasklet);
2794 if (*isr & MASK_03) {
2795 //printk("av7110_irq: GPIO\n");
2796 tasklet_schedule(&av7110->gpio_tasklet);
2799 if ((*isr & MASK_10) && budgetpatch)
2800 tasklet_schedule(&av7110->vpe_tasklet);
2804 static struct saa7146_extension av7110_extension_driver;
2806 #define MAKE_AV7110_INFO(x_var,x_name) \
2807 static struct saa7146_pci_extension_data x_var = { \
2808 .ext_priv = x_name, \
2809 .ext = &av7110_extension_driver }
2811 MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C");
2812 MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X");
2813 MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X");
2814 MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X");
2815 MAKE_AV7110_INFO(tts_2_X, "Technotrend/Hauppauge WinTV Nexus-S rev2.X");
2816 MAKE_AV7110_INFO(tts_2_3, "Technotrend/Hauppauge WinTV Nexus-S rev2.3");
2817 MAKE_AV7110_INFO(tts_1_3se, "Technotrend/Hauppauge WinTV DVB-S rev1.3 SE");
2818 MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T");
2819 MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C");
2820 MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6");
2821 MAKE_AV7110_INFO(gxs_1_3, "Galaxis DVB-S rev1.3");
2823 static struct pci_device_id pci_tbl[] = {
2824 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
2825 MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000),
2826 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001),
2827 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002),
2828 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003),
2829 MAKE_EXTENSION_PCI(gxs_1_3, 0x13c2, 0x0004),
2830 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006),
2831 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008),
2832 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
2833 MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e),
2834 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
2836 /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1
2837 /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0009), UNDEFINED CARD */ // TT/Hauppauge WinTV Nexus-CA v????
2844 MODULE_DEVICE_TABLE(pci, pci_tbl);
2847 static struct saa7146_extension av7110_extension_driver = {
2849 .flags = SAA7146_USE_I2C_IRQ,
2851 .module = THIS_MODULE,
2852 .pci_tbl = &pci_tbl[0],
2853 .attach = av7110_attach,
2854 .detach = __devexit_p(av7110_detach),
2856 .irq_mask = MASK_19 | MASK_03 | MASK_10,
2857 .irq_func = av7110_irq,
2861 static int __init av7110_init(void)
2864 retval = saa7146_register_extension(&av7110_extension_driver);
2869 static void __exit av7110_exit(void)
2871 saa7146_unregister_extension(&av7110_extension_driver);
2874 module_init(av7110_init);
2875 module_exit(av7110_exit);
2877 MODULE_DESCRIPTION("driver for the SAA7146 based AV110 PCI DVB cards by "
2878 "Siemens, Technotrend, Hauppauge");
2879 MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others");
2880 MODULE_LICENSE("GPL");