diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2007-09-19 15:39:22 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2007-09-19 15:39:22 -0300 |
commit | 631a2a6aa106d15af6c8fe401d654d2da0c4bdac (patch) | |
tree | d8ee5f824c9eea45452a7ee046cfdb9017041f89 /linux | |
parent | 534ed3cae7cb15e779515ae9fb9d5eccdab2809c (diff) | |
download | mediapointer-dvb-s2-631a2a6aa106d15af6c8fe401d654d2da0c4bdac.tar.gz mediapointer-dvb-s2-631a2a6aa106d15af6c8fe401d654d2da0c4bdac.tar.bz2 |
tm6000: Split header processing from header find
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/staging/tm6000/tm6000-video.c | 217 |
1 files changed, 116 insertions, 101 deletions
diff --git a/linux/drivers/staging/tm6000/tm6000-video.c b/linux/drivers/staging/tm6000/tm6000-video.c index 160317a4d..22a670789 100644 --- a/linux/drivers/staging/tm6000/tm6000-video.c +++ b/linux/drivers/staging/tm6000/tm6000-video.c @@ -190,16 +190,14 @@ static void inline buffer_filled (struct tm6000_core *dev, /* * Identify the tm5600/6000 buffer header type and properly handles */ -static int copy_streams(u8 *data, u8 *out_p, unsigned long len, - struct urb *urb, struct tm6000_buffer **buf) +static u8 *copy_packet (struct urb *urb, u32 header, u8 *data, u8 *endp, + u8 *out_p, struct tm6000_buffer **buf) { struct tm6000_dmaqueue *dma_q = urb->context; struct tm6000_core *dev= container_of(dma_q,struct tm6000_core,vidq); - u8 *ptr=data, *endp=data+len; + u8 *ptr=data; u8 c; unsigned int cmd, cpysize, pktsize, size, field, block, line, pos=0; - unsigned long header; - int rc=0; /* FIXME: this is the hardcoded window size */ @@ -207,67 +205,46 @@ static int copy_streams(u8 *data, u8 *out_p, unsigned long len, //static int last_line=-2; - for (ptr=data; ptr<endp;) { - if (!dev->isoc_ctl.cmd) { - /* Seek for sync */ - for (ptr+=3;ptr<endp;ptr++) { - if (*ptr==0x47) { - ptr-=3; - break; - } - } - if (ptr>=endp) - return rc; - - /* Get message header */ - header=*(unsigned long *)ptr; - ptr+=4; - c=(header>>24) & 0xff; - - /* split the header fields */ - size = (((header & 0x7e)<<1) -1) *4; - block = (header>>7) & 0xf; - field = (header>>11) & 0x1; - line = (header>>12) & 0x1ff; - cmd = (header>>21) & 0x7; - - /* FIXME: Maximum possible line is 511. - * This doesn't seem to be enough for PAL standards - */ - - /* Validates header fields */ - if(size>TM6000_URB_MSG_LEN) - size=TM6000_URB_MSG_LEN; - if(block>=8) - cmd = TM6000_URB_MSG_ERR; - - /* FIXME: Mounts the image as field0+field1 - * It should, instead, check if the user selected - * entrelaced or non-entrelaced mode - */ - pos=((line<<1)+field)*linesize+ - block*TM6000_URB_MSG_LEN; - - - - /* Don't allow to write out of the buffer */ -#if 1 - if (pos+TM6000_URB_MSG_LEN > (*buf)->vb.size) - cmd = TM6000_URB_MSG_ERR; + if (!dev->isoc_ctl.cmd) { + c=(header>>24) & 0xff; + + /* split the header fields */ + size = (((header & 0x7e)<<1) -1) *4; + block = (header>>7) & 0xf; + field = (header>>11) & 0x1; + line = (header>>12) & 0x1ff; + cmd = (header>>21) & 0x7; + + /* Validates header fields */ + if(size>TM6000_URB_MSG_LEN) + size=TM6000_URB_MSG_LEN; + if(block>=8) + cmd = TM6000_URB_MSG_ERR; + + /* FIXME: Mounts the image as field0+field1 + * It should, instead, check if the user selected + * entrelaced or non-entrelaced mode + */ + pos=((line<<1)+field)*linesize+ + block*TM6000_URB_MSG_LEN; + + /* Don't allow to write out of the buffer */ + if (pos+TM6000_URB_MSG_LEN > (*buf)->vb.size) + cmd = TM6000_URB_MSG_ERR; + + /* Prints debug info */ + dprintk(dev, V4L2_DEBUG_ISOC, "size=%d, num=%d, " + " line=%d, field=%d\n", + size, block, line, field); +#if 0 /* DEBUG */ + if ((last_line!=line)&&(last_line+1!=line)) { /* Prints debug info */ dprintk(dev, V4L2_DEBUG_ISOC, "size=%d, num=%d, " - " line=%d, field=%d\n", - size, block, line, field); -#endif -#if 0 /* DEBUG */ - if ((last_line!=line)&&(last_line+1!=line)) { - /* Prints debug info */ - dprintk(dev, V4L2_DEBUG_ISOC, "size=%d, num=%d, " - " line=%d, field=%d\n", - size, block, line, field); - last_line=line; - } + " line=%d, field=%d\n", + size, block, line, field); + last_line=line; + } #endif #if 0 if (dev->isoc_ctl.field != field) { @@ -282,49 +259,88 @@ static int copy_streams(u8 *data, u8 *out_p, unsigned long len, *buf=NULL; } #endif +#if 0 + dev->isoc_ctl.cmd = cmd; + dev->isoc_ctl.size = size; + dev->isoc_ctl.pos = pos; + dev->isoc_ctl.pktsize = pktsize; +#endif + pktsize = TM6000_URB_MSG_LEN; +///////////////////////////// +/// nao seria size??? + + } else { + /* Continue the last copy */ + cmd = dev->isoc_ctl.cmd; + size= dev->isoc_ctl.size; + pos = dev->isoc_ctl.pos; + pktsize = dev->isoc_ctl.pktsize; + } - dev->isoc_ctl.cmd = cmd; - dev->isoc_ctl.size = size; - dev->isoc_ctl.pos = pos; - dev->isoc_ctl.pktsize = pktsize = TM6000_URB_MSG_LEN; - } else { - cmd = dev->isoc_ctl.cmd; - size= dev->isoc_ctl.size; - pos = dev->isoc_ctl.pos; - pktsize = dev->isoc_ctl.pktsize; - } #if 0 - if (!buf) - cmd=TM6000_URB_MSG_ERR; - else { - if (pos+180*2 > (*buf)->vb.size) - cmd = TM6000_URB_MSG_ERR; - } + if (!buf) + cmd=TM6000_URB_MSG_ERR; + else { + if (pos+180*2 > (*buf)->vb.size) + cmd = TM6000_URB_MSG_ERR; + } #endif - cpysize=(endp-ptr>size)?size:endp-ptr; - - if (cpysize) { - /* handles each different URB message */ - switch(cmd) { - case TM6000_URB_MSG_VIDEO: - /* Fills video buffer */ - bufcpy(*buf,&out_p[pos],ptr,cpysize); + cpysize=(endp-ptr>size)?size:endp-ptr; + + if (cpysize) { + /* handles each different URB message */ + switch(cmd) { + case TM6000_URB_MSG_VIDEO: + /* Fills video buffer */ + bufcpy(*buf,&out_p[pos],ptr,cpysize); break; - } } - if (cpysize<size) { - /* End of URB packet, but cmd processing is not - * complete. Preserve the state for a next packet - */ - dev->isoc_ctl.pos = pos+cpysize; - dev->isoc_ctl.size= size-cpysize; - dev->isoc_ctl.cmd = cmd; - dev->isoc_ctl.pktsize = pktsize-cpysize; - ptr+=cpysize; - } else { - dev->isoc_ctl.cmd = 0; - ptr+=pktsize; + } + if (cpysize<size) { + /* End of URB packet, but cmd processing is not + * complete. Preserve the state for a next packet + */ + dev->isoc_ctl.pos = pos+cpysize; + dev->isoc_ctl.size= size-cpysize; + dev->isoc_ctl.cmd = cmd; + dev->isoc_ctl.pktsize = pktsize-cpysize; + ptr+=cpysize; + } else { + dev->isoc_ctl.cmd = 0; + ptr+=pktsize; + } + + return ptr; +} + +static int copy_streams(u8 *data, u8 *out_p, unsigned long len, + struct urb *urb, struct tm6000_buffer **buf) +{ + struct tm6000_dmaqueue *dma_q = urb->context; + struct tm6000_core *dev= container_of(dma_q,struct tm6000_core,vidq); + u8 *ptr=data, *endp=data+len; + u32 header=0; + int rc=0; + + for (ptr=data; ptr<endp;) { + if (!dev->isoc_ctl.cmd) { + /* Seek for sync */ + for (ptr+=3;ptr<endp;ptr++) { + if (*ptr==0x47) { + ptr-=3; + break; + } + } + if (ptr>=endp) + return rc; + + /* Get message header */ + header=*(unsigned long *)ptr; + ptr+=4; } + + /* Copy or continue last copy */ + ptr=copy_packet(urb,header,ptr,endp,out_p,buf); } return rc; @@ -867,7 +883,6 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, /* Round to an enough number of URBs */ urbsize=(urbsize+dev->max_isoc_in-1)/dev->max_isoc_in; - printk("Allocating %d packets to handle %lu size\n", urbsize,buf->vb.size); dprintk(dev, V4L2_DEBUG_QUEUE, "Allocating %d packets to handle " |