This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/v4l-utils.git tree:
Subject: libv4l: Add v4l2_write function and plugin op Author: Hans de Goede <[email protected]> Date: Sun Jul 24 19:35:11 2011 +0200 Signed-off-by: Hans de Goede <[email protected]> lib/include/libv4l2-plugin.h | 10 ++++++++++ lib/include/libv4l2.h | 1 + lib/libv4l2/libv4l2.c | 21 +++++++++++++++++++++ lib/libv4l2/v4l2-plugin.c | 14 ++++++++++---- lib/libv4lconvert/libv4lsyscall-priv.h | 4 ++-- 5 files changed, 44 insertions(+), 6 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=17da0f9320ddfb12ae61b3cdfebbbf2a58ff5810 diff --git a/lib/include/libv4l2-plugin.h b/lib/include/libv4l2-plugin.h index 158c0c2..150eb17 100644 --- a/lib/include/libv4l2-plugin.h +++ b/lib/include/libv4l2-plugin.h @@ -31,6 +31,16 @@ struct libv4l2_dev_ops { void (*close)(void *dev_ops_priv); int (*ioctl)(void *dev_ops_priv, int fd, unsigned long int request, void *arg); ssize_t (*read)(void *dev_ops_priv, int fd, void *buffer, size_t n); + ssize_t (*write)(void *dev_ops_priv, int fd, const void *buffer, size_t n); + /* For future plugin API extension, plugins implementing the current API + must set these all to NULL, as future versions may check for these */ + void (*reserved1)(void); + void (*reserved2)(void); + void (*reserved3)(void); + void (*reserved4)(void); + void (*reserved5)(void); + void (*reserved6)(void); + void (*reserved7)(void); }; #endif diff --git a/lib/include/libv4l2.h b/lib/include/libv4l2.h index 1985e08..20960d2 100644 --- a/lib/include/libv4l2.h +++ b/lib/include/libv4l2.h @@ -70,6 +70,7 @@ LIBV4L_PUBLIC int v4l2_close(int fd); LIBV4L_PUBLIC int v4l2_dup(int fd); LIBV4L_PUBLIC int v4l2_ioctl(int fd, unsigned long int request, ...); LIBV4L_PUBLIC ssize_t v4l2_read(int fd, void *buffer, size_t n); +LIBV4L_PUBLIC ssize_t v4l2_write(int fd, const void *buffer, size_t n); LIBV4L_PUBLIC void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd, int64_t offset); LIBV4L_PUBLIC int v4l2_munmap(void *_start, size_t length); diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c index 04689b8..c8e75f7 100644 --- a/lib/libv4l2/libv4l2.c +++ b/lib/libv4l2/libv4l2.c @@ -1414,6 +1414,11 @@ ssize_t v4l2_read(int fd, void *dest, size_t n) if (index == -1) return SYS_READ(fd, dest, n); + if (!devices[index].dev_ops->read) { + errno = EINVAL; + return -1; + } + pthread_mutex_lock(&devices[index].stream_lock); /* When not converting and the device supports read let the kernel handle @@ -1466,6 +1471,22 @@ leave: return result; } +ssize_t v4l2_write(int fd, const void *buffer, size_t n) +{ + int index = v4l2_get_index(fd); + + if (index == -1) + return SYS_WRITE(fd, buffer, n); + + if (!devices[index].dev_ops->write) { + errno = EINVAL; + return -1; + } + + return devices[index].dev_ops->write( + devices[index].dev_ops_priv, fd, buffer, n); +} + void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd, int64_t offset) { diff --git a/lib/libv4l2/v4l2-plugin.c b/lib/libv4l2/v4l2-plugin.c index 3c513a7..0b74d2e 100644 --- a/lib/libv4l2/v4l2-plugin.c +++ b/lib/libv4l2/v4l2-plugin.c @@ -66,11 +66,18 @@ static ssize_t dev_read(void *dev_ops_priv, int fd, void *buf, size_t len) return SYS_READ(fd, buf, len); } +static ssize_t dev_write(void *dev_ops_priv, int fd, const void *buf, + size_t len) +{ + return SYS_WRITE(fd, buf, len); +} + const struct libv4l2_dev_ops libv4l2_default_dev_ops = { .init = dev_init, .close = dev_close, .ioctl = dev_ioctl, - .read = dev_read + .read = dev_read, + .write = dev_write, }; void v4l2_plugin_init(int fd, void **plugin_lib_ret, void **plugin_priv_ret, @@ -113,9 +120,8 @@ void v4l2_plugin_init(int fd, void **plugin_lib_ret, void **plugin_priv_ret, if (!libv4l2_plugin->init || !libv4l2_plugin->close || - !libv4l2_plugin->ioctl || - !libv4l2_plugin->read) { - V4L2_LOG("PLUGIN: does not have all functions\n"); + !libv4l2_plugin->ioctl) { + V4L2_LOG("PLUGIN: does not have all mandatory ops\n"); dlclose(plugin_library); continue; } diff --git a/lib/libv4lconvert/libv4lsyscall-priv.h b/lib/libv4lconvert/libv4lsyscall-priv.h index 87028ef..8d8a1d1 100644 --- a/lib/libv4lconvert/libv4lsyscall-priv.h +++ b/lib/libv4lconvert/libv4lsyscall-priv.h @@ -81,7 +81,7 @@ typedef off_t __off_t; #define SYS_READ(fd, buf, len) \ syscall(SYS_read, (int)(fd), (void *)(buf), (size_t)(len)); #define SYS_WRITE(fd, buf, len) \ - syscall(SYS_write, (int)(fd), (void *)(buf), (size_t)(len)); + syscall(SYS_write, (int)(fd), (const void *)(buf), (size_t)(len)); #ifdef __FreeBSD__ #define SYS_MMAP(addr, len, prot, flags, fd, off) \ @@ -102,7 +102,7 @@ int v4lx_open_wrapper(const char *, int, int); int v4lx_close_wrapper(int); int v4lx_ioctl_wrapper(int, unsigned long, void *); int v4lx_read_wrapper(int, void *, size_t); -int v4lx_write_wrapper(int, void *, size_t); +int v4lx_write_wrapper(int, const void *, size_t); void *v4lx_mmap_wrapper(void *, size_t, int, int, int, off_t); int v4lx_munmap_wrapper(void *, size_t); _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
