libv4l on OpenBSD
Hi,
in OpenBSD we recently updated our videoio.h (= videodev2.h in Linux) header and also imported libv4l in our ports tree
(https://marc.info/?l=openbsd-ports-cvs&m=145218684026568&w=2).
However, we need a few patches to have it working. As there is already FreeBSD support in libv4l, I would like to ask you if it would be possible to add OpenBSD support as well (so that it works out of the box)? The diffs (on top of https://git.linuxtv.org/v4l-utils.git)
towards this goal are as follows.
Thank you!
Best regards,
Ingo
configure.ac +4 -1
@@ -142,6 +142,9 @@ case "$host_os" in linux*) linux_os="yes" ;; + freebsd*) + freebsd_os="yes" + ;; esac AM_CONDITIONAL([LINUX_OS], [test x$linux_os = xyes])
@@ -410,7 +413,7 @@ AS_IF([test x$enable_libv4l = xno], [AC_SUBST([ENFORCE_LIBV4L_STATIC], ["-st if test "x$linux_os" = "xyes"; then CPPFLAGS="-I\$(top_srcdir)/include $CPPFLAGS" -else +elif test "x$freebsd_os" = "xyes"; then CPPFLAGS="-I\$(top_srcdir)/contrib/freebsd/include $CPPFLAGS" fi
lib/include/libv4l1-videodev.h +1 -1
@@ -6,7 +6,7 @@#include <linux/ioctl.h> #endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)#include <sys/ioctl.h> #endif
lib/include/libv4l2rds.h +4 -0
@@ -24,7 +24,11 @@#include <stdbool.h> #include <stdint.h> +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#else #include <linux/videodev2.h> +#endif #ifdef __cplusplusextern "C" {
lib/include/libv4lconvert.h +5 -1
@@ -28,7 +28,7 @@#include <linux/ioctl.h> #endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)#include <sys/time.h> #include <sys/types.h> #include <sys/ioctl.h>
@@ -36,7 +36,11 @@/* end broken header workaround includes */ +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#else #include <linux/videodev2.h> +#endif #ifdef __cplusplusextern "C" {
lib/libv4l-mplane/libv4l-mplane.c +5 -0
@@ -26,7 +26,12 @@#include <unistd.h> #include <sys/syscall.h> +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#include <sys/ioctl.h> +#else #include <linux/videodev2.h> +#endif #include "libv4l-plugin.h"
lib/libv4l1/libv4l1.c +4 -0
@@ -58,7 +58,11 @@#include <sys/types.h> #include <sys/mman.h> #include "../libv4lconvert/libv4lsyscall-priv.h" +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#else #include <linux/videodev2.h> +#endif #include <libv4l2.h> #include "libv4l1.h" #include "libv4l1-priv.h"
lib/libv4l2/log.c +4 -0
@@ -28,7 +28,11 @@#include <string.h> #include <errno.h> #include "../libv4lconvert/libv4lsyscall-priv.h" +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#else #include <linux/videodev2.h> +#endif #include "libv4l2.h" #include "libv4l2-priv.h"
lib/libv4l2/v4l2convert.c +4 -0
@@ -36,7 +36,11 @@#include <string.h> #include <sys/ioctl.h> #include <sys/mman.h> +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#else #include <linux/videodev2.h> +#endif #include <libv4l2.h> #include "../libv4lconvert/libv4lsyscall-priv.h"
lib/libv4l2rds/libv4l2rds.c +4 -0
@@ -27,7 +27,11 @@#include <sys/types.h> #include <sys/mman.h> +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#else #include <linux/videodev2.h> +#endif #include "../include/libv4l2rds.h"
lib/libv4lconvert/control/libv4lcontrol.c +4 -0
@@ -35,7 +35,11 @@#include "libv4lcontrol.h" #include "libv4lcontrol-priv.h" #include "../libv4lsyscall-priv.h" +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#else #include <linux/videodev2.h> +#endif #define ARRAY_SIZE (x) ((int)sizeof(x) / (int)sizeof((x)[0]))
lib/libv4lconvert/libv4lsyscall-priv.h +14 -0
@@ -63,6 +63,15 @@#define MMAP2_PAGE_SHIFT 0#endif +#if defined(__OpenBSD__) +#include <sys/syscall.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#define _IOC_NR (cmd) ((cmd) & 0xFF) +#define _IOC_TYPE (cmd) IOCGROUP(cmd) +#define MMAP2_PAGE_SHIFT 0 +#endif +#undef SYS_OPEN#undef SYS_CLOSE#undef SYS_IOCTL
@@ -97,6 +106,11 @@#define SYS_MMAP (addr, len, prot, flags, fd, off) \ syscall(SYS_mmap, (void *)(addr), (size_t)(len), \ (int)(prot), (int)(flags), (int)(fd), (off_t)(off)) +#elif defined(__OpenBSD__) +register_t __syscall (quad_t , ...); +#define SYS_MMAP (addr, len, prot, flags, fd, offset) \ + __syscall((quad_t)SYS_mmap, (void *)(addr), (size_t)(len), \ + (int)(prot), (int)(flags), (int)(fd), 0, (off_t)(offset))#else #define SYS_MMAP (addr, len, prot, flags, fd, off) \ syscall(SYS_mmap2, (void *)(addr), (size_t)(len), \
lib/libv4lconvert/processing/libv4lprocessing.h +4 -0
@@ -22,7 +22,11 @@#define __LIBV4LPROCESSING_H#include "../libv4lsyscall-priv.h" +#if defined(__OpenBSD__) +#include <sys/videoio.h> +#else #include <linux/videodev2.h> +#endif struct v4lprocessing_data ;struct v4lcontrol_data ;
Hello,
Quoted 9 lines · Ingo Feinerer
in OpenBSD we recently updated our
videoio.h(=videodev2.hin Linux) header and also imported libv4l in our ports tree
(https://marc.info/?l=openbsd-ports-cvs&m=145218684026568&w=2).However, we need a few patches to have it working. As there is already FreeBSD support in libv4l, I would like to ask you if it would be possible to add OpenBSD support as well (so that it works out of the box)? The diffs (on top of https://git.linuxtv.org/v4l-utils.git)
towards this goal are as follows.
I will try to get out a new v4l-utils release soon and will have a look at your patch afterwards. What I'd like to see in the BSDs is a working V4L header (videodev2.h) that is a drop-in replacement for the Linux one. That would help to get rid of all the #ifdef portions in the code.
Thanks,
Gregor