Hi Cédric, On Saturday 18 April 2009 19:29:32 [email protected] wrote: > Hello everyone, > > I am using the webcam to do some traking. I noticed some latency during > fast motion. > > For example, with luvcview, when I do a movement with my hand and stop, I > can see my hand on the screen trying to catch up and stops about 1 sec > after I actually stopped. > > In the source code, I saw that Laurent Pinchart uses 4 user buffers. I am > pretty sure they are not the main reason of this latency. So, I went > through the uvcvideo driver source code and I saw that is is also 5 URBs. > > If I understood well, URBs are for IRQs. > Is there a minimum of URBs to use?
URB stands for USB Request Block. See http://www.mjmwired.net/kernel/Documentation/usb/URB.txt for more information. > Is there a way to not use any user buffer (in the queue->mainqueue)? > Or basically, what is the minimale configuration? > (2URBs & 2user buffers)? > (2URBs & 0user buffers)? > (0URBs & 2user buffers)? > (1URBs & 1user buffers)? You definitely need both URBs and V4L2 buffers, otherwise no data will be transferred at all (this will get rid of latency, but probably not the way you want it to :-)). Decreasing the number of URBs or buffers will not reduce latency per se. Isochronous URBs (I assume your device uses an isochronous endpoint to stream video data) group several isochronous packet transfers. The more packets per URB, the bigger the delay between uvcvideo driver video completion callbacks. However, this only matters for the last URB of each frame, as the driver has to wait until the end of frame before handing it to the application. For example, when using 32 packets per URB, there can be at most a 31 packets delay between the last packet of a frame and the time the completion callback is called. This introduces latency. Lowering the number of packets per URB will reduce latency, but will also eats CPU cycles. Make sure you increase the number of URBs if you reduce the number of packets, otherwise you might lose packets if the CPU doesn't cope with the higher number of interrupts. Similarly, V4L2 buffers don't introduce latency. They are used to transfer video data between the driver and the userspace application in such a way that short temporary increases in the userspace processing delay doesn't result in frame loss. The buffer queue can, however, hold frames, making latency more noticeable if the application can't cope with incoming data fast enough. As a summary, latency is the sum of - camera latency - USB transfer time - interrupt latency on the host (lowering the number of packets per URB can reduce this) - userspace application latency The first thing to do, before hacking the driver, is to make sure the userspace application is fast enough and can cope with the frame rate. If it can't, you could drop a frame from times to times. Best regards, Laurent Pinchart _______________________________________________ Linux-uvc-devel mailing list [email protected] https://lists.berlios.de/mailman/listinfo/linux-uvc-devel
