From fa59c01eadd849ed2e5b0cf1406347bf632c80ed Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Mon, 13 Apr 2009 20:02:34 +0200 Subject: libv4l: add video processing: whitebalance and normalize From: Hans de Goede As the version number shows this work is the basis for a beta release of the 0.6.x series, the big change here is the addition of video processing to libv4l currently this only does whitebalance and normalizing (which turns out to be useless for most cams) but the basic framework for doing video processing, and being able to control it through fake v4l2 controls using for example v4l2ucp is there. The initial version of this code was written by 3 of my computer science students: Elmar Kleijn, Sjoerd Piepenbrink and Radjnies Bhansingh. This initial hg commit is a cleaned up and somewhat bug fixed version of their code. Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/include/libv4lconvert.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'v4l2-apps/libv4l/include') diff --git a/v4l2-apps/libv4l/include/libv4lconvert.h b/v4l2-apps/libv4l/include/libv4lconvert.h index 626c43473..fcc31dace 100644 --- a/v4l2-apps/libv4l/include/libv4lconvert.h +++ b/v4l2-apps/libv4l/include/libv4lconvert.h @@ -81,6 +81,14 @@ LIBV4L_PUBLIC int v4lconvert_enum_framesizes(struct v4lconvert_data *data, LIBV4L_PUBLIC int v4lconvert_enum_frameintervals(struct v4lconvert_data *data, struct v4l2_frmivalenum *frmival); +/* Pass calls to query, get and set video controls to the libv4lcontrol class */ +LIBV4L_PUBLIC int v4lconvert_vidioc_queryctrl(struct v4lconvert_data *data, + void *arg); +LIBV4L_PUBLIC int v4lconvert_vidioc_g_ctrl(struct v4lconvert_data *data, + void *arg); +LIBV4L_PUBLIC int v4lconvert_vidioc_s_ctrl(struct v4lconvert_data *data, + void *arg); + #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit v1.2.3 From 58d3334b54c207b8e04e7035969e0c2acfa1ce73 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Tue, 14 Apr 2009 15:03:07 +0200 Subject: libv4l: Only allow supported destination formats when doing processing From: Hans de Goede Only report / allow supported destination formats in enum_fmt / try_fmt / g_fmt / s_fmt when processing, rotating or flipping. Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/include/libv4lconvert.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'v4l2-apps/libv4l/include') diff --git a/v4l2-apps/libv4l/include/libv4lconvert.h b/v4l2-apps/libv4l/include/libv4lconvert.h index fcc31dace..7901b35dc 100644 --- a/v4l2-apps/libv4l/include/libv4lconvert.h +++ b/v4l2-apps/libv4l/include/libv4lconvert.h @@ -42,18 +42,30 @@ struct v4lconvert_data; LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create(int fd); LIBV4L_PUBLIC void v4lconvert_destroy(struct v4lconvert_data *data); +/* When doing flipping / rotating / video-processing, only supported + destination formats can be used (as flipping / rotating / video-processing + is not supported on other formats). This function can be used to query + if that is the case. */ +LIBV4L_PUBLIC int v4lconvert_supported_dst_fmt_only( + struct v4lconvert_data *data); + /* With regards to dest_fmt just like VIDIOC_TRY_FMT, except that the try format will succeed and return the requested V4L2_PIX_FMT_foo in dest_fmt if the cam has a format from which v4lconvert can convert to dest_fmt. The real format to which the cam should be set is returned through src_fmt - when not NULL. */ + when not NULL. + Note that just like the real VIDIOC_TRY_FMT this function will change the + dest_fmt when not supported. This includes changing it to a supported + destination format when trying a native format of the camera and + v4lconvert_supported_dst_fmt_only() returns true. */ LIBV4L_PUBLIC int v4lconvert_try_format(struct v4lconvert_data *data, struct v4l2_format *dest_fmt, /* in / out */ struct v4l2_format *src_fmt /* out */ ); -/* Just like VIDIOC_ENUM_FMT, except that the emulated formats are added at - the end of the list */ +/* Like VIDIOC_ENUM_FMT, but the emulated formats are added at the end of the + list, except if flipping / processing is active for the device, then only + supported destination formats are listed */ LIBV4L_PUBLIC int v4lconvert_enum_fmt(struct v4lconvert_data *data, struct v4l2_fmtdesc *fmt); /* Is conversion necessary or can the app use the data directly? */ @@ -89,6 +101,9 @@ LIBV4L_PUBLIC int v4lconvert_vidioc_g_ctrl(struct v4lconvert_data *data, LIBV4L_PUBLIC int v4lconvert_vidioc_s_ctrl(struct v4lconvert_data *data, void *arg); +/* Is the passed in pixelformat supported as destination format ? */ +LIBV4L_PUBLIC int v4lconvert_supported_dst_format(unsigned int pixelformat); + #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit v1.2.3 From 2ffc360be1c38ab86399d6d574ee7cc0671c03d6 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Mon, 25 May 2009 15:35:21 +0200 Subject: libv4l: Obsolete the V4L2_ENABLE_ENUM_FMT_EMULATION v4l2_fd_open flag From: Hans de Goede The V4L2_ENABLE_ENUM_FMT_EMULATION v4l2_fd_open flag is obsolete, libv4l2 now *always* reports emulated formats through the ENUM_FMT ioctl Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/include/libv4l2.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'v4l2-apps/libv4l/include') diff --git a/v4l2-apps/libv4l/include/libv4l2.h b/v4l2-apps/libv4l/include/libv4l2.h index b05b57cb6..b2451dced 100644 --- a/v4l2-apps/libv4l/include/libv4l2.h +++ b/v4l2-apps/libv4l/include/libv4l2.h @@ -41,18 +41,12 @@ LIBV4L_PUBLIC extern FILE *v4l2_log_file; format which is not supported by the cam, but is supported by libv4lconvert, then the try_fmt / set_fmt will succeed as if the cam supports the format and on dqbuf / read the data will be converted for you and returned in - the request format. + the request format. enum_fmt will also report support for the formats to + which conversion is possible. Another difference is that you can make v4l2_read() calls even on devices which do not support the regular read() method. - Note that libv4l2 normally does not interfere with enum_fmt, so enum_fmt - will still return the actual formats the hardware supports, and not any - formats which may be emulated on top of that. If you pass the - V4L2_ENABLE_ENUM_FMT_EMULATION flag to v4l2_fd_open (as the v4l2convert.so - wrapper does) then enum_fmt will also report support for the formats to - which conversion is possible. - Note the device name passed to v4l2_open must be of a video4linux2 device, if it is anything else (including a video4linux1 device), v4l2_open will fail. @@ -89,11 +83,14 @@ LIBV4L_PUBLIC int v4l2_get_control(int fd, int cid); /* Flags for v4l2_fd_open's v4l2_flags argument */ -/* Disable all format conversion done by libv4l2 (reduces libv4l2 functionality - to offering v4l2_read() even on devices which don't implement read()) */ +/* Disable all format conversion done by libv4l2, this includes the software + whitebalance, gamma correction, flipping, etc. libv4lconvert does. Use this + if you want raw frame data, but still want the additional error checks and + the read() emulation libv4l2 offers. */ #define V4L2_DISABLE_CONVERSION 0x01 -/* Report not only real but also emulated formats with the ENUM_FMT ioctl */ -#define V4L2_ENABLE_ENUM_FMT_EMULATION 02 +/* This flag is *OBSOLETE*, since version 0.5.98 libv4l *always* reports + emulated formats to ENUM_FMT, except when conversion is disabled. */ +#define V4L2_ENABLE_ENUM_FMT_EMULATION 0x02 /* v4l2_fd_open: open an already opened fd for further use through v4l2lib and possibly modify libv4l2's default behavior through the -- cgit v1.2.3 From 5999b7d164dbf3118a3a75ee3f6f0b48cb8845c1 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Tue, 2 Jun 2009 15:34:34 +0200 Subject: libv4l: initial support for compiling on FreeBSD From: Hans Petter Selasky Add a patch by Hans Petter Selasky , which should lead to allowing use of libv4l (and the Linux webcam drivers ported to userspace usb drivers) on FreeBSd, this is a work in progress Priority: normal Signed-off-by: Hans Petter Selasky Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/include/libv4l1.h | 2 +- v4l2-apps/libv4l/include/libv4l2.h | 2 +- v4l2-apps/libv4l/include/libv4lconvert.h | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'v4l2-apps/libv4l/include') diff --git a/v4l2-apps/libv4l/include/libv4l1.h b/v4l2-apps/libv4l/include/libv4l1.h index c878cc198..4ddf8efdb 100644 --- a/v4l2-apps/libv4l/include/libv4l1.h +++ b/v4l2-apps/libv4l/include/libv4l1.h @@ -63,7 +63,7 @@ LIBV4L_PUBLIC int v4l1_dup(int fd); LIBV4L_PUBLIC int v4l1_ioctl (int fd, unsigned long int request, ...); LIBV4L_PUBLIC ssize_t v4l1_read (int fd, void* buffer, size_t n); LIBV4L_PUBLIC void *v4l1_mmap(void *start, size_t length, int prot, int flags, int fd, - __off64_t offset); + int64_t offset); LIBV4L_PUBLIC int v4l1_munmap(void *_start, size_t length); #ifdef __cplusplus diff --git a/v4l2-apps/libv4l/include/libv4l2.h b/v4l2-apps/libv4l/include/libv4l2.h index b2451dced..0403a29dd 100644 --- a/v4l2-apps/libv4l/include/libv4l2.h +++ b/v4l2-apps/libv4l/include/libv4l2.h @@ -58,7 +58,7 @@ 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 void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd, - __off64_t offset); + int64_t offset); LIBV4L_PUBLIC int v4l2_munmap(void *_start, size_t length); diff --git a/v4l2-apps/libv4l/include/libv4lconvert.h b/v4l2-apps/libv4l/include/libv4lconvert.h index 7901b35dc..b274c938b 100644 --- a/v4l2-apps/libv4l/include/libv4lconvert.h +++ b/v4l2-apps/libv4l/include/libv4lconvert.h @@ -21,10 +21,21 @@ /* These headers are not needed by us, but by linux/videodev2.h, which is broken on some systems and doesn't include them itself :( */ + +#ifdef linux #include #include #include +#endif + +#ifdef __FreeBSD__ +#include +#include +#include +#endif + /* end broken header workaround includes */ + #include #ifdef __cplusplus -- cgit v1.2.3 From 4dc7af7e5508c90e1117c8cc909ec1b7acb1979a Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Fri, 12 Jun 2009 10:42:17 +0200 Subject: libv4l: add missing stdint.h include to libv4l2.h From: Hans de Goede libv4l: add missing stdint.h include to libv4l2.h Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/include/libv4l2.h | 1 + 1 file changed, 1 insertion(+) (limited to 'v4l2-apps/libv4l/include') diff --git a/v4l2-apps/libv4l/include/libv4l2.h b/v4l2-apps/libv4l/include/libv4l2.h index 0403a29dd..7ecbb2cee 100644 --- a/v4l2-apps/libv4l/include/libv4l2.h +++ b/v4l2-apps/libv4l/include/libv4l2.h @@ -21,6 +21,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { -- cgit v1.2.3