[zbar-commits] push rev [345]: fix v4l config and build variations (bug #3348888)
Status: Beta
Brought to you by:
spadix
From: <sp...@us...> - 2011-09-19 20:35:18
|
changeset: 345:443c9f0e3c8f user: sp...@us... date: Mon Sep 19 10:36:29 2011 -0700 details: http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbarzbar/rev/443c9f0e3c8f description: fix v4l config and build variations (bug #3348888) - thanks to jarekczek for reporting this! - NB v4l1 removed from kernel as of 2.6.38 diffstat: ChangeLog | 3 ++ configure.ac | 36 +++++++++++++++------------ test/Makefile.am.inc | 2 +- zbar/Makefile.am.inc | 9 ++++-- zbar/video/v4l.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ zbar/video/v4l1.c | 32 +----------------------- 6 files changed, 99 insertions(+), 50 deletions(-) diffs (225 lines): diff -r cd365c1a623d -r 443c9f0e3c8f ChangeLog --- a/ChangeLog Sun Sep 18 18:44:38 2011 -0700 +++ b/ChangeLog Mon Sep 19 10:36:29 2011 -0700 @@ -1,4 +1,7 @@ current: + * fix v4l config and build variations (bug #3348888) + - thanks to jarekczek for reporting this! + - NB v4l1 removed from kernel as of 2.6.38 * fix missing python thread initialization (bug #3349199) - thanks to jarekczek for reporting this problem! * fix missing configure check for Python.h (bug #3092663) diff -r cd365c1a623d -r 443c9f0e3c8f configure.ac --- a/configure.ac Sun Sep 18 18:44:38 2011 -0700 +++ b/configure.ac Mon Sep 19 10:36:29 2011 -0700 @@ -176,23 +176,26 @@ [], [enable_video="yes"]) -with_video="no" -AS_IF([test "x$enable_video" != "xno"], - [AS_IF([test "x$win32" = "xno"], - [AC_CHECK_HEADERS([linux/videodev.h], [with_video="v4l1"], - [AC_MSG_FAILURE([test for video support failed! +have_v4l1="no" +have_v4l2="no" +AS_IF([test "x$enable_video" = "xno"], + [], + [test "x$win32" = "xno"], + [AC_CHECK_HEADERS([linux/videodev.h], [have_v4l1="yes"]) + AC_CHECK_HEADERS([linux/videodev2.h], [have_v4l2="yes"]) + AS_IF([test "x$have_v4l2" = "xno" && test "x$have_v4l1" = "xno"], + [AC_MSG_FAILURE([test for video support failed! rebuild your kernel to include video4linux support or -configure --disable-video to skip building video support.])]) - AC_CHECK_HEADERS([linux/videodev2.h], [with_video="v4l2"], - [AC_MSG_WARN([v4l2 API not detected, upgrade your kernel!])])], - [AC_CHECK_HEADERS([vfw.h], [with_video="vfw"], - [AC_MSG_FAILURE([test for VfW video support failed! -configure --disable-video to skip building vidoe support.])])]) -]) +configure --disable-video to skip building video support.])], + [test "x$have_v4l2" = "xno"], + [AC_MSG_WARN([v4l2 API not detected, upgrade your kernel!])])], + [AC_CHECK_HEADERS([vfw.h], [with_video="vfw"], + [AC_MSG_FAILURE([test for VfW video support failed! +configure --disable-video to skip building video support.])])]) + AM_CONDITIONAL([HAVE_VIDEO], [test "x$enable_video" != "xno"]) -AM_CONDITIONAL([HAVE_V4L1], - [test "x$with_video" = "xv4l1" || test "x$with_video" = "xv4l2"]) -AM_CONDITIONAL([HAVE_V4L2], [test "x$with_video" = "xv4l2"]) +AM_CONDITIONAL([HAVE_V4L1], [test "x$have_v4l1" != "xno"]) +AM_CONDITIONAL([HAVE_V4L2], [test "x$have_v4l2" != "xno"]) dnl X AC_ARG_VAR([XSHM_LIBS], [linker flags for X shared memory extension]) @@ -509,7 +512,8 @@ dnl FIXME switches for shm, mmap AC_HEADER_ASSERT AC_CHECK_HEADERS([errno.h fcntl.h features.h inttypes.h stdlib.h string.h \ - unistd.h sys/ioctl.h sys/time.h sys/times.h sys/ipc.h sys/shm.h sys/mman.h]) + unistd.h sys/types.h sys/stat.h sys/ioctl.h sys/time.h sys/times.h \ + sys/ipc.h sys/shm.h sys/mman.h]) dnl types diff -r cd365c1a623d -r 443c9f0e3c8f test/Makefile.am.inc --- a/test/Makefile.am.inc Sun Sep 18 18:44:38 2011 -0700 +++ b/test/Makefile.am.inc Mon Sep 19 10:36:29 2011 -0700 @@ -84,4 +84,4 @@ check-local: check-cpp check-decoder check-images regress: regress-decoder regress-images -.PHONY: check-decoder check-images regress-decoder regress-images regress +.PHONY: check-cpp check-decoder check-images regress-decoder regress-images regress diff -r cd365c1a623d -r 443c9f0e3c8f zbar/Makefile.am.inc --- a/zbar/Makefile.am.inc Sun Sep 18 18:44:38 2011 -0700 +++ b/zbar/Makefile.am.inc Mon Sep 19 10:36:29 2011 -0700 @@ -59,11 +59,14 @@ zbar_libzbar_la_SOURCES += zbar/processor/posix.h zbar/processor/posix.c endif +if HAVE_V4L2 +zbar_libzbar_la_SOURCES += zbar/video/v4l.c zbar/video/v4l2.c +endif if HAVE_V4L1 +if !HAVE_V4L2 +zbar_libzbar_la_SOURCES += zbar/video/v4l.c +endif zbar_libzbar_la_SOURCES += zbar/video/v4l1.c -if HAVE_V4L2 -zbar_libzbar_la_SOURCES += zbar/video/v4l2.c -endif endif if WIN32 if HAVE_VIDEO diff -r cd365c1a623d -r 443c9f0e3c8f zbar/video/v4l.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zbar/video/v4l.c Mon Sep 19 10:36:29 2011 -0700 @@ -0,0 +1,67 @@ +/*------------------------------------------------------------------------ + * Copyright 2007-2011 (c) Jeff Brown <sp...@us...> + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include <config.h> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#ifdef HAVE_FCNTL_H +# include <fcntl.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif + +#include "video.h" + +extern int _zbar_v4l1_probe(zbar_video_t*); +extern int _zbar_v4l2_probe(zbar_video_t*); + +int _zbar_video_open (zbar_video_t *vdo, + const char *dev) +{ + vdo->fd = open(dev, O_RDWR); + if(vdo->fd < 0) + return(err_capture_str(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, + "opening video device '%s'", dev)); + zprintf(1, "opened camera device %s (fd=%d)\n", dev, vdo->fd); + + int rc = -1; +#ifdef HAVE_LINUX_VIDEODEV2_H + if(vdo->intf != VIDEO_V4L1) + rc = _zbar_v4l2_probe(vdo); +#endif +#ifdef HAVE_LINUX_VIDEODEV_H + if(rc && vdo->intf != VIDEO_V4L2) + rc = _zbar_v4l1_probe(vdo); +#endif + + if(rc && vdo->fd >= 0) { + close(vdo->fd); + vdo->fd = -1; + } + return(rc); +} diff -r cd365c1a623d -r 443c9f0e3c8f zbar/video/v4l1.c --- a/zbar/video/v4l1.c Sun Sep 18 18:44:38 2011 -0700 +++ b/zbar/video/v4l1.c Mon Sep 19 10:36:29 2011 -0700 @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2009 (c) Jeff Brown <sp...@us...> + * Copyright 2007-2011 (c) Jeff Brown <sp...@us...> * * This file is part of the ZBar Bar Code Reader. * @@ -46,8 +46,6 @@ #include "video.h" #include "image.h" -extern int _zbar_v4l2_probe(zbar_video_t*); - typedef struct v4l1_format_s { uint32_t format; uint8_t bpp; @@ -371,7 +369,7 @@ return(0); } -static int _zbar_v4l1_probe (zbar_video_t *vdo) +int _zbar_v4l1_probe (zbar_video_t *vdo) { /* check capabilities */ struct video_capability vcap; @@ -407,29 +405,3 @@ vdo->dq = v4l1_dq; return(0); } - -int _zbar_video_open (zbar_video_t *vdo, - const char *dev) -{ - vdo->fd = open(dev, O_RDWR); - if(vdo->fd < 0) - return(err_capture_str(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, - "opening video device '%s'", dev)); - zprintf(1, "opened camera device %s (fd=%d)\n", dev, vdo->fd); - - int rc = -1; -#ifdef HAVE_LINUX_VIDEODEV2_H - if(vdo->intf != VIDEO_V4L1) - rc = _zbar_v4l2_probe(vdo); - if(rc) -#else - zprintf(1, "WARNING: not compiled with v4l2 support, trying v4l1\n"); -#endif - rc = _zbar_v4l1_probe(vdo); - - if(rc && vdo->fd >= 0) { - close(vdo->fd); - vdo->fd = -1; - } - return(rc); -} |