diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-12 11:10:42 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-12 11:10:42 -0300 |
commit | 7787613f5c5a3a00ebd6aca9893ef2c4ad679bc1 (patch) | |
tree | 4ffb8dbda509405c10b484edacb44807b16c5466 /v4l2-apps/libv4l/include | |
parent | 84c19b03d182a3ad1a04fa4be0772ef587225fe6 (diff) | |
parent | d32bcc1401cca5f2ea369ce78ab70947034b5c8f (diff) | |
download | mediapointer-dvb-s2-7787613f5c5a3a00ebd6aca9893ef2c4ad679bc1.tar.gz mediapointer-dvb-s2-7787613f5c5a3a00ebd6aca9893ef2c4ad679bc1.tar.bz2 |
merge: http://jusst.de/hg/v4l-dvb
From: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'v4l2-apps/libv4l/include')
-rw-r--r-- | v4l2-apps/libv4l/include/libv4l1.h | 73 | ||||
-rw-r--r-- | v4l2-apps/libv4l/include/libv4l2.h | 110 | ||||
-rw-r--r-- | v4l2-apps/libv4l/include/libv4lconvert.h | 88 |
3 files changed, 271 insertions, 0 deletions
diff --git a/v4l2-apps/libv4l/include/libv4l1.h b/v4l2-apps/libv4l/include/libv4l1.h new file mode 100644 index 000000000..c878cc198 --- /dev/null +++ b/v4l2-apps/libv4l/include/libv4l1.h @@ -0,0 +1,73 @@ +/* +# (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 +*/ + +#ifndef __LIBV4L1_H +#define __LIBV4L1_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <stdio.h> +#include <unistd.h> + +#if __GNUC__ >= 4 +#define LIBV4L_PUBLIC __attribute__ ((visibility("default"))) +#else +#define LIBV4L_PUBLIC +#endif + +/* Point this to a FILE opened for writing when you want to log error and + status messages to a file, when NULL errors will get send to stderr */ +LIBV4L_PUBLIC extern FILE *v4l1_log_file; + +/* Just like your regular open/close/etc, except that when opening a v4l2 + capture only device, full v4l1 emulation is done including emulating the + often not implemented in v4l2 drivers CGMBUF ioctl and v4l1 style mmap call + in userspace. + + 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 then SPICT will succeed and on SYNC / read the + data will be converted for you and returned in the request format. + + Note that currently libv4l1 depends on the kernel v4l1 compatibility layer + for: 1) Devices which are not capture only, 2) Emulation of many basic + v4l1 ioctl's which require no driver specific handling. + + Note that no functionality is added to v4l1 devices, so if for example an + obscure v4l1 device is opened which only supports some weird capture format + then libv4l1 will not be of any help (in this case it would be best to get + the driver converted to v4l2, as v4l2 has been designed to include weird + capture formats, like hw specific bayer compression methods). +*/ + +LIBV4L_PUBLIC int v4l1_open (const char *file, int oflag, ...); +LIBV4L_PUBLIC int v4l1_close(int fd); +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); +LIBV4L_PUBLIC int v4l1_munmap(void *_start, size_t length); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/v4l2-apps/libv4l/include/libv4l2.h b/v4l2-apps/libv4l/include/libv4l2.h new file mode 100644 index 000000000..b05b57cb6 --- /dev/null +++ b/v4l2-apps/libv4l/include/libv4l2.h @@ -0,0 +1,110 @@ +/* +# (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 +*/ + +#ifndef __LIBV4L2_H +#define __LIBV4L2_H + +#include <stdio.h> +#include <unistd.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if __GNUC__ >= 4 +#define LIBV4L_PUBLIC __attribute__ ((visibility("default"))) +#else +#define LIBV4L_PUBLIC +#endif + +/* Point this to a FILE opened for writing when you want to log error and + status messages to a file, when NULL errors will get send to stderr */ +LIBV4L_PUBLIC extern FILE *v4l2_log_file; + +/* 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, + 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. + + 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. +*/ + +LIBV4L_PUBLIC int v4l2_open (const char *file, int oflag, ...); +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 void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd, + __off64_t offset); +LIBV4L_PUBLIC int v4l2_munmap(void *_start, size_t length); + + +/* Misc utility functions */ + +/* This function takes a value of 0 - 65535, and then scales that range to + the actual range of the given v4l control id, and then if the cid exists + and is not locked sets the cid to the scaled value. + + Normally returns 0, even if the cid did not exist or was locked, returns + non 0 when an other error occured. */ +LIBV4L_PUBLIC int v4l2_set_control(int fd, int cid, int value); + +/* This function returns a value of 0 - 65535, scaled to from the actual range + of the given v4l control id. when the cid does not exist, could not be + accessed for some reason, or some error occured 0 is returned. */ +LIBV4L_PUBLIC int v4l2_get_control(int fd, int cid); + + +/* "low level" access functions, these functions allow somewhat lower level + access to libv4l2 (currently there only is v4l2_fd_open here) */ + +/* 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()) */ +#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 + +/* v4l2_fd_open: open an already opened fd for further use through + v4l2lib and possibly modify libv4l2's default behavior through the + v4l2_flags argument. + + Returns fd on success, -1 if the fd is not suitable for use through libv4l2 + (note the fd is left open in this case). */ +LIBV4L_PUBLIC int v4l2_fd_open(int fd, int v4l2_flags); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/v4l2-apps/libv4l/include/libv4lconvert.h b/v4l2-apps/libv4l/include/libv4lconvert.h new file mode 100644 index 000000000..626c43473 --- /dev/null +++ b/v4l2-apps/libv4l/include/libv4lconvert.h @@ -0,0 +1,88 @@ +/* +# (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 +*/ + +#ifndef __LIBV4LCONVERT_H +#define __LIBV4LCONVERT_H + +/* These headers are not needed by us, but by linux/videodev2.h, + which is broken on some systems and doesn't include them itself :( */ +#include <sys/time.h> +#include <linux/types.h> +#include <linux/ioctl.h> +/* end broken header workaround includes */ +#include <linux/videodev2.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if __GNUC__ >= 4 +#define LIBV4L_PUBLIC __attribute__ ((visibility("default"))) +#else +#define LIBV4L_PUBLIC +#endif + +struct v4lconvert_data; + +LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create(int fd); +LIBV4L_PUBLIC void v4lconvert_destroy(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. */ +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 */ +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? */ +LIBV4L_PUBLIC int v4lconvert_needs_conversion(struct v4lconvert_data *data, + const struct v4l2_format *src_fmt, /* in */ + const struct v4l2_format *dest_fmt); /* in */ + +/* return value of -1 on error, otherwise the amount of bytes written to + dest */ +LIBV4L_PUBLIC int v4lconvert_convert(struct v4lconvert_data *data, + const struct v4l2_format *src_fmt, /* in */ + const struct v4l2_format *dest_fmt, /* in */ + unsigned char *src, int src_size, unsigned char *dest, int dest_size); + +/* get a string describing the last error*/ +LIBV4L_PUBLIC const char *v4lconvert_get_error_message(struct v4lconvert_data *data); + +/* Just like VIDIOC_ENUM_FRAMESIZE, except that the framesizes of emulated + formats can be enumerated as well. */ +LIBV4L_PUBLIC int v4lconvert_enum_framesizes(struct v4lconvert_data *data, + struct v4l2_frmsizeenum *frmsize); + +/* Just like VIDIOC_ENUM_FRAMEINTERVALS, except that the intervals of emulated + formats can be enumerated as well. */ +LIBV4L_PUBLIC int v4lconvert_enum_frameintervals(struct v4lconvert_data *data, + struct v4l2_frmivalenum *frmival); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif |