|
|
@ -1,522 +1,119 @@
|
|
|
|
diff --git a/configure.ac b/configure.ac
|
|
|
|
diff -r 38e78368283d configure.ac
|
|
|
|
--- a/configure.ac
|
|
|
|
--- a/configure.ac Sun Oct 14 23:02:08 2012 -0700
|
|
|
|
+++ b/configure.ac
|
|
|
|
+++ b/configure.ac Fri Feb 22 10:04:52 2013 -0300
|
|
|
|
@@ -179,20 +179,13 @@ AC_ARG_ENABLE([video],
|
|
|
|
@@ -3,7 +3,8 @@
|
|
|
|
with_video="no"
|
|
|
|
AC_INIT([zbar], [0.10], [spadix@users.sourceforge.net])
|
|
|
|
AS_IF([test "x$enable_video" != "xno"],
|
|
|
|
AC_CONFIG_AUX_DIR(config)
|
|
|
|
[AS_IF([test "x$win32" = "xno"],
|
|
|
|
AC_CONFIG_MACRO_DIR(config)
|
|
|
|
- [AC_CHECK_HEADERS([linux/videodev.h], [with_video="v4l1"],
|
|
|
|
-AM_INIT_AUTOMAKE([1.10 -Wall -Werror foreign subdir-objects std-options dist-bzip2])
|
|
|
|
- [AC_MSG_FAILURE([test for video support failed!
|
|
|
|
+AM_INIT_AUTOMAKE([1.10 -Werror foreign subdir-objects std-options dist-bzip2])
|
|
|
|
-rebuild your kernel to include video4linux support or
|
|
|
|
+AM_PROG_AR
|
|
|
|
-configure --disable-video to skip building video support.])])
|
|
|
|
AC_CONFIG_HEADERS([include/config.h])
|
|
|
|
- AC_CHECK_HEADERS([linux/videodev2.h], [with_video="v4l2"],
|
|
|
|
AC_CONFIG_SRCDIR(zbar/scanner.c)
|
|
|
|
+ [AC_CHECK_LIB([v4l2], [v4l2_open], [],
|
|
|
|
LT_PREREQ([2.2])
|
|
|
|
[AC_MSG_WARN([v4l2 API not detected, upgrade your kernel!])])],
|
|
|
|
@@ -47,7 +48,7 @@
|
|
|
|
[AC_CHECK_HEADERS([vfw.h], [with_video="vfw"],
|
|
|
|
[Library revision])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AM_CPPFLAGS="-I$srcdir/include"
|
|
|
|
|
|
|
|
-AM_CFLAGS="-Wall -Wno-parentheses -Werror"
|
|
|
|
|
|
|
|
+AM_CFLAGS="-Wall -Wno-parentheses"
|
|
|
|
|
|
|
|
AM_CXXFLAGS="$AM_CFLAGS"
|
|
|
|
|
|
|
|
AC_SUBST([AM_CPPFLAGS])
|
|
|
|
|
|
|
|
AC_SUBST([AM_CFLAGS])
|
|
|
|
|
|
|
|
@@ -179,11 +180,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
have_v4l1="no"
|
|
|
|
|
|
|
|
have_v4l2="no"
|
|
|
|
|
|
|
|
+have_libv4l="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"])
|
|
|
|
|
|
|
|
+ AC_CHECK_HEADERS([libv4l2.h], [have_libv4l="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
|
|
|
|
|
|
|
|
@@ -194,9 +197,15 @@
|
|
|
|
[AC_MSG_FAILURE([test for VfW video support failed!
|
|
|
|
[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.])])])
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
+AS_IF([test "x$have_libv4l" = "xyes"],
|
|
|
|
|
|
|
|
+ AC_CHECK_LIB([v4l2], [v4l2_open], [],
|
|
|
|
|
|
|
|
+ [AC_MSG_FAILURE([unable to find libv4l.so])]),
|
|
|
|
|
|
|
|
+ [AC_MSG_WARN([libv4l not detected. Install it to support more cameras!])])
|
|
|
|
|
|
|
|
+
|
|
|
|
AM_CONDITIONAL([HAVE_VIDEO], [test "x$enable_video" != "xno"])
|
|
|
|
AM_CONDITIONAL([HAVE_VIDEO], [test "x$enable_video" != "xno"])
|
|
|
|
-AM_CONDITIONAL([HAVE_V4L1],
|
|
|
|
AM_CONDITIONAL([HAVE_V4L1], [test "x$have_v4l1" != "xno"])
|
|
|
|
- [test "x$with_video" = "xv4l1" || test "x$with_video" = "xv4l2"])
|
|
|
|
AM_CONDITIONAL([HAVE_V4L2], [test "x$have_v4l2" != "xno"])
|
|
|
|
-AM_CONDITIONAL([HAVE_V4L2], [test "x$with_video" = "xv4l2"])
|
|
|
|
+AM_CONDITIONAL([HAVE_LIBV4L], [test "x$have_libv4l" != "xno"])
|
|
|
|
|
|
|
|
|
|
|
|
dnl X
|
|
|
|
dnl X
|
|
|
|
AC_ARG_VAR([XSHM_LIBS], [linker flags for X shared memory extension])
|
|
|
|
AC_ARG_VAR([XSHM_LIBS], [linker flags for X shared memory extension])
|
|
|
|
@@ -500,7 +493,7 @@ echo "please verify that the detected co
|
|
|
|
@@ -571,6 +580,8 @@
|
|
|
|
echo "------------------------------------------------------------------------"
|
|
|
|
echo "v4l --enable-video=$enable_video"
|
|
|
|
echo "X --with-x=$have_x"
|
|
|
|
|
|
|
|
echo "pthreads --enable-pthread=$enable_pthread"
|
|
|
|
|
|
|
|
-echo "v4l --enable-video=$enable_video"
|
|
|
|
|
|
|
|
+echo "v4l2 --enable-video=$enable_video"
|
|
|
|
|
|
|
|
AS_IF([test "x$enable_video" != "xyes"],
|
|
|
|
AS_IF([test "x$enable_video" != "xyes"],
|
|
|
|
[echo " => zbarcam video scanner will *NOT* be built"])
|
|
|
|
[echo " => zbarcam video scanner will *NOT* be built"])
|
|
|
|
|
|
|
|
+AS_IF([test "x$have_libv4l" != "xyes"],
|
|
|
|
|
|
|
|
+ [echo " => libv4l will *NOT* be used"])
|
|
|
|
echo "jpeg --with-jpeg=$with_jpeg"
|
|
|
|
echo "jpeg --with-jpeg=$with_jpeg"
|
|
|
|
diff --git a/zbar/Makefile.am.inc b/zbar/Makefile.am.inc
|
|
|
|
AS_IF([test "x$with_jpeg" != "xyes"],
|
|
|
|
--- a/zbar/Makefile.am.inc
|
|
|
|
[echo " => JPEG image conversions will *NOT* be supported"])
|
|
|
|
+++ b/zbar/Makefile.am.inc
|
|
|
|
diff -r 38e78368283d zbar/video/v4l.c
|
|
|
|
@@ -59,21 +59,17 @@ else
|
|
|
|
--- a/zbar/video/v4l.c Sun Oct 14 23:02:08 2012 -0700
|
|
|
|
zbar_libzbar_la_SOURCES += zbar/processor/posix.h zbar/processor/posix.c
|
|
|
|
+++ b/zbar/video/v4l.c Fri Feb 22 10:04:52 2013 -0300
|
|
|
|
endif
|
|
|
|
@@ -34,6 +34,13 @@
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
|
|
|
# include <unistd.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef HAVE_LIBV4L2_H
|
|
|
|
|
|
|
|
+# include <fcntl.h>
|
|
|
|
|
|
|
|
+# include <libv4l2.h>
|
|
|
|
|
|
|
|
+#else
|
|
|
|
|
|
|
|
+# define v4l2_open open
|
|
|
|
|
|
|
|
+# define v4l2_close close
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
|
|
-if HAVE_V4L1
|
|
|
|
#include "video.h"
|
|
|
|
-zbar_libzbar_la_SOURCES += zbar/video/v4l1.c
|
|
|
|
|
|
|
|
-if HAVE_V4L2
|
|
|
|
|
|
|
|
-zbar_libzbar_la_SOURCES += zbar/video/v4l2.c
|
|
|
|
|
|
|
|
-endif
|
|
|
|
|
|
|
|
-endif
|
|
|
|
|
|
|
|
+if HAVE_VIDEO
|
|
|
|
|
|
|
|
if WIN32
|
|
|
|
|
|
|
|
-if HAVE_VIDEO
|
|
|
|
|
|
|
|
zbar_libzbar_la_SOURCES += zbar/video/vfw.c
|
|
|
|
|
|
|
|
zbar_libzbar_la_LIBADD += -lvfw32
|
|
|
|
|
|
|
|
-endif
|
|
|
|
|
|
|
|
-endif
|
|
|
|
|
|
|
|
-if !HAVE_VIDEO
|
|
|
|
|
|
|
|
+else
|
|
|
|
|
|
|
|
+zbar_libzbar_la_SOURCES += zbar/video/v4l2.c
|
|
|
|
|
|
|
|
+zbar_libzbar_la_LDFLAGS += -lv4l2
|
|
|
|
|
|
|
|
+endif #WIN32
|
|
|
|
|
|
|
|
+else
|
|
|
|
|
|
|
|
zbar_libzbar_la_SOURCES += zbar/video/null.c
|
|
|
|
|
|
|
|
-endif
|
|
|
|
|
|
|
|
+endif #HAVE_VIDEO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if HAVE_JPEG
|
|
|
|
@@ -43,7 +50,7 @@
|
|
|
|
zbar_libzbar_la_SOURCES += zbar/jpeg.c
|
|
|
|
int _zbar_video_open (zbar_video_t *vdo,
|
|
|
|
diff --git a/zbar/video/v4l1.c b/zbar/video/v4l1.c
|
|
|
|
const char *dev)
|
|
|
|
deleted file mode 100644
|
|
|
|
{
|
|
|
|
--- a/zbar/video/v4l1.c
|
|
|
|
|
|
|
|
+++ /dev/null
|
|
|
|
|
|
|
|
@@ -1,435 +0,0 @@
|
|
|
|
|
|
|
|
-/*------------------------------------------------------------------------
|
|
|
|
|
|
|
|
- * Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
|
|
|
|
|
|
- *
|
|
|
|
|
|
|
|
- * 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_INTTYPES_H
|
|
|
|
|
|
|
|
-# include <inttypes.h>
|
|
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-#ifdef HAVE_STDLIB_H
|
|
|
|
|
|
|
|
-# include <stdlib.h>
|
|
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-#include <string.h>
|
|
|
|
|
|
|
|
-#include <sys/types.h>
|
|
|
|
|
|
|
|
-#include <sys/stat.h>
|
|
|
|
|
|
|
|
-#include <unistd.h>
|
|
|
|
|
|
|
|
-#include <fcntl.h>
|
|
|
|
|
|
|
|
-#include <errno.h>
|
|
|
|
|
|
|
|
-#include <assert.h>
|
|
|
|
|
|
|
|
-#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
|
|
|
|
-# include <sys/ioctl.h>
|
|
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-#ifdef HAVE_SYS_MMAN_H
|
|
|
|
|
|
|
|
-# include <sys/mman.h>
|
|
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-#include <linux/videodev.h>
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-#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;
|
|
|
|
|
|
|
|
-} v4l1_format_t;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-/* static v4l1 "palette" mappings
|
|
|
|
|
|
|
|
- * documentation for v4l1 formats is terrible...
|
|
|
|
|
|
|
|
- */
|
|
|
|
|
|
|
|
-static const v4l1_format_t v4l1_formats[17] = {
|
|
|
|
|
|
|
|
- /* format bpp */
|
|
|
|
|
|
|
|
- { 0, 0 },
|
|
|
|
|
|
|
|
- { fourcc('G','R','E','Y'), 8 }, /* GREY */
|
|
|
|
|
|
|
|
- { fourcc('H','I','2','4'), 8 }, /* HI240 (BT848) */
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- /* component ordering for RGB palettes is unspecified,
|
|
|
|
|
|
|
|
- * convention appears to place red in the most significant bits
|
|
|
|
|
|
|
|
- * FIXME is this true for other drivers? big endian machines?
|
|
|
|
|
|
|
|
- */
|
|
|
|
|
|
|
|
- { fourcc('R','G','B','P'), 16 }, /* RGB565 */
|
|
|
|
|
|
|
|
- { fourcc('B','G','R','3'), 24 }, /* RGB24 */
|
|
|
|
|
|
|
|
- { fourcc('B','G','R','4'), 32 }, /* RGB32 */
|
|
|
|
|
|
|
|
- { fourcc('R','G','B','O'), 16 }, /* RGB555 */
|
|
|
|
|
|
|
|
- { fourcc('Y','U','Y','2'), 16 }, /* YUV422 (8 bpp?!) */
|
|
|
|
|
|
|
|
- { fourcc('Y','U','Y','V'), 16 }, /* YUYV */
|
|
|
|
|
|
|
|
- { fourcc('U','Y','V','Y'), 16 }, /* UYVY */
|
|
|
|
|
|
|
|
- { 0, 12 }, /* YUV420 (24 bpp?) FIXME?! */
|
|
|
|
|
|
|
|
- { fourcc('Y','4','1','P'), 12 }, /* YUV411 */
|
|
|
|
|
|
|
|
- { 0, 0 }, /* Bt848 raw */
|
|
|
|
|
|
|
|
- { fourcc('4','2','2','P'), 16 }, /* YUV422P (24 bpp?) */
|
|
|
|
|
|
|
|
- { fourcc('4','1','1','P'), 12 }, /* YUV411P */
|
|
|
|
|
|
|
|
- { fourcc('Y','U','1','2'), 12 }, /* YUV420P */
|
|
|
|
|
|
|
|
- { fourcc('Y','U','V','9'), 9 }, /* YUV410P */
|
|
|
|
|
|
|
|
-};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static int v4l1_nq (zbar_video_t *vdo,
|
|
|
|
|
|
|
|
- zbar_image_t *img)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- if(video_nq_image(vdo, img))
|
|
|
|
|
|
|
|
- return(-1);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- if(vdo->iomode != VIDEO_MMAP)
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- struct video_mmap vmap;
|
|
|
|
|
|
|
|
- vmap.frame = img->srcidx;
|
|
|
|
|
|
|
|
- vmap.width = vdo->width;
|
|
|
|
|
|
|
|
- vmap.height = vdo->height;
|
|
|
|
|
|
|
|
- vmap.format = vdo->palette;
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCMCAPTURE, &vmap) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "initiating video capture (VIDIOCMCAPTURE)"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static zbar_image_t *v4l1_dq (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- video_iomode_t iomode = vdo->iomode;
|
|
|
|
|
|
|
|
- int fd = vdo->fd;
|
|
|
|
|
|
|
|
- zbar_image_t *img = video_dq_image(vdo);
|
|
|
|
|
|
|
|
- if(!img)
|
|
|
|
|
|
|
|
- return(NULL);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- if(iomode == VIDEO_MMAP) {
|
|
|
|
|
|
|
|
- int frame = img->srcidx;
|
|
|
|
|
|
|
|
- if(ioctl(fd, VIDIOCSYNC, &frame) < 0)
|
|
|
|
|
|
|
|
- return(NULL);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- else if(read(fd, (void*)img->data, img->datalen) != img->datalen)
|
|
|
|
|
|
|
|
- return(NULL);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- return(img);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static int v4l1_mmap_buffers (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
-#ifdef HAVE_SYS_MMAN_H
|
|
|
|
|
|
|
|
- /* map camera image to memory */
|
|
|
|
|
|
|
|
- struct video_mbuf vbuf;
|
|
|
|
|
|
|
|
- memset(&vbuf, 0, sizeof(vbuf));
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGMBUF, &vbuf) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "querying video frame buffers (VIDIOCGMBUF)"));
|
|
|
|
|
|
|
|
- assert(vbuf.frames && vbuf.size);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- zprintf(1, "mapping %d buffers size=0x%x\n", vbuf.frames, vbuf.size);
|
|
|
|
|
|
|
|
- vdo->buflen = vbuf.size;
|
|
|
|
|
|
|
|
- vdo->buf = mmap(0, vbuf.size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
|
|
|
|
|
|
|
- vdo->fd, 0);
|
|
|
|
|
|
|
|
- if(vdo->buf == MAP_FAILED)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "mapping video frame buffers"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- int i;
|
|
|
|
|
|
|
|
- for(i = 0; i < vbuf.frames; i++) {
|
|
|
|
|
|
|
|
- zbar_image_t *img = vdo->images[i];
|
|
|
|
|
|
|
|
- zprintf(2, " [%02d] @%08x\n", img->srcidx, vbuf.offsets[i]);
|
|
|
|
|
|
|
|
- img->data = vdo->buf + vbuf.offsets[i];
|
|
|
|
|
|
|
|
- img->datalen = vdo->datalen;
|
|
|
|
|
|
|
|
- int next_offset = ((i + 1 < vdo->num_images)
|
|
|
|
|
|
|
|
- ? vbuf.offsets[i + 1]
|
|
|
|
|
|
|
|
- : vbuf.size);
|
|
|
|
|
|
|
|
- if(next_offset < vbuf.offsets[i] + vdo->datalen)
|
|
|
|
|
|
|
|
- fprintf(stderr, "WARNING: insufficient v4l1 video buffer size:\n"
|
|
|
|
|
|
|
|
- "\tvbuf[%d]=%x vbuf[%d]=%x datalen=%lx\n"
|
|
|
|
|
|
|
|
- "\timage=%d x %d %.4s(%08x) palette=%d\n",
|
|
|
|
|
|
|
|
- i, vbuf.offsets[i], i + 1, next_offset,
|
|
|
|
|
|
|
|
- vdo->datalen, vdo->width, vdo->height,
|
|
|
|
|
|
|
|
- (char*)&vdo->format, vdo->format, vdo->palette);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-#else
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__,
|
|
|
|
|
|
|
|
- "memory mapping not supported"));
|
|
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static int v4l1_start (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static int v4l1_stop (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static inline int v4l1_set_format (zbar_video_t *vdo,
|
|
|
|
|
|
|
|
- uint32_t fmt)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- struct video_picture vpic;
|
|
|
|
|
|
|
|
- memset(&vpic, 0, sizeof(vpic));
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGPICT, &vpic) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "querying video format (VIDIOCGPICT)"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- vdo->palette = 0;
|
|
|
|
|
|
|
|
- int ifmt;
|
|
|
|
|
|
|
|
- for(ifmt = 1; ifmt <= VIDEO_PALETTE_YUV410P; ifmt++)
|
|
|
|
|
|
|
|
- if(v4l1_formats[ifmt].format == fmt)
|
|
|
|
|
|
|
|
- break;
|
|
|
|
|
|
|
|
- if(!fmt || ifmt >= VIDEO_PALETTE_YUV410P)
|
|
|
|
|
|
|
|
- return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
|
|
|
|
|
|
|
|
- "invalid v4l1 format: %x", fmt));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- vpic.palette = ifmt;
|
|
|
|
|
|
|
|
- vpic.depth = v4l1_formats[ifmt].bpp;
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCSPICT, &vpic) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "setting format (VIDIOCSPICT)"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- memset(&vpic, 0, sizeof(vpic));
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGPICT, &vpic) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "querying video format (VIDIOCGPICT)"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- if(vpic.palette != ifmt || vpic.depth != v4l1_formats[ifmt].bpp) {
|
|
|
|
|
|
|
|
- fprintf(stderr,
|
|
|
|
|
|
|
|
- "WARNING: set v4l1 palette %d which should have depth %d bpp\n"
|
|
|
|
|
|
|
|
- " but probed palette %d with depth %d bpp?"
|
|
|
|
|
|
|
|
- " ...continuing anyway\n",
|
|
|
|
|
|
|
|
- ifmt, v4l1_formats[ifmt].bpp, vpic.palette, vpic.depth);
|
|
|
|
|
|
|
|
- err_capture_int(vdo, SEV_WARNING, ZBAR_ERR_INVALID, __func__,
|
|
|
|
|
|
|
|
- "driver format (%x) inconsistency", fmt);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- vdo->format = fmt;
|
|
|
|
|
|
|
|
- vdo->palette = ifmt;
|
|
|
|
|
|
|
|
- vdo->datalen = (vdo->width * vdo->height * v4l1_formats[ifmt].bpp + 7) >> 3;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- zprintf(1, "set new format: %.4s(%08x) depth=%d palette=%d size=0x%lx\n",
|
|
|
|
|
|
|
|
- (char*)&vdo->format, vdo->format, vpic.depth, vdo->palette,
|
|
|
|
|
|
|
|
- vdo->datalen);
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static int v4l1_init (zbar_video_t *vdo,
|
|
|
|
|
|
|
|
- uint32_t fmt)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- if(v4l1_set_format(vdo, fmt))
|
|
|
|
|
|
|
|
- return(-1);
|
|
|
|
|
|
|
|
- if(vdo->iomode == VIDEO_MMAP && v4l1_mmap_buffers(vdo))
|
|
|
|
|
|
|
|
- return(-1);
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static int v4l1_cleanup (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
-#ifdef HAVE_SYS_MMAN_H
|
|
|
|
|
|
|
|
- /* FIXME should avoid holding onto mmap'd buffers so long? */
|
|
|
|
|
|
|
|
- if(vdo->iomode == VIDEO_MMAP && vdo->buf) {
|
|
|
|
|
|
|
|
- if(munmap(vdo->buf, vdo->buflen))
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "unmapping video frame buffers"));
|
|
|
|
|
|
|
|
- vdo->buf = NULL;
|
|
|
|
|
|
|
|
- /* FIXME reset image */
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- /* close open device */
|
|
|
|
|
|
|
|
- if(vdo->fd >= 0) {
|
|
|
|
|
|
|
|
- close(vdo->fd);
|
|
|
|
|
|
|
|
- vdo->fd = -1;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static int v4l1_probe_iomode (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- vdo->iomode = VIDEO_READWRITE;
|
|
|
|
|
|
|
|
-#ifdef HAVE_SYS_MMAN_H
|
|
|
|
|
|
|
|
- struct video_mbuf vbuf;
|
|
|
|
|
|
|
|
- memset(&vbuf, 0, sizeof(vbuf));
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGMBUF, &vbuf) < 0) {
|
|
|
|
|
|
|
|
- if(errno != EINVAL)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "querying video frame buffers (VIDIOCGMBUF)"));
|
|
|
|
|
|
|
|
- /* not supported */
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if(!vbuf.frames || !vbuf.size)
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
- vdo->iomode = VIDEO_MMAP;
|
|
|
|
|
|
|
|
- if(vdo->num_images > vbuf.frames)
|
|
|
|
|
|
|
|
- vdo->num_images = vbuf.frames;
|
|
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
- zprintf(1, "using %d images in %s mode\n", vdo->num_images,
|
|
|
|
|
|
|
|
- (vdo->iomode == VIDEO_READWRITE) ? "READ" : "MMAP");
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static inline int v4l1_probe_formats (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- struct video_picture vpic;
|
|
|
|
|
|
|
|
- memset(&vpic, 0, sizeof(vpic));
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGPICT, &vpic) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "querying format (VIDIOCGPICT)"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- vdo->format = 0;
|
|
|
|
|
|
|
|
- if(vpic.palette <= VIDEO_PALETTE_YUV410P)
|
|
|
|
|
|
|
|
- vdo->format = v4l1_formats[vpic.palette].format;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- zprintf(1, "current format: %.4s(%08x) depth=%d palette=%d\n",
|
|
|
|
|
|
|
|
- (char*)&vdo->format, vdo->format, vpic.depth, vpic.palette);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- vdo->formats = calloc(16, sizeof(uint32_t));
|
|
|
|
|
|
|
|
- if(!vdo->formats)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_FATAL, ZBAR_ERR_NOMEM, __func__,
|
|
|
|
|
|
|
|
- "allocating format list"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- int num_formats = 0;
|
|
|
|
|
|
|
|
- zprintf(2, "probing supported formats:\n");
|
|
|
|
|
|
|
|
- int i;
|
|
|
|
|
|
|
|
- for(i = 1; i <= VIDEO_PALETTE_YUV410P; i++) {
|
|
|
|
|
|
|
|
- if(!v4l1_formats[i].format)
|
|
|
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
|
- vpic.depth = v4l1_formats[i].bpp;
|
|
|
|
|
|
|
|
- vpic.palette = i;
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCSPICT, &vpic) < 0) {
|
|
|
|
|
|
|
|
- zprintf(2, " [%02d] %.4s...no (set fails)\n",
|
|
|
|
|
|
|
|
- i, (char*)&v4l1_formats[i].format);
|
|
|
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGPICT, &vpic) < 0 ||
|
|
|
|
|
|
|
|
- vpic.palette != i) {
|
|
|
|
|
|
|
|
- zprintf(2, " [%02d] %.4s...no (set ignored)\n",
|
|
|
|
|
|
|
|
- i, (char*)&v4l1_formats[i].format);
|
|
|
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- zprintf(2, " [%02d] %.4s...yes\n",
|
|
|
|
|
|
|
|
- i, (char*)&v4l1_formats[i].format);
|
|
|
|
|
|
|
|
- vdo->formats[num_formats++] = v4l1_formats[i].format;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- vdo->formats = realloc(vdo->formats, (num_formats + 1) * sizeof(uint32_t));
|
|
|
|
|
|
|
|
- assert(vdo->formats);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- return(v4l1_set_format(vdo, vdo->format));
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static inline int v4l1_init_window (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- struct video_window vwin;
|
|
|
|
|
|
|
|
- memset(&vwin, 0, sizeof(vwin));
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGWIN, &vwin) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "querying video window settings (VIDIOCGWIN)"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- zprintf(1, "current window: %d x %d @(%d, %d)%s\n",
|
|
|
|
|
|
|
|
- vwin.width, vwin.height, vwin.x, vwin.y,
|
|
|
|
|
|
|
|
- (vwin.flags & 1) ? " INTERLACE" : "");
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- if(vwin.width == vdo->width && vwin.height == vdo->height)
|
|
|
|
|
|
|
|
- /* max window already set */
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- struct video_window maxwin;
|
|
|
|
|
|
|
|
- memcpy(&maxwin, &vwin, sizeof(maxwin));
|
|
|
|
|
|
|
|
- maxwin.width = vdo->width;
|
|
|
|
|
|
|
|
- maxwin.height = vdo->height;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- zprintf(1, "setting max win: %d x %d @(%d, %d)%s\n",
|
|
|
|
|
|
|
|
- maxwin.width, maxwin.height, maxwin.x, maxwin.y,
|
|
|
|
|
|
|
|
- (maxwin.flags & 1) ? " INTERLACE" : "");
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCSWIN, &maxwin) < 0) {
|
|
|
|
|
|
|
|
- zprintf(1, "set FAILED...trying to recover original window\n");
|
|
|
|
|
|
|
|
- /* ignore errors (driver broken anyway) */
|
|
|
|
|
|
|
|
- ioctl(vdo->fd, VIDIOCSWIN, &vwin);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- /* re-query resulting parameters */
|
|
|
|
|
|
|
|
- memset(&vwin, 0, sizeof(vwin));
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGWIN, &vwin) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
|
|
|
|
- "querying video window settings (VIDIOCGWIN)"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- zprintf(1, " final window: %d x %d @(%d, %d)%s\n",
|
|
|
|
|
|
|
|
- vwin.width, vwin.height, vwin.x, vwin.y,
|
|
|
|
|
|
|
|
- (vwin.flags & 1) ? " INTERLACE" : "");
|
|
|
|
|
|
|
|
- vdo->width = vwin.width;
|
|
|
|
|
|
|
|
- vdo->height = vwin.height;
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-static int _zbar_v4l1_probe (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- /* check capabilities */
|
|
|
|
|
|
|
|
- struct video_capability vcap;
|
|
|
|
|
|
|
|
- memset(&vcap, 0, sizeof(vcap));
|
|
|
|
|
|
|
|
- if(ioctl(vdo->fd, VIDIOCGCAP, &vcap) < 0)
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__,
|
|
|
|
|
|
|
|
- "video4linux version 1 not supported (VIDIOCGCAP)"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- zprintf(1, "%s (%sCAPTURE) (%d x %d) - (%d x %d)\n",
|
|
|
|
|
|
|
|
- vcap.name, (vcap.type & VID_TYPE_CAPTURE) ? "" : "*NO* ",
|
|
|
|
|
|
|
|
- vcap.minwidth, vcap.minheight, vcap.maxwidth, vcap.maxheight);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- if(!(vcap.type & VID_TYPE_CAPTURE))
|
|
|
|
|
|
|
|
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__,
|
|
|
|
|
|
|
|
- "v4l1 device does not support CAPTURE"));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- if(!vdo->width || !vdo->height) {
|
|
|
|
|
|
|
|
- vdo->width = vcap.maxwidth;
|
|
|
|
|
|
|
|
- vdo->height = vcap.maxheight;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- if(v4l1_init_window(vdo) ||
|
|
|
|
|
|
|
|
- v4l1_probe_formats(vdo) ||
|
|
|
|
|
|
|
|
- v4l1_probe_iomode(vdo))
|
|
|
|
|
|
|
|
- return(-1);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
- vdo->intf = VIDEO_V4L1;
|
|
|
|
|
|
|
|
- vdo->init = v4l1_init;
|
|
|
|
|
|
|
|
- vdo->cleanup = v4l1_cleanup;
|
|
|
|
|
|
|
|
- vdo->start = v4l1_start;
|
|
|
|
|
|
|
|
- vdo->stop = v4l1_stop;
|
|
|
|
|
|
|
|
- vdo->nq = v4l1_nq;
|
|
|
|
|
|
|
|
- vdo->dq = v4l1_dq;
|
|
|
|
|
|
|
|
- return(0);
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-int _zbar_video_open (zbar_video_t *vdo,
|
|
|
|
|
|
|
|
- const char *dev)
|
|
|
|
|
|
|
|
-{
|
|
|
|
|
|
|
|
- vdo->fd = open(dev, O_RDWR);
|
|
|
|
- vdo->fd = open(dev, O_RDWR);
|
|
|
|
- if(vdo->fd < 0)
|
|
|
|
+ vdo->fd = v4l2_open(dev, O_RDWR);
|
|
|
|
- return(err_capture_str(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
if(vdo->fd < 0)
|
|
|
|
- "opening video device '%s'", dev));
|
|
|
|
return(err_capture_str(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
- zprintf(1, "opened camera device %s (fd=%d)\n", dev, vdo->fd);
|
|
|
|
"opening video device '%s'", dev));
|
|
|
|
-
|
|
|
|
@@ -60,7 +67,7 @@
|
|
|
|
- int rc = -1;
|
|
|
|
#endif
|
|
|
|
-#ifdef HAVE_LINUX_VIDEODEV2_H
|
|
|
|
|
|
|
|
- if(vdo->intf != VIDEO_V4L1)
|
|
|
|
if(rc && vdo->fd >= 0) {
|
|
|
|
- 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);
|
|
|
|
- close(vdo->fd);
|
|
|
|
- vdo->fd = -1;
|
|
|
|
+ v4l2_close(vdo->fd);
|
|
|
|
- }
|
|
|
|
vdo->fd = -1;
|
|
|
|
- return(rc);
|
|
|
|
}
|
|
|
|
-}
|
|
|
|
return(rc);
|
|
|
|
diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
diff -r 38e78368283d zbar/video/v4l2.c
|
|
|
|
--- a/zbar/video/v4l2.c
|
|
|
|
--- a/zbar/video/v4l2.c Sun Oct 14 23:02:08 2012 -0700
|
|
|
|
+++ b/zbar/video/v4l2.c
|
|
|
|
+++ b/zbar/video/v4l2.c Fri Feb 22 10:04:52 2013 -0300
|
|
|
|
@@ -38,6 +38,8 @@
|
|
|
|
@@ -38,6 +38,15 @@
|
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
|
|
|
# include <sys/mman.h>
|
|
|
|
# include <sys/mman.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef HAVE_LIBV4L2_H
|
|
|
|
+# include <fcntl.h>
|
|
|
|
+# include <fcntl.h>
|
|
|
|
+# include <libv4l2.h>
|
|
|
|
+# include <libv4l2.h>
|
|
|
|
|
|
|
|
+#else
|
|
|
|
|
|
|
|
+# define v4l2_close close
|
|
|
|
|
|
|
|
+# define v4l2_ioctl ioctl
|
|
|
|
|
|
|
|
+# define v4l2_mmap mmap
|
|
|
|
|
|
|
|
+# define v4l2_munmap munmap
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "video.h"
|
|
|
|
#include "video.h"
|
|
|
|
@@ -67,7 +69,7 @@ static int v4l2_nq (zbar_video_t *vdo,
|
|
|
|
@@ -67,7 +76,7 @@
|
|
|
|
vbuf.length = img->datalen;
|
|
|
|
vbuf.length = img->datalen;
|
|
|
|
vbuf.index = img->srcidx; /* FIXME workaround broken drivers */
|
|
|
|
vbuf.index = img->srcidx; /* FIXME workaround broken drivers */
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -525,7 +122,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"queuing video buffer (VIDIOC_QBUF)"));
|
|
|
|
"queuing video buffer (VIDIOC_QBUF)"));
|
|
|
|
return(0);
|
|
|
|
return(0);
|
|
|
|
@@ -91,7 +93,7 @@ static zbar_image_t *v4l2_dq (zbar_video
|
|
|
|
@@ -91,7 +100,7 @@
|
|
|
|
else
|
|
|
|
else
|
|
|
|
vbuf.memory = V4L2_MEMORY_USERPTR;
|
|
|
|
vbuf.memory = V4L2_MEMORY_USERPTR;
|
|
|
|
|
|
|
|
|
|
|
@ -534,7 +131,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(NULL);
|
|
|
|
return(NULL);
|
|
|
|
|
|
|
|
|
|
|
|
if(iomode == VIDEO_MMAP) {
|
|
|
|
if(iomode == VIDEO_MMAP) {
|
|
|
|
@@ -132,7 +134,7 @@ static int v4l2_start (zbar_video_t *vdo
|
|
|
|
@@ -132,7 +141,7 @@
|
|
|
|
return(0);
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
|
|
|
|
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
@ -543,7 +140,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"starting video stream (VIDIOC_STREAMON)"));
|
|
|
|
"starting video stream (VIDIOC_STREAMON)"));
|
|
|
|
return(0);
|
|
|
|
return(0);
|
|
|
|
@@ -144,7 +146,7 @@ static int v4l2_stop (zbar_video_t *vdo)
|
|
|
|
@@ -144,7 +153,7 @@
|
|
|
|
return(0);
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
|
|
|
|
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
@ -552,7 +149,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"stopping video stream (VIDIOC_STREAMOFF)"));
|
|
|
|
"stopping video stream (VIDIOC_STREAMOFF)"));
|
|
|
|
return(0);
|
|
|
|
return(0);
|
|
|
|
@@ -164,7 +166,7 @@ static int v4l2_cleanup (zbar_video_t *v
|
|
|
|
@@ -164,7 +173,7 @@
|
|
|
|
for(i = 0; i < vdo->num_images; i++) {
|
|
|
|
for(i = 0; i < vdo->num_images; i++) {
|
|
|
|
zbar_image_t *img = vdo->images[i];
|
|
|
|
zbar_image_t *img = vdo->images[i];
|
|
|
|
if(img->data &&
|
|
|
|
if(img->data &&
|
|
|
@ -561,7 +158,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
err_capture(vdo, SEV_WARNING, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
err_capture(vdo, SEV_WARNING, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"unmapping video frame buffers");
|
|
|
|
"unmapping video frame buffers");
|
|
|
|
img->data = NULL;
|
|
|
|
img->data = NULL;
|
|
|
|
@@ -177,27 +179,27 @@ static int v4l2_cleanup (zbar_video_t *v
|
|
|
|
@@ -177,14 +186,14 @@
|
|
|
|
/* requesting 0 buffers
|
|
|
|
/* requesting 0 buffers
|
|
|
|
* should implicitly disable streaming
|
|
|
|
* should implicitly disable streaming
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -579,13 +176,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
vdo->fd = -1;
|
|
|
|
vdo->fd = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
@@ -197,7 +206,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
-static int v4l2_mmap_buffers (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
+static int v4l2_v4l2_mmap_buffers (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct v4l2_requestbuffers rb;
|
|
|
|
|
|
|
|
memset(&rb, 0, sizeof(rb));
|
|
|
|
|
|
|
|
rb.count = vdo->num_images;
|
|
|
|
rb.count = vdo->num_images;
|
|
|
|
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
rb.memory = V4L2_MEMORY_MMAP;
|
|
|
|
rb.memory = V4L2_MEMORY_MMAP;
|
|
|
@ -594,7 +185,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"requesting video frame buffers (VIDIOC_REQBUFS)"));
|
|
|
|
"requesting video frame buffers (VIDIOC_REQBUFS)"));
|
|
|
|
zprintf(1, "mapping %u buffers (of %d requested)\n",
|
|
|
|
zprintf(1, "mapping %u buffers (of %d requested)\n",
|
|
|
|
@@ -216,7 +218,7 @@ static int v4l2_mmap_buffers (zbar_video
|
|
|
|
@@ -216,7 +225,7 @@
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < vdo->num_images; i++) {
|
|
|
|
for(i = 0; i < vdo->num_images; i++) {
|
|
|
|
vbuf.index = i;
|
|
|
|
vbuf.index = i;
|
|
|
@ -603,7 +194,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
/* FIXME cleanup */
|
|
|
|
/* FIXME cleanup */
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"querying video buffer (VIDIOC_QUERYBUF)"));
|
|
|
|
"querying video buffer (VIDIOC_QUERYBUF)"));
|
|
|
|
@@ -229,7 +231,7 @@ static int v4l2_mmap_buffers (zbar_video
|
|
|
|
@@ -229,7 +238,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
zbar_image_t *img = vdo->images[i];
|
|
|
|
zbar_image_t *img = vdo->images[i];
|
|
|
|
img->datalen = vbuf.length;
|
|
|
|
img->datalen = vbuf.length;
|
|
|
@ -612,7 +203,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
vdo->fd, vbuf.m.offset);
|
|
|
|
vdo->fd, vbuf.m.offset);
|
|
|
|
if(img->data == MAP_FAILED)
|
|
|
|
if(img->data == MAP_FAILED)
|
|
|
|
/* FIXME cleanup */
|
|
|
|
/* FIXME cleanup */
|
|
|
|
@@ -253,7 +255,7 @@ static int v4l2_set_format (zbar_video_t
|
|
|
|
@@ -253,7 +262,7 @@
|
|
|
|
vpix->pixelformat = fmt;
|
|
|
|
vpix->pixelformat = fmt;
|
|
|
|
vpix->field = V4L2_FIELD_NONE;
|
|
|
|
vpix->field = V4L2_FIELD_NONE;
|
|
|
|
int rc = 0;
|
|
|
|
int rc = 0;
|
|
|
@ -621,7 +212,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
/* several broken drivers return an error if we request
|
|
|
|
/* several broken drivers return an error if we request
|
|
|
|
* no interlacing (NB v4l2 spec violation)
|
|
|
|
* no interlacing (NB v4l2 spec violation)
|
|
|
|
* ...try again with an interlaced request
|
|
|
|
* ...try again with an interlaced request
|
|
|
|
@@ -264,7 +266,7 @@ static int v4l2_set_format (zbar_video_t
|
|
|
|
@@ -264,7 +273,7 @@
|
|
|
|
/* FIXME this might be _ANY once we can de-interlace */
|
|
|
|
/* FIXME this might be _ANY once we can de-interlace */
|
|
|
|
vpix->field = V4L2_FIELD_INTERLACED;
|
|
|
|
vpix->field = V4L2_FIELD_INTERLACED;
|
|
|
|
|
|
|
|
|
|
|
@ -630,7 +221,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"setting format %x (VIDIOC_S_FMT)", fmt));
|
|
|
|
"setting format %x (VIDIOC_S_FMT)", fmt));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -276,7 +278,7 @@ static int v4l2_set_format (zbar_video_t
|
|
|
|
@@ -276,7 +285,7 @@
|
|
|
|
struct v4l2_pix_format *newpix = &newfmt.fmt.pix;
|
|
|
|
struct v4l2_pix_format *newpix = &newfmt.fmt.pix;
|
|
|
|
memset(&newfmt, 0, sizeof(newfmt));
|
|
|
|
memset(&newfmt, 0, sizeof(newfmt));
|
|
|
|
newfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
newfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
@ -639,16 +230,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"querying format (VIDIOC_G_FMT)"));
|
|
|
|
"querying format (VIDIOC_G_FMT)"));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -307,7 +309,7 @@ static int v4l2_init (zbar_video_t *vdo,
|
|
|
|
@@ -322,7 +331,7 @@
|
|
|
|
if(v4l2_set_format(vdo, fmt))
|
|
|
|
|
|
|
|
return(-1);
|
|
|
|
|
|
|
|
if(vdo->iomode == VIDEO_MMAP)
|
|
|
|
|
|
|
|
- return(v4l2_mmap_buffers(vdo));
|
|
|
|
|
|
|
|
+ return(v4l2_v4l2_mmap_buffers(vdo));
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -322,7 +324,7 @@ static int v4l2_probe_iomode (zbar_video
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
rb.memory = V4L2_MEMORY_USERPTR;
|
|
|
|
rb.memory = V4L2_MEMORY_USERPTR;
|
|
|
|
|
|
|
|
|
|
|
@ -657,7 +239,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
if(vdo->iomode)
|
|
|
|
if(vdo->iomode)
|
|
|
|
return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
|
|
|
|
return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
|
|
|
|
"unsupported iomode requested (%d)",
|
|
|
|
"unsupported iomode requested (%d)",
|
|
|
|
@@ -350,7 +352,7 @@ static inline int v4l2_probe_formats (zb
|
|
|
|
@@ -350,7 +359,7 @@
|
|
|
|
memset(&desc, 0, sizeof(desc));
|
|
|
|
memset(&desc, 0, sizeof(desc));
|
|
|
|
desc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
desc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
for(desc.index = 0; desc.index < V4L2_FORMATS_MAX; desc.index++) {
|
|
|
|
for(desc.index = 0; desc.index < V4L2_FORMATS_MAX; desc.index++) {
|
|
|
@ -666,7 +248,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
zprintf(2, " [%d] %.4s : %s%s\n",
|
|
|
|
zprintf(2, " [%d] %.4s : %s%s\n",
|
|
|
|
desc.index, (char*)&desc.pixelformat, desc.description,
|
|
|
|
desc.index, (char*)&desc.pixelformat, desc.description,
|
|
|
|
@@ -368,7 +370,7 @@ static inline int v4l2_probe_formats (zb
|
|
|
|
@@ -368,7 +377,7 @@
|
|
|
|
struct v4l2_pix_format *pix = &fmt.fmt.pix;
|
|
|
|
struct v4l2_pix_format *pix = &fmt.fmt.pix;
|
|
|
|
memset(&fmt, 0, sizeof(fmt));
|
|
|
|
memset(&fmt, 0, sizeof(fmt));
|
|
|
|
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
@ -675,7 +257,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"querying current video format (VIDIO_G_FMT)"));
|
|
|
|
"querying current video format (VIDIO_G_FMT)"));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -390,15 +392,15 @@ static inline int v4l2_probe_formats (zb
|
|
|
|
@@ -390,15 +399,15 @@
|
|
|
|
maxpix->height = vdo->height;
|
|
|
|
maxpix->height = vdo->height;
|
|
|
|
|
|
|
|
|
|
|
|
zprintf(1, "setting requested size: %d x %d\n", vdo->width, vdo->height);
|
|
|
|
zprintf(1, "setting requested size: %d x %d\n", vdo->width, vdo->height);
|
|
|
@ -694,7 +276,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"querying current video format (VIDIOC_G_FMT)"));
|
|
|
|
"querying current video format (VIDIOC_G_FMT)"));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -420,7 +422,7 @@ static inline int v4l2_reset_crop (zbar_
|
|
|
|
@@ -420,7 +429,7 @@
|
|
|
|
struct v4l2_cropcap ccap;
|
|
|
|
struct v4l2_cropcap ccap;
|
|
|
|
memset(&ccap, 0, sizeof(ccap));
|
|
|
|
memset(&ccap, 0, sizeof(ccap));
|
|
|
|
ccap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
ccap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
@ -703,7 +285,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"querying crop support (VIDIOC_CROPCAP)"));
|
|
|
|
"querying crop support (VIDIOC_CROPCAP)"));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -442,7 +444,7 @@ static inline int v4l2_reset_crop (zbar_
|
|
|
|
@@ -442,7 +451,7 @@
|
|
|
|
memset(&crop, 0, sizeof(crop));
|
|
|
|
memset(&crop, 0, sizeof(crop));
|
|
|
|
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
crop.c = ccap.defrect;
|
|
|
|
crop.c = ccap.defrect;
|
|
|
@ -712,7 +294,7 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
|
|
"setting default crop window (VIDIOC_S_CROP)"));
|
|
|
|
"setting default crop window (VIDIOC_S_CROP)"));
|
|
|
|
return(0);
|
|
|
|
return(0);
|
|
|
|
@@ -453,7 +455,7 @@ int _zbar_v4l2_probe (zbar_video_t *vdo)
|
|
|
|
@@ -453,7 +462,7 @@
|
|
|
|
/* check capabilities */
|
|
|
|
/* check capabilities */
|
|
|
|
struct v4l2_capability vcap;
|
|
|
|
struct v4l2_capability vcap;
|
|
|
|
memset(&vcap, 0, sizeof(vcap));
|
|
|
|
memset(&vcap, 0, sizeof(vcap));
|
|
|
@ -721,35 +303,3 @@ diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
|
|
|
|
return(err_capture(vdo, SEV_WARNING, ZBAR_ERR_UNSUPPORTED, __func__,
|
|
|
|
return(err_capture(vdo, SEV_WARNING, ZBAR_ERR_UNSUPPORTED, __func__,
|
|
|
|
"video4linux version 2 not supported (VIDIOC_QUERYCAP)"));
|
|
|
|
"video4linux version 2 not supported (VIDIOC_QUERYCAP)"));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -507,3 +509,21 @@ int _zbar_v4l2_probe (zbar_video_t *vdo)
|
|
|
|
|
|
|
|
vdo->dq = v4l2_dq;
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+int _zbar_video_open (zbar_video_t *vdo,
|
|
|
|
|
|
|
|
+ const char *dev)
|
|
|
|
|
|
|
|
+{
|
|
|
|
|
|
|
|
+ vdo->fd = v4l2_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 = _zbar_v4l2_probe(vdo);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ if(rc && vdo->fd >= 0) {
|
|
|
|
|
|
|
|
+ v4l2_close(vdo->fd);
|
|
|
|
|
|
|
|
+ vdo->fd = -1;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ return(rc);
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
diff --git a/zbarcam/Makefile.am.inc b/zbarcam/Makefile.am.inc
|
|
|
|
|
|
|
|
--- a/zbarcam/Makefile.am.inc
|
|
|
|
|
|
|
|
+++ b/zbarcam/Makefile.am.inc
|
|
|
|
|
|
|
|
@@ -7,4 +7,6 @@ CLEANFILES += zbarcam/.libs/zbarcam
|
|
|
|
|
|
|
|
if WIN32
|
|
|
|
|
|
|
|
zbarcam_zbarcam_SOURCES += zbarcam/zbarcam.rc
|
|
|
|
|
|
|
|
zbarcam_zbarcam_LDADD += zbarcam/zbarcam-rc.o
|
|
|
|
|
|
|
|
+else
|
|
|
|
|
|
|
|
+zbarcam_zbarcam_LDADD += -lv4l2
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|