summaryrefslogtreecommitdiff
path: root/v4l2-apps/lib
diff options
context:
space:
mode:
authorhans@localhost.localdomain <hans@localhost.localdomain>2008-08-03 19:25:44 +0200
committerhans@localhost.localdomain <hans@localhost.localdomain>2008-08-03 19:25:44 +0200
commit7ab958ab10b1a5c28dc0c0c798939c57e41e40a4 (patch)
treed5cd3bf410fcf0394d94c4a7fefb6c0bd793484a /v4l2-apps/lib
parenta1c8635315d9fcc9768035549e3ff5ea61f1faf2 (diff)
downloadmediapointer-dvb-s2-7ab958ab10b1a5c28dc0c0c798939c57e41e40a4.tar.gz
mediapointer-dvb-s2-7ab958ab10b1a5c28dc0c0c798939c57e41e40a4.tar.bz2
libv4l: use driver read() when possible
From: Hans de Goede <j.w.r.degoede@hhs.nl> When the driver supports read() and we are not converting let the driver handle read() instead of emulating it with mmap mode Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Diffstat (limited to 'v4l2-apps/lib')
-rw-r--r--v4l2-apps/lib/libv4l/ChangeLog6
-rw-r--r--v4l2-apps/lib/libv4l/Makefile2
-rw-r--r--v4l2-apps/lib/libv4l/libv4l2/libv4l2.c12
3 files changed, 19 insertions, 1 deletions
diff --git a/v4l2-apps/lib/libv4l/ChangeLog b/v4l2-apps/lib/libv4l/ChangeLog
index 675019bd2..3d4e40ad2 100644
--- a/v4l2-apps/lib/libv4l/ChangeLog
+++ b/v4l2-apps/lib/libv4l/ChangeLog
@@ -1,3 +1,9 @@
+libv4l-0.4.1
+------------
+* When the driver supports read() and we are not converting let the driver
+ handle read() instead of emulating it with mmap mode
+
+
libv4l-0.4.0
------------
* Be more relaxed in our checks for mixing read and mmap access, we were
diff --git a/v4l2-apps/lib/libv4l/Makefile b/v4l2-apps/lib/libv4l/Makefile
index 7f8867cd9..31254a09e 100644
--- a/v4l2-apps/lib/libv4l/Makefile
+++ b/v4l2-apps/lib/libv4l/Makefile
@@ -1,5 +1,5 @@
LIB_RELEASE=0
-V4L2_LIB_VERSION=$(LIB_RELEASE).4.0
+V4L2_LIB_VERSION=$(LIB_RELEASE).4.1
all clean install:
$(MAKE) -C libv4lconvert V4L2_LIB_VERSION=$(V4L2_LIB_VERSION) $@
diff --git a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c b/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
index fc41c665d..a40ab4ffe 100644
--- a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
+++ b/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
@@ -75,6 +75,7 @@
#define V4L2_STREAMON 0x0100
#define V4L2_BUFFERS_REQUESTED_BY_READ 0x0200
#define V4L2_STREAM_CONTROLLED_BY_READ 0x0400
+#define V4L2_SUPPORTS_READ 0x0800
#define V4L2_MMAP_OFFSET_MAGIC 0xABCDEF00u
@@ -456,6 +457,8 @@ int v4l2_fd_open(int fd, int v4l2_flags)
}
devices[index].flags = v4l2_flags;
+ if (cap.capabilities & V4L2_CAP_READWRITE)
+ devices[index].flags |= V4L2_SUPPORTS_READ;
devices[index].open_count = 1;
devices[index].src_fmt = fmt;
devices[index].dest_fmt = fmt;
@@ -908,6 +911,15 @@ ssize_t v4l2_read (int fd, void* buffer, size_t n)
pthread_mutex_lock(&devices[index].stream_lock);
+ /* When not converting and the device supports read let the kernel handle
+ it */
+ if ((devices[index].flags & V4L2_SUPPORTS_READ) &&
+ devices[index].src_fmt.fmt.pix.pixelformat ==
+ devices[index].dest_fmt.fmt.pix.pixelformat) {
+ result = syscall(SYS_read, fd, buffer, n);
+ goto leave;
+ }
+
if (!(devices[index].flags & V4L2_STREAM_CONTROLLED_BY_READ)) {
if ((devices[index].flags & V4L2_STREAMON) ||
devices[index].frame_queued) {