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: Move dev ops to libv4lconvert Author: Gregor Jasny <[email protected]> Date: Mon Jun 11 21:59:25 2012 +0200 As discussed with Hans de Goede, this patch moves the plugin dev-ops structure to libv4lconvert. It was also renamed to libv4l_dev_ops. As a positive side effect we restored SONAME compatibility with the 0.8.x releases. Signed-off-by: Gregor Jasny <[email protected]> lib/include/libv4l-plugin.h | 46 +++++++++++++++++++++++ lib/include/libv4l2-plugin.h | 46 ----------------------- lib/include/libv4l2.h | 5 --- lib/include/libv4lconvert.h | 10 +++-- lib/libv4l2/Makefile.am | 2 +- lib/libv4l2/libv4l2-priv.h | 6 ++-- lib/libv4l2/libv4l2.c | 6 ++-- lib/libv4l2/v4l2-plugin.c | 45 +++-------------------- lib/libv4lconvert/Makefile.am | 2 +- lib/libv4lconvert/control/libv4lcontrol-priv.h | 4 +- lib/libv4lconvert/control/libv4lcontrol.c | 2 +- lib/libv4lconvert/control/libv4lcontrol.h | 4 +- lib/libv4lconvert/libv4lconvert-priv.h | 3 +- lib/libv4lconvert/libv4lconvert.c | 47 +++++++++++++++++++++++- utils/qv4l2/qv4l2.cpp | 3 +- 15 files changed, 119 insertions(+), 112 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=e0384a01debc87e11fa0b015a7f64419eb161221 diff --git a/lib/include/libv4l-plugin.h b/lib/include/libv4l-plugin.h new file mode 100644 index 0000000..23b2dfb --- /dev/null +++ b/lib/include/libv4l-plugin.h @@ -0,0 +1,46 @@ +/* +* Copyright (C) 2010 Nokia Corporation <[email protected]> + +* 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 +* Lesser 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 +*/ + +#ifndef __LIBV4L_PLUGIN_H +#define __LIBV4L_PLUGIN_H + +#include <sys/types.h> + +/* Structure libv4l_dev_ops holds the calls from libv4ls to video nodes. + They can be normal open/close/ioctl etc. or any of them may be replaced + with a callback by a loaded plugin. +*/ + +struct libv4l_dev_ops { + void * (*init)(int fd); + 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-plugin.h b/lib/include/libv4l2-plugin.h deleted file mode 100644 index 150eb17..0000000 --- a/lib/include/libv4l2-plugin.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Copyright (C) 2010 Nokia Corporation <[email protected]> - -* 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 -* Lesser 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 -*/ - -#ifndef __LIBV4L2_PLUGIN_H -#define __LIBV4L2_PLUGIN_H - -#include <sys/types.h> - -/* Structure libv4l2_dev_ops holds the calls from libv4ls to video nodes. - They can be normal open/close/ioctl etc. or any of them may be replaced - with a callback by a loaded plugin. -*/ - -struct libv4l2_dev_ops { - void * (*init)(int fd); - 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 20960d2..9ca473e 100644 --- a/lib/include/libv4l2.h +++ b/lib/include/libv4l2.h @@ -37,11 +37,6 @@ extern "C" { status messages to a file, when NULL errors will get send to stderr */ LIBV4L_PUBLIC extern FILE *v4l2_log_file; -/* For apps which want to directly use libv4lconvert, but don't want to - define their own device ops. Apps which do this call v4lconvert_create - with NULL as dev_ops_priv and this as dev_ops parameter */ -LIBV4L_PUBLIC extern const struct libv4l2_dev_ops libv4l2_default_dev_ops; - /* Just like your regular open/close/etc, except that format conversion is done if necessary when capturing. That is if you (try to) set a capture format which is not supported by the cam, but is supported by libv4lconvert, diff --git a/lib/include/libv4lconvert.h b/lib/include/libv4lconvert.h index abce1bd..9ec1cf6 100644 --- a/lib/include/libv4lconvert.h +++ b/lib/include/libv4lconvert.h @@ -38,8 +38,6 @@ #include <linux/videodev2.h> -#include "libv4l2-plugin.h" - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -50,10 +48,14 @@ extern "C" { #define LIBV4L_PUBLIC #endif +struct libv4l_dev_ops; struct v4lconvert_data; -LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create(int fd, - void *dev_ops_priv, const struct libv4l2_dev_ops *dev_ops); +LIBV4L_PUBLIC const struct libv4l_dev_ops *v4lconvert_get_default_dev_ops(); + +LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create(int fd); +LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd, + void *dev_ops_priv, const struct libv4l_dev_ops *dev_ops); LIBV4L_PUBLIC void v4lconvert_destroy(struct v4lconvert_data *data); /* When doing flipping / rotating / video-processing, only supported diff --git a/lib/libv4l2/Makefile.am b/lib/libv4l2/Makefile.am index 6251a3f..34f10ee 100644 --- a/lib/libv4l2/Makefile.am +++ b/lib/libv4l2/Makefile.am @@ -1,6 +1,6 @@ if WITH_LIBV4L lib_LTLIBRARIES = libv4l2.la -include_HEADERS = ../include/libv4l2.h ../include/libv4l2-plugin.h +include_HEADERS = ../include/libv4l2.h ../include/libv4l-plugin.h libv4l2priv_LTLIBRARIES = v4l2convert.la pkgconfig_DATA = libv4l2.pc else diff --git a/lib/libv4l2/libv4l2-priv.h b/lib/libv4l2/libv4l2-priv.h index 9b4de4f..6577055 100644 --- a/lib/libv4l2/libv4l2-priv.h +++ b/lib/libv4l2/libv4l2-priv.h @@ -90,14 +90,14 @@ struct v4l2_dev_info { /* plugin info */ void *plugin_library; void *dev_ops_priv; - const struct libv4l2_dev_ops *dev_ops; + const struct libv4l_dev_ops *dev_ops; }; /* From v4l2-plugin.c */ void v4l2_plugin_init(int fd, void **plugin_lib_ret, void **plugin_priv_ret, - const struct libv4l2_dev_ops **dev_ops_ret); + const struct libv4l_dev_ops **dev_ops_ret); void v4l2_plugin_cleanup(void *plugin_lib, void *plugin_priv, - const struct libv4l2_dev_ops *dev_ops); + const struct libv4l_dev_ops *dev_ops); /* From log.c */ extern const char *v4l2_ioctls[]; diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c index 44fba71..161c44d 100644 --- a/lib/libv4l2/libv4l2.c +++ b/lib/libv4l2/libv4l2.c @@ -68,7 +68,7 @@ #include <sys/stat.h> #include "libv4l2.h" #include "libv4l2-priv.h" -#include "libv4l2-plugin.h" +#include "libv4l-plugin.h" /* Note these flags are stored together with the flags passed to v4l2_fd_open() in v4l2_dev_info's flags member, so care should be taken that the do not @@ -596,7 +596,7 @@ int v4l2_fd_open(int fd, int v4l2_flags) struct v4lconvert_data *convert = NULL; void *plugin_library; void *dev_ops_priv; - const struct libv4l2_dev_ops *dev_ops; + const struct libv4l_dev_ops *dev_ops; v4l2_plugin_init(fd, &plugin_library, &dev_ops_priv, &dev_ops); @@ -640,7 +640,7 @@ int v4l2_fd_open(int fd, int v4l2_flags) /* init libv4lconvert */ if (!(v4l2_flags & V4L2_DISABLE_CONVERSION)) { - convert = v4lconvert_create(fd, dev_ops_priv, dev_ops); + convert = v4lconvert_create_with_dev_ops(fd, dev_ops_priv, dev_ops); if (!convert) { int saved_err = errno; v4l2_plugin_cleanup(plugin_library, dev_ops_priv, diff --git a/lib/libv4l2/v4l2-plugin.c b/lib/libv4l2/v4l2-plugin.c index 2e093c6..fbf92d8 100644 --- a/lib/libv4l2/v4l2-plugin.c +++ b/lib/libv4l2/v4l2-plugin.c @@ -25,7 +25,7 @@ #include <sys/mman.h> #include "libv4l2.h" #include "libv4l2-priv.h" -#include "libv4l2-plugin.h" +#include "libv4l-plugin.h" /* libv4l plugin support: it is provided by functions v4l2_plugin_[open,close,etc]. @@ -48,49 +48,16 @@ #define PLUGINS_PATTERN LIBV4L2_PLUGIN_DIR "/*.so" -static void *dev_init(int fd) -{ - return NULL; -} - -static void dev_close(void *dev_ops_priv) -{ -} - -static int dev_ioctl(void *dev_ops_priv, int fd, unsigned long cmd, void *arg) -{ - return SYS_IOCTL(fd, cmd, arg); -} - -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, - .write = dev_write, -}; - void v4l2_plugin_init(int fd, void **plugin_lib_ret, void **plugin_priv_ret, - const struct libv4l2_dev_ops **dev_ops_ret) + const struct libv4l_dev_ops **dev_ops_ret) { char *error; int glob_ret, i; void *plugin_library = NULL; - const struct libv4l2_dev_ops *libv4l2_plugin = NULL; + const struct libv4l_dev_ops *libv4l2_plugin = NULL; glob_t globbuf; - *dev_ops_ret = &libv4l2_default_dev_ops; + *dev_ops_ret = v4lconvert_get_default_dev_ops(); *plugin_lib_ret = NULL; *plugin_priv_ret = NULL; @@ -110,7 +77,7 @@ void v4l2_plugin_init(int fd, void **plugin_lib_ret, void **plugin_priv_ret, continue; dlerror(); /* Clear any existing error */ - libv4l2_plugin = (struct libv4l2_dev_ops *) + libv4l2_plugin = (struct libv4l_dev_ops *) dlsym(plugin_library, "libv4l2_plugin"); error = dlerror(); if (error != NULL) { @@ -144,7 +111,7 @@ leave: } void v4l2_plugin_cleanup(void *plugin_lib, void *plugin_priv, - const struct libv4l2_dev_ops *dev_ops) + const struct libv4l_dev_ops *dev_ops) { if (plugin_lib) { dev_ops->close(plugin_priv); diff --git a/lib/libv4lconvert/Makefile.am b/lib/libv4lconvert/Makefile.am index 3744cc3..a903ce7 100644 --- a/lib/libv4lconvert/Makefile.am +++ b/lib/libv4lconvert/Makefile.am @@ -21,7 +21,7 @@ if HAVE_JPEG libv4lconvert_la_SOURCES += jpeg_memsrcdest.c jpeg_memsrcdest.h endif libv4lconvert_la_CPPFLAGS = -fvisibility=hidden $(ENFORCE_LIBV4L_STATIC) -libv4lconvert_la_LDFLAGS = -version-info 1 -lrt -lm $(JPEG_LIBS) $(ENFORCE_LIBV4L_STATIC) +libv4lconvert_la_LDFLAGS = -version-info 0 -lrt -lm $(JPEG_LIBS) $(ENFORCE_LIBV4L_STATIC) ov511_decomp_SOURCES = ov511-decomp.c diff --git a/lib/libv4lconvert/control/libv4lcontrol-priv.h b/lib/libv4lconvert/control/libv4lcontrol-priv.h index d91ae69..5268b7c 100644 --- a/lib/libv4lconvert/control/libv4lcontrol-priv.h +++ b/lib/libv4lconvert/control/libv4lcontrol-priv.h @@ -22,7 +22,7 @@ #ifndef __LIBV4LCONTROL_PRIV_H #define __LIBV4LCONTROL_PRIV_H -#include "libv4l2-plugin.h" +#include "libv4l-plugin.h" #define V4LCONTROL_SHM_SIZE 4096 @@ -41,7 +41,7 @@ struct v4lcontrol_data { unsigned int old_values[V4LCONTROL_COUNT]; /* for controls_changed() */ const struct v4lcontrol_flags_info *flags_info; void *dev_ops_priv; - const struct libv4l2_dev_ops *dev_ops; + const struct libv4l_dev_ops *dev_ops; }; struct v4lcontrol_flags_info { diff --git a/lib/libv4lconvert/control/libv4lcontrol.c b/lib/libv4lconvert/control/libv4lcontrol.c index 6db78dc..1272256 100644 --- a/lib/libv4lconvert/control/libv4lcontrol.c +++ b/lib/libv4lconvert/control/libv4lcontrol.c @@ -546,7 +546,7 @@ static void v4lcontrol_get_flags_from_db(struct v4lcontrol_data *data, } struct v4lcontrol_data *v4lcontrol_create(int fd, void *dev_ops_priv, - const struct libv4l2_dev_ops *dev_ops, int always_needs_conversion) + const struct libv4l_dev_ops *dev_ops, int always_needs_conversion) { int shm_fd; int i, rc, got_usb_info, speed, init = 0; diff --git a/lib/libv4lconvert/control/libv4lcontrol.h b/lib/libv4lconvert/control/libv4lcontrol.h index 00ffb34..804f1c5 100644 --- a/lib/libv4lconvert/control/libv4lcontrol.h +++ b/lib/libv4lconvert/control/libv4lcontrol.h @@ -22,7 +22,7 @@ #ifndef __LIBV4LCONTROL_H #define __LIBV4LCONTROL_H -#include "libv4l2-plugin.h" +#include "libv4l-plugin.h" /* Flags */ #define V4LCONTROL_HFLIPPED 0x01 @@ -51,7 +51,7 @@ enum { struct v4lcontrol_data; struct v4lcontrol_data *v4lcontrol_create(int fd, void *dev_ops_priv, - const struct libv4l2_dev_ops *dev_ops, int always_needs_conversion); + const struct libv4l_dev_ops *dev_ops, int always_needs_conversion); void v4lcontrol_destroy(struct v4lcontrol_data *data); int v4lcontrol_get_bandwidth(struct v4lcontrol_data *data); diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h index ac02371..c37e220 100644 --- a/lib/libv4lconvert/libv4lconvert-priv.h +++ b/lib/libv4lconvert/libv4lconvert-priv.h @@ -27,6 +27,7 @@ #include <jpeglib.h> #endif #include <setjmp.h> +#include "libv4l-plugin.h" #include "libv4lconvert.h" #include "control/libv4lcontrol.h" #include "processing/libv4lprocessing.h" @@ -77,7 +78,7 @@ struct v4lconvert_data { struct v4lcontrol_data *control; struct v4lprocessing_data *processing; void *dev_ops_priv; - const struct libv4l2_dev_ops *dev_ops; + const struct libv4l_dev_ops *dev_ops; /* Data for external decompression helpers code */ pid_t decompress_pid; diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c index 97d8672..60010f1 100644 --- a/lib/libv4lconvert/libv4lconvert.c +++ b/lib/libv4lconvert/libv4lconvert.c @@ -29,6 +29,44 @@ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) +static void *dev_init(int fd) +{ + return NULL; +} + +static void dev_close(void *dev_ops_priv) +{ +} + +static int dev_ioctl(void *dev_ops_priv, int fd, unsigned long cmd, void *arg) +{ + return SYS_IOCTL(fd, cmd, arg); +} + +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); +} + +static const struct libv4l_dev_ops default_dev_ops = { + .init = dev_init, + .close = dev_close, + .ioctl = dev_ioctl, + .read = dev_read, + .write = dev_write, +}; + +const struct libv4l_dev_ops *v4lconvert_get_default_dev_ops() +{ + return &default_dev_ops; +} + static void v4lconvert_get_framesizes(struct v4lconvert_data *data, unsigned int pixelformat, int index); @@ -109,8 +147,13 @@ static const int v4lconvert_crop_res[][2] = { { 176, 144 }, }; -struct v4lconvert_data *v4lconvert_create(int fd, void *dev_ops_priv, - const struct libv4l2_dev_ops *dev_ops) +struct v4lconvert_data *v4lconvert_create(int fd) +{ + return v4lconvert_create_with_dev_ops(fd, NULL, &default_dev_ops); +} + +struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd, void *dev_ops_priv, + const struct libv4l_dev_ops *dev_ops) { int i, j; struct v4lconvert_data *data = calloc(1, sizeof(struct v4lconvert_data)); diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp index 1f3c6e9..fe4f4e9 100644 --- a/utils/qv4l2/qv4l2.cpp +++ b/utils/qv4l2/qv4l2.cpp @@ -153,8 +153,7 @@ void ApplicationWindow::setDevice(const QString &device, bool rawOpen) statusBar()->clearMessage(); m_tabs->show(); m_tabs->setFocus(); - m_convertData = v4lconvert_create(fd(), NULL, - &libv4l2_default_dev_ops); + m_convertData = v4lconvert_create(fd()); m_capStartAct->setEnabled(fd() >= 0 && !m_genTab->isRadio()); } _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
