diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-08 07:20:50 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-08 07:20:50 -0300 |
commit | 9380e197397e3f8404fa2d2effe5c84b6f56735b (patch) | |
tree | 81fcf4dc9edfd73f6e0ff211cb2df17a9e79dc16 /v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c | |
parent | ea33affdbd8d71fab71e3f62845b9239d6f60ff8 (diff) | |
parent | 4e748efa7677d0762f4b1738cd8869df5eb106b6 (diff) | |
download | mediapointer-dvb-s2-9380e197397e3f8404fa2d2effe5c84b6f56735b.tar.gz mediapointer-dvb-s2-9380e197397e3f8404fa2d2effe5c84b6f56735b.tar.bz2 |
merge: http://www.linuxtv.org/hg/~tmerle/v4l2-library
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c')
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c b/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c new file mode 100644 index 000000000..db3a0027b --- /dev/null +++ b/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c @@ -0,0 +1,117 @@ +/* +# open/close/ioctl/mmap/munmap library call wrapper doing v4l1 api emulation +# for v4l2 devices + +# (C) 2008 Hans de Goede <j.w.r.degoede@hhs.nl> + +# 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 +*/ + +#define _LARGEFILE64_SOURCE 1 + +#include <stdlib.h> +#include <stdarg.h> +#include <fcntl.h> +#include <libv4l1.h> + +/* 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 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); +} + +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); +} + +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); +} |