Hi Laurent, > -----Original Message----- > From: Laurent Pinchart [mailto:laurent.pinchart@xxxxxxxxxxxxxxxx] > Sent: Thursday, March 28, 2013 2:35 PM > To: Bhupesh SHARMA > Cc: linux-usb@xxxxxxxxxxxxxxx; balbi@xxxxxx; bhupesh.linux@xxxxxxxxx; > mgr@xxxxxxxxxxxxxx; gang.chen@xxxxxxxxxxx; tipecaml@xxxxxxxxx > Subject: Re: [PATCH V5 1/2] usb: gadget/uvc: Port UVC webcam gadget to > use videobuf2 framework > > Hi Bhupesh, > > Thanks for the patch. We're almost there :-) > > On Thursday 28 March 2013 10:39:13 Bhupesh Sharma wrote: > > This patch reworks the videobuffer management logic present in the UVC > > webcam gadget and ports it to use the "more apt" videobuf2 framework > > for video buffer management. > > > > To support routing video data captured from a real V4L2 video capture > > device with a "zero copy" operation on videobuffers (as they pass from > > the V4L2 domain to UVC domain via a user-space application), we need > > to support USER_PTR IO method at the UVC gadget side. > > > > So the V4L2 capture device driver can still continue to use MMAP IO > > method and now the user-space application can just pass a pointer to > > the video buffers being dequeued from the V4L2 device side while > > queueing them at the UVC gadget end. This ensures that we have a "zero- > copy" > > design as the videobuffers pass from the V4L2 capture device to the > > UVC gadget. > > > > Note that there will still be a need to apply UVC specific payload > > headers on top of each UVC payload data, which will still require a > > copy operation to be performed in the 'encode' routines of the UVC > gadget. > > > > This patch also addresses one issue found out while porting the UVC > > gadget to videobuf2 framework: > > - In case the usb requests queued by the gadget get completed > > with a status of -ESHUTDOWN (disconnected from host), > > the queue of videobuf2 should be cancelled to ensure that the > > application space daemon is not left in a state waiting for > > a vb2 to be successfully absorbed at the USB side. > > > > Signed-off-by: Bhupesh Sharma <bhupesh.sharma@xxxxxx> > > [snip] > > > diff --git a/drivers/usb/gadget/uvc_queue.c > > b/drivers/usb/gadget/uvc_queue.c index 104ae9c..0d30171 100644 > > --- a/drivers/usb/gadget/uvc_queue.c > > +++ b/drivers/usb/gadget/uvc_queue.c > > [snip] > > > > +static int uvc_queue_buffer(struct uvc_video_queue *queue, > > + struct v4l2_buffer *buf) > > +{ > > + unsigned long flags; > > + int ret; > > > > + mutex_lock(&queue->mutex); > > spin_lock_irqsave(&queue->irqlock, flags); > > + ret = vb2_qbuf(&queue->queue, buf); > > vb2_qbuf() must be called before spin_lock_irqsave(), as the > uvc_buffer_queue() operation takes the same lock. The spin lock must thus > protect the two lines below only. Ok. V6 will fix this issue. Regards, Bhupesh > > ret = (queue->flags & UVC_QUEUE_PAUSED) != 0; > > queue->flags &= ~UVC_QUEUE_PAUSED; > > spin_unlock_irqrestore(&queue->irqlock, flags); > > mutex_unlock(&queue->mutex); > > > > + return ret; > > } > > -- > Regards, > > Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html