From 1e8ee38c5ab44a4b296a8d47c22691d82e7515be Mon Sep 17 00:00:00 2001 From: Thierry MERLE Date: Tue, 1 Jul 2008 21:16:07 +0200 Subject: v4l2-library: libv4l1 and v4l1compat From: Hans de Goede libv4l1 is the base of the v4l1compat.so wrapper lib, which is a .so which can be LD_PRELOAD-ed and the overrules the libc's open/close/etc, and when opening /dev/videoX calls v4l1_open. Signed-off-by: Hans de Goede Signed-off-by: Thierry MERLE --- v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c (limited to 'v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c') diff --git a/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c b/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c new file mode 100644 index 000000000..3300d56d9 --- /dev/null +++ b/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c @@ -0,0 +1,88 @@ +/* +# open/close/ioctl/mmap/munmap library call wrapper doing v4l1 api emulation +# for v4l2 devices + +# (C) 2008 Hans de Goede + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include + +/* Check that open/read/mmap is not a define */ +#if defined open || defined read || defined mmap +#error open/read/mmap is a prepocessor macro !! +#endif + +int open (const char *file, int oflag, ...) +{ + int fd; + + if (oflag & O_CREAT) + { + va_list ap; + mode_t mode; + + va_start (ap, oflag); + mode = va_arg (ap, mode_t); + + fd = v4l1_open(file, oflag, mode); + + va_end(ap); + } else + fd = v4l1_open(file, oflag); + + return fd; +} + +int close(int fd) { + return v4l1_close(fd); +} + +int dup(int fd) +{ + return v4l1_dup(fd); +} + +int ioctl (int fd, unsigned long int request, ...) +{ + void *arg; + va_list ap; + + va_start (ap, request); + arg = va_arg (ap, void *); + va_end (ap); + + return v4l1_ioctl (fd, request, arg); +} + +ssize_t read(int fd, void* buffer, size_t n) +{ + return v4l1_read (fd, buffer, n); +} + +void mmap(void *start, size_t length, int prot, int flags, int fd, + off_t offset) +{ + return v4l1_mmap(start, length, prot, flags, fd, offset); +} + +int munmap(void *start, size_t length) +{ + return v4l1_munmap(start, length); +} -- cgit v1.2.3 From 63c4e4bef7b1537de4e313ee9d20907a372d8f56 Mon Sep 17 00:00:00 2001 From: Thierry MERLE Date: Fri, 4 Jul 2008 19:30:13 +0200 Subject: v4l2-library: libv4l-warnings.patch From: Hans de Goede Fix all compiler warnings in libv4l Signed-off-by: Hans de Goede Signed-off-by: Thierry MERLE --- v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c') diff --git a/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c b/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c index 3300d56d9..4a4e5c253 100644 --- a/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c +++ b/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c @@ -77,7 +77,7 @@ ssize_t read(int fd, void* buffer, size_t n) } void mmap(void *start, size_t length, int prot, int flags, int fd, - off_t offset) + __off_t offset) { return v4l1_mmap(start, length, prot, flags, fd, offset); } -- cgit v1.2.3 From ab715d2e8eb29998b60fa3bbc1ad95441cfb69b3 Mon Sep 17 00:00:00 2001 From: Thierry MERLE Date: Sun, 6 Jul 2008 14:07:34 +0200 Subject: v4l2-library: libv4l-sync-with-0.3.3-release From: Hans de Goede * Add open64 and mmap64 wrappers to the LD_PRELOAD wrapper libs, so that they also work for applications compiled with FILE_OFFSET_BITS=64, this fixes using them with v4l-info * While looking at xawtv in general, found a few bugs in xawtv itself, added a patch to fix those to the appl-patches dir * Talking about the appl-patches dir, restore that as it accidentally got dropped from 0.3.2 * Be more verbose in various places when it comes to logging (esp errors) * Change v4lconvert_enum_fmt code a bit, so that it is easier to add more supported destination formats to libv4lconvert * Don't return -EINVAL from try_fmt when we cannot convert because the cam doesn't have any formats we know. Instead just return as format whatever the cam returns from try_fmt, this new behavior is compliant with the v4l2 api as documented Signed-off-by: Hans de Goede Signed-off-by: Thierry MERLE --- v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c') diff --git a/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c b/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c index 4a4e5c253..db3a0027b 100644 --- a/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c +++ b/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c @@ -19,6 +19,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _LARGEFILE64_SOURCE 1 + #include #include #include @@ -50,6 +52,27 @@ int open (const char *file, int oflag, ...) return fd; } +int open64 (const char *file, int oflag, ...) +{ + int fd; + + if (oflag & O_CREAT) + { + va_list ap; + mode_t mode; + + va_start (ap, oflag); + mode = va_arg (ap, mode_t); + + fd = v4l1_open(file, oflag | O_LARGEFILE, mode); + + va_end(ap); + } else + fd = v4l1_open(file, oflag | O_LARGEFILE); + + return fd; +} + int close(int fd) { return v4l1_close(fd); } @@ -82,6 +105,12 @@ void mmap(void *start, size_t length, int prot, int flags, int fd, return v4l1_mmap(start, length, prot, flags, fd, offset); } +void mmap64(void *start, size_t length, int prot, int flags, int fd, + __off64_t offset) +{ + return v4l1_mmap(start, length, prot, flags, fd, offset); +} + int munmap(void *start, size_t length) { return v4l1_munmap(start, length); -- cgit v1.2.3