diff options
author | Johannes Stezenbach <devnull@localhost> | 2004-01-05 16:58:19 +0000 |
---|---|---|
committer | Johannes Stezenbach <devnull@localhost> | 2004-01-05 16:58:19 +0000 |
commit | 55306535d34ac2209d4dd76428d2ee388cfe449b (patch) | |
tree | 0bff1e2edbe6b75b37c4316089174ea2184459b5 /linux/drivers | |
parent | 3612bc6917d94cb4178e4301fa2ac6d27289c704 (diff) | |
download | mediapointer-dvb-s2-55306535d34ac2209d4dd76428d2ee388cfe449b.tar.gz mediapointer-dvb-s2-55306535d34ac2209d4dd76428d2ee388cfe449b.tar.bz2 |
- removed some unused fields from struct av7110
- retab
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/dvb/ttpci/av7110.c | 1298 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/av7110.h | 182 |
2 files changed, 737 insertions, 743 deletions
diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c index ac9f283f1..295b25b06 100644 --- a/linux/drivers/media/dvb/ttpci/av7110.c +++ b/linux/drivers/media/dvb/ttpci/av7110.c @@ -1,5 +1,6 @@ /* - * av7110.c: driver for the SAA7146 based AV110 cards (like the Fujitsu-Siemens DVB) + * driver for the SAA7146 based AV110 cards (like the Fujitsu-Siemens DVB) + * av7110.c: initialization and demux stuff * * Copyright (C) 1999-2002 Ralph Metzler * & Marcus Metzler for convergence integrated media GmbH @@ -86,31 +87,31 @@ static void recover_arm(struct av7110 *av7110) { DEB_EE(("av7110: %p\n",av7110)); - if (current->files) - bootarm(av7110); - else { - printk("OOPS, no current->files\n"); - reset_arm(av7110); - } + if (current->files) + bootarm(av7110); + else { + printk("OOPS, no current->files\n"); + reset_arm(av7110); + } - dvb_delay(100); - restart_feeds(av7110); - outcom(av7110, COMTYPE_PIDFILTER, SetIR, 1, av7110->ir_config); + dvb_delay(100); + restart_feeds(av7110); + outcom(av7110, COMTYPE_PIDFILTER, SetIR, 1, av7110->ir_config); } static void arm_error(struct av7110 *av7110) { DEB_EE(("av7110: %p\n",av7110)); - av7110->arm_errors++; - av7110->arm_ready=0; - recover_arm(av7110); + av7110->arm_errors++; + av7110->arm_ready=0; + recover_arm(av7110); } static int arm_thread(void *data) { struct av7110 *av7110 = data; - u16 newloops = 0; + u16 newloops = 0; DEB_EE(("av7110: %p\n",av7110)); @@ -118,30 +119,30 @@ static int arm_thread(void *data) av7110->arm_thread = current; while (!av7110->arm_rmmod && !signal_pending(current)) { - interruptible_sleep_on_timeout(&av7110->arm_wait, 5*HZ); + interruptible_sleep_on_timeout(&av7110->arm_wait, 5*HZ); - if (!av7110->arm_ready) - continue; + if (!av7110->arm_ready) + continue; - if (down_interruptible(&av7110->dcomlock)) - break; + if (down_interruptible(&av7110->dcomlock)) + break; - newloops=rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2); - up(&av7110->dcomlock); + newloops=rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2); + up(&av7110->dcomlock); - if (newloops==av7110->arm_loops) { - printk(KERN_ERR "av7110%d: ARM crashed!\n", + if (newloops==av7110->arm_loops) { + printk(KERN_ERR "av7110%d: ARM crashed!\n", av7110->dvb_adapter->num); arm_error(av7110); - if (down_interruptible(&av7110->dcomlock)) - break; + if (down_interruptible(&av7110->dcomlock)) + break; - newloops=rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2)-1; - up(&av7110->dcomlock); - } - av7110->arm_loops=newloops; + newloops=rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2)-1; + up(&av7110->dcomlock); + } + av7110->arm_loops=newloops; } av7110->arm_thread = NULL; @@ -176,20 +177,20 @@ static void (*irc_handler)(u32); void av7110_register_irc_handler(void (*func)(u32)) { - //DEB_EE(("registering %08x\n",func)); - irc_handler = func; + //DEB_EE(("registering %08x\n",func)); + irc_handler = func; } void av7110_unregister_irc_handler(void (*func)(u32)) { - //DEB_EE(("unregistering %08x\n",func)); - irc_handler = NULL; + //DEB_EE(("unregistering %08x\n",func)); + irc_handler = NULL; } void run_handlers(unsigned long ircom) { - if (irc_handler != NULL) - (*irc_handler)((u32) ircom); + if (irc_handler != NULL) + (*irc_handler)((u32) ircom); } DECLARE_TASKLET(irtask,run_handlers,0); @@ -197,8 +198,8 @@ DECLARE_TASKLET(irtask,run_handlers,0); void IR_handle(struct av7110 *av7110, u32 ircom) { DEB_S(("av7110: ircommand = %08x\n", ircom)); - irtask.data = (unsigned long) ircom; - tasklet_schedule(&irtask); + irtask.data = (unsigned long) ircom; + tasklet_schedule(&irtask); } /**************************************************************************** @@ -206,53 +207,53 @@ void IR_handle(struct av7110 *av7110, u32 ircom) ****************************************************************************/ static inline int DvbDmxFilterCallback(u8 * buffer1, size_t buffer1_len, - u8 * buffer2, size_t buffer2_len, - struct dvb_demux_filter *dvbdmxfilter, - enum dmx_success success, - struct av7110 *av7110) + u8 * buffer2, size_t buffer2_len, + struct dvb_demux_filter *dvbdmxfilter, + enum dmx_success success, + struct av7110 *av7110) { DEB_INT(("av7110: %p\n",av7110)); - if (!dvbdmxfilter->feed->demux->dmx.frontend) - return 0; - if (dvbdmxfilter->feed->demux->dmx.frontend->source==DMX_MEMORY_FE) - return 0; - - switch(dvbdmxfilter->type) { - case DMX_TYPE_SEC: - if ((((buffer1[1]<<8)|buffer1[2])&0xfff)+3!=buffer1_len) - return 0; - if (dvbdmxfilter->doneq) { - struct dmx_section_filter *filter=&dvbdmxfilter->filter; - int i; - u8 xor, neq=0; - - for (i=0; i<DVB_DEMUX_MASK_MAX; i++) { - xor=filter->filter_value[i]^buffer1[i]; - neq|=dvbdmxfilter->maskandnotmode[i]&xor; - } - if (!neq) - return 0; - } - return dvbdmxfilter->feed->cb.sec(buffer1, buffer1_len, + if (!dvbdmxfilter->feed->demux->dmx.frontend) + return 0; + if (dvbdmxfilter->feed->demux->dmx.frontend->source==DMX_MEMORY_FE) + return 0; + + switch(dvbdmxfilter->type) { + case DMX_TYPE_SEC: + if ((((buffer1[1]<<8)|buffer1[2])&0xfff)+3!=buffer1_len) + return 0; + if (dvbdmxfilter->doneq) { + struct dmx_section_filter *filter=&dvbdmxfilter->filter; + int i; + u8 xor, neq=0; + + for (i=0; i<DVB_DEMUX_MASK_MAX; i++) { + xor=filter->filter_value[i]^buffer1[i]; + neq|=dvbdmxfilter->maskandnotmode[i]&xor; + } + if (!neq) + return 0; + } + return dvbdmxfilter->feed->cb.sec(buffer1, buffer1_len, buffer2, buffer2_len, &dvbdmxfilter->filter, DMX_OK); - case DMX_TYPE_TS: - if (!(dvbdmxfilter->feed->ts_type & TS_PACKET)) - return 0; - if (dvbdmxfilter->feed->ts_type & TS_PAYLOAD_ONLY) - return dvbdmxfilter->feed->cb.ts(buffer1, buffer1_len, - buffer2, buffer2_len, - &dvbdmxfilter->feed->feed.ts, - DMX_OK); - else - pes_to_ts(buffer1, buffer1_len, - dvbdmxfilter->feed->pid, - &av7110->p2t_filter[dvbdmxfilter->index]); + case DMX_TYPE_TS: + if (!(dvbdmxfilter->feed->ts_type & TS_PACKET)) + return 0; + if (dvbdmxfilter->feed->ts_type & TS_PAYLOAD_ONLY) + return dvbdmxfilter->feed->cb.ts(buffer1, buffer1_len, + buffer2, buffer2_len, + &dvbdmxfilter->feed->feed.ts, + DMX_OK); + else + pes_to_ts(buffer1, buffer1_len, + dvbdmxfilter->feed->pid, + &av7110->p2t_filter[dvbdmxfilter->index]); default: - return 0; - } + return 0; + } } @@ -260,192 +261,191 @@ static inline int DvbDmxFilterCallback(u8 * buffer1, size_t buffer1_len, static inline void print_time(char *s) { #ifdef DEBUG_TIMING - struct timeval tv; - do_gettimeofday(&tv); - printk("%s: %d.%d\n", s, (int)tv.tv_sec, (int)tv.tv_usec); + struct timeval tv; + do_gettimeofday(&tv); + printk("%s: %d.%d\n", s, (int)tv.tv_sec, (int)tv.tv_usec); #endif } static void debiirq (unsigned long data) { struct av7110 *av7110 = (struct av7110*) data; - int type=av7110->debitype; - int handle=(type>>8)&0x1f; + int type=av7110->debitype; + int handle=(type>>8)&0x1f; // DEB_EE(("av7110: %p\n",av7110)); - print_time("debi"); - saa7146_write(av7110->dev, IER, - saa7146_read(av7110->dev, IER) & ~MASK_19 ); - saa7146_write(av7110->dev, ISR, MASK_19 ); + print_time("debi"); + saa7146_write(av7110->dev, IER, + saa7146_read(av7110->dev, IER) & ~MASK_19 ); + saa7146_write(av7110->dev, ISR, MASK_19 ); - if (type==-1) { - printk("DEBI irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n", + if (type==-1) { + printk("DEBI irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n", jiffies, saa7146_read(av7110->dev,PSR), saa7146_read(av7110->dev,SSR)); spin_lock(&av7110->debilock); - ARM_ClearMailBox(av7110); - ARM_ClearIrq(av7110); + ARM_ClearMailBox(av7110); + ARM_ClearIrq(av7110); spin_unlock(&av7110->debilock); - return; - } - av7110->debitype=-1; - - switch (type&0xff) { - - case DATA_TS_RECORD: - dvb_dmx_swfilter_packets(&av7110->demux, - (const u8 *)av7110->debi_virt, - av7110->debilen/188); - spin_lock(&av7110->debilock); - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - ARM_ClearMailBox(av7110); - spin_unlock(&av7110->debilock); - return; - - case DATA_PES_RECORD: - if (av7110->demux.recording) - record_cb(&av7110->p2t[handle], - (u8 *)av7110->debi_virt, - av7110->debilen); - spin_lock(&av7110->debilock); - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - ARM_ClearMailBox(av7110); - spin_unlock(&av7110->debilock); - return; - - case DATA_IPMPE: - case DATA_FSECTION: - case DATA_PIPING: - if (av7110->handle2filter[handle]) - DvbDmxFilterCallback((u8 *)av7110->debi_virt, - av7110->debilen, 0, 0, - av7110->handle2filter[handle], - DMX_OK, av7110); - spin_lock(&av7110->debilock); - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - ARM_ClearMailBox(av7110); - spin_unlock(&av7110->debilock); - return; - - case DATA_CI_GET: - { - u8 *data=av7110->debi_virt; - - if ((data[0]<2) && data[2]==0xff) { - int flags=0; - if (data[5]>0) - flags|=CA_CI_MODULE_PRESENT; - if (data[5]>5) - flags|=CA_CI_MODULE_READY; - av7110->ci_slot[data[0]].flags=flags; - } else - ci_get_data(&av7110->ci_rbuffer, - av7110->debi_virt, - av7110->debilen); - spin_lock(&av7110->debilock); - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - ARM_ClearMailBox(av7110); - spin_unlock(&av7110->debilock); - return; - } - - case DATA_COMMON_INTERFACE: - CI_handle(av7110, (u8 *)av7110->debi_virt, av7110->debilen); + return; + } + av7110->debitype=-1; + + switch (type&0xff) { + + case DATA_TS_RECORD: + dvb_dmx_swfilter_packets(&av7110->demux, + (const u8 *)av7110->debi_virt, + av7110->debilen/188); + spin_lock(&av7110->debilock); + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + ARM_ClearMailBox(av7110); + spin_unlock(&av7110->debilock); + return; + + case DATA_PES_RECORD: + if (av7110->demux.recording) + record_cb(&av7110->p2t[handle], + (u8 *)av7110->debi_virt, + av7110->debilen); + spin_lock(&av7110->debilock); + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + ARM_ClearMailBox(av7110); + spin_unlock(&av7110->debilock); + return; + + case DATA_IPMPE: + case DATA_FSECTION: + case DATA_PIPING: + if (av7110->handle2filter[handle]) + DvbDmxFilterCallback((u8 *)av7110->debi_virt, + av7110->debilen, 0, 0, + av7110->handle2filter[handle], + DMX_OK, av7110); + spin_lock(&av7110->debilock); + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + ARM_ClearMailBox(av7110); + spin_unlock(&av7110->debilock); + return; + + case DATA_CI_GET: + { + u8 *data=av7110->debi_virt; + + if ((data[0]<2) && data[2]==0xff) { + int flags=0; + if (data[5]>0) + flags|=CA_CI_MODULE_PRESENT; + if (data[5]>5) + flags|=CA_CI_MODULE_READY; + av7110->ci_slot[data[0]].flags=flags; + } else + ci_get_data(&av7110->ci_rbuffer, + av7110->debi_virt, + av7110->debilen); + spin_lock(&av7110->debilock); + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + ARM_ClearMailBox(av7110); + spin_unlock(&av7110->debilock); + return; + } + + case DATA_COMMON_INTERFACE: + CI_handle(av7110, (u8 *)av7110->debi_virt, av7110->debilen); #if 0 - { - int i; - - printk("av7110%d: ", av7110->num); - printk("%02x ", *(u8 *)av7110->debi_virt); - printk("%02x ", *(1+(u8 *)av7110->debi_virt)); - for (i=2; i<av7110->debilen; i++) - printk("%02x ", (*(i+(unsigned char *)av7110->debi_virt))); - for (i=2; i<av7110->debilen; i++) - printk("%c", chtrans(*(i+(unsigned char *)av7110->debi_virt))); - - printk("\n"); - } + { + int i; + + printk("av7110%d: ", av7110->num); + printk("%02x ", *(u8 *)av7110->debi_virt); + printk("%02x ", *(1+(u8 *)av7110->debi_virt)); + for (i=2; i<av7110->debilen; i++) + printk("%02x ", (*(i+(unsigned char *)av7110->debi_virt))); + for (i=2; i<av7110->debilen; i++) + printk("%c", chtrans(*(i+(unsigned char *)av7110->debi_virt))); + + printk("\n"); + } #endif - spin_lock(&av7110->debilock); - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - ARM_ClearMailBox(av7110); - spin_unlock(&av7110->debilock); - return; - - case DATA_DEBUG_MESSAGE: - ((s8*)av7110->debi_virt)[Reserved_SIZE-1]=0; - printk("%s\n", (s8 *)av7110->debi_virt); - spin_lock(&av7110->debilock); - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - ARM_ClearMailBox(av7110); - spin_unlock(&av7110->debilock); - return; - - case DATA_CI_PUT: - case DATA_MPEG_PLAY: - case DATA_BMP_LOAD: - spin_lock(&av7110->debilock); - iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); - ARM_ClearMailBox(av7110); - spin_unlock(&av7110->debilock); - return; - default: - break; - } - spin_lock(&av7110->debilock); - ARM_ClearMailBox(av7110); - spin_unlock(&av7110->debilock); + spin_lock(&av7110->debilock); + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + ARM_ClearMailBox(av7110); + spin_unlock(&av7110->debilock); + return; + + case DATA_DEBUG_MESSAGE: + ((s8*)av7110->debi_virt)[Reserved_SIZE-1]=0; + printk("%s\n", (s8 *)av7110->debi_virt); + spin_lock(&av7110->debilock); + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + ARM_ClearMailBox(av7110); + spin_unlock(&av7110->debilock); + return; + + case DATA_CI_PUT: + case DATA_MPEG_PLAY: + case DATA_BMP_LOAD: + spin_lock(&av7110->debilock); + iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); + ARM_ClearMailBox(av7110); + spin_unlock(&av7110->debilock); + return; + default: + break; + } + spin_lock(&av7110->debilock); + ARM_ClearMailBox(av7110); + spin_unlock(&av7110->debilock); } static void gpioirq (unsigned long data) { struct av7110 *av7110 = (struct av7110*) data; - u32 rxbuf, txbuf; - int len; + u32 rxbuf, txbuf; + int len; - //printk("GPIO0 irq\n"); + //printk("GPIO0 irq\n"); - if (av7110->debitype !=-1) - printk("GPIO0 irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n", + if (av7110->debitype !=-1) + printk("GPIO0 irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n", jiffies, saa7146_read(av7110->dev,PSR), saa7146_read(av7110->dev,SSR)); - spin_lock(&av7110->debilock); + spin_lock(&av7110->debilock); ARM_ClearIrq(av7110); - saa7146_write(av7110->dev, IER, - saa7146_read(av7110->dev, IER) & ~MASK_19 ); - saa7146_write(av7110->dev, ISR, MASK_19 ); + saa7146_write(av7110->dev, IER, + saa7146_read(av7110->dev, IER) & ~MASK_19 ); + saa7146_write(av7110->dev, ISR, MASK_19 ); - av7110->debitype = irdebi(av7110, DEBINOSWAP, IRQ_STATE, 0, 2); - av7110->debilen = irdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); - av7110->debibuf = 0; - rxbuf=irdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - txbuf=irdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); - len=(av7110->debilen+3)&(~3); + av7110->debitype = irdebi(av7110, DEBINOSWAP, IRQ_STATE, 0, 2); + av7110->debilen = irdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); + rxbuf=irdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + txbuf=irdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); + len=(av7110->debilen+3)&(~3); -// DEB_D(("GPIO0 irq %d %d\n", av7110->debitype, av7110->debilen)); - print_time("gpio"); +// DEB_D(("GPIO0 irq %d %d\n", av7110->debitype, av7110->debilen)); + print_time("gpio"); -// DEB_D(("GPIO0 irq %02x\n", av7110->debitype&0xff)); - switch (av7110->debitype&0xff) { +// DEB_D(("GPIO0 irq %02x\n", av7110->debitype&0xff)); + switch (av7110->debitype&0xff) { - case DATA_TS_PLAY: - case DATA_PES_PLAY: - break; + case DATA_TS_PLAY: + case DATA_PES_PLAY: + break; case DATA_MPEG_VIDEO_EVENT: { u32 h_ar; struct video_event event; - av7110->video_size.w = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_WIDTH, 0, 2); - h_ar = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_HEIGHT_AR, 0, 2); + av7110->video_size.w = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_WIDTH, 0, 2); + h_ar = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_HEIGHT_AR, 0, 2); - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); av7110->video_size.h = h_ar & 0xfff; DEB_D(("GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n", @@ -477,163 +477,163 @@ static void gpioirq (unsigned long data) break; } - case DATA_CI_PUT: - { - int avail; - struct dvb_ringbuffer *cibuf=&av7110->ci_wbuffer; - - avail=dvb_ringbuffer_avail(cibuf); - if (avail<=2) { - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); - break; - } - len= DVB_RINGBUFFER_PEEK(cibuf,0)<<8; - len|=DVB_RINGBUFFER_PEEK(cibuf,1); - if (avail<len+2) { - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); - break; - } - DVB_RINGBUFFER_SKIP(cibuf,2); - - dvb_ringbuffer_read(cibuf,av7110->debi_virt,len,0); - - wake_up(&cibuf->queue); - iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2); - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2); - saa7146_wait_for_debi_done(av7110->dev); - saa7146_write(av7110->dev, IER, - saa7146_read(av7110->dev, IER) | MASK_19 ); - if (len<5) len=5; /* we want a real DEBI DMA */ - iwdebi(av7110, DEBISWAB, DPRAM_BASE+txbuf, 0, (len+3)&~3); - spin_unlock(&av7110->debilock); - return; - } - - case DATA_MPEG_PLAY: - if (!av7110->playing) { - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); - break; - } - len=0; - if (av7110->debitype&0x100) { - spin_lock(&av7110->aout.lock); - len=pes_play(av7110->debi_virt, &av7110->aout, 2048); - spin_unlock(&av7110->aout.lock); - } - if (len<=0 && (av7110->debitype&0x200) - &&av7110->videostate.play_state!=VIDEO_FREEZED) { - spin_lock(&av7110->avout.lock); - len=pes_play(av7110->debi_virt, &av7110->avout, 2048); - spin_unlock(&av7110->avout.lock); - } - if (len<=0) { - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); - break; - } - DEB_D(("GPIO0 PES_PLAY len=%04x\n", len)); - iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2); - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2); - saa7146_wait_for_debi_done(av7110->dev); - saa7146_write(av7110->dev, IER, - saa7146_read(av7110->dev, IER) | MASK_19 ); - - iwdebi(av7110, DEBISWAB, DPRAM_BASE+txbuf, 0, (len+3)&~3); - spin_unlock(&av7110->debilock); - return; - - case DATA_BMP_LOAD: - len=av7110->debilen; - if (!len) { - av7110->bmp_state=BMP_LOADED; - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); - iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); - wake_up(&av7110->bmpq); - break; - } - if (len>av7110->bmplen) - len=av7110->bmplen; - if (len>2*1024) - len=2*1024; - iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2); - iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2); - memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len); - av7110->bmpp+=len; - av7110->bmplen-=len; - saa7146_wait_for_debi_done(av7110->dev); - saa7146_write(av7110->dev, IER, - saa7146_read(av7110->dev, IER) | MASK_19 ); - if (len<5) len=5; /* we want a real DEBI DMA */ - iwdebi(av7110, DEBISWAB, DPRAM_BASE+txbuf, 0, (len+3)&~3); - spin_unlock(&av7110->debilock); - return; - - case DATA_CI_GET: - case DATA_COMMON_INTERFACE: - case DATA_FSECTION: - case DATA_IPMPE: - case DATA_PIPING: - if (!len || len>4*1024) { - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - break; - } /* yes, fall through */ - case DATA_TS_RECORD: - case DATA_PES_RECORD: - saa7146_wait_for_debi_done(av7110->dev); - saa7146_write(av7110->dev, IER, - saa7146_read(av7110->dev, IER) | MASK_19); - irdebi(av7110, DEBISWAB, DPRAM_BASE+rxbuf, 0, len); - spin_unlock(&av7110->debilock); - return; - - case DATA_DEBUG_MESSAGE: - saa7146_wait_for_debi_done(av7110->dev); - if (!len || len>0xff) { - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - break; - } - saa7146_write(av7110->dev, IER, - saa7146_read(av7110->dev, IER) | MASK_19); - irdebi(av7110, DEBISWAB, Reserved, 0, len); - spin_unlock(&av7110->debilock); - return; - - case DATA_IRCOMMAND: - IR_handle(av7110, - swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); - iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); - break; - - default: - printk("gpioirq unknown type=%d len=%d\n", - av7110->debitype, av7110->debilen); - break; - } - ARM_ClearMailBox(av7110); - av7110->debitype=-1; - spin_unlock(&av7110->debilock); + case DATA_CI_PUT: + { + int avail; + struct dvb_ringbuffer *cibuf=&av7110->ci_wbuffer; + + avail=dvb_ringbuffer_avail(cibuf); + if (avail<=2) { + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); + break; + } + len= DVB_RINGBUFFER_PEEK(cibuf,0)<<8; + len|=DVB_RINGBUFFER_PEEK(cibuf,1); + if (avail<len+2) { + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); + break; + } + DVB_RINGBUFFER_SKIP(cibuf,2); + + dvb_ringbuffer_read(cibuf,av7110->debi_virt,len,0); + + wake_up(&cibuf->queue); + iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2); + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2); + saa7146_wait_for_debi_done(av7110->dev); + saa7146_write(av7110->dev, IER, + saa7146_read(av7110->dev, IER) | MASK_19 ); + if (len<5) len=5; /* we want a real DEBI DMA */ + iwdebi(av7110, DEBISWAB, DPRAM_BASE+txbuf, 0, (len+3)&~3); + spin_unlock(&av7110->debilock); + return; + } + + case DATA_MPEG_PLAY: + if (!av7110->playing) { + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); + break; + } + len=0; + if (av7110->debitype&0x100) { + spin_lock(&av7110->aout.lock); + len=pes_play(av7110->debi_virt, &av7110->aout, 2048); + spin_unlock(&av7110->aout.lock); + } + if (len<=0 && (av7110->debitype&0x200) + &&av7110->videostate.play_state!=VIDEO_FREEZED) { + spin_lock(&av7110->avout.lock); + len=pes_play(av7110->debi_virt, &av7110->avout, 2048); + spin_unlock(&av7110->avout.lock); + } + if (len<=0) { + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); + break; + } + DEB_D(("GPIO0 PES_PLAY len=%04x\n", len)); + iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2); + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2); + saa7146_wait_for_debi_done(av7110->dev); + saa7146_write(av7110->dev, IER, + saa7146_read(av7110->dev, IER) | MASK_19 ); + + iwdebi(av7110, DEBISWAB, DPRAM_BASE+txbuf, 0, (len+3)&~3); + spin_unlock(&av7110->debilock); + return; + + case DATA_BMP_LOAD: + len=av7110->debilen; + if (!len) { + av7110->bmp_state=BMP_LOADED; + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2); + iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2); + wake_up(&av7110->bmpq); + break; + } + if (len>av7110->bmplen) + len=av7110->bmplen; + if (len>2*1024) + len=2*1024; + iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2); + iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2); + memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len); + av7110->bmpp+=len; + av7110->bmplen-=len; + saa7146_wait_for_debi_done(av7110->dev); + saa7146_write(av7110->dev, IER, + saa7146_read(av7110->dev, IER) | MASK_19 ); + if (len<5) len=5; /* we want a real DEBI DMA */ + iwdebi(av7110, DEBISWAB, DPRAM_BASE+txbuf, 0, (len+3)&~3); + spin_unlock(&av7110->debilock); + return; + + case DATA_CI_GET: + case DATA_COMMON_INTERFACE: + case DATA_FSECTION: + case DATA_IPMPE: + case DATA_PIPING: + if (!len || len>4*1024) { + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + break; + } /* yes, fall through */ + case DATA_TS_RECORD: + case DATA_PES_RECORD: + saa7146_wait_for_debi_done(av7110->dev); + saa7146_write(av7110->dev, IER, + saa7146_read(av7110->dev, IER) | MASK_19); + irdebi(av7110, DEBISWAB, DPRAM_BASE+rxbuf, 0, len); + spin_unlock(&av7110->debilock); + return; + + case DATA_DEBUG_MESSAGE: + saa7146_wait_for_debi_done(av7110->dev); + if (!len || len>0xff) { + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + break; + } + saa7146_write(av7110->dev, IER, + saa7146_read(av7110->dev, IER) | MASK_19); + irdebi(av7110, DEBISWAB, Reserved, 0, len); + spin_unlock(&av7110->debilock); + return; + + case DATA_IRCOMMAND: + IR_handle(av7110, + swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); + iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); + break; + + default: + printk("gpioirq unknown type=%d len=%d\n", + av7110->debitype, av7110->debilen); + break; + } + ARM_ClearMailBox(av7110); + av7110->debitype=-1; + spin_unlock(&av7110->debilock); } #ifdef CONFIG_DVB_AV7110_OSD static int dvb_osd_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, void *parg) + unsigned int cmd, void *parg) { struct dvb_device *dvbdev=(struct dvb_device *) file->private_data; - struct av7110 *av7110=(struct av7110 *) dvbdev->priv; + struct av7110 *av7110=(struct av7110 *) dvbdev->priv; DEB_EE(("av7110: %p\n",av7110)); - if (cmd==OSD_SEND_CMD) - return OSD_DrawCommand(av7110, (osd_cmd_t *)parg); + if (cmd==OSD_SEND_CMD) + return OSD_DrawCommand(av7110, (osd_cmd_t *)parg); return -EINVAL; } @@ -657,7 +657,7 @@ static struct dvb_device dvbdev_osd = { static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, - u16 subpid, u16 pcrpid) + u16 subpid, u16 pcrpid) { DEB_EE(("av7110: %p\n",av7110)); @@ -670,8 +670,8 @@ static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, av7110->pids[DMX_PES_PCR] = 0; } - return outcom(av7110, COMTYPE_PIDFILTER, MultiPID, 5, - pcrpid, vpid, apid, ttpid, subpid); + return outcom(av7110, COMTYPE_PIDFILTER, MultiPID, 5, + pcrpid, vpid, apid, ttpid, subpid); } void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, @@ -679,22 +679,22 @@ void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, { DEB_EE(("av7110: %p\n",av7110)); - if (down_interruptible(&av7110->pid_mutex)) + if (down_interruptible(&av7110->pid_mutex)) return; - if (!(vpid&0x8000)) av7110->pids[DMX_PES_VIDEO]=vpid; - if (!(apid&0x8000)) av7110->pids[DMX_PES_AUDIO]=apid; - if (!(ttpid&0x8000)) av7110->pids[DMX_PES_TELETEXT]=ttpid; - if (!(pcrpid&0x8000)) av7110->pids[DMX_PES_PCR]=pcrpid; + if (!(vpid&0x8000)) av7110->pids[DMX_PES_VIDEO]=vpid; + if (!(apid&0x8000)) av7110->pids[DMX_PES_AUDIO]=apid; + if (!(ttpid&0x8000)) av7110->pids[DMX_PES_TELETEXT]=ttpid; + if (!(pcrpid&0x8000)) av7110->pids[DMX_PES_PCR]=pcrpid; - av7110->pids[DMX_PES_SUBTITLE]=0; + av7110->pids[DMX_PES_SUBTITLE]=0; - if (av7110->fe_synced) { - pcrpid = av7110->pids[DMX_PES_PCR]; - SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid); - } + if (av7110->fe_synced) { + pcrpid = av7110->pids[DMX_PES_PCR]; + SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid); + } - up(&av7110->pid_mutex); + up(&av7110->pid_mutex); } @@ -704,284 +704,284 @@ void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, static int StartHWFilter(struct dvb_demux_filter *dvbdmxfilter) { - struct dvb_demux_feed *dvbdmxfeed=dvbdmxfilter->feed; - struct av7110 *av7110=(struct av7110 *) dvbdmxfeed->demux->priv; - u16 buf[20]; - int ret, i; - u16 handle; -// u16 mode=0x0320; - u16 mode=0xb96a; + struct dvb_demux_feed *dvbdmxfeed=dvbdmxfilter->feed; + struct av7110 *av7110=(struct av7110 *) dvbdmxfeed->demux->priv; + u16 buf[20]; + int ret, i; + u16 handle; +// u16 mode=0x0320; + u16 mode=0xb96a; DEB_EE(("av7110: %p\n",av7110)); - if (dvbdmxfilter->type==DMX_TYPE_SEC) { + if (dvbdmxfilter->type==DMX_TYPE_SEC) { if (hw_sections) { - buf[4]=(dvbdmxfilter->filter.filter_value[0]<<8)| + buf[4]=(dvbdmxfilter->filter.filter_value[0]<<8)| dvbdmxfilter->maskandmode[0]; for (i=3; i<18; i++) buf[i+4-2]=(dvbdmxfilter->filter.filter_value[i]<<8)| dvbdmxfilter->maskandmode[i]; - mode=4; + mode=4; } - } else - if ((dvbdmxfeed->ts_type & TS_PACKET) && - !(dvbdmxfeed->ts_type & TS_PAYLOAD_ONLY)) - init_p2t(&av7110->p2t_filter[dvbdmxfilter->index], dvbdmxfeed); - - buf[0] = (COMTYPE_PID_FILTER << 8) + AddPIDFilter; - buf[1] = 16; - buf[2] = dvbdmxfeed->pid; - buf[3] = mode; - - ret=CommandRequest(av7110, buf, 20, &handle, 1); - if (ret<0) { + } else + if ((dvbdmxfeed->ts_type & TS_PACKET) && + !(dvbdmxfeed->ts_type & TS_PAYLOAD_ONLY)) + init_p2t(&av7110->p2t_filter[dvbdmxfilter->index], dvbdmxfeed); + + buf[0] = (COMTYPE_PID_FILTER << 8) + AddPIDFilter; + buf[1] = 16; + buf[2] = dvbdmxfeed->pid; + buf[3] = mode; + + ret=CommandRequest(av7110, buf, 20, &handle, 1); + if (ret<0) { printk("StartHWFilter error\n"); - return ret; + return ret; } - av7110->handle2filter[handle]=dvbdmxfilter; - dvbdmxfilter->hw_handle=handle; + av7110->handle2filter[handle]=dvbdmxfilter; + dvbdmxfilter->hw_handle=handle; - return ret; + return ret; } static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter) { - struct av7110 *av7110=(struct av7110 *) dvbdmxfilter->feed->demux->priv; - u16 buf[3]; - u16 answ[2]; - int ret; - u16 handle; + struct av7110 *av7110=(struct av7110 *) dvbdmxfilter->feed->demux->priv; + u16 buf[3]; + u16 answ[2]; + int ret; + u16 handle; DEB_EE(("av7110: %p\n",av7110)); - handle=dvbdmxfilter->hw_handle; - if (handle>32) { - DEB_S(("dvb: StopHWFilter tried to stop invalid filter %d.\n", - handle)); - DEB_S(("dvb: filter type = %d\n", dvbdmxfilter->type)); - return 0; - } + handle=dvbdmxfilter->hw_handle; + if (handle>32) { + DEB_S(("dvb: StopHWFilter tried to stop invalid filter %d.\n", + handle)); + DEB_S(("dvb: filter type = %d\n", dvbdmxfilter->type)); + return 0; + } - av7110->handle2filter[handle]=NULL; + av7110->handle2filter[handle]=NULL; - buf[0] = (COMTYPE_PID_FILTER << 8) + DelPIDFilter; - buf[1] = 1; - buf[2] = handle; - ret=CommandRequest(av7110, buf, 3, answ, 2); + buf[0] = (COMTYPE_PID_FILTER << 8) + DelPIDFilter; + buf[1] = 1; + buf[2] = handle; + ret=CommandRequest(av7110, buf, 3, answ, 2); if (ret) printk("StopHWFilter error\n"); - if (answ[1] != handle) { - DEB_S(("dvb: filter %d shutdown error :%d\n", handle, answ[1])); - ret=-1; - } - return ret; + if (answ[1] != handle) { + DEB_S(("dvb: filter %d shutdown error :%d\n", handle, answ[1])); + ret=-1; + } + return ret; } static void dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed) { - struct dvb_demux *dvbdmx=dvbdmxfeed->demux; - struct av7110 *av7110=(struct av7110 *) dvbdmx->priv; - u16 *pid=dvbdmx->pids, npids[5]; - int i; + struct dvb_demux *dvbdmx=dvbdmxfeed->demux; + struct av7110 *av7110=(struct av7110 *) dvbdmx->priv; + u16 *pid=dvbdmx->pids, npids[5]; + int i; DEB_EE(("av7110: %p\n",av7110)); - npids[0]=npids[1]=npids[2]=npids[3]=0xffff; - npids[4]=0xffff; - i=dvbdmxfeed->pes_type; - npids[i]=(pid[i]&0x8000) ? 0 : pid[i]; - if ((i==2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) { - npids[i]=0; - ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); - StartHWFilter(dvbdmxfeed->filter); - return; - } - if (dvbdmxfeed->pes_type<=2 || dvbdmxfeed->pes_type==4) - ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); - - if (dvbdmxfeed->pes_type<2 && npids[0]) - if (av7110->fe_synced) - outcom(av7110, COMTYPE_PIDFILTER, Scan, 0); - - if ((dvbdmxfeed->ts_type & TS_PACKET)) { - if (dvbdmxfeed->pes_type == 0 && - !(dvbdmx->pids[0]&0x8000)) - AV_StartRecord(av7110, RP_AUDIO, - dvbdmxfeed); - if (dvbdmxfeed->pes_type == 1 && - !(dvbdmx->pids[1]&0x8000)) - AV_StartRecord(av7110, RP_VIDEO, - dvbdmxfeed); - } + npids[0]=npids[1]=npids[2]=npids[3]=0xffff; + npids[4]=0xffff; + i=dvbdmxfeed->pes_type; + npids[i]=(pid[i]&0x8000) ? 0 : pid[i]; + if ((i==2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) { + npids[i]=0; + ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); + StartHWFilter(dvbdmxfeed->filter); + return; + } + if (dvbdmxfeed->pes_type<=2 || dvbdmxfeed->pes_type==4) + ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); + + if (dvbdmxfeed->pes_type<2 && npids[0]) + if (av7110->fe_synced) + outcom(av7110, COMTYPE_PIDFILTER, Scan, 0); + + if ((dvbdmxfeed->ts_type & TS_PACKET)) { + if (dvbdmxfeed->pes_type == 0 && + !(dvbdmx->pids[0]&0x8000)) + AV_StartRecord(av7110, RP_AUDIO, + dvbdmxfeed); + if (dvbdmxfeed->pes_type == 1 && + !(dvbdmx->pids[1]&0x8000)) + AV_StartRecord(av7110, RP_VIDEO, + dvbdmxfeed); + } } static void dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed) { - struct dvb_demux *dvbdmx=dvbdmxfeed->demux; - struct av7110 *av7110=(struct av7110 *) dvbdmx->priv; - u16 *pid=dvbdmx->pids, npids[5]; - int i; + struct dvb_demux *dvbdmx=dvbdmxfeed->demux; + struct av7110 *av7110=(struct av7110 *) dvbdmx->priv; + u16 *pid=dvbdmx->pids, npids[5]; + int i; DEB_EE(("av7110: %p\n",av7110)); - if (dvbdmxfeed->pes_type<=1) { - AV_Stop(av7110, dvbdmxfeed->pes_type ? - RP_VIDEO : RP_AUDIO); - if (!av7110->rec_mode) - dvbdmx->recording=0; - if (!av7110->playing) - dvbdmx->playing=0; - } - npids[0]=npids[1]=npids[2]=npids[3]=0xffff; - npids[4]=0xffff; - i=dvbdmxfeed->pes_type; - switch (i) { - case 2: //teletext - if (dvbdmxfeed->ts_type & TS_PACKET) - StopHWFilter(dvbdmxfeed->filter); - npids[2]=0; - break; - case 0: - case 1: - case 4: - if (!pids_off) - return; - npids[i]=(pid[i]&0x8000) ? 0 : pid[i]; - break; - } - ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); + if (dvbdmxfeed->pes_type<=1) { + AV_Stop(av7110, dvbdmxfeed->pes_type ? + RP_VIDEO : RP_AUDIO); + if (!av7110->rec_mode) + dvbdmx->recording=0; + if (!av7110->playing) + dvbdmx->playing=0; + } + npids[0]=npids[1]=npids[2]=npids[3]=0xffff; + npids[4]=0xffff; + i=dvbdmxfeed->pes_type; + switch (i) { + case 2: //teletext + if (dvbdmxfeed->ts_type & TS_PACKET) + StopHWFilter(dvbdmxfeed->filter); + npids[2]=0; + break; + case 0: + case 1: + case 4: + if (!pids_off) + return; + npids[i]=(pid[i]&0x8000) ? 0 : pid[i]; + break; + } + ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); } static int av7110_start_feed(struct dvb_demux_feed *feed) { - struct dvb_demux *demux = feed->demux; - struct av7110 *av7110 = (struct av7110 *) demux->priv; + struct dvb_demux *demux = feed->demux; + struct av7110 *av7110 = (struct av7110 *) demux->priv; DEB_EE(("av7110: %p\n",av7110)); - if (!demux->dmx.frontend) - return -EINVAL; + if (!demux->dmx.frontend) + return -EINVAL; - if (feed->pid > 0x1fff) - return -EINVAL; + if (feed->pid > 0x1fff) + return -EINVAL; - if (feed->type == DMX_TYPE_TS) { - if ((feed->ts_type & TS_DECODER) && + if (feed->type == DMX_TYPE_TS) { + if ((feed->ts_type & TS_DECODER) && (feed->pes_type < DMX_TS_PES_OTHER)) { - switch (demux->dmx.frontend->source) { + switch (demux->dmx.frontend->source) { case DMX_MEMORY_FE: - if (feed->ts_type & TS_DECODER) + if (feed->ts_type & TS_DECODER) if (feed->pes_type < 2 && - !(demux->pids[0] & 0x8000) && + !(demux->pids[0] & 0x8000) && !(demux->pids[1] & 0x8000)) { - dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout); - dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout); - AV_StartPlay(av7110,RP_AV); - demux->playing = 1; + dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout); + dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout); + AV_StartPlay(av7110,RP_AV); + demux->playing = 1; } break; default: - dvb_feed_start_pid(feed); + dvb_feed_start_pid(feed); break; } } else - if ((feed->ts_type & TS_PACKET) && - (demux->dmx.frontend->source!=DMX_MEMORY_FE)) - StartHWFilter(feed->filter); - } + if ((feed->ts_type & TS_PACKET) && + (demux->dmx.frontend->source!=DMX_MEMORY_FE)) + StartHWFilter(feed->filter); + } - if (feed->type == DMX_TYPE_SEC) { - int i; + if (feed->type == DMX_TYPE_SEC) { + int i; - for (i=0; i<demux->filternum; i++) { - if (demux->filter[i].state!=DMX_STATE_READY) - continue; + for (i=0; i<demux->filternum; i++) { + if (demux->filter[i].state!=DMX_STATE_READY) + continue; if (demux->filter[i].type!=DMX_TYPE_SEC) - continue; + continue; if (demux->filter[i].filter.parent!=&feed->feed.sec) - continue; + continue; demux->filter[i].state=DMX_STATE_GO; - if (demux->dmx.frontend->source!=DMX_MEMORY_FE) - StartHWFilter(&demux->filter[i]); - } + if (demux->dmx.frontend->source!=DMX_MEMORY_FE) + StartHWFilter(&demux->filter[i]); + } } - return 0; + return 0; } static int av7110_stop_feed(struct dvb_demux_feed *feed) { - struct dvb_demux *demux = feed->demux; - struct av7110 *av7110 = (struct av7110 *) demux->priv; + struct dvb_demux *demux = feed->demux; + struct av7110 *av7110 = (struct av7110 *) demux->priv; DEB_EE(("av7110: %p\n",av7110)); - if (feed->type == DMX_TYPE_TS) { - if (feed->ts_type & TS_DECODER) { - if (feed->pes_type >= DMX_TS_PES_OTHER || - !demux->pesfilter[feed->pes_type]) - return -EINVAL; - demux->pids[feed->pes_type]|=0x8000; - demux->pesfilter[feed->pes_type]=0; - } - if (feed->ts_type & TS_DECODER && + if (feed->type == DMX_TYPE_TS) { + if (feed->ts_type & TS_DECODER) { + if (feed->pes_type >= DMX_TS_PES_OTHER || + !demux->pesfilter[feed->pes_type]) + return -EINVAL; + demux->pids[feed->pes_type]|=0x8000; + demux->pesfilter[feed->pes_type]=0; + } + if (feed->ts_type & TS_DECODER && feed->pes_type < DMX_TS_PES_OTHER) { - dvb_feed_stop_pid(feed); - } else - if ((feed->ts_type & TS_PACKET) && - (demux->dmx.frontend->source != DMX_MEMORY_FE)) - StopHWFilter(feed->filter); - } - - if (feed->type == DMX_TYPE_SEC) { - int i; - - for (i=0; i<demux->filternum; i++) - if (demux->filter[i].state==DMX_STATE_GO && + dvb_feed_stop_pid(feed); + } else + if ((feed->ts_type & TS_PACKET) && + (demux->dmx.frontend->source != DMX_MEMORY_FE)) + StopHWFilter(feed->filter); + } + + if (feed->type == DMX_TYPE_SEC) { + int i; + + for (i=0; i<demux->filternum; i++) + if (demux->filter[i].state==DMX_STATE_GO && demux->filter[i].filter.parent==&feed->feed.sec) { - demux->filter[i].state=DMX_STATE_READY; - if (demux->dmx.frontend->source!=DMX_MEMORY_FE) - StopHWFilter(&demux->filter[i]); - } + demux->filter[i].state=DMX_STATE_READY; + if (demux->dmx.frontend->source!=DMX_MEMORY_FE) + StopHWFilter(&demux->filter[i]); + } } - return 0; + return 0; } static void restart_feeds(struct av7110 *av7110) { - struct dvb_demux *dvbdmx=&av7110->demux; - struct dvb_demux_feed *feed; - int mode; - int i; + struct dvb_demux *dvbdmx=&av7110->demux; + struct dvb_demux_feed *feed; + int mode; + int i; DEB_EE(("av7110: %p\n",av7110)); - mode=av7110->playing; - av7110->playing=0; - av7110->rec_mode=0; + mode=av7110->playing; + av7110->playing=0; + av7110->rec_mode=0; - for (i=0; i<dvbdmx->filternum; i++) { - feed=&dvbdmx->feed[i]; - if (feed->state==DMX_STATE_GO) - av7110_start_feed(feed); - } + for (i=0; i<dvbdmx->filternum; i++) { + feed=&dvbdmx->feed[i]; + if (feed->state==DMX_STATE_GO) + av7110_start_feed(feed); + } - if (mode) - AV_StartPlay(av7110, mode); + if (mode) + AV_StartPlay(av7110, mode); } static int dvb_get_stc(struct dmx_demux *demux, unsigned int num, uint64_t *stc, unsigned int *base) { int ret; - u16 fwstc[4]; - u16 tag = ((COMTYPE_REQUEST << 8) + ReqSTC); + u16 fwstc[4]; + u16 tag = ((COMTYPE_REQUEST << 8) + ReqSTC); struct dvb_demux *dvbdemux; struct av7110 *av7110; @@ -998,7 +998,7 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num, if (num != 0) return -EINVAL; - ret = CommandRequest(av7110, &tag, 0, fwstc, 4); + ret = CommandRequest(av7110, &tag, 0, fwstc, 4); if (ret) { printk(KERN_ERR "%s: CommandRequest error\n", __FUNCTION__); return -EIO; @@ -1006,7 +1006,7 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num, DEB_EE(("av7110: fwstc = %04hx %04hx %04hx %04hx\n", fwstc[0], fwstc[1], fwstc[2], fwstc[3])); - *stc = (((uint64_t) ((fwstc[3] & 0x8000) >> 15)) << 32) | + *stc = (((uint64_t) ((fwstc[3] & 0x8000) >> 15)) << 32) | (((uint64_t) fwstc[1]) << 16) | ((uint64_t)fwstc[0]); *base = 1; @@ -1065,40 +1065,40 @@ static void av7110_before_after_tune (fe_status_t s, void *data) DEB_EE(("av7110: %p\n",av7110)); - av7110->fe_synced = (s & FE_HAS_LOCK) ? 1 : 0; + av7110->fe_synced = (s & FE_HAS_LOCK) ? 1 : 0; - if (av7110->playing) - return; + if (av7110->playing) + return; - if (down_interruptible(&av7110->pid_mutex)) - return; + if (down_interruptible(&av7110->pid_mutex)) + return; if (av7110->fe_synced) { - SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO], - av7110->pids[DMX_PES_AUDIO], - av7110->pids[DMX_PES_TELETEXT], 0, - av7110->pids[DMX_PES_PCR]); - outcom(av7110, COMTYPE_PIDFILTER, Scan, 0); + SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO], + av7110->pids[DMX_PES_AUDIO], + av7110->pids[DMX_PES_TELETEXT], 0, + av7110->pids[DMX_PES_PCR]); + outcom(av7110, COMTYPE_PIDFILTER, Scan, 0); } else { SetPIDs(av7110, 0, 0, 0, 0, 0); - outcom(av7110, COMTYPE_PIDFILTER, FlushTSQueue, 0); + outcom(av7110, COMTYPE_PIDFILTER, FlushTSQueue, 0); } - up(&av7110->pid_mutex); + up(&av7110->pid_mutex); } static int av7110_register(struct av7110 *av7110) { - int ret, i; - struct dvb_demux *dvbdemux=&av7110->demux; + int ret, i; + struct dvb_demux *dvbdemux=&av7110->demux; DEB_EE(("av7110: %p\n",av7110)); - if (av7110->registered) - return -1; + if (av7110->registered) + return -1; - av7110->registered=1; + av7110->registered=1; dvb_add_frontend_notifier (av7110->dvb_adapter, av7110_before_after_tune, av7110); @@ -1109,7 +1109,7 @@ static int av7110_register(struct av7110 *av7110) dvb_add_frontend_ioctls (av7110->dvb_adapter, av7110_diseqc_ioctl, NULL, av7110); - dvbdemux->priv = (void *) av7110; + dvbdemux->priv = (void *) av7110; for (i=0; i<32; i++) av7110->handle2filter[i]=NULL; @@ -1131,24 +1131,24 @@ static int av7110_register(struct av7110 *av7110) dvb_dmxdev_init(&av7110->dmxdev, av7110->dvb_adapter); - av7110->hw_frontend.source = DMX_FRONTEND_0; + av7110->hw_frontend.source = DMX_FRONTEND_0; - ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->hw_frontend); + ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->hw_frontend); if (ret < 0) - return ret; + return ret; - av7110->mem_frontend.source = DMX_MEMORY_FE; + av7110->mem_frontend.source = DMX_MEMORY_FE; ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->mem_frontend); if (ret < 0) - return ret; + return ret; - ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, + ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &av7110->hw_frontend); - if (ret < 0) - return ret; + if (ret < 0) + return ret; av7110_av_register(av7110); av7110_ca_register(av7110); @@ -1158,7 +1158,7 @@ static int av7110_register(struct av7110 *av7110) &dvbdev_osd, av7110, DVB_DEVICE_OSD); #endif - dvb_net_init(av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx); + dvb_net_init(av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx); return 0; } @@ -1166,21 +1166,21 @@ static int av7110_register(struct av7110 *av7110) static void dvb_unregister(struct av7110 *av7110) { - struct dvb_demux *dvbdemux=&av7110->demux; + struct dvb_demux *dvbdemux=&av7110->demux; DEB_EE(("av7110: %p\n",av7110)); - if (!av7110->registered) - return; + if (!av7110->registered) + return; dvb_net_release(&av7110->dvb_net); dvbdemux->dmx.close(&dvbdemux->dmx); - dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->hw_frontend); - dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->mem_frontend); + dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->hw_frontend); + dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->mem_frontend); - dvb_dmxdev_release(&av7110->dmxdev); - dvb_dmx_release(&av7110->demux); + dvb_dmxdev_release(&av7110->dmxdev); + dvb_dmx_release(&av7110->demux); dvb_remove_frontend_notifier (av7110->dvb_adapter, av7110_before_after_tune); @@ -1200,33 +1200,33 @@ static void dvb_unregister(struct av7110 *av7110) int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val) { - u8 msg[2]={ reg, val }; - struct dvb_i2c_bus *i2c = av7110->i2c_bus; - struct i2c_msg msgs; - - msgs.flags=0; - msgs.addr=id/2; - msgs.len=2; - msgs.buf=msg; - return i2c->xfer (i2c, &msgs, 1); + u8 msg[2]={ reg, val }; + struct dvb_i2c_bus *i2c = av7110->i2c_bus; + struct i2c_msg msgs; + + msgs.flags=0; + msgs.addr=id/2; + msgs.len=2; + msgs.buf=msg; + return i2c->xfer (i2c, &msgs, 1); } u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg) { - struct dvb_i2c_bus *i2c = av7110->i2c_bus; - u8 mm1[] = {0x00}; - u8 mm2[] = {0x00}; - struct i2c_msg msgs[2]; - - msgs[0].flags=0; - msgs[1].flags=I2C_M_RD; - msgs[0].addr=msgs[1].addr=id/2; - mm1[0]=reg; - msgs[0].len=1; msgs[1].len=1; - msgs[0].buf=mm1; msgs[1].buf=mm2; - i2c->xfer(i2c, msgs, 2); - - return mm2[0]; + struct dvb_i2c_bus *i2c = av7110->i2c_bus; + u8 mm1[] = {0x00}; + u8 mm2[] = {0x00}; + struct i2c_msg msgs[2]; + + msgs[0].flags=0; + msgs[1].flags=I2C_M_RD; + msgs[0].addr=msgs[1].addr=id/2; + mm1[0]=reg; + msgs[0].len=1; msgs[1].len=1; + msgs[0].buf=mm1; msgs[1].buf=mm2; + i2c->xfer(i2c, msgs, 2); + + return mm2[0]; } static int master_xfer (struct dvb_i2c_bus *i2c, const struct i2c_msg msgs[], int num) @@ -1384,49 +1384,49 @@ static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_ /* upload all */ saa7146_write(dev, MC2, 0x077c077c); - saa7146_write(dev, GPIO_CTRL, 0x000000); + saa7146_write(dev, GPIO_CTRL, 0x000000); tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110); tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110); - sema_init(&av7110->pid_mutex, 1); + sema_init(&av7110->pid_mutex, 1); - /* locks for data transfers from/to AV7110 */ - spin_lock_init (&av7110->debilock); - sema_init(&av7110->dcomlock, 1); - av7110->debilock=SPIN_LOCK_UNLOCKED; - av7110->debitype=-1; + /* locks for data transfers from/to AV7110 */ + spin_lock_init (&av7110->debilock); + sema_init(&av7110->dcomlock, 1); + av7110->debilock=SPIN_LOCK_UNLOCKED; + av7110->debitype=-1; - /* default OSD window */ - av7110->osdwin=1; + /* default OSD window */ + av7110->osdwin=1; - /* ARM "watchdog" */ + /* ARM "watchdog" */ init_waitqueue_head(&av7110->arm_wait); - av7110->arm_thread=0; + av7110->arm_thread=0; - /* allocate and init buffers */ - av7110->debi_virt = pci_alloc_consistent(dev->pci, 8192, + /* allocate and init buffers */ + av7110->debi_virt = pci_alloc_consistent(dev->pci, 8192, &av7110->debi_bus); if (!av7110->debi_virt) { ret = -ENOMEM; - goto err; + goto err; } - av7110->iobuf = vmalloc(AVOUTLEN+AOUTLEN+BMPLEN+4*IPACKS); + av7110->iobuf = vmalloc(AVOUTLEN+AOUTLEN+BMPLEN+4*IPACKS); if (!av7110->iobuf) { ret = -ENOMEM; - goto err; + goto err; } av7110_av_init(av7110); - /* init BMP buffer */ - av7110->bmpbuf=av7110->iobuf+AVOUTLEN+AOUTLEN; - init_waitqueue_head(&av7110->bmpq); + /* init BMP buffer */ + av7110->bmpbuf=av7110->iobuf+AVOUTLEN+AOUTLEN; + init_waitqueue_head(&av7110->bmpq); av7110_ca_init(av7110); - /* load firmware into AV7110 cards */ + /* load firmware into AV7110 cards */ bootarm(av7110); firmversion(av7110); @@ -1442,7 +1442,7 @@ static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_ VidMode(av7110, vidmode); - /* handle different card types */ + /* handle different card types */ /* remaining inits according to card and frontend type */ av7110->has_analog_tuner = 0; av7110->current_input = 0; @@ -1497,7 +1497,7 @@ static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_ printk(KERN_INFO "av7110: found av7110-%d.\n",av7110_num); av7110->device_initialized = 1; av7110_num++; - return 0; + return 0; err: if (NULL != av7110 ) { diff --git a/linux/drivers/media/dvb/ttpci/av7110.h b/linux/drivers/media/dvb/ttpci/av7110.h index e843cceae..9c23a2f04 100644 --- a/linux/drivers/media/dvb/ttpci/av7110.h +++ b/linux/drivers/media/dvb/ttpci/av7110.h @@ -32,38 +32,38 @@ enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM}; struct av7110_p2t { - u8 pes[TS_SIZE]; - u8 counter; - long int pos; - int frags; - struct dvb_demux_feed *feed; + u8 pes[TS_SIZE]; + u8 counter; + long int pos; + int frags; + struct dvb_demux_feed *feed; }; /* video MPEG decoder events: */ /* (code copied from dvb_frontend.c, should maybe be factored out...) */ #define MAX_VIDEO_EVENT 8 struct dvb_video_events { - struct video_event events[MAX_VIDEO_EVENT]; - int eventw; - int eventr; - int overflow; - wait_queue_head_t wait_queue; - spinlock_t lock; + struct video_event events[MAX_VIDEO_EVENT]; + int eventw; + int eventr; + int overflow; + wait_queue_head_t wait_queue; + spinlock_t lock; }; /* place to store all the necessary device information */ struct av7110 { - /* devices */ + /* devices */ - struct dvb_device dvb_dev; - struct dvb_net dvb_net; + struct dvb_device dvb_dev; + struct dvb_net dvb_net; struct video_device v4l_dev; struct video_device vbi_dev; - struct saa7146_dev *dev; + struct saa7146_dev *dev; struct dvb_i2c_bus *i2c_bus; char *card_name; @@ -73,137 +73,131 @@ struct av7110 { int current_input; u32 current_freq; - struct tasklet_struct debi_tasklet; - struct tasklet_struct gpio_tasklet; + struct tasklet_struct debi_tasklet; + struct tasklet_struct gpio_tasklet; - int adac_type; /* audio DAC type */ -#define DVB_ADAC_TI 0 + int adac_type; /* audio DAC type */ +#define DVB_ADAC_TI 0 #define DVB_ADAC_CRYSTAL 1 -#define DVB_ADAC_MSP 2 -#define DVB_ADAC_NONE -1 +#define DVB_ADAC_MSP 2 +#define DVB_ADAC_NONE -1 - /* buffers */ + /* buffers */ - void *iobuf; /* memory for all buffers */ - struct dvb_ringbuffer avout; /* buffer for video or A/V mux */ + void *iobuf; /* memory for all buffers */ + struct dvb_ringbuffer avout; /* buffer for video or A/V mux */ #define AVOUTLEN (128*1024) - struct dvb_ringbuffer aout; /* buffer for audio */ + struct dvb_ringbuffer aout; /* buffer for audio */ #define AOUTLEN (64*1024) - void *bmpbuf; + void *bmpbuf; #define BMPLEN (8*32768+1024) - /* bitmap buffers and states */ + /* bitmap buffers and states */ - int bmpp; - int bmplen; - int bmp_win; - u16 bmp_x, bmp_y; - int bmp_trans; - int bmp_state; + int bmpp; + int bmplen; + int bmp_state; #define BMP_NONE 0 #define BMP_LOADING 1 #define BMP_LOADINGS 2 #define BMP_LOADED 3 - wait_queue_head_t bmpq; + wait_queue_head_t bmpq; - /* DEBI and polled command interface */ + /* DEBI and polled command interface */ - spinlock_t debilock; - struct semaphore dcomlock; - int debitype; - int debilen; - int debibuf; + spinlock_t debilock; + struct semaphore dcomlock; + int debitype; + int debilen; - /* Recording and playback flags */ + /* Recording and playback flags */ - int rec_mode; - int playing; + int rec_mode; + int playing; #define RP_NONE 0 #define RP_VIDEO 1 #define RP_AUDIO 2 -#define RP_AV 3 +#define RP_AV 3 - /* OSD */ + /* OSD */ - int osdwin; /* currently active window */ - u16 osdbpp[8]; + int osdwin; /* currently active window */ + u16 osdbpp[8]; - /* CA */ + /* CA */ - ca_slot_info_t ci_slot[2]; + ca_slot_info_t ci_slot[2]; - int vidmode; - struct dmxdev dmxdev; - struct dvb_demux demux; + int vidmode; + struct dmxdev dmxdev; + struct dvb_demux demux; - struct dmx_frontend hw_frontend; - struct dmx_frontend mem_frontend; + struct dmx_frontend hw_frontend; + struct dmx_frontend mem_frontend; - int fe_synced; - struct semaphore pid_mutex; + int fe_synced; + struct semaphore pid_mutex; - int video_blank; - struct video_status videostate; - int display_ar; - int trickmode; + int video_blank; + struct video_status videostate; + int display_ar; + int trickmode; #define TRICK_NONE 0 #define TRICK_FAST 1 #define TRICK_SLOW 2 #define TRICK_FREEZE 3 - struct audio_status audiostate; + struct audio_status audiostate; - struct dvb_demux_filter *handle2filter[32]; - struct av7110_p2t p2t_filter[MAXFILT]; - struct dvb_filter_pes2ts p2t[2]; - struct ipack ipack[2]; - u8 *kbuf[2]; + struct dvb_demux_filter *handle2filter[32]; + struct av7110_p2t p2t_filter[MAXFILT]; + struct dvb_filter_pes2ts p2t[2]; + struct ipack ipack[2]; + u8 *kbuf[2]; - int sinfo; - int feeding; + int sinfo; + int feeding; - int arm_errors; - int registered; + int arm_errors; + int registered; /* AV711X */ - u32 arm_fw; - u32 arm_rtsl; - u32 arm_vid; - u32 arm_app; - u32 avtype; - int arm_ready; - struct task_struct *arm_thread; - wait_queue_head_t arm_wait; - u16 arm_loops; - int arm_rmmod; + u32 arm_fw; + u32 arm_rtsl; + u32 arm_vid; + u32 arm_app; + u32 avtype; + int arm_ready; + struct task_struct *arm_thread; + wait_queue_head_t arm_wait; + u16 arm_loops; + int arm_rmmod; - void *debi_virt; - dma_addr_t debi_bus; + void *debi_virt; + dma_addr_t debi_bus; - u16 pids[DMX_PES_OTHER]; + u16 pids[DMX_PES_OTHER]; - struct dvb_ringbuffer ci_rbuffer; - struct dvb_ringbuffer ci_wbuffer; + struct dvb_ringbuffer ci_rbuffer; + struct dvb_ringbuffer ci_wbuffer; - struct dvb_adapter *dvb_adapter; - struct dvb_device *video_dev; - struct dvb_device *audio_dev; - struct dvb_device *ca_dev; - struct dvb_device *osd_dev; + struct dvb_adapter *dvb_adapter; + struct dvb_device *video_dev; + struct dvb_device *audio_dev; + struct dvb_device *ca_dev; + struct dvb_device *osd_dev; struct dvb_video_events video_events; - video_size_t video_size; + video_size_t video_size; - int dsp_dev; - - u32 ir_config; + u32 ir_config; /* firmware stuff */ unsigned int device_initialized; |