libv4l: Fix reqbuf Device or Resource busy error when using read
authorhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>
Fri, 14 Aug 2009 07:50:33 +0000 (09:50 +0200)
committerhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>
Fri, 14 Aug 2009 07:50:33 +0000 (09:50 +0200)
commitfb7932c068705de264bf31e273839a5ddd3165b1
treeb9f686a0fd09ab3336013605621188e55aacf5e9
parentf5f02b0bd33a7fa20de9b74e16f1563d04cf3880
libv4l: Fix reqbuf Device or Resource busy error when using read

From: Hans de Goede <hdegoede@redhat.com>

Some applications such as v4l2-apps/test/capture-example.c, in read mode
use select() together with read() and do a select() before the first read().

This causes issues together with certain drivers (gspca for example),
do not allow switching from read mode to mmap mode and they assume read()
mode if a select or poll() is done before any buffers are requested.

When not using libv4l2, this is not an issue but libv4l2 uses mmap mode
under the hood when converting as that safes a memcpy for each frame read.

This fails with such drivers when the application has done a select() before
the first read() as the driver now is in "read mode" and disallows switching
to mmap mode.

This patch fixes this by falling back to using read() for v4l2_read() when
using mmap mode fails.

Priority: normal

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
lib/ChangeLog
lib/libv4l2/libv4l2-priv.h
lib/libv4l2/libv4l2.c