V4L/DVB (12828): tm6000: fixes several CodingStyle and do some cleanups
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
204193d959
commit
c4acf48cad
1 changed files with 144 additions and 165 deletions
|
@ -33,9 +33,6 @@
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#ifdef CONFIG_VIDEO_V4L1_COMPAT
|
|
||||||
#include <linux/videodev.h>
|
|
||||||
#endif
|
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/kthread.h>
|
#include <linux/kthread.h>
|
||||||
#include <linux/highmem.h>
|
#include <linux/highmem.h>
|
||||||
|
@ -93,7 +90,7 @@ static struct v4l2_queryctrl tm6000_qctrl[] = {
|
||||||
.minimum = -128,
|
.minimum = -128,
|
||||||
.maximum = 127,
|
.maximum = 127,
|
||||||
.step = 0x1,
|
.step = 0x1,
|
||||||
.default_value = 0, //4 ?
|
.default_value = 0,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -105,11 +102,11 @@ static struct tm6000_fmt format[] = {
|
||||||
.name = "4:2:2, packed, YVY2",
|
.name = "4:2:2, packed, YVY2",
|
||||||
.fourcc = V4L2_PIX_FMT_YUYV,
|
.fourcc = V4L2_PIX_FMT_YUYV,
|
||||||
.depth = 16,
|
.depth = 16,
|
||||||
},{
|
}, {
|
||||||
.name = "4:2:2, packed, UYVY",
|
.name = "4:2:2, packed, UYVY",
|
||||||
.fourcc = V4L2_PIX_FMT_UYVY,
|
.fourcc = V4L2_PIX_FMT_UYVY,
|
||||||
.depth = 16,
|
.depth = 16,
|
||||||
},{
|
}, {
|
||||||
.name = "A/V + VBI mux packet",
|
.name = "A/V + VBI mux packet",
|
||||||
.fourcc = V4L2_PIX_FMT_TM6000,
|
.fourcc = V4L2_PIX_FMT_TM6000,
|
||||||
.depth = 16,
|
.depth = 16,
|
||||||
|
@ -125,20 +122,19 @@ static LIST_HEAD(tm6000_corelist);
|
||||||
#define norm_maxw(a) 720
|
#define norm_maxw(a) 720
|
||||||
#define norm_maxh(a) 576
|
#define norm_maxh(a) 576
|
||||||
|
|
||||||
//#define norm_minw(a) norm_maxw(a)
|
|
||||||
#define norm_minw(a) norm_maxw(a)
|
#define norm_minw(a) norm_maxw(a)
|
||||||
#define norm_minh(a) norm_maxh(a)
|
#define norm_minh(a) norm_maxh(a)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* video-buf generic routine to get the next available buffer
|
* video-buf generic routine to get the next available buffer
|
||||||
*/
|
*/
|
||||||
static int inline get_next_buf (struct tm6000_dmaqueue *dma_q,
|
static inline int get_next_buf(struct tm6000_dmaqueue *dma_q,
|
||||||
struct tm6000_buffer **buf)
|
struct tm6000_buffer **buf)
|
||||||
{
|
{
|
||||||
struct tm6000_core *dev= container_of(dma_q,struct tm6000_core,vidq);
|
struct tm6000_core *dev = container_of(dma_q, struct tm6000_core, vidq);
|
||||||
|
|
||||||
if (list_empty(&dma_q->active)) {
|
if (list_empty(&dma_q->active)) {
|
||||||
dprintk(dev, V4L2_DEBUG_QUEUE,"No active queue to serve\n");
|
dprintk(dev, V4L2_DEBUG_QUEUE, "No active queue to serve\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,9 +147,9 @@ static int inline get_next_buf (struct tm6000_dmaqueue *dma_q,
|
||||||
/*
|
/*
|
||||||
* Announces that a buffer were filled and request the next
|
* Announces that a buffer were filled and request the next
|
||||||
*/
|
*/
|
||||||
static void inline buffer_filled (struct tm6000_core *dev,
|
static inline void buffer_filled(struct tm6000_core *dev,
|
||||||
struct tm6000_dmaqueue *dma_q,
|
struct tm6000_dmaqueue *dma_q,
|
||||||
struct tm6000_buffer *buf)
|
struct tm6000_buffer *buf)
|
||||||
{
|
{
|
||||||
/* Nobody is waiting something to be done, just return */
|
/* Nobody is waiting something to be done, just return */
|
||||||
if (!waitqueue_active(&buf->vb.done)) {
|
if (!waitqueue_active(&buf->vb.done)) {
|
||||||
|
@ -166,7 +162,7 @@ static void inline buffer_filled (struct tm6000_core *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Advice that buffer was filled */
|
/* Advice that buffer was filled */
|
||||||
dprintk(dev, V4L2_DEBUG_ISOC, "[%p/%d] wakeup\n",buf,buf->vb.i);
|
dprintk(dev, V4L2_DEBUG_ISOC, "[%p/%d] wakeup\n", buf, buf->vb.i);
|
||||||
buf->vb.state = VIDEOBUF_DONE;
|
buf->vb.state = VIDEOBUF_DONE;
|
||||||
buf->vb.field_count++;
|
buf->vb.field_count++;
|
||||||
do_gettimeofday(&buf->vb.ts);
|
do_gettimeofday(&buf->vb.ts);
|
||||||
|
@ -175,72 +171,61 @@ static void inline buffer_filled (struct tm6000_core *dev,
|
||||||
wake_up(&buf->vb.done);
|
wake_up(&buf->vb.done);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
const char *tm6000_msg_type[] = {
|
||||||
* Macro to allow copying data into the proper memory type
|
"unknown(0)", /* 0 */
|
||||||
*/
|
"video", /* 1 */
|
||||||
|
"audio", /* 2 */
|
||||||
#define bufcpy(buf,out_ptr,in_ptr,size) \
|
"vbi", /* 3 */
|
||||||
{ \
|
"pts", /* 4 */
|
||||||
if (__copy_to_user(out_ptr,in_ptr,size)!=0) \
|
"err", /* 5 */
|
||||||
tm6000_err("copy_to_user failed.\n"); \
|
"unknown(6)", /* 6 */
|
||||||
}
|
"unknown(7)", /* 7 */
|
||||||
|
|
||||||
|
|
||||||
const char *tm6000_msg_type[]= {
|
|
||||||
"unknown(0)", //0
|
|
||||||
"video", //1
|
|
||||||
"audio", //2
|
|
||||||
"vbi", //3
|
|
||||||
"pts", //4
|
|
||||||
"err", //5
|
|
||||||
"unknown(6)", //6
|
|
||||||
"unknown(7)", //7
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Identify the tm5600/6000 buffer header type and properly handles
|
* Identify the tm5600/6000 buffer header type and properly handles
|
||||||
*/
|
*/
|
||||||
static int copy_packet (struct urb *urb, u32 header, u8 **ptr, u8 *endp,
|
static int copy_packet(struct urb *urb, u32 header, u8 **ptr, u8 *endp,
|
||||||
u8 *out_p, struct tm6000_buffer **buf)
|
u8 *out_p, struct tm6000_buffer **buf)
|
||||||
{
|
{
|
||||||
struct tm6000_dmaqueue *dma_q = urb->context;
|
struct tm6000_dmaqueue *dma_q = urb->context;
|
||||||
struct tm6000_core *dev= container_of(dma_q,struct tm6000_core,vidq);
|
struct tm6000_core *dev = container_of(dma_q, struct tm6000_core, vidq);
|
||||||
u8 c;
|
u8 c;
|
||||||
unsigned int cmd, cpysize, pktsize, size, field, block, line, pos=0;
|
unsigned int cmd, cpysize, pktsize, size, field, block, line, pos = 0;
|
||||||
int rc=0;
|
int rc = 0;
|
||||||
/* FIXME: move to tm6000-isoc */
|
/* FIXME: move to tm6000-isoc */
|
||||||
static int last_line=-2, start_line=-2, last_field=-2;
|
static int last_line = -2, start_line = -2, last_field = -2;
|
||||||
|
|
||||||
/* FIXME: this is the hardcoded window size
|
/* FIXME: this is the hardcoded window size
|
||||||
*/
|
*/
|
||||||
unsigned int linewidth=(*buf)->vb.width<<1;
|
unsigned int linewidth = (*buf)->vb.width << 1;
|
||||||
|
|
||||||
c=(header>>24) & 0xff;
|
c = (header >> 24) & 0xff;
|
||||||
|
|
||||||
/* split the header fields */
|
/* split the header fields */
|
||||||
size = (((header & 0x7e)<<1) -1) *4;
|
size = (((header & 0x7e) << 1) - 1) * 4;
|
||||||
block = (header>>7) & 0xf;
|
block = (header >> 7) & 0xf;
|
||||||
field = (header>>11) & 0x1;
|
field = (header >> 11) & 0x1;
|
||||||
line = (header>>12) & 0x1ff;
|
line = (header >> 12) & 0x1ff;
|
||||||
cmd = (header>>21) & 0x7;
|
cmd = (header >> 21) & 0x7;
|
||||||
|
|
||||||
/* Validates header fields */
|
/* Validates header fields */
|
||||||
if(size>TM6000_URB_MSG_LEN)
|
if (size > TM6000_URB_MSG_LEN)
|
||||||
size = TM6000_URB_MSG_LEN;
|
size = TM6000_URB_MSG_LEN;
|
||||||
|
|
||||||
if (cmd == TM6000_URB_MSG_VIDEO) {
|
if (cmd == TM6000_URB_MSG_VIDEO) {
|
||||||
if ((block+1)*TM6000_URB_MSG_LEN>linewidth)
|
if ((block + 1) * TM6000_URB_MSG_LEN > linewidth)
|
||||||
cmd = TM6000_URB_MSG_ERR;
|
cmd = TM6000_URB_MSG_ERR;
|
||||||
|
|
||||||
/* FIXME: Mounts the image as field0+field1
|
/* FIXME: Mounts the image as field0+field1
|
||||||
* It should, instead, check if the user selected
|
* It should, instead, check if the user selected
|
||||||
* entrelaced or non-entrelaced mode
|
* entrelaced or non-entrelaced mode
|
||||||
*/
|
*/
|
||||||
pos= ((line<<1)+field)*linewidth +
|
pos = ((line << 1) + field) * linewidth +
|
||||||
block*TM6000_URB_MSG_LEN;
|
block * TM6000_URB_MSG_LEN;
|
||||||
|
|
||||||
/* Don't allow to write out of the buffer */
|
/* Don't allow to write out of the buffer */
|
||||||
if (pos+TM6000_URB_MSG_LEN > (*buf)->vb.size) {
|
if (pos + TM6000_URB_MSG_LEN > (*buf)->vb.size) {
|
||||||
dprintk(dev, V4L2_DEBUG_ISOC,
|
dprintk(dev, V4L2_DEBUG_ISOC,
|
||||||
"ERR: size=%d, num=%d, line=%d, "
|
"ERR: size=%d, num=%d, line=%d, "
|
||||||
"field=%d\n",
|
"field=%d\n",
|
||||||
|
@ -249,7 +234,7 @@ static int copy_packet (struct urb *urb, u32 header, u8 **ptr, u8 *endp,
|
||||||
cmd = TM6000_URB_MSG_ERR;
|
cmd = TM6000_URB_MSG_ERR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pos=0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prints debug info */
|
/* Prints debug info */
|
||||||
|
@ -273,60 +258,59 @@ static int copy_packet (struct urb *urb, u32 header, u8 **ptr, u8 *endp,
|
||||||
}
|
}
|
||||||
dev->isoc_ctl.last_line = line;
|
dev->isoc_ctl.last_line = line;
|
||||||
|
|
||||||
if ((last_line!=line)&&(last_line+1!=line) &&
|
if ((last_line != line) && (last_line + 1 != line) &&
|
||||||
(cmd != TM6000_URB_MSG_ERR) ) {
|
(cmd != TM6000_URB_MSG_ERR)) {
|
||||||
if (cmd != TM6000_URB_MSG_VIDEO) {
|
if (cmd != TM6000_URB_MSG_VIDEO) {
|
||||||
dprintk(dev, V4L2_DEBUG_ISOC, "cmd=%d, "
|
dprintk(dev, V4L2_DEBUG_ISOC, "cmd=%d, "
|
||||||
"size=%d, num=%d, line=%d, field=%d\n",
|
"size=%d, num=%d, line=%d, field=%d\n",
|
||||||
cmd, size, block, line, field);
|
cmd, size, block, line, field);
|
||||||
}
|
}
|
||||||
if (start_line<0)
|
if (start_line < 0)
|
||||||
start_line=last_line;
|
start_line = last_line;
|
||||||
/* Prints debug info */
|
/* Prints debug info */
|
||||||
dprintk(dev, V4L2_DEBUG_ISOC, "lines= %d-%d, "
|
dprintk(dev, V4L2_DEBUG_ISOC, "lines= %d-%d, "
|
||||||
"field=%d\n",
|
"field=%d\n",
|
||||||
start_line, last_line, field);
|
start_line, last_line, field);
|
||||||
|
|
||||||
if ((start_line<6 && last_line>200) &&
|
if ((start_line < 6 && last_line > 200) &&
|
||||||
(last_field != field) ) {
|
(last_field != field)) {
|
||||||
|
|
||||||
dev->isoc_ctl.nfields++;
|
dev->isoc_ctl.nfields++;
|
||||||
if (dev->isoc_ctl.nfields>=2) {
|
if (dev->isoc_ctl.nfields >= 2)
|
||||||
dev->isoc_ctl.nfields=0;
|
dev->isoc_ctl.nfields = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_line=line;
|
start_line = line;
|
||||||
last_field=field;
|
last_field = field;
|
||||||
}
|
}
|
||||||
last_line=line;
|
last_line = line;
|
||||||
|
|
||||||
pktsize = TM6000_URB_MSG_LEN;
|
pktsize = TM6000_URB_MSG_LEN;
|
||||||
|
|
||||||
cpysize=(endp-(*ptr)>size)?size:endp-(*ptr);
|
cpysize = (endp-(*ptr) > size) ? size : endp - *ptr;
|
||||||
|
|
||||||
if (cpysize) {
|
if (cpysize) {
|
||||||
/* handles each different URB message */
|
/* handles each different URB message */
|
||||||
switch(cmd) {
|
switch (cmd) {
|
||||||
case TM6000_URB_MSG_VIDEO:
|
case TM6000_URB_MSG_VIDEO:
|
||||||
/* Fills video buffer */
|
/* Fills video buffer */
|
||||||
if (__copy_to_user(&out_p[pos],*ptr,cpysize)!=0)
|
if (__copy_to_user(&out_p[pos], *ptr, cpysize) != 0)
|
||||||
tm6000_err("copy_to_user failed.\n");
|
tm6000_err("copy_to_user failed.\n");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TM6000_URB_MSG_PTS:
|
case TM6000_URB_MSG_PTS:
|
||||||
break;
|
break;
|
||||||
case TM6000_URB_MSG_AUDIO:
|
case TM6000_URB_MSG_AUDIO:
|
||||||
/* Need some code to process audio */
|
/* Need some code to process audio */
|
||||||
printk ("%ld: cmd=%s, size=%d\n", jiffies,
|
printk(KERN_INFO "%ld: cmd=%s, size=%d\n", jiffies,
|
||||||
tm6000_msg_type[cmd],size);
|
tm6000_msg_type[cmd], size);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dprintk (dev, V4L2_DEBUG_ISOC, "cmd=%s, size=%d\n",
|
dprintk(dev, V4L2_DEBUG_ISOC, "cmd=%s, size=%d\n",
|
||||||
tm6000_msg_type[cmd],size);
|
tm6000_msg_type[cmd], size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(*ptr)+=cpysize;
|
(*ptr) += cpysize;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -335,10 +319,10 @@ static int copy_streams(u8 *data, u8 *out_p, unsigned long len,
|
||||||
struct urb *urb, struct tm6000_buffer **buf)
|
struct urb *urb, struct tm6000_buffer **buf)
|
||||||
{
|
{
|
||||||
struct tm6000_dmaqueue *dma_q = urb->context;
|
struct tm6000_dmaqueue *dma_q = urb->context;
|
||||||
struct tm6000_core *dev= container_of(dma_q,struct tm6000_core,vidq);
|
struct tm6000_core *dev = container_of(dma_q, struct tm6000_core, vidq);
|
||||||
u8 *ptr, *endp;
|
u8 *ptr, *endp;
|
||||||
unsigned long header=0;
|
unsigned long header = 0;
|
||||||
int rc=0, size;
|
int rc = 0, size;
|
||||||
|
|
||||||
/* Process pending data */
|
/* Process pending data */
|
||||||
if (dev->isoc_ctl.pending) {
|
if (dev->isoc_ctl.pending) {
|
||||||
|
@ -347,26 +331,26 @@ static int copy_streams(u8 *data, u8 *out_p, unsigned long len,
|
||||||
|
|
||||||
/* Seek for sync */
|
/* Seek for sync */
|
||||||
endp = dev->isoc_ctl.tbuf + sizeof(dev->isoc_ctl.tbuf);
|
endp = dev->isoc_ctl.tbuf + sizeof(dev->isoc_ctl.tbuf);
|
||||||
for (ptr = dev->isoc_ctl.tbuf;ptr < endp - 3;ptr++) {
|
for (ptr = dev->isoc_ctl.tbuf; ptr < endp - 3; ptr++) {
|
||||||
if (*(ptr + 3) == 0x47)
|
if (*(ptr + 3) == 0x47)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
header=*(unsigned long *)ptr;
|
header = *(unsigned long *)ptr;
|
||||||
size = (((header & 0x7e) << 1) - 1) * 4;
|
size = (((header & 0x7e) << 1) - 1) * 4;
|
||||||
if(size > TM6000_URB_MSG_LEN)
|
if (size > TM6000_URB_MSG_LEN)
|
||||||
size = TM6000_URB_MSG_LEN;
|
size = TM6000_URB_MSG_LEN;
|
||||||
|
|
||||||
if (ptr+3+size >= endp) {
|
if (ptr + 3 + size >= endp) {
|
||||||
printk(KERN_ERR "tm6000: broken data\n");
|
printk(KERN_ERR "tm6000: broken data\n");
|
||||||
ptr = data;
|
ptr = data;
|
||||||
goto process_new_uri;
|
goto process_new_uri;
|
||||||
}
|
}
|
||||||
ptr+=4;
|
ptr += 4;
|
||||||
|
|
||||||
/* Copy or continue last copy */
|
/* Copy or continue last copy */
|
||||||
rc=copy_packet(urb, header, &ptr, endp, out_p, buf);
|
rc = copy_packet(urb, header, &ptr, endp, out_p, buf);
|
||||||
if (rc<0) {
|
if (rc < 0) {
|
||||||
buf=NULL;
|
buf = NULL;
|
||||||
printk(KERN_ERR "tm6000: buffer underrun at %ld\n",
|
printk(KERN_ERR "tm6000: buffer underrun at %ld\n",
|
||||||
jiffies);
|
jiffies);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -378,33 +362,33 @@ static int copy_streams(u8 *data, u8 *out_p, unsigned long len,
|
||||||
|
|
||||||
process_new_uri:
|
process_new_uri:
|
||||||
endp = data + len;
|
endp = data + len;
|
||||||
while (ptr<endp) {
|
while (ptr < endp) {
|
||||||
if (!dev->isoc_ctl.pending) {
|
if (!dev->isoc_ctl.pending) {
|
||||||
/* Seek for sync */
|
/* Seek for sync */
|
||||||
for (;ptr<endp-3;ptr++) {
|
for (; ptr < endp - 3; ptr++) {
|
||||||
if (*(ptr+3)==0x47)
|
if (*(ptr + 3) == 0x47)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
header=*(unsigned long *)ptr;
|
header = *(unsigned long *)ptr;
|
||||||
size = (((header & 0x7e)<<1) -1) *4;
|
size = (((header & 0x7e) << 1) - 1) * 4;
|
||||||
if(size>TM6000_URB_MSG_LEN)
|
if (size > TM6000_URB_MSG_LEN)
|
||||||
size = TM6000_URB_MSG_LEN;
|
size = TM6000_URB_MSG_LEN;
|
||||||
|
|
||||||
if (ptr+3+size >= endp) {
|
if (ptr + 3 + size >= endp) {
|
||||||
int len = endp - ptr;
|
int len = endp - ptr;
|
||||||
|
|
||||||
memcpy (dev->isoc_ctl.tbuf, ptr, len);
|
memcpy(dev->isoc_ctl.tbuf, ptr, len);
|
||||||
dev->isoc_ctl.len = len;
|
dev->isoc_ctl.len = len;
|
||||||
dev->isoc_ctl.pending = 1;
|
dev->isoc_ctl.pending = 1;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
ptr+=4;
|
ptr += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy or continue last copy */
|
/* Copy or continue last copy */
|
||||||
rc=copy_packet(urb, header, &ptr, endp, out_p, buf);
|
rc = copy_packet(urb, header, &ptr, endp, out_p, buf);
|
||||||
if (rc<0) {
|
if (rc < 0) {
|
||||||
buf=NULL;
|
buf = NULL;
|
||||||
printk(KERN_ERR "tm6000: buffer underrun at %ld\n",
|
printk(KERN_ERR "tm6000: buffer underrun at %ld\n",
|
||||||
jiffies);
|
jiffies);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -420,40 +404,42 @@ static int copy_multiplexed(u8 *ptr, u8 *out_p, unsigned long len,
|
||||||
struct urb *urb, struct tm6000_buffer **buf)
|
struct urb *urb, struct tm6000_buffer **buf)
|
||||||
{
|
{
|
||||||
struct tm6000_dmaqueue *dma_q = urb->context;
|
struct tm6000_dmaqueue *dma_q = urb->context;
|
||||||
struct tm6000_core *dev= container_of(dma_q,struct tm6000_core,vidq);
|
struct tm6000_core *dev = container_of(dma_q, struct tm6000_core, vidq);
|
||||||
unsigned int pos=dev->isoc_ctl.pos,cpysize;
|
unsigned int pos = dev->isoc_ctl.pos, cpysize;
|
||||||
int rc=1;
|
int rc = 1;
|
||||||
|
|
||||||
while (len>0) {
|
while (len > 0) {
|
||||||
cpysize=min(len,(*buf)->vb.size-pos);
|
cpysize = min(len, (*buf)->vb.size-pos);
|
||||||
//printk("Copying %d bytes (max=%lu) from %p to %p[%u]\n",cpysize,(*buf)->vb.size,ptr,out_p,pos);
|
|
||||||
bufcpy(*buf,&out_p[pos],ptr,cpysize);
|
if (__copy_to_user(&out_p[pos], ptr, cpysize) != 0)
|
||||||
pos+=cpysize;
|
tm6000_err("copy_to_user failed.\n");
|
||||||
ptr+=cpysize;
|
|
||||||
len-=cpysize;
|
pos += cpysize;
|
||||||
|
ptr += cpysize;
|
||||||
|
len -= cpysize;
|
||||||
if (pos >= (*buf)->vb.size) {
|
if (pos >= (*buf)->vb.size) {
|
||||||
pos=0;
|
pos = 0;
|
||||||
/* Announces that a new buffer were filled */
|
/* Announces that a new buffer were filled */
|
||||||
buffer_filled (dev, dma_q, *buf);
|
buffer_filled(dev, dma_q, *buf);
|
||||||
dprintk(dev, V4L2_DEBUG_ISOC, "new buffer filled\n");
|
dprintk(dev, V4L2_DEBUG_ISOC, "new buffer filled\n");
|
||||||
rc=get_next_buf (dma_q, buf);
|
rc = get_next_buf(dma_q, buf);
|
||||||
if (rc<=0) {
|
if (rc <= 0) {
|
||||||
*buf=NULL;
|
*buf = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->isoc_ctl.pos=pos;
|
dev->isoc_ctl.pos = pos;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void inline print_err_status (struct tm6000_core *dev,
|
static inline void print_err_status(struct tm6000_core *dev,
|
||||||
int packet, int status)
|
int packet, int status)
|
||||||
{
|
{
|
||||||
char *errmsg = "Unknown";
|
char *errmsg = "Unknown";
|
||||||
|
|
||||||
switch(status) {
|
switch (status) {
|
||||||
case -ENOENT:
|
case -ENOENT:
|
||||||
errmsg = "unlinked synchronuously";
|
errmsg = "unlinked synchronuously";
|
||||||
break;
|
break;
|
||||||
|
@ -479,11 +465,12 @@ static void inline print_err_status (struct tm6000_core *dev,
|
||||||
errmsg = "Device does not respond";
|
errmsg = "Device does not respond";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (packet<0) {
|
if (packet < 0) {
|
||||||
dprintk(dev, V4L2_DEBUG_QUEUE, "URB status %d [%s].\n",
|
dprintk(dev, V4L2_DEBUG_QUEUE, "URB status %d [%s].\n",
|
||||||
status, errmsg);
|
status, errmsg);
|
||||||
} else {
|
} else {
|
||||||
dprintk(dev, V4L2_DEBUG_QUEUE, "URB packet %d, status %d [%s].\n",
|
dprintk(dev, V4L2_DEBUG_QUEUE,
|
||||||
|
"URB packet %d, status %d [%s].\n",
|
||||||
packet, status, errmsg);
|
packet, status, errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,45 +482,40 @@ static void inline print_err_status (struct tm6000_core *dev,
|
||||||
static inline int tm6000_isoc_copy(struct urb *urb, struct tm6000_buffer **buf)
|
static inline int tm6000_isoc_copy(struct urb *urb, struct tm6000_buffer **buf)
|
||||||
{
|
{
|
||||||
struct tm6000_dmaqueue *dma_q = urb->context;
|
struct tm6000_dmaqueue *dma_q = urb->context;
|
||||||
struct tm6000_core *dev= container_of(dma_q,struct tm6000_core,vidq);
|
struct tm6000_core *dev = container_of(dma_q, struct tm6000_core, vidq);
|
||||||
void *outp=videobuf_to_vmalloc (&((*buf)->vb));
|
void *outp = videobuf_to_vmalloc(&((*buf)->vb));
|
||||||
int i, len=0, rc=1;
|
int i, len = 0, rc = 1;
|
||||||
int size=(*buf)->vb.size;
|
int size = (*buf)->vb.size;
|
||||||
char *p;
|
char *p;
|
||||||
unsigned long copied;
|
unsigned long copied = 0;
|
||||||
|
|
||||||
copied=0;
|
if (urb->status < 0) {
|
||||||
|
print_err_status(dev, -1, urb->status);
|
||||||
if (urb->status<0) {
|
|
||||||
print_err_status (dev,-1,urb->status);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < urb->number_of_packets; i++) {
|
for (i = 0; i < urb->number_of_packets; i++) {
|
||||||
int status = urb->iso_frame_desc[i].status;
|
int status = urb->iso_frame_desc[i].status;
|
||||||
|
|
||||||
if (status<0) {
|
if (status < 0) {
|
||||||
print_err_status (dev,i,status);
|
print_err_status(dev, i, status);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
len=urb->iso_frame_desc[i].actual_length;
|
len = urb->iso_frame_desc[i].actual_length;
|
||||||
|
|
||||||
// if (len>=TM6000_URB_MSG_LEN) {
|
p = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
|
||||||
p=urb->transfer_buffer + urb->iso_frame_desc[i].offset;
|
if (!urb->iso_frame_desc[i].status) {
|
||||||
if (!urb->iso_frame_desc[i].status) {
|
if (((*buf)->fmt->fourcc) == V4L2_PIX_FMT_TM6000) {
|
||||||
if (((*buf)->fmt->fourcc)==V4L2_PIX_FMT_TM6000) {
|
rc = copy_multiplexed(p, outp, len, urb, buf);
|
||||||
rc=copy_multiplexed(p,outp,len,urb,buf);
|
if (rc <= 0)
|
||||||
if (rc<=0)
|
return rc;
|
||||||
return rc;
|
} else
|
||||||
} else {
|
copy_streams(p, outp, len, urb, buf);
|
||||||
copy_streams(p,outp,len,urb,buf);
|
}
|
||||||
}
|
copied += len;
|
||||||
}
|
if (copied >= size)
|
||||||
copied += len;
|
break;
|
||||||
if (copied>=size)
|
|
||||||
break;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -549,43 +531,41 @@ static void tm6000_irq_callback(struct urb *urb)
|
||||||
{
|
{
|
||||||
struct tm6000_buffer *buf;
|
struct tm6000_buffer *buf;
|
||||||
struct tm6000_dmaqueue *dma_q = urb->context;
|
struct tm6000_dmaqueue *dma_q = urb->context;
|
||||||
struct tm6000_core *dev= container_of(dma_q,struct tm6000_core,vidq);
|
struct tm6000_core *dev = container_of(dma_q, struct tm6000_core, vidq);
|
||||||
int rc,i;
|
int rc, i;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->slock,flags);
|
spin_lock_irqsave(&dev->slock, flags);
|
||||||
|
|
||||||
buf=dev->isoc_ctl.buf;
|
buf = dev->isoc_ctl.buf;
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
rc=get_next_buf (dma_q, &buf);
|
rc = get_next_buf(dma_q, &buf);
|
||||||
if (rc<=0)
|
if (rc <= 0)
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy data from URB */
|
/* Copy data from URB */
|
||||||
rc=tm6000_isoc_copy(urb, &buf);
|
rc = tm6000_isoc_copy(urb, &buf);
|
||||||
|
|
||||||
dev->isoc_ctl.buf=buf;
|
dev->isoc_ctl.buf = buf;
|
||||||
ret:
|
ret:
|
||||||
/* Reset urb buffers */
|
/* Reset urb buffers */
|
||||||
for (i = 0; i < urb->number_of_packets; i++) {
|
for (i = 0; i < urb->number_of_packets; i++) {
|
||||||
urb->iso_frame_desc[i].status = 0;
|
urb->iso_frame_desc[i].status = 0;
|
||||||
urb->iso_frame_desc[i].actual_length = 0;
|
urb->iso_frame_desc[i].actual_length = 0;
|
||||||
}
|
}
|
||||||
urb->status = 0;
|
|
||||||
|
|
||||||
if ((urb->status = usb_submit_urb(urb, GFP_ATOMIC))) {
|
urb->status = usb_submit_urb(urb, GFP_ATOMIC);
|
||||||
|
if (urb->status)
|
||||||
tm6000_err("urb resubmit failed (error=%i)\n",
|
tm6000_err("urb resubmit failed (error=%i)\n",
|
||||||
urb->status);
|
urb->status);
|
||||||
}
|
|
||||||
|
|
||||||
if (rc>=0) {
|
/* Data filled, reset watchdog */
|
||||||
/* Data filled, reset watchdog */
|
if (rc >= 0)
|
||||||
mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
|
mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
|
||||||
// }
|
|
||||||
}
|
spin_unlock_irqrestore(&dev->slock, flags);
|
||||||
spin_unlock_irqrestore(&dev->slock,flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -641,7 +621,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev,
|
||||||
int max_packets, int num_bufs)
|
int max_packets, int num_bufs)
|
||||||
{
|
{
|
||||||
struct tm6000_dmaqueue *dma_q = &dev->vidq;
|
struct tm6000_dmaqueue *dma_q = &dev->vidq;
|
||||||
int i, rc;
|
int i;
|
||||||
int sb_size, pipe;
|
int sb_size, pipe;
|
||||||
struct urb *urb;
|
struct urb *urb;
|
||||||
int j, k;
|
int j, k;
|
||||||
|
@ -700,7 +680,6 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev,
|
||||||
}
|
}
|
||||||
memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size);
|
memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size);
|
||||||
|
|
||||||
|
|
||||||
pipe=usb_rcvisocpipe(dev->udev,
|
pipe=usb_rcvisocpipe(dev->udev,
|
||||||
dev->isoc_in->desc.bEndpointAddress &
|
dev->isoc_in->desc.bEndpointAddress &
|
||||||
USB_ENDPOINT_NUMBER_MASK);
|
USB_ENDPOINT_NUMBER_MASK);
|
||||||
|
|
Loading…
Reference in a new issue