diff options
author | hans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain> | 2009-06-02 15:34:34 +0200 |
---|---|---|
committer | hans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain> | 2009-06-02 15:34:34 +0200 |
commit | 5999b7d164dbf3118a3a75ee3f6f0b48cb8845c1 (patch) | |
tree | f752c096c3af7126110654d7cebaa9eeb6cf0f74 /v4l2-apps/libv4l/libv4l1 | |
parent | 2e6d2fb93c7435890fd4789e4c01456f4150ff7e (diff) | |
download | mediapointer-dvb-s2-5999b7d164dbf3118a3a75ee3f6f0b48cb8845c1.tar.gz mediapointer-dvb-s2-5999b7d164dbf3118a3a75ee3f6f0b48cb8845c1.tar.bz2 |
libv4l: initial support for compiling on FreeBSD
From: Hans Petter Selasky <hselasky@freebsd.org>
Add a patch by Hans Petter Selasky <hselasky@freebsd.org>, 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 <hselasky@freebsd.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'v4l2-apps/libv4l/libv4l1')
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/libv4l1-priv.h | 9 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/libv4l1.c | 46 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/log.c | 7 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/v4l1compat.c | 5 |
4 files changed, 27 insertions, 40 deletions
diff --git a/v4l2-apps/libv4l/libv4l1/libv4l1-priv.h b/v4l2-apps/libv4l/libv4l1/libv4l1-priv.h index 651599255..370686b3a 100644 --- a/v4l2-apps/libv4l/libv4l1/libv4l1-priv.h +++ b/v4l2-apps/libv4l/libv4l1/libv4l1-priv.h @@ -22,14 +22,7 @@ #include <stdio.h> #include <pthread.h> -/* On 32 bits archs we always use mmap2, on 64 bits archs there is no mmap2 */ -#ifdef __NR_mmap2 -#define SYS_mmap2 __NR_mmap2 -#define MMAP2_PAGE_SHIFT 12 -#else -#define SYS_mmap2 SYS_mmap -#define MMAP2_PAGE_SHIFT 0 -#endif +#include "../libv4lconvert/libv4lsyscall-priv.h" #define V4L1_MAX_DEVICES 16 #define V4L1_NO_FRAMES 4 diff --git a/v4l2-apps/libv4l/libv4l1/libv4l1.c b/v4l2-apps/libv4l/libv4l1/libv4l1.c index a7de0af8e..b676d69ed 100644 --- a/v4l2-apps/libv4l/libv4l1/libv4l1.c +++ b/v4l2-apps/libv4l/libv4l1/libv4l1.c @@ -44,18 +44,12 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> -#include <syscall.h> #include <fcntl.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/mman.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 <asm/types.h> -#include <linux/ioctl.h> -/* end broken header workaround includes */ +#include "../libv4lconvert/libv4lsyscall-priv.h" #include <linux/videodev.h> #include <linux/videodev2.h> #include <libv4l2.h> @@ -225,14 +219,14 @@ static void v4l1_find_min_and_max_size(int index, struct v4l2_format *fmt2) for (i = 0; ; i++) { fmtdesc2.index = i; - if (syscall(SYS_ioctl, devices[index].fd, VIDIOC_ENUM_FMT, &fmtdesc2)) + if (SYS_IOCTL(devices[index].fd, VIDIOC_ENUM_FMT, &fmtdesc2)) break; fmt2->fmt.pix.pixelformat = fmtdesc2.pixelformat; fmt2->fmt.pix.width = 48; fmt2->fmt.pix.height = 32; - if (syscall(SYS_ioctl, devices[index].fd, VIDIOC_TRY_FMT, fmt2) == 0) { + if (SYS_IOCTL(devices[index].fd, VIDIOC_TRY_FMT, fmt2) == 0) { if (fmt2->fmt.pix.width < devices[index].min_width) devices[index].min_width = fmt2->fmt.pix.width; if (fmt2->fmt.pix.height < devices[index].min_height) @@ -243,7 +237,7 @@ static void v4l1_find_min_and_max_size(int index, struct v4l2_format *fmt2) fmt2->fmt.pix.width = 100000; fmt2->fmt.pix.height = 100000; - if (syscall(SYS_ioctl, devices[index].fd, VIDIOC_TRY_FMT, fmt2) == 0) { + if (SYS_IOCTL(devices[index].fd, VIDIOC_TRY_FMT, fmt2) == 0) { if (fmt2->fmt.pix.width > devices[index].max_width) devices[index].max_width = fmt2->fmt.pix.width; if (fmt2->fmt.pix.height > devices[index].max_height) @@ -280,11 +274,12 @@ int v4l1_open (const char *file, int oflag, ...) va_start (ap, oflag); mode = va_arg (ap, mode_t); - fd = syscall(SYS_open, file, oflag, mode); + fd = SYS_OPEN(file, oflag, mode); va_end(ap); } else - fd = syscall(SYS_open, file, oflag); + fd = SYS_OPEN(file, oflag, 0); + /* end of original open code */ if (fd == -1 || !v4l_device) @@ -292,7 +287,7 @@ int v4l1_open (const char *file, int oflag, ...) /* check that this is an v4l2 device, no need to emulate v4l1 on a v4l1 device */ - if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP, &cap2)) + if (SYS_IOCTL(fd, VIDIOC_QUERYCAP, &cap2)) return fd; /* IMPROVEME */ @@ -314,7 +309,7 @@ int v4l1_open (const char *file, int oflag, ...) emulation for us */ if (v4l2_fd_open(fd, V4L2_ENABLE_ENUM_FMT_EMULATION) == -1) { int saved_err = errno; - syscall(SYS_close, fd); + SYS_CLOSE(fd); errno = saved_err; return -1; } @@ -323,7 +318,7 @@ int v4l1_open (const char *file, int oflag, ...) fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (v4l2_ioctl(fd, VIDIOC_G_FMT, &fmt2)) { int saved_err = errno; - syscall(SYS_close, fd); + SYS_CLOSE(fd); errno = saved_err; return -1; } @@ -400,7 +395,7 @@ int v4l1_close(int fd) { int index, result; if ((index = v4l1_get_index(fd)) == -1) - return syscall(SYS_close, fd); + return SYS_CLOSE(fd); /* Abuse stream_lock to stop 2 closes from racing and trying to free the resources twice */ @@ -418,7 +413,7 @@ int v4l1_close(int fd) { V4L1_LOG("v4l1 capture buffer still mapped: %d times on close()\n", devices[index].v4l1_frame_buf_map_count); else - syscall(SYS_munmap, devices[index].v4l1_frame_pointer, + SYS_MUNMAP(devices[index].v4l1_frame_pointer, V4L1_NO_FRAMES * V4L1_FRAME_BUF_SIZE); devices[index].v4l1_frame_pointer = MAP_FAILED; } @@ -447,7 +442,6 @@ int v4l1_dup(int fd) return v4l2_dup(fd); } - int v4l1_ioctl (int fd, unsigned long int request, ...) { void *arg; @@ -459,7 +453,7 @@ int v4l1_ioctl (int fd, unsigned long int request, ...) va_end (ap); if ((index = v4l1_get_index(fd)) == -1) - return syscall(SYS_ioctl, fd, request, arg); + return SYS_IOCTL(fd, request, arg); /* Appearantly the kernel and / or glibc ignore the 32 most significant bits when long = 64 bits, and some applications pass an int holding the req to @@ -486,7 +480,7 @@ int v4l1_ioctl (int fd, unsigned long int request, ...) { struct video_capability *cap = arg; - result = syscall(SYS_ioctl, fd, request, arg); + result = SYS_IOCTL(fd, request, arg); /* override kernel v4l1 compat min / max size with our own more accurate values */ @@ -563,7 +557,7 @@ int v4l1_ioctl (int fd, unsigned long int request, ...) case VIDIOCGWIN: devices[index].flags |= V4L1_PIX_SIZE_TOUCHED; - result = syscall(SYS_ioctl, fd, request, arg); + result = SYS_IOCTL(fd, request, arg); break; case VIDIOCGCHAN: @@ -573,7 +567,7 @@ int v4l1_ioctl (int fd, unsigned long int request, ...) if ((devices[index].flags & V4L1_SUPPORTS_ENUMINPUT) && (devices[index].flags & V4L1_SUPPORTS_ENUMSTD)) { - result = syscall(SYS_ioctl, fd, request, arg); + result = SYS_IOCTL(fd, request, arg); break; } @@ -615,7 +609,7 @@ int v4l1_ioctl (int fd, unsigned long int request, ...) struct video_channel *chan = arg; if ((devices[index].flags & V4L1_SUPPORTS_ENUMINPUT) && (devices[index].flags & V4L1_SUPPORTS_ENUMSTD)) { - result = syscall(SYS_ioctl, fd, request, arg); + result = SYS_IOCTL(fd, request, arg); break; } /* In case of no ENUMSTD support, ignore the norm member of the @@ -651,7 +645,7 @@ int v4l1_ioctl (int fd, unsigned long int request, ...) } if (devices[index].v4l1_frame_pointer == MAP_FAILED) { - devices[index].v4l1_frame_pointer = (void *)syscall(SYS_mmap2, NULL, + devices[index].v4l1_frame_pointer = (void *)SYS_MMAP(NULL, (size_t)mbuf->size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); @@ -748,7 +742,7 @@ ssize_t v4l1_read(int fd, void* buffer, size_t n) ssize_t result; if ((index = v4l1_get_index(fd)) == -1) - return syscall(SYS_read, fd, buffer, n); + return SYS_READ(fd, buffer, n); pthread_mutex_lock(&devices[index].stream_lock); result = v4l2_read(fd, buffer, n); @@ -759,7 +753,7 @@ ssize_t v4l1_read(int fd, void* buffer, size_t n) void *v4l1_mmap(void *start, size_t length, int prot, int flags, int fd, - __off64_t offset) + int64_t offset) { int index; void *result; diff --git a/v4l2-apps/libv4l/libv4l1/log.c b/v4l2-apps/libv4l/libv4l1/log.c index 9ff0cea46..fd095817f 100644 --- a/v4l2-apps/libv4l/libv4l1/log.c +++ b/v4l2-apps/libv4l/libv4l1/log.c @@ -18,12 +18,7 @@ #include <stdio.h> #include <stdlib.h> -#include <linux/ioctl.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 <asm/types.h> -/* end broken header workaround includes */ +#include "../libv4lconvert/libv4lsyscall-priv.h" #include <linux/videodev.h> #include "libv4l1-priv.h" diff --git a/v4l2-apps/libv4l/libv4l1/v4l1compat.c b/v4l2-apps/libv4l/libv4l1/v4l1compat.c index e4293d2f9..704ec22dd 100644 --- a/v4l2-apps/libv4l/libv4l1/v4l1compat.c +++ b/v4l2-apps/libv4l/libv4l1/v4l1compat.c @@ -25,6 +25,7 @@ #include <stdarg.h> #include <fcntl.h> #include <libv4l1.h> +#include "../libv4lconvert/libv4lsyscall-priv.h" /* for __off_t */ #include <sys/ioctl.h> #include <sys/mman.h> @@ -61,6 +62,7 @@ LIBV4L_PUBLIC int open (const char *file, int oflag, ...) return fd; } +#ifdef linux LIBV4L_PUBLIC int open64 (const char *file, int oflag, ...) { int fd; @@ -81,6 +83,7 @@ LIBV4L_PUBLIC int open64 (const char *file, int oflag, ...) return fd; } +#endif LIBV4L_PUBLIC int close(int fd) { return v4l1_close(fd); @@ -114,11 +117,13 @@ LIBV4L_PUBLIC void *mmap(void *start, size_t length, int prot, int flags, int fd return v4l1_mmap(start, length, prot, flags, fd, offset); } +#ifdef linux LIBV4L_PUBLIC void *mmap64(void *start, size_t length, int prot, int flags, int fd, __off64_t offset) { return v4l1_mmap(start, length, prot, flags, fd, offset); } +#endif LIBV4L_PUBLIC int munmap(void *start, size_t length) { |