diff options
author | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-08-03 19:25:44 +0200 |
---|---|---|
committer | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-08-03 19:25:44 +0200 |
commit | 7ab958ab10b1a5c28dc0c0c798939c57e41e40a4 (patch) | |
tree | d5cd3bf410fcf0394d94c4a7fefb6c0bd793484a /v4l2-apps/lib/libv4l/libv4l2/libv4l2.c | |
parent | a1c8635315d9fcc9768035549e3ff5ea61f1faf2 (diff) | |
download | mediapointer-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/libv4l/libv4l2/libv4l2.c')
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4l2/libv4l2.c | 12 |
1 files changed, 12 insertions, 0 deletions
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) { |