struct uvc_buffer *buf = NULL;
unsigned long flags;
int ret;
+ int i;
+ atomic_t *urb_state=NULL;
switch (urb->status) {
case 0:
return;
}
+ for (i = 0; i < UVC_URBS; ++i) {
+ if (stream->urb[i] == urb) {
+ urb_state = &stream->urb_state[i];
+ break;
+ }
+ }
+
+ if (urb_state == NULL) {
+ printk("urb(%p) cann't be finded in stream->urb(%p, %p, %p, %p, %p)\n",
+ urb,stream->urb[0],stream->urb[1],stream->urb[2],stream->urb[3],stream->urb[4]);
+ BUG();
+ }
+
+ if (atomic_read(urb_state)==UrbDeactive) {
+ printk(KERN_DEBUG "urb is deactive, this urb complete cancel!");
+ uvc_queue_cancel(queue, urb->status == -ESHUTDOWN);
+ return;
+ }
+
spin_lock_irqsave(&queue->irqlock, flags);
if (!list_empty(&queue->irqqueue))
buf = list_first_entry(&queue->irqqueue, struct uvc_buffer,
queue);
- spin_unlock_irqrestore(&queue->irqlock, flags);
-
+ spin_unlock_irqrestore(&queue->irqlock, flags);
+
stream->decode(urb, stream, buf);
-
+
if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
uvc_printk(KERN_ERR, "Failed to resubmit video URB (%d).\n",
ret);
}
static void uvc_video_complete_tasklet(unsigned long data)
{
- struct urb *urb = (struct urb*)data;
- struct uvc_streaming *stream = urb->context;
- struct tasklet_struct *tasklet = NULL;
- int i;
+ struct urb *urb = (struct urb*)data;
- uvc_video_complete_fun(urb);
- for (i = 0; i < UVC_URBS; ++i) {
- if (stream->urb[i] == urb) {
- tasklet = stream->tasklet[i];
- break;
- }
- }
+ uvc_video_complete_fun(urb);
return;
}
int i;
struct uvc_streaming *stream = urb->context;
struct tasklet_struct *tasklet = NULL;
+ atomic_t *urb_state;
for (i = 0; i < UVC_URBS; ++i) {
if (stream->urb[i] == urb) {
tasklet = stream->tasklet[i];
+ urb_state = &stream->urb_state[i];
break;
}
}
- if (tasklet != NULL) {
+ if ((tasklet != NULL)&&(atomic_read(urb_state)==UrbActive)) {
tasklet_schedule(tasklet);
} else {
uvc_video_complete_fun(urb);
urb = stream->urb[i];
if (urb == NULL)
continue;
-
- /* ddl@rock-chips.com: Tasklet must be kill before kill urb in uninit */
+ else
+ atomic_set(&stream->urb_state[i],UrbDeactive);
+
if (stream->tasklet[i]) {
tasklet_kill(stream->tasklet[i]);
kfree(stream->tasklet[i]);
stream->urb[i] = urb;
/* ddl@rock-chips.com */
+ atomic_set(&stream->urb_state[i],UrbActive);
stream->tasklet[i] = kmalloc(sizeof(struct tasklet_struct), GFP_KERNEL);
if (stream->tasklet[i] == NULL) {
uvc_printk(KERN_ERR, "device %s requested tasklet memory fail!\n",