summaryrefslogtreecommitdiff
path: root/v4l2-apps/libv4l
diff options
context:
space:
mode:
Diffstat (limited to 'v4l2-apps/libv4l')
-rw-r--r--v4l2-apps/libv4l/ChangeLog6
-rw-r--r--v4l2-apps/libv4l/Makefile2
-rw-r--r--v4l2-apps/libv4l/include/libv4l1.h2
-rw-r--r--v4l2-apps/libv4l/include/libv4l2.h2
-rw-r--r--v4l2-apps/libv4l/include/libv4lconvert.h11
-rw-r--r--v4l2-apps/libv4l/libv4l1/libv4l1-priv.h9
-rw-r--r--v4l2-apps/libv4l/libv4l1/libv4l1.c46
-rw-r--r--v4l2-apps/libv4l/libv4l1/log.c7
-rw-r--r--v4l2-apps/libv4l/libv4l1/v4l1compat.c5
-rw-r--r--v4l2-apps/libv4l/libv4l2/libv4l2-priv.h9
-rw-r--r--v4l2-apps/libv4l/libv4l2/libv4l2.c84
-rw-r--r--v4l2-apps/libv4l/libv4l2/log.c7
-rw-r--r--v4l2-apps/libv4l/libv4l2/v4l2convert.c18
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c25
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c20
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/libv4lsyscall-priv.h112
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/processing/autogain.c14
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing-priv.h1
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.c1
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.h7
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/processing/whitebalance.c1
21 files changed, 237 insertions, 152 deletions
diff --git a/v4l2-apps/libv4l/ChangeLog b/v4l2-apps/libv4l/ChangeLog
index 3f709a632..08b221c2a 100644
--- a/v4l2-apps/libv4l/ChangeLog
+++ b/v4l2-apps/libv4l/ChangeLog
@@ -1,7 +1,11 @@
-libv4l-0.6
+libv4l-0.5.99
----------
* Link libv4lconvert with -lm for powf by Gregor Jasny
* Fix black screen on devices with hardware gamma control
+* Fix crash with devices on which we do not emulate fake controls
+* 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
libv4l-0.5.98
-------------
diff --git a/v4l2-apps/libv4l/Makefile b/v4l2-apps/libv4l/Makefile
index ef86fd130..374cfab7b 100644
--- a/v4l2-apps/libv4l/Makefile
+++ b/v4l2-apps/libv4l/Makefile
@@ -1,5 +1,5 @@
LIB_RELEASE=0
-V4L2_LIB_VERSION=$(LIB_RELEASE).5.98
+V4L2_LIB_VERSION=$(LIB_RELEASE).5.99
all install:
$(MAKE) -C libv4lconvert V4L2_LIB_VERSION=$(V4L2_LIB_VERSION) $@
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 <sys/time.h>
#include <linux/types.h>
#include <linux/ioctl.h>
+#endif
+
+#ifdef __FreeBSD__
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#endif
+
/* end broken header workaround includes */
+
#include <linux/videodev2.h>
#ifdef __cplusplus
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)
{
diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2-priv.h b/v4l2-apps/libv4l/libv4l2/libv4l2-priv.h
index 8724832e1..0bfd53e2a 100644
--- a/v4l2-apps/libv4l/libv4l2/libv4l2-priv.h
+++ b/v4l2-apps/libv4l/libv4l2/libv4l2-priv.h
@@ -23,14 +23,7 @@
#include <pthread.h>
#include <libv4lconvert.h> /* includes videodev2.h for us */
-/* 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 V4L2_MAX_DEVICES 16
/* Warning when making this larger the frame_queued and frame_mapped members of
diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c
index 382dc405b..a12b41c2c 100644
--- a/v4l2-apps/libv4l/libv4l2/libv4l2.c
+++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c
@@ -59,7 +59,6 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <syscall.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
@@ -100,7 +99,7 @@ static int v4l2_request_read_buffers(int index)
devices[index].nreadbuffers;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
- if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_REQBUFS, &req)) < 0){
+ if ((result = SYS_IOCTL(devices[index].fd, VIDIOC_REQBUFS, &req)) < 0){
int saved_err = errno;
V4L2_LOG_ERR("requesting %u buffers: %s\n", req.count, strerror(errno));
errno = saved_err;
@@ -127,7 +126,7 @@ static void v4l2_unrequest_read_buffers(int index)
req.count = 0;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
- if(syscall(SYS_ioctl, devices[index].fd, VIDIOC_REQBUFS, &req) < 0)
+ if(SYS_IOCTL(devices[index].fd, VIDIOC_REQBUFS, &req) < 0)
return;
devices[index].no_frames = MIN(req.count, V4L2_MAX_NO_FRAMES);
@@ -148,7 +147,7 @@ static int v4l2_map_buffers(int index)
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
- result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_QUERYBUF, &buf);
+ result = SYS_IOCTL(devices[index].fd, VIDIOC_QUERYBUF, &buf);
if (result) {
int saved_err = errno;
V4L2_LOG_ERR("querying buffer %u: %s\n", i, strerror(errno));
@@ -156,9 +155,9 @@ static int v4l2_map_buffers(int index)
break;
}
- devices[index].frame_pointers[i] = (void *)syscall(SYS_mmap2, NULL,
+ devices[index].frame_pointers[i] = (void *)SYS_MMAP(NULL,
(size_t)buf.length, PROT_READ|PROT_WRITE, MAP_SHARED, devices[index].fd,
- (__off_t)(buf.m.offset >> MMAP2_PAGE_SHIFT));
+ buf.m.offset);
if (devices[index].frame_pointers[i] == MAP_FAILED) {
int saved_err = errno;
V4L2_LOG_ERR("mmapping buffer %u: %s\n", i, strerror(errno));
@@ -182,7 +181,7 @@ static void v4l2_unmap_buffers(int index)
/* unmap the buffers */
for (i = 0; i < devices[index].no_frames; i++) {
if (devices[index].frame_pointers[i] != MAP_FAILED) {
- syscall(SYS_munmap, devices[index].frame_pointers[i],
+ SYS_MUNMAP(devices[index].frame_pointers[i],
devices[index].frame_sizes[i]);
devices[index].frame_pointers[i] = MAP_FAILED;
V4L2_LOG("unmapped buffer %u\n", i);
@@ -196,7 +195,7 @@ static int v4l2_streamon(int index)
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (!(devices[index].flags & V4L2_STREAMON)) {
- if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_STREAMON,
+ if ((result = SYS_IOCTL(devices[index].fd, VIDIOC_STREAMON,
&type))) {
int saved_err = errno;
V4L2_LOG_ERR("turning on stream: %s\n", strerror(errno));
@@ -215,7 +214,7 @@ static int v4l2_streamoff(int index)
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (devices[index].flags & V4L2_STREAMON) {
- if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_STREAMOFF,
+ if ((result = SYS_IOCTL(devices[index].fd, VIDIOC_STREAMOFF,
&type))) {
int saved_err = errno;
V4L2_LOG_ERR("turning off stream: %s\n", strerror(errno));
@@ -243,7 +242,7 @@ static int v4l2_queue_read_buffer(int index, int buffer_index)
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = buffer_index;
- if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_QBUF, &buf))) {
+ if ((result = SYS_IOCTL(devices[index].fd, VIDIOC_QBUF, &buf))) {
int saved_err = errno;
V4L2_LOG_ERR("queuing buf %d: %s\n", buffer_index, strerror(errno));
errno = saved_err;
@@ -265,7 +264,7 @@ static int v4l2_dequeue_and_convert(int index, struct v4l2_buffer *buf,
return result;
do {
- if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_DQBUF, buf))) {
+ if ((result = SYS_IOCTL(devices[index].fd, VIDIOC_DQBUF, buf))) {
if (errno != EAGAIN) {
int saved_err = errno;
V4L2_LOG_ERR("dequeuing buf: %s\n", strerror(errno));
@@ -386,7 +385,7 @@ static int v4l2_buffers_mapped(int index)
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
- if (syscall(SYS_ioctl, devices[index].fd, VIDIOC_QUERYBUF, &buf)) {
+ if (SYS_IOCTL(devices[index].fd, VIDIOC_QUERYBUF, &buf)) {
int saved_err = errno;
V4L2_LOG_ERR("querying buffer %u: %s\n", i, strerror(errno));
errno = saved_err;
@@ -422,12 +421,12 @@ int v4l2_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)
@@ -435,7 +434,7 @@ int v4l2_open (const char *file, int oflag, ...)
if (v4l2_fd_open(fd, 0) == -1) {
int saved_err = errno;
- syscall(SYS_close, fd);
+ SYS_CLOSE(fd);
errno = saved_err;
return -1;
}
@@ -457,7 +456,7 @@ int v4l2_fd_open(int fd, int v4l2_flags)
v4l2_log_file = fopen(lfname, "w");
/* check that this is an v4l2 device */
- if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP, &cap)) {
+ if (SYS_IOCTL(fd, VIDIOC_QUERYCAP, &cap)) {
int saved_err = errno;
V4L2_LOG_ERR("getting capabilities: %s\n", strerror(errno));
errno = saved_err;
@@ -472,7 +471,7 @@ int v4l2_fd_open(int fd, int v4l2_flags)
/* Get current cam format */
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (syscall(SYS_ioctl, fd, VIDIOC_G_FMT, &fmt)) {
+ if (SYS_IOCTL(fd, VIDIOC_G_FMT, &fmt)) {
int saved_err = errno;
V4L2_LOG_ERR("getting pixformat: %s\n", strerror(errno));
errno = saved_err;
@@ -553,7 +552,7 @@ int v4l2_close(int fd)
int index, result;
if ((index = v4l2_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 */
@@ -571,7 +570,7 @@ int v4l2_close(int fd)
if (v4l2_buffers_mapped(index))
V4L2_LOG_WARN("v4l2 mmap buffers still mapped on close()\n");
else
- syscall(SYS_munmap, devices[index].convert_mmap_buf,
+ SYS_MUNMAP(devices[index].convert_mmap_buf,
devices[index].no_frames * V4L2_FRAME_BUF_SIZE);
devices[index].convert_mmap_buf = MAP_FAILED;
}
@@ -585,7 +584,7 @@ int v4l2_close(int fd)
/* Since we've marked the fd as no longer used, and freed the resources,
redo the close in case it was interrupted */
do {
- result = syscall(SYS_close, fd);
+ result = SYS_CLOSE(fd);
} while (result == -1 && errno == EINTR);
V4L2_LOG("close: %d\n", fd);
@@ -622,7 +621,7 @@ static int v4l2_check_buffer_change_ok(int index)
/* We may change from convert to non conversion mode and
v4l2_unrequest_read_buffers may change the no_frames, so free the
convert mmap buffer */
- syscall(SYS_munmap, devices[index].convert_mmap_buf,
+ SYS_MUNMAP(devices[index].convert_mmap_buf,
devices[index].no_frames * V4L2_FRAME_BUF_SIZE);
devices[index].convert_mmap_buf = MAP_FAILED;
@@ -676,7 +675,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
va_end (ap);
if ((index = v4l2_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
@@ -740,7 +739,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
}
if (!is_capture_request) {
- result = syscall(SYS_ioctl, fd, request, arg);
+ result = SYS_IOCTL(fd, request, arg);
saved_err = errno;
v4l2_log_ioctl(request, arg, result);
errno = saved_err;
@@ -787,7 +786,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
{
struct v4l2_capability *cap = arg;
- result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_QUERYCAP, cap);
+ result = SYS_IOCTL(devices[index].fd, VIDIOC_QUERYCAP, cap);
if (result == 0)
/* We always support read() as we fake it using mmap mode */
cap->capabilities |= V4L2_CAP_READWRITE;
@@ -838,7 +837,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
}
if (devices[index].flags & V4L2_DISABLE_CONVERSION) {
- result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_TRY_FMT,
+ result = SYS_IOCTL(devices[index].fd, VIDIOC_TRY_FMT,
dest_fmt);
src_fmt = *dest_fmt;
} else {
@@ -878,7 +877,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
break;
req_pix_fmt = src_fmt.fmt.pix;
- result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_S_FMT, &src_fmt);
+ result = SYS_IOCTL(devices[index].fd, VIDIOC_S_FMT, &src_fmt);
if (result) {
saved_err = errno;
V4L2_LOG_ERR("setting pixformat: %s\n", strerror(errno));
@@ -928,7 +927,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
if (req->count > V4L2_MAX_NO_FRAMES)
req->count = V4L2_MAX_NO_FRAMES;
- result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_REQBUFS, req);
+ result = SYS_IOCTL(devices[index].fd, VIDIOC_REQBUFS, req);
if (result < 0)
break;
result = 0; /* some drivers return the number of buffers on success */
@@ -948,7 +947,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
/* Do a real query even when converting to let the driver fill in
things like buf->field */
- result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_QUERYBUF, buf);
+ result = SYS_IOCTL(devices[index].fd, VIDIOC_QUERYBUF, buf);
if (result || !v4l2_needs_conversion(index))
break;
@@ -971,7 +970,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
if ((result = v4l2_map_buffers(index)))
break;
- result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_QBUF, arg);
+ result = SYS_IOCTL(devices[index].fd, VIDIOC_QBUF, arg);
break;
case VIDIOC_DQBUF:
@@ -983,7 +982,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
break;
if (!v4l2_needs_conversion(index)) {
- result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_DQBUF, buf);
+ result = SYS_IOCTL(devices[index].fd, VIDIOC_DQBUF, buf);
if (result) {
int saved_err = errno;
V4L2_LOG_ERR("dequeuing buf: %s\n", strerror(errno));
@@ -996,7 +995,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
but we need the buffer _now_ to write our converted data
to it! */
if (devices[index].convert_mmap_buf == MAP_FAILED) {
- devices[index].convert_mmap_buf = (void *)syscall(SYS_mmap2, NULL,
+ devices[index].convert_mmap_buf = (void *)SYS_MMAP(NULL,
(size_t)(
devices[index].no_frames *
V4L2_FRAME_BUF_SIZE),
@@ -1041,7 +1040,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
break;
default:
- result = syscall(SYS_ioctl, fd, request, arg);
+ result = SYS_IOCTL(fd, request, arg);
}
if (stream_needs_locking)
@@ -1062,7 +1061,7 @@ ssize_t v4l2_read (int fd, void* dest, size_t n)
struct v4l2_buffer buf;
if ((index = v4l2_get_index(fd)) == -1)
- return syscall(SYS_read, fd, dest, n);
+ return SYS_READ(fd, dest, n);
pthread_mutex_lock(&devices[index].stream_lock);
@@ -1070,7 +1069,7 @@ ssize_t v4l2_read (int fd, void* dest, size_t n)
it */
if ((devices[index].flags & V4L2_SUPPORTS_READ) &&
!v4l2_needs_conversion(index)) {
- result = syscall(SYS_read, fd, dest, n);
+ result = SYS_READ(fd, dest, n);
goto leave;
}
@@ -1099,7 +1098,7 @@ leave:
}
void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd,
- __off64_t offset)
+ int64_t offset)
{
int index;
unsigned int buffer_index;
@@ -1119,8 +1118,7 @@ void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd,
return MAP_FAILED;
}
- return (void *)syscall(SYS_mmap2, start, length, prot, flags, fd,
- (__off_t)(offset >> MMAP2_PAGE_SHIFT));
+ return (void *)SYS_MMAP(start, length, prot, flags, fd, offset);
}
pthread_mutex_lock(&devices[index].stream_lock);
@@ -1135,7 +1133,7 @@ void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd,
}
if (devices[index].convert_mmap_buf == MAP_FAILED) {
- devices[index].convert_mmap_buf = (void *)syscall(SYS_mmap2, NULL,
+ devices[index].convert_mmap_buf = (void *)SYS_MMAP(NULL,
(size_t)(
devices[index].no_frames *
V4L2_FRAME_BUF_SIZE),
@@ -1208,7 +1206,7 @@ int v4l2_munmap(void *_start, size_t length)
V4L2_LOG("v4l2 unknown munmap %p, %d\n", start, (int)length);
- return syscall(SYS_munmap, _start, length);
+ return SYS_MUNMAP(_start, length);
}
/* Misc utility functions */
@@ -1218,7 +1216,7 @@ int v4l2_set_control(int fd, int cid, int value)
struct v4l2_control ctrl = { .id = cid };
int result;
- if ((result = syscall(SYS_ioctl, fd, VIDIOC_QUERYCTRL, &qctrl)))
+ if ((result = SYS_IOCTL(fd, VIDIOC_QUERYCTRL, &qctrl)))
return result;
if (!(qctrl.flags & V4L2_CTRL_FLAG_DISABLED) &&
@@ -1229,7 +1227,7 @@ int v4l2_set_control(int fd, int cid, int value)
ctrl.value = (value * (qctrl.maximum - qctrl.minimum) + 32767) / 65535 +
qctrl.minimum;
- result = syscall(SYS_ioctl, fd, VIDIOC_S_CTRL, &ctrl);
+ result = SYS_IOCTL(fd, VIDIOC_S_CTRL, &ctrl);
}
return result;
@@ -1240,13 +1238,13 @@ int v4l2_get_control(int fd, int cid)
struct v4l2_queryctrl qctrl = { .id = cid };
struct v4l2_control ctrl = { .id = cid };
- if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCTRL, &qctrl))
+ if (SYS_IOCTL(fd, VIDIOC_QUERYCTRL, &qctrl))
return 0;
if (qctrl.flags & V4L2_CTRL_FLAG_DISABLED)
return 0;
- if (syscall(SYS_ioctl, fd, VIDIOC_G_CTRL, &ctrl))
+ if (SYS_IOCTL(fd, VIDIOC_G_CTRL, &ctrl))
return 0;
return ((ctrl.value - qctrl.minimum) * 65535 +
diff --git a/v4l2-apps/libv4l/libv4l2/log.c b/v4l2-apps/libv4l/libv4l2/log.c
index a08ae3554..86d71b64e 100644
--- a/v4l2-apps/libv4l/libv4l2/log.c
+++ b/v4l2-apps/libv4l/libv4l2/log.c
@@ -22,12 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.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/videodev2.h>
#include "libv4l2.h"
#include "libv4l2-priv.h"
diff --git a/v4l2-apps/libv4l/libv4l2/v4l2convert.c b/v4l2-apps/libv4l/libv4l2/v4l2convert.c
index b1354772d..4b75a5ebf 100644
--- a/v4l2-apps/libv4l/libv4l2/v4l2convert.c
+++ b/v4l2-apps/libv4l/libv4l2/v4l2convert.c
@@ -24,17 +24,11 @@
#include <stdarg.h>
#include <stdlib.h>
-#include <syscall.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.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/videodev2.h>
#include <libv4l2.h>
@@ -72,18 +66,18 @@ LIBV4L_PUBLIC int 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)
return fd;
/* check that this is an v4l2 device, libv4l2 only supports v4l2 devices */
- if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP, &cap))
+ if (SYS_IOCTL(fd, VIDIOC_QUERYCAP, &cap))
return fd;
/* libv4l2 only adds functionality to capture capable devices */
@@ -97,6 +91,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;
@@ -119,6 +114,7 @@ LIBV4L_PUBLIC int open64(const char *file, int oflag, ...)
return fd;
}
+#endif
LIBV4L_PUBLIC int close(int fd)
{
@@ -153,11 +149,13 @@ LIBV4L_PUBLIC void *mmap(void *start, size_t length, int prot, int flags, int fd
return v4l2_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 v4l2_mmap(start, length, prot, flags, fd, offset);
}
+#endif
LIBV4L_PUBLIC int munmap(void *start, size_t length)
{
diff --git a/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c b/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c
index da2fbcdce..2f459c396 100644
--- a/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c
+++ b/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c
@@ -28,16 +28,9 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <syscall.h>
#include "libv4lcontrol.h"
#include "libv4lcontrol-priv.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 "../libv4lsyscall-priv.h"
#include <linux/videodev2.h>
#define ARRAY_SIZE(x) ((int)sizeof(x)/(int)sizeof((x)[0]))
@@ -102,8 +95,8 @@ static void v4lcontrol_init_flags(struct v4lcontrol_data *data)
char c, *s, buf[32];
struct v4l2_input input;
- if ((syscall(SYS_ioctl, data->fd, VIDIOC_G_INPUT, &input.index) == 0) &&
- (syscall(SYS_ioctl, data->fd, VIDIOC_ENUMINPUT, &input) == 0)) {
+ if ((SYS_IOCTL(data->fd, VIDIOC_G_INPUT, &input.index) == 0) &&
+ (SYS_IOCTL(data->fd, VIDIOC_ENUMINPUT, &input) == 0)) {
if (input.status & V4L2_IN_ST_HFLIP)
data->flags |= V4LCONTROL_HFLIPPED;
if (input.status & V4L2_IN_ST_VFLIP)
@@ -229,7 +222,7 @@ struct v4lcontrol_data *v4lcontrol_create(int fd, int always_needs_conversion)
data->flags = strtol(s, NULL, 0);
ctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
- if (syscall(SYS_ioctl, data->fd, VIDIOC_QUERYCTRL, &ctrl) == 0)
+ if (SYS_IOCTL(data->fd, VIDIOC_QUERYCTRL, &ctrl) == 0)
data->priv_flags |= V4LCONTROL_SUPPORTS_NEXT_CTRL;
/* If the device always needs conversion, we can add fake controls at no cost
@@ -237,7 +230,7 @@ struct v4lcontrol_data *v4lcontrol_create(int fd, int always_needs_conversion)
if (always_needs_conversion || v4lcontrol_needs_conversion(data)) {
for (i = 0; i < V4LCONTROL_AUTO_ENABLE_COUNT; i++) {
ctrl.id = fake_controls[i].id;
- if (syscall(SYS_ioctl, data->fd, VIDIOC_QUERYCTRL, &ctrl) == -1)
+ if (SYS_IOCTL(data->fd, VIDIOC_QUERYCTRL, &ctrl) == -1)
data->controls |= 1 << i;
}
}
@@ -253,7 +246,7 @@ struct v4lcontrol_data *v4lcontrol_create(int fd, int always_needs_conversion)
if (data->controls == 0)
return data; /* No need to create a shared memory segment */
- syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP, &cap);
+ SYS_IOCTL(fd, VIDIOC_QUERYCAP, &cap);
snprintf(shm_name, 256, "/%s:%s", cap.bus_info, cap.card);
/* / is not allowed inside shm names */
@@ -403,7 +396,7 @@ int v4lcontrol_vidioc_queryctrl(struct v4lcontrol_data *data, void *arg)
}
/* find out what the kernel driver would respond. */
- retval = syscall(SYS_ioctl, data->fd, VIDIOC_QUERYCTRL, arg);
+ retval = SYS_IOCTL(data->fd, VIDIOC_QUERYCTRL, arg);
if ((data->priv_flags & V4LCONTROL_SUPPORTS_NEXT_CTRL) &&
(orig_id & V4L2_CTRL_FLAG_NEXT_CTRL)) {
@@ -440,7 +433,7 @@ int v4lcontrol_vidioc_g_ctrl(struct v4lcontrol_data *data, void *arg)
return 0;
}
- return syscall(SYS_ioctl, data->fd, VIDIOC_G_CTRL, arg);
+ return SYS_IOCTL(data->fd, VIDIOC_G_CTRL, arg);
}
int v4lcontrol_vidioc_s_ctrl(struct v4lcontrol_data *data, void *arg)
@@ -461,7 +454,7 @@ int v4lcontrol_vidioc_s_ctrl(struct v4lcontrol_data *data, void *arg)
return 0;
}
- return syscall(SYS_ioctl, data->fd, VIDIOC_S_CTRL, arg);
+ return SYS_IOCTL(data->fd, VIDIOC_S_CTRL, arg);
}
int v4lcontrol_get_flags(struct v4lcontrol_data *data)
diff --git a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
index 1b95d0657..ef23be362 100644
--- a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
+++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
@@ -19,12 +19,12 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
-#include <syscall.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "libv4lconvert.h"
#include "libv4lconvert-priv.h"
+#include "libv4lsyscall-priv.h"
#define MIN(a,b) (((a)<(b))?(a):(b))
@@ -103,7 +103,7 @@ struct v4lconvert_data *v4lconvert_create(int fd)
fmt.index = i;
- if (syscall(SYS_ioctl, fd, VIDIOC_ENUM_FMT, &fmt))
+ if (SYS_IOCTL(data->fd, VIDIOC_ENUM_FMT, &fmt))
break;
for (j = 0; j < ARRAY_SIZE(supported_src_pixfmts); j++)
@@ -122,7 +122,7 @@ struct v4lconvert_data *v4lconvert_create(int fd)
data->no_formats = i;
/* Check if this cam has any special flags */
- if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP, &cap) == 0) {
+ if (SYS_IOCTL(data->fd, VIDIOC_QUERYCAP, &cap) == 0) {
if (!strcmp((char *)cap.driver, "uvcvideo"))
data->flags |= V4LCONVERT_IS_UVC;
else if (!strcmp((char *)cap.driver, "sn9c20x"))
@@ -192,7 +192,7 @@ int v4lconvert_enum_fmt(struct v4lconvert_data *data, struct v4l2_fmtdesc *fmt)
if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
(!v4lconvert_supported_dst_fmt_only(data) &&
fmt->index < data->no_formats))
- return syscall(SYS_ioctl, data->fd, VIDIOC_ENUM_FMT, fmt);
+ return SYS_IOCTL(data->fd, VIDIOC_ENUM_FMT, fmt);
for (i = 0; i < ARRAY_SIZE(supported_dst_pixfmts); i++)
if (v4lconvert_supported_dst_fmt_only(data) ||
@@ -300,7 +300,7 @@ static int v4lconvert_do_try_format(struct v4lconvert_data *data,
try_fmt = *dest_fmt;
try_fmt.fmt.pix.pixelformat = supported_src_pixfmts[i].fmt;
- if (!syscall(SYS_ioctl, data->fd, VIDIOC_TRY_FMT, &try_fmt))
+ if (!SYS_IOCTL(data->fd, VIDIOC_TRY_FMT, &try_fmt))
{
if (try_fmt.fmt.pix.pixelformat == supported_src_pixfmts[i].fmt) {
int size_x_diff = abs((int)try_fmt.fmt.pix.width -
@@ -368,7 +368,7 @@ int v4lconvert_try_format(struct v4lconvert_data *data,
if (!v4lconvert_supported_dst_format(dest_fmt->fmt.pix.pixelformat) ||
dest_fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
v4lconvert_do_try_format(data, &try_dest, &try_src)) {
- result = syscall(SYS_ioctl, data->fd, VIDIOC_TRY_FMT, dest_fmt);
+ result = SYS_IOCTL(data->fd, VIDIOC_TRY_FMT, dest_fmt);
if (src_fmt)
*src_fmt = *dest_fmt;
return result;
@@ -1041,7 +1041,7 @@ static void v4lconvert_get_framesizes(struct v4lconvert_data *data,
for (i = 0; ; i++) {
frmsize.index = i;
- if (syscall(SYS_ioctl, data->fd, VIDIOC_ENUM_FRAMESIZES, &frmsize))
+ if (SYS_IOCTL(data->fd, VIDIOC_ENUM_FRAMESIZES, &frmsize))
break;
/* We got a framesize, check we don't have the same one already */
@@ -1101,7 +1101,7 @@ int v4lconvert_enum_framesizes(struct v4lconvert_data *data,
errno = EINVAL;
return -1;
}
- return syscall(SYS_ioctl, data->fd, VIDIOC_ENUM_FRAMESIZES, frmsize);
+ return SYS_IOCTL(data->fd, VIDIOC_ENUM_FRAMESIZES, frmsize);
}
if (frmsize->index >= data->no_framesizes) {
@@ -1141,7 +1141,7 @@ int v4lconvert_enum_frameintervals(struct v4lconvert_data *data,
errno = EINVAL;
return -1;
}
- res = syscall(SYS_ioctl, data->fd, VIDIOC_ENUM_FRAMEINTERVALS, frmival);
+ res = SYS_IOCTL(data->fd, VIDIOC_ENUM_FRAMEINTERVALS, frmival);
if (res)
V4LCONVERT_ERR("%s\n", strerror(errno));
return res;
@@ -1185,7 +1185,7 @@ int v4lconvert_enum_frameintervals(struct v4lconvert_data *data,
frmival->pixel_format = src_fmt.fmt.pix.pixelformat;
frmival->width = src_fmt.fmt.pix.width;
frmival->height = src_fmt.fmt.pix.height;
- res = syscall(SYS_ioctl, data->fd, VIDIOC_ENUM_FRAMEINTERVALS, frmival);
+ res = SYS_IOCTL(data->fd, VIDIOC_ENUM_FRAMEINTERVALS, frmival);
if (res) {
int dest_pixfmt = dest_fmt.fmt.pix.pixelformat;
int src_pixfmt = src_fmt.fmt.pix.pixelformat;
diff --git a/v4l2-apps/libv4l/libv4lconvert/libv4lsyscall-priv.h b/v4l2-apps/libv4l/libv4lconvert/libv4lsyscall-priv.h
new file mode 100644
index 000000000..a456ceea3
--- /dev/null
+++ b/v4l2-apps/libv4l/libv4lconvert/libv4lsyscall-priv.h
@@ -0,0 +1,112 @@
+/*-
+ * Copyright (c) 2009 Hans Petter Selasky. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * The following file allows for having the complete V4L stack and
+ * hardware drivers in userland.
+ */
+
+#ifndef _LIBV4LSYSCALL_PRIV_H_
+#define _LIBV4LSYSCALL_PRIV_H_
+
+/* Some of 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 <sys/time.h>
+#include <syscall.h>
+#include <linux/types.h>
+#include <linux/ioctl.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
+#endif
+
+#ifdef __FreeBSD__
+#include <sys/time.h>
+#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 _IOC_SIZE(cmd) IOCPARM_LEN(cmd)
+#define MAP_ANONYMOUS MAP_ANON
+#define SYS_mmap2 SYS_mmap
+#define MMAP2_PAGE_SHIFT 0
+typedef off_t __off_t;
+#endif
+
+#undef SYS_OPEN
+#undef SYS_CLOSE
+#undef SYS_IOCTL
+#undef SYS_READ
+#undef SYS_WRITE
+#undef SYS_MMAP
+#undef SYS_MUNMAP
+
+#ifndef CONFIG_SYS_WRAPPER
+
+#define SYS_OPEN(file, oflag, mode) \
+ syscall(SYS_open, (const char *)(file), (int)(oflag), (mode_t)(mode))
+#define SYS_CLOSE(fd) \
+ syscall(SYS_close, (int)(fd))
+#define SYS_IOCTL(fd, cmd, arg) \
+ syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg))
+#define SYS_READ(fd, buf, len) \
+ syscall(SYS_read, (int)(fd), (void *)(buf), (size_t)(len));
+#define SYS_WRITE(fd, buf, len) \
+ syscall(SYS_write, (int)(fd), (void *)(buf), (size_t)(len));
+#define SYS_MMAP(addr, len, prot, flags, fd, off) \
+ syscall(SYS_mmap2, (void *)(addr), (size_t)(len), \
+ (int)(prot), (int)(flags), (int)(fd), (__off_t)((off) >> MMAP2_PAGE_SHIFT))
+#define SYS_MUNMAP(addr, len) \
+ syscall(SYS_munmap, (void *)(addr), (size_t)(len))
+
+#else
+
+int v4lx_open_wrapper(const char *, int, int);
+int v4lx_close_wrapper(int);
+int v4lx_ioctl_wrapper(int, unsigned long, void *);
+int v4lx_read_wrapper(int, void *, size_t);
+int v4lx_write_wrapper(int, void *, size_t);
+void *v4lx_mmap_wrapper(void *, size_t, int, int, int, off_t);
+int v4lx_munmap_wrapper(void *, size_t);
+
+#define SYS_OPEN(...) v4lx_open_wrapper(__VA_ARGS__)
+#define SYS_CLOSE(...) v4lx_close_wrapper(__VA_ARGS__)
+#define SYS_IOCTL(...) v4lx_ioctl_wrapper(__VA_ARGS__)
+#define SYS_READ(...) v4lx_read_wrapper(__VA_ARGS__)
+#define SYS_WRITE(...) v4lx_write_wrapper(__VA_ARGS__)
+#define SYS_MMAP(...) v4lx_mmap_wrapper(__VA_ARGS__)
+#define SYS_MUNMAP(...) v4lx_munmap_wrapper(__VA_ARGS__)
+
+#endif
+
+#endif /* _LIBV4LSYSCALL_PRIV_H_ */
diff --git a/v4l2-apps/libv4l/libv4lconvert/processing/autogain.c b/v4l2-apps/libv4l/libv4lconvert/processing/autogain.c
index ed4b8224f..358264c68 100644
--- a/v4l2-apps/libv4l/libv4lconvert/processing/autogain.c
+++ b/v4l2-apps/libv4l/libv4lconvert/processing/autogain.c
@@ -20,12 +20,12 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <syscall.h>
#include <unistd.h>
#include "libv4lprocessing.h"
#include "libv4lprocessing-priv.h"
#include "../libv4lconvert-priv.h" /* for PIX_FMT defines */
+#include "../libv4lsyscall-priv.h"
static int autogain_active(struct v4lprocessing_data *data) {
return v4lcontrol_get_ctrl(data->control, V4LCONTROL_AUTOGAIN);
@@ -45,15 +45,15 @@ static int autogain_calculate_lookup_tables(
ctrl.id = V4L2_CID_EXPOSURE;
expoctrl.id = V4L2_CID_EXPOSURE;
- if (syscall(SYS_ioctl, data->fd, VIDIOC_QUERYCTRL, &expoctrl) ||
- syscall(SYS_ioctl, data->fd, VIDIOC_G_CTRL, &ctrl))
+ if (SYS_IOCTL(data->fd, VIDIOC_QUERYCTRL, &expoctrl) ||
+ SYS_IOCTL(data->fd, VIDIOC_G_CTRL, &ctrl))
return 0;
exposure = orig_exposure = ctrl.value;
ctrl.id = V4L2_CID_GAIN;
gainctrl.id = V4L2_CID_GAIN;
- if (syscall(SYS_ioctl, data->fd, VIDIOC_QUERYCTRL, &gainctrl) ||
- syscall(SYS_ioctl, data->fd, VIDIOC_G_CTRL, &ctrl))
+ if (SYS_IOCTL(data->fd, VIDIOC_QUERYCTRL, &gainctrl) ||
+ SYS_IOCTL(data->fd, VIDIOC_G_CTRL, &ctrl))
return 0;
gain = orig_gain = ctrl.value;
@@ -125,12 +125,12 @@ static int autogain_calculate_lookup_tables(
if (gain != orig_gain) {
ctrl.id = V4L2_CID_GAIN;
ctrl.value = gain;
- syscall(SYS_ioctl, data->fd, VIDIOC_S_CTRL, &ctrl);
+ SYS_IOCTL(data->fd, VIDIOC_S_CTRL, &ctrl);
}
if (exposure != orig_exposure) {
ctrl.id = V4L2_CID_EXPOSURE;
ctrl.value = exposure;
- syscall(SYS_ioctl, data->fd, VIDIOC_S_CTRL, &ctrl);
+ SYS_IOCTL(data->fd, VIDIOC_S_CTRL, &ctrl);
}
return 0;
diff --git a/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing-priv.h b/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing-priv.h
index 008d352ff..b73c73b53 100644
--- a/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing-priv.h
+++ b/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing-priv.h
@@ -22,6 +22,7 @@
#define __LIBV4LPROCESSING_PRIV_H
#include "../control/libv4lcontrol.h"
+#include "../libv4lsyscall-priv.h"
#define V4L2PROCESSING_UPDATE_RATE 10
diff --git a/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.c b/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.c
index f050086e3..cbbcca73c 100644
--- a/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.c
+++ b/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.c
@@ -22,7 +22,6 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <syscall.h>
#include <unistd.h>
#include "libv4lprocessing.h"
#include "libv4lprocessing-priv.h"
diff --git a/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.h b/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.h
index f1892a279..69d8865b2 100644
--- a/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.h
+++ b/v4l2-apps/libv4l/libv4lconvert/processing/libv4lprocessing.h
@@ -21,12 +21,7 @@
#ifndef __LIBV4LPROCESSING_H
#define __LIBV4LPROCESSING_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 "../libv4lsyscall-priv.h"
#include <linux/videodev2.h>
struct v4lprocessing_data;
diff --git a/v4l2-apps/libv4l/libv4lconvert/processing/whitebalance.c b/v4l2-apps/libv4l/libv4lconvert/processing/whitebalance.c
index f5bfd961c..64d20b3ff 100644
--- a/v4l2-apps/libv4l/libv4lconvert/processing/whitebalance.c
+++ b/v4l2-apps/libv4l/libv4lconvert/processing/whitebalance.c
@@ -22,7 +22,6 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <syscall.h>
#include <unistd.h>
#include "libv4lprocessing.h"
#include "libv4lprocessing-priv.h"