From 8fabb280152af70dddc25fd3c57a346b94326a33 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Fri, 10 Apr 2009 13:29:11 +0200 Subject: libv4l: Adds Makefile pre-requisites to libv4l From: Gilles Gigan This patch update libv4l's Makefiles so they automatically update and include dependency information for each source file. Priority: normal Signed-off-by: Gilles Gigan Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/Makefile b/v4l2-apps/libv4l/libv4l2/Makefile index 614b36cf8..c3af123c8 100644 --- a/v4l2-apps/libv4l/libv4l2/Makefile +++ b/v4l2-apps/libv4l/libv4l2/Makefile @@ -13,9 +13,10 @@ INCLUDES = ../include/libv4l2.h ifeq ($(LINKTYPE),static) V4L2_LIB = libv4l2.a +V4L2_DEPS = $(V4L2_OBJS) else V4L2_LIB = libv4l2.so -V4L2_OBJS += ../libv4lconvert/libv4lconvert.so +V4L2_DEPS += $(V4L2_OBJS) ../libv4lconvert/libv4lconvert.so TARGETS += $(V4L2CONVERT) override CPPFLAGS += -fPIC endif @@ -34,7 +35,9 @@ endif all: $(TARGETS) -$(V4L2_LIB): $(V4L2_OBJS) +include $(V4L2_OBJS:.o=.d) + +$(V4L2_LIB): $(V4L2_DEPS) $(V4L2CONVERT): $(V4L2CONVERT_O) $(V4L2_LIB) @@ -70,8 +73,12 @@ endif clean:: rm -f *.a *.so* *.o *.d libv4l2.pc log *~ *.orig *.rej +%.d: %.c + @set -e; rm -f $@; \ + gcc -MM $(CPPFLAGS) $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@ + %.o: %.c - $(CC) -c -MMD $(CPPFLAGS) $(CFLAGS) -o $@ $< + $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< %.so: $(CC) -shared $(LDFLAGS) -Wl,-soname,$@.$(LIB_RELEASE) -o $@.$(LIB_RELEASE) $^ $(LIBS_$*) -- cgit v1.2.3 From fa59c01eadd849ed2e5b0cf1406347bf632c80ed Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Mon, 13 Apr 2009 20:02:34 +0200 Subject: libv4l: add video processing: whitebalance and normalize From: Hans de Goede As the version number shows this work is the basis for a beta release of the 0.6.x series, the big change here is the addition of video processing to libv4l currently this only does whitebalance and normalizing (which turns out to be useless for most cams) but the basic framework for doing video processing, and being able to control it through fake v4l2 controls using for example v4l2ucp is there. The initial version of this code was written by 3 of my computer science students: Elmar Kleijn, Sjoerd Piepenbrink and Radjnies Bhansingh. This initial hg commit is a cleaned up and somewhat bug fixed version of their code. Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/Makefile | 2 +- v4l2-apps/libv4l/libv4l2/libv4l2.c | 15 +++++++++++++++ v4l2-apps/libv4l/libv4l2/log.c | 4 +++- 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/Makefile b/v4l2-apps/libv4l/libv4l2/Makefile index c3af123c8..4356c0975 100644 --- a/v4l2-apps/libv4l/libv4l2/Makefile +++ b/v4l2-apps/libv4l/libv4l2/Makefile @@ -3,7 +3,7 @@ override CPPFLAGS += -I../include -I../../../include -fvisibility=hidden CFLAGS := -g -O1 CFLAGS += -Wall -Wno-unused -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -LIBS_libv4l2 = -lpthread +LIBS_libv4l2 = -lpthread -lrt V4L2_OBJS = libv4l2.o log.o V4L2CONVERT = v4l2convert.so diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index b6ddef6e8..91e0193ee 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -676,6 +676,9 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) /* Is this a capture request and do we need to take the stream lock? */ switch (request) { + case VIDIOC_QUERYCTRL: + case VIDIOC_G_CTRL: + case VIDIOC_S_CTRL: case VIDIOC_QUERYCAP: is_capture_request = 1; break; @@ -739,6 +742,18 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) &devices[index].src_fmt, &devices[index].dest_fmt); switch (request) { + case VIDIOC_QUERYCTRL: + result = v4lconvert_vidioc_queryctrl(devices[index].convert, arg); + break; + + case VIDIOC_G_CTRL: + result = v4lconvert_vidioc_g_ctrl(devices[index].convert, arg); + break; + + case VIDIOC_S_CTRL: + result = v4lconvert_vidioc_s_ctrl(devices[index].convert, arg); + break; + case VIDIOC_QUERYCAP: { struct v4l2_capability *cap = arg; diff --git a/v4l2-apps/libv4l/libv4l2/log.c b/v4l2-apps/libv4l/libv4l2/log.c index c29086ff4..251b46ecf 100644 --- a/v4l2-apps/libv4l/libv4l2/log.c +++ b/v4l2-apps/libv4l/libv4l2/log.c @@ -1,5 +1,7 @@ /* -# (C) 2008 Hans de Goede +# (C) 2008 Elmar Kleijn +# (C) 2008 Sjoerd Piepenbrink +# (C) 2008 Hans de Goede # 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 -- cgit v1.2.3 From 58d3334b54c207b8e04e7035969e0c2acfa1ce73 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Tue, 14 Apr 2009 15:03:07 +0200 Subject: libv4l: Only allow supported destination formats when doing processing From: Hans de Goede Only report / allow supported destination formats in enum_fmt / try_fmt / g_fmt / s_fmt when processing, rotating or flipping. Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index 91e0193ee..8d01b034c 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -516,6 +516,14 @@ int v4l2_fd_open(int fd, int v4l2_flags) V4L2_LOG("open: %d\n", fd); + if (v4lconvert_supported_dst_fmt_only(convert) && + !v4lconvert_supported_dst_format(fmt.fmt.pix.pixelformat)) { + V4L2_LOG("open %d: setting pixelformat to RGB24\n", fd); + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; + v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt); + V4L2_LOG("open %d: done setting pixelformat\n", fd); + } + return fd; } -- cgit v1.2.3 From 67f9c69681d56764910ae950b367bc99dfc51d4f Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Tue, 14 Apr 2009 16:49:43 +0200 Subject: libv4l: fix reading wrong memory when doing yuv420->rgb conversion From: Hans de Goede Fix reading outside of the source memory when doing yuv420->rgb conversion. Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/log.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/log.c b/v4l2-apps/libv4l/libv4l2/log.c index 251b46ecf..a08ae3554 100644 --- a/v4l2-apps/libv4l/libv4l2/log.c +++ b/v4l2-apps/libv4l/libv4l2/log.c @@ -163,7 +163,7 @@ void v4l2_log_ioctl(unsigned long int request, void *arg, int result) struct v4l2_frmsizeenum *frmsize = arg; int pixfmt = frmsize->pixel_format; - fprintf(v4l2_log_file, " index: %u pixelformat: %c%c%c%c", + fprintf(v4l2_log_file, " index: %u pixelformat: %c%c%c%c\n", frmsize->index, pixfmt & 0xff, (pixfmt >> 8) & 0xff, @@ -171,12 +171,12 @@ void v4l2_log_ioctl(unsigned long int request, void *arg, int result) pixfmt >> 24); switch (frmsize->type) { case V4L2_FRMSIZE_TYPE_DISCRETE: - fprintf(v4l2_log_file, " %ux%u\n", frmsize->discrete.width, + fprintf(v4l2_log_file, " %ux%u\n", frmsize->discrete.width, frmsize->discrete.height); break; case V4L2_FRMSIZE_TYPE_CONTINUOUS: case V4L2_FRMSIZE_TYPE_STEPWISE: - fprintf(v4l2_log_file, " %ux%u -> %ux%u\n", + fprintf(v4l2_log_file, " %ux%u -> %ux%u\n", frmsize->stepwise.min_width, frmsize->stepwise.min_height, frmsize->stepwise.max_width, frmsize->stepwise.max_height); break; @@ -188,7 +188,7 @@ void v4l2_log_ioctl(unsigned long int request, void *arg, int result) struct v4l2_frmivalenum *frmival = arg; int pixfmt = frmival->pixel_format; - fprintf(v4l2_log_file, " index: %u pixelformat: %c%c%c%c %ux%u: ", + fprintf(v4l2_log_file, " index: %u pixelformat: %c%c%c%c %ux%u:\n", frmival->index, pixfmt & 0xff, (pixfmt >> 8) & 0xff, @@ -198,12 +198,12 @@ void v4l2_log_ioctl(unsigned long int request, void *arg, int result) frmival->height); switch (frmival->type) { case V4L2_FRMIVAL_TYPE_DISCRETE: - fprintf(v4l2_log_file, "%u/%u\n", frmival->discrete.numerator, + fprintf(v4l2_log_file, " %u/%u\n", frmival->discrete.numerator, frmival->discrete.denominator); break; case V4L2_FRMIVAL_TYPE_CONTINUOUS: case V4L2_FRMIVAL_TYPE_STEPWISE: - fprintf(v4l2_log_file, "%u/%u -> %u/%u\n", + fprintf(v4l2_log_file, " %u/%u -> %u/%u\n", frmival->stepwise.min.numerator, frmival->stepwise.min.denominator, frmival->stepwise.max.numerator, -- cgit v1.2.3 From 3c523ed18793284d90b8b2940f85e747dd24ac47 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Wed, 15 Apr 2009 14:03:32 +0200 Subject: libv4l: Don't add "fake" controls when not doing conversion From: Hans de Goede Since all things fake controls enable (such as whitebalancing) depend upon libv4lconvert_convert being called, do not fake controls when conversion is disabled. Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index 8d01b034c..fc5e63eaa 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -687,6 +687,9 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) case VIDIOC_QUERYCTRL: case VIDIOC_G_CTRL: case VIDIOC_S_CTRL: + if (!(devices[index].flags & V4L2_DISABLE_CONVERSION)) + is_capture_request = 1; + break; case VIDIOC_QUERYCAP: is_capture_request = 1; break; -- cgit v1.2.3 From 419bda948df875f0c02e25d005d8d20b58fc0931 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Thu, 16 Apr 2009 10:49:08 +0200 Subject: libv4l: link libv4lcontrol against rt, not libv4l2 From: Hans de Goede libv4l: link libv4lcontrol against rt, not libv4l2 Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/Makefile b/v4l2-apps/libv4l/libv4l2/Makefile index 4356c0975..463e4e833 100644 --- a/v4l2-apps/libv4l/libv4l2/Makefile +++ b/v4l2-apps/libv4l/libv4l2/Makefile @@ -3,7 +3,7 @@ override CPPFLAGS += -I../include -I../../../include -fvisibility=hidden CFLAGS := -g -O1 CFLAGS += -Wall -Wno-unused -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -LIBS_libv4l2 = -lpthread -lrt +LIBS_libv4l2 = -lpthread V4L2_OBJS = libv4l2.o log.o V4L2CONVERT = v4l2convert.so @@ -86,4 +86,3 @@ clean:: %.a: $(AR) cqs $@ $^ - -- cgit v1.2.3 From 9fdc384d90d5bfd705bd5d619d2a7fbdd93aeaf0 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Thu, 16 Apr 2009 10:52:39 +0200 Subject: libv4l: Makefiles: better dependency generation From: Gregor Jasny libv4l: Makefiles: better dependency generation Priority: normal Signed-off-by: Gregor Jasny Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/Makefile b/v4l2-apps/libv4l/libv4l2/Makefile index 463e4e833..6a2271572 100644 --- a/v4l2-apps/libv4l/libv4l2/Makefile +++ b/v4l2-apps/libv4l/libv4l2/Makefile @@ -35,7 +35,7 @@ endif all: $(TARGETS) -include $(V4L2_OBJS:.o=.d) +-include $(V4L2_OBJS:.o=.d) $(V4L2_LIB): $(V4L2_DEPS) @@ -73,12 +73,8 @@ endif clean:: rm -f *.a *.so* *.o *.d libv4l2.pc log *~ *.orig *.rej -%.d: %.c - @set -e; rm -f $@; \ - gcc -MM $(CPPFLAGS) $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@ - %.o: %.c - $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< + $(CC) -Wp,-MMD,"$*.d",-MQ,"$@",-MP -c $(CPPFLAGS) $(CFLAGS) -o $@ $< %.so: $(CC) -shared $(LDFLAGS) -Wl,-soname,$@.$(LIB_RELEASE) -o $@.$(LIB_RELEASE) $^ $(LIBS_$*) -- cgit v1.2.3 From fbb8b6b6db6a69404ec9735bff66ca628dd6c2f5 Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Thu, 21 May 2009 16:20:32 +0200 Subject: libv4l: Do not set format for control applications From: Hans de Goede When we must do conversion (as we want todo flipping / processing) and the cam does not default to a supported dest format, we set the emulated format to rgb24, wait with doing this till the app actually does something format related, otherwise control applications like v4l2ucp used to become the stream owner locking out other apps. Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index fc5e63eaa..4f88ffd73 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -77,6 +77,7 @@ #define V4L2_STREAM_CONTROLLED_BY_READ 0x0400 #define V4L2_SUPPORTS_READ 0x0800 #define V4L2_IS_UVC 0x1000 +#define V4L2_STREAM_TOUCHED 0x2000 #define V4L2_MMAP_OFFSET_MAGIC 0xABCDEF00u @@ -516,14 +517,6 @@ int v4l2_fd_open(int fd, int v4l2_flags) V4L2_LOG("open: %d\n", fd); - if (v4lconvert_supported_dst_fmt_only(convert) && - !v4lconvert_supported_dst_format(fmt.fmt.pix.pixelformat)) { - V4L2_LOG("open %d: setting pixelformat to RGB24\n", fd); - fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; - v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt); - V4L2_LOG("open %d: done setting pixelformat\n", fd); - } - return fd; } @@ -746,8 +739,27 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) } - if (stream_needs_locking) + if (stream_needs_locking) { + /* If this is the first stream related ioctl, and we should only allow + libv4lconvert supported destination formats (so that it can do flipping, + processing, etc.) and the current destination format is not supported, + try setting the format to RGB24 (which is a supported dest. format). */ + if (!(devices[index].flags & V4L2_STREAM_TOUCHED) && + !(devices[index].flags & V4L2_DISABLE_CONVERSION) && + v4lconvert_supported_dst_fmt_only(devices[index].convert) && + !v4lconvert_supported_dst_format( + devices[index].dest_fmt.fmt.pix.pixelformat)) { + struct v4l2_format fmt = devices[index].dest_fmt; + + V4L2_LOG("Setting pixelformat to RGB24 (supported_dst_fmt_only)"); + devices[index].flags |= V4L2_STREAM_TOUCHED; + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; + v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt); + V4L2_LOG("Done setting pixelformat (supported_dst_fmt_only)"); + } pthread_mutex_lock(&devices[index].stream_lock); + devices[index].flags |= V4L2_STREAM_TOUCHED; + } converting = v4lconvert_needs_conversion(devices[index].convert, &devices[index].src_fmt, &devices[index].dest_fmt); -- cgit v1.2.3 From e021d3a000c760f4af4aa098b1d5a2dd24a86129 Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Thu, 21 May 2009 16:49:03 +0200 Subject: libv4l: fix detection of conversion mode in v4l2_buffers_mapped() From: Hans de Goede libv4l: fix detection of conversion mode in v4l2_buffers_mapped() Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index 4f88ffd73..2562987b4 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -369,8 +369,8 @@ static int v4l2_buffers_mapped(int index) { unsigned int i; - if (devices[index].src_fmt.fmt.pix.pixelformat == - devices[index].dest_fmt.fmt.pix.pixelformat) { + if (!v4lconvert_needs_conversion(devices[index].convert, + &devices[index].src_fmt, &devices[index].dest_fmt)) { /* Normal (no conversion) mode */ struct v4l2_buffer buf; @@ -559,7 +559,6 @@ int v4l2_close(int fd) /* Free resources */ v4l2_unmap_buffers(index); - v4lconvert_destroy(devices[index].convert); if (devices[index].convert_mmap_buf != MAP_FAILED) { if (v4l2_buffers_mapped(index)) V4L2_LOG_WARN("v4l2 mmap buffers still mapped on close()\n"); @@ -568,6 +567,7 @@ int v4l2_close(int fd) devices[index].no_frames * V4L2_FRAME_BUF_SIZE); devices[index].convert_mmap_buf = MAP_FAILED; } + v4lconvert_destroy(devices[index].convert); /* Remove the fd from our list of managed fds before closing it, because as soon as we've done the actual close the fd maybe returned by an open in -- cgit v1.2.3 From 5a77f99540d308be03bced1c0dea4f480cd50894 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Thu, 21 May 2009 22:34:25 +0200 Subject: libv4l: better handling of the V4L2_DISABLE_CONVERSION flag From: Hans de Goede libv4l: better handling of the V4L2_DISABLE_CONVERSION flag Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index 2562987b4..053e6e28b 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -365,12 +365,20 @@ static int v4l2_deactivate_read_stream(int index) return 0; } +static int v4l2_needs_conversion(int index) +{ + if (!(devices[index].flags & V4L2_DISABLE_CONVERSION)) + return v4lconvert_needs_conversion(devices[index].convert, + &devices[index].src_fmt, &devices[index].dest_fmt); + + return 0; +} + static int v4l2_buffers_mapped(int index) { unsigned int i; - if (!v4lconvert_needs_conversion(devices[index].convert, - &devices[index].src_fmt, &devices[index].dest_fmt)) { + if (!v4l2_needs_conversion(index)) { /* Normal (no conversion) mode */ struct v4l2_buffer buf; @@ -660,7 +668,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) { void *arg; va_list ap; - int result, converting, index, saved_err; + int result, index, saved_err; int is_capture_request = 0, stream_needs_locking = 0; va_start (ap, request); @@ -697,7 +705,8 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) is_capture_request = 1; break; case VIDIOC_TRY_FMT: - if (((struct v4l2_format *)arg)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) + if (((struct v4l2_format *)arg)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && + !(devices[index].flags & V4L2_DISABLE_CONVERSION)) is_capture_request = 1; break; case VIDIOC_S_FMT: @@ -761,9 +770,6 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) devices[index].flags |= V4L2_STREAM_TOUCHED; } - converting = v4lconvert_needs_conversion(devices[index].convert, - &devices[index].src_fmt, &devices[index].dest_fmt); - switch (request) { case VIDIOC_QUERYCTRL: result = v4lconvert_vidioc_queryctrl(devices[index].convert, arg); @@ -943,7 +949,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); - if (result || !converting) + if (result || !v4l2_needs_conversion(index)) break; buf->m.offset = V4L2_MMAP_OFFSET_MAGIC | buf->index; @@ -961,7 +967,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) break; /* With some drivers the buffers must be mapped before queuing */ - if (converting) + if (v4l2_needs_conversion(index)) if ((result = v4l2_map_buffers(index))) break; @@ -976,7 +982,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) if ((result = v4l2_deactivate_read_stream(index))) break; - if (!converting) { + if (!v4l2_needs_conversion(index)) { result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_DQBUF, buf); if (result) { int saved_err = errno; @@ -1063,8 +1069,7 @@ ssize_t v4l2_read (int fd, void* dest, size_t n) /* When not converting and the device supports read let the kernel handle it */ if ((devices[index].flags & V4L2_SUPPORTS_READ) && - !v4lconvert_needs_conversion(devices[index].convert, - &devices[index].src_fmt, &devices[index].dest_fmt)) { + !v4l2_needs_conversion(index)) { result = syscall(SYS_read, fd, dest, n); goto leave; } @@ -1123,8 +1128,7 @@ void *v4l2_mmap(void *start, size_t length, int prot, int flags, int fd, buffer_index = offset & 0xff; if (buffer_index >= devices[index].no_frames || /* Got magic offset and not converting ?? */ - !v4lconvert_needs_conversion(devices[index].convert, - &devices[index].src_fmt, &devices[index].dest_fmt)) { + !v4l2_needs_conversion(index)) { errno = EINVAL; result = MAP_FAILED; goto leave; -- cgit v1.2.3 From 2ffc360be1c38ab86399d6d574ee7cc0671c03d6 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Mon, 25 May 2009 15:35:21 +0200 Subject: libv4l: Obsolete the V4L2_ENABLE_ENUM_FMT_EMULATION v4l2_fd_open flag From: Hans de Goede The V4L2_ENABLE_ENUM_FMT_EMULATION v4l2_fd_open flag is obsolete, libv4l2 now *always* reports emulated formats through the ENUM_FMT ioctl Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 4 ++-- v4l2-apps/libv4l/libv4l2/v4l2convert.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index 053e6e28b..382dc405b 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -696,12 +696,12 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) break; case VIDIOC_ENUM_FMT: if (((struct v4l2_fmtdesc *)arg)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && - (devices[index].flags & V4L2_ENABLE_ENUM_FMT_EMULATION)) + !(devices[index].flags & V4L2_DISABLE_CONVERSION)) is_capture_request = 1; break; case VIDIOC_ENUM_FRAMESIZES: case VIDIOC_ENUM_FRAMEINTERVALS: - if (devices[index].flags & V4L2_ENABLE_ENUM_FMT_EMULATION) + if (!(devices[index].flags & V4L2_DISABLE_CONVERSION)) is_capture_request = 1; break; case VIDIOC_TRY_FMT: diff --git a/v4l2-apps/libv4l/libv4l2/v4l2convert.c b/v4l2-apps/libv4l/libv4l2/v4l2convert.c index 307a03ce5..b1354772d 100644 --- a/v4l2-apps/libv4l/libv4l2/v4l2convert.c +++ b/v4l2-apps/libv4l/libv4l2/v4l2convert.c @@ -92,7 +92,7 @@ LIBV4L_PUBLIC int open (const char *file, int oflag, ...) /* Try to Register with libv4l2 (in case of failure pass the fd to the application as is) */ - v4l2_fd_open(fd, V4L2_ENABLE_ENUM_FMT_EMULATION); + v4l2_fd_open(fd, 0); return fd; } -- cgit v1.2.3 From 5999b7d164dbf3118a3a75ee3f6f0b48cb8845c1 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Tue, 2 Jun 2009 15:34:34 +0200 Subject: libv4l: initial support for compiling on FreeBSD From: Hans Petter Selasky Add a patch by Hans Petter Selasky , 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 Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2-priv.h | 9 +--- v4l2-apps/libv4l/libv4l2/libv4l2.c | 84 ++++++++++++++++----------------- v4l2-apps/libv4l/libv4l2/log.c | 7 +-- v4l2-apps/libv4l/libv4l2/v4l2convert.c | 18 ++++--- 4 files changed, 51 insertions(+), 67 deletions(-) (limited to 'v4l2-apps/libv4l/libv4l2') 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 #include /* 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 #include #include -#include #include #include #include @@ -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 #include #include -#include -/* 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 -#include -/* end broken header workaround includes */ +#include "../libv4lconvert/libv4lsyscall-priv.h" #include #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 #include -#include #include #include #include #include -/* 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 -#include -#include -/* end broken header workaround includes */ +#include "../libv4lconvert/libv4lsyscall-priv.h" #include #include @@ -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) { -- cgit v1.2.3 From f78597ecea4ce107d99124eca84df338bfcbb29a Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Mon, 8 Jun 2009 11:22:32 +0200 Subject: libv4l: remove DEADJOE files during make clean From: Gregor Jasny libv4l: remove DEADJOE files during make clean Priority: normal Signed-off-by: Gregor Jasny Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/Makefile b/v4l2-apps/libv4l/libv4l2/Makefile index 6a2271572..06c010f3c 100644 --- a/v4l2-apps/libv4l/libv4l2/Makefile +++ b/v4l2-apps/libv4l/libv4l2/Makefile @@ -71,7 +71,7 @@ endif install -m 644 libv4l2.pc $(DESTDIR)$(LIBDIR)/pkgconfig clean:: - rm -f *.a *.so* *.o *.d libv4l2.pc log *~ *.orig *.rej + rm -f *.a *.so* *.o *.d libv4l2.pc log *~ *.orig *.rej DEADJOE %.o: %.c $(CC) -Wp,-MMD,"$*.d",-MQ,"$@",-MP -c $(CPPFLAGS) $(CFLAGS) -o $@ $< -- cgit v1.2.3 From f62a7a8cd7c03f7694ea5260ac38b1f2cf7826d5 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Wed, 17 Jun 2009 15:38:46 +0200 Subject: libv4l: Report aligned resolution on first get_fmt From: Hans de Goede When a user does a try_fmt with the current dest_fmt and the dest_fmt is a supported one we will align the resulution (see try_fmt for why). Do the on the result of the first get_fmt, so that a try_fmt on the result of a get_fmt done immediately after open leaves the fmt unchanged Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index a12b41c2c..36fb8e21e 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -507,6 +507,16 @@ int v4l2_fd_open(int fd, int v4l2_flags) devices[index].src_fmt = fmt; devices[index].dest_fmt = fmt; + /* When a user does a try_fmt with the current dest_fmt and the dest_fmt + is a supported one we will align the resulution (see try_fmt for why). + Do the same here now, so that a try_fmt on the result of a get_fmt done + immediately after open leaves the fmt unchanged. */ + if (v4lconvert_supported_dst_format( + devices[index].dest_fmt.fmt.pix.pixelformat)) { + devices[index].dest_fmt.fmt.pix.width &= ~7; + devices[index].dest_fmt.fmt.pix.height &= ~1; + } + pthread_mutex_init(&devices[index].stream_lock, NULL); devices[index].no_frames = 0; @@ -748,6 +758,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) if (stream_needs_locking) { + pthread_mutex_lock(&devices[index].stream_lock); /* If this is the first stream related ioctl, and we should only allow libv4lconvert supported destination formats (so that it can do flipping, processing, etc.) and the current destination format is not supported, @@ -765,7 +776,6 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt); V4L2_LOG("Done setting pixelformat (supported_dst_fmt_only)"); } - pthread_mutex_lock(&devices[index].stream_lock); devices[index].flags |= V4L2_STREAM_TOUCHED; } -- cgit v1.2.3 From e84f05aeceff30413ad2d1ee68bb11888e04e167 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Wed, 17 Jun 2009 15:45:32 +0200 Subject: libv4l: fix deadlock introduced by locking fix in previous patch From: Hans de Goede libv4l: fix deadlock introduced by locking fix in previous patch Priority: normal Signed-off-by: Hans de Goede --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'v4l2-apps/libv4l/libv4l2') diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index 36fb8e21e..b71c9b4c6 100644 --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c @@ -773,7 +773,9 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) V4L2_LOG("Setting pixelformat to RGB24 (supported_dst_fmt_only)"); devices[index].flags |= V4L2_STREAM_TOUCHED; fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; + pthread_mutex_unlock(&devices[index].stream_lock); v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt); + pthread_mutex_lock(&devices[index].stream_lock); V4L2_LOG("Done setting pixelformat (supported_dst_fmt_only)"); } devices[index].flags |= V4L2_STREAM_TOUCHED; -- cgit v1.2.3