summaryrefslogtreecommitdiff
path: root/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
diff options
context:
space:
mode:
authorThierry MERLE <thierry.merle@free.fr>2008-07-06 14:07:34 +0200
committerThierry MERLE <thierry.merle@free.fr>2008-07-06 14:07:34 +0200
commitab715d2e8eb29998b60fa3bbc1ad95441cfb69b3 (patch)
tree78731a6290210dba267ee4f6f3655659334835d4 /v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
parentc1a4267284bcd81240221187f5a16454f36ba02e (diff)
downloadmediapointer-dvb-s2-ab715d2e8eb29998b60fa3bbc1ad95441cfb69b3.tar.gz
mediapointer-dvb-s2-ab715d2e8eb29998b60fa3bbc1ad95441cfb69b3.tar.bz2
v4l2-library: libv4l-sync-with-0.3.3-release
From: Hans de Goede <j.w.r.degoede@hhs.nl> * Add open64 and mmap64 wrappers to the LD_PRELOAD wrapper libs, so that they also work for applications compiled with FILE_OFFSET_BITS=64, this fixes using them with v4l-info * While looking at xawtv in general, found a few bugs in xawtv itself, added a patch to fix those to the appl-patches dir * Talking about the appl-patches dir, restore that as it accidentally got dropped from 0.3.2 * Be more verbose in various places when it comes to logging (esp errors) * Change v4lconvert_enum_fmt code a bit, so that it is easier to add more supported destination formats to libv4lconvert * Don't return -EINVAL from try_fmt when we cannot convert because the cam doesn't have any formats we know. Instead just return as format whatever the cam returns from try_fmt, this new behavior is compliant with the v4l2 api as documented Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl> Signed-off-by: Thierry MERLE <thierry.merle@free.fr>
Diffstat (limited to 'v4l2-apps/lib/libv4l/libv4l2/libv4l2.c')
-rw-r--r--v4l2-apps/lib/libv4l/libv4l2/libv4l2.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c b/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
index 0ed6ebdc6..5830576ae 100644
--- a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
+++ b/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
@@ -55,9 +55,6 @@
When modifications are made, one should be carefull that this behavior is
preserved.
*/
-
-#define _LARGEFILE64_SOURCE 1
-
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@@ -161,8 +158,9 @@ static int v4l2_map_buffers(int index)
break;
}
- devices[index].frame_pointers[i] = mmap64(NULL, buf.length,
- PROT_READ, MAP_SHARED, devices[index].fd, buf.m.offset);
+ devices[index].frame_pointers[i] = (void *)syscall(SYS_mmap2, NULL,
+ (size_t)buf.length, PROT_READ, MAP_SHARED, devices[index].fd,
+ (__off_t)(buf.m.offset >> MMAP2_PAGE_SHIFT));
if (devices[index].frame_pointers[i] == MAP_FAILED) {
int saved_err = errno;
V4L2_LOG_ERR("mmapping buffer %u: %s\n", i, strerror(errno));
@@ -583,8 +581,13 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
}
}
- if (!is_capture_request)
- return syscall(SYS_ioctl, fd, request, arg);
+ if (!is_capture_request) {
+ result = syscall(SYS_ioctl, fd, request, arg);
+ saved_err = errno;
+ v4l2_log_ioctl(request, arg, result);
+ errno = saved_err;
+ return result;
+ }
if (stream_needs_locking)
@@ -755,16 +758,22 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
struct v4l2_buffer *buf = arg;
result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_DQBUF, buf);
- if (result || !converting)
+ if (result) {
+ V4L2_LOG_ERR("dequeing buffer: %s\n", strerror(errno));
+ break;
+ }
+
+ if (!converting)
break;
/* An application can do a DQBUF before mmap-ing in the buffer,
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 = mmap64(NULL,
- devices[index].no_frames *
- V4L2_FRAME_BUF_SIZE,
+ devices[index].convert_mmap_buf = (void *)syscall(SYS_mmap2,
+ (size_t)(
+ devices[index].no_frames *
+ V4L2_FRAME_BUF_SIZE),
PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE,
-1, 0);
@@ -789,8 +798,11 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
devices[index].convert_mmap_buf +
buf->index * V4L2_FRAME_BUF_SIZE,
V4L2_FRAME_BUF_SIZE);
- if (result < 0)
+ if (result < 0) {
+ V4L2_LOG_ERR("converting / decoding frame data: %s\n",
+ v4lconvert_get_error_message(devices[index].convert));
break;
+ }
buf->bytesused = result;
buf->length = V4L2_FRAME_BUF_SIZE;
@@ -861,6 +873,10 @@ ssize_t v4l2_read (int fd, void* buffer, size_t n)
v4l2_queue_read_buffer(index, frame_index);
+ if (result < 0)
+ V4L2_LOG_ERR("converting / decoding frame data: %s\n",
+ v4lconvert_get_error_message(devices[index].convert));
+
leave:
pthread_mutex_unlock(&devices[index].stream_lock);
@@ -868,7 +884,7 @@ leave:
}
void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd,
- __off_t offset)
+ __off64_t offset)
{
int index;
unsigned int buffer_index;
@@ -882,7 +898,14 @@ void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd,
if (index != -1)
V4L2_LOG("Passing mmap(%p, %d, ..., %x, through to the driver\n",
start, (int)length, (int)offset);
- return mmap64(start, length, prot, flags, fd, offset);
+
+ if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+
+ return (void *)syscall(SYS_mmap2, start, length, prot, flags, fd,
+ (__off_t)(offset >> MMAP2_PAGE_SHIFT));
}
pthread_mutex_lock(&devices[index].stream_lock);
@@ -899,9 +922,10 @@ 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 = mmap64(NULL,
- devices[index].no_frames *
- V4L2_FRAME_BUF_SIZE,
+ devices[index].convert_mmap_buf = (void *)syscall(SYS_mmap2, NULL,
+ (size_t)(
+ devices[index].no_frames *
+ V4L2_FRAME_BUF_SIZE),
PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE,
-1, 0);