You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
306 lines
12 KiB
306 lines
12 KiB
diff -r 38e78368283d configure.ac
|
|
--- a/configure.ac Sun Oct 14 23:02:08 2012 -0700
|
|
+++ b/configure.ac Fri Feb 22 10:04:52 2013 -0300
|
|
@@ -3,7 +3,8 @@
|
|
AC_INIT([zbar], [0.10], [spadix@users.sourceforge.net])
|
|
AC_CONFIG_AUX_DIR(config)
|
|
AC_CONFIG_MACRO_DIR(config)
|
|
-AM_INIT_AUTOMAKE([1.10 -Wall -Werror foreign subdir-objects std-options dist-bzip2])
|
|
+AM_INIT_AUTOMAKE([1.10 -Werror foreign subdir-objects std-options dist-bzip2])
|
|
+AM_PROG_AR
|
|
AC_CONFIG_HEADERS([include/config.h])
|
|
AC_CONFIG_SRCDIR(zbar/scanner.c)
|
|
LT_PREREQ([2.2])
|
|
@@ -47,7 +48,7 @@
|
|
[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!
|
|
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_V4L1], [test "x$have_v4l1" != "xno"])
|
|
AM_CONDITIONAL([HAVE_V4L2], [test "x$have_v4l2" != "xno"])
|
|
+AM_CONDITIONAL([HAVE_LIBV4L], [test "x$have_libv4l" != "xno"])
|
|
|
|
dnl X
|
|
AC_ARG_VAR([XSHM_LIBS], [linker flags for X shared memory extension])
|
|
@@ -571,6 +580,8 @@
|
|
echo "v4l --enable-video=$enable_video"
|
|
AS_IF([test "x$enable_video" != "xyes"],
|
|
[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"
|
|
AS_IF([test "x$with_jpeg" != "xyes"],
|
|
[echo " => JPEG image conversions will *NOT* be supported"])
|
|
diff -r 38e78368283d zbar/video/v4l.c
|
|
--- a/zbar/video/v4l.c Sun Oct 14 23:02:08 2012 -0700
|
|
+++ b/zbar/video/v4l.c Fri Feb 22 10:04:52 2013 -0300
|
|
@@ -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
|
|
|
|
#include "video.h"
|
|
|
|
@@ -43,7 +50,7 @@
|
|
int _zbar_video_open (zbar_video_t *vdo,
|
|
const char *dev)
|
|
{
|
|
- vdo->fd = open(dev, O_RDWR);
|
|
+ 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));
|
|
@@ -60,7 +67,7 @@
|
|
#endif
|
|
|
|
if(rc && vdo->fd >= 0) {
|
|
- close(vdo->fd);
|
|
+ v4l2_close(vdo->fd);
|
|
vdo->fd = -1;
|
|
}
|
|
return(rc);
|
|
diff -r 38e78368283d zbar/video/v4l2.c
|
|
--- a/zbar/video/v4l2.c Sun Oct 14 23:02:08 2012 -0700
|
|
+++ b/zbar/video/v4l2.c Fri Feb 22 10:04:52 2013 -0300
|
|
@@ -38,6 +38,15 @@
|
|
#ifdef HAVE_SYS_MMAN_H
|
|
# include <sys/mman.h>
|
|
#endif
|
|
+#ifdef HAVE_LIBV4L2_H
|
|
+# include <fcntl.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 "video.h"
|
|
@@ -67,7 +76,7 @@
|
|
vbuf.length = img->datalen;
|
|
vbuf.index = img->srcidx; /* FIXME workaround broken drivers */
|
|
}
|
|
- if(ioctl(vdo->fd, VIDIOC_QBUF, &vbuf) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_QBUF, &vbuf) < 0)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"queuing video buffer (VIDIOC_QBUF)"));
|
|
return(0);
|
|
@@ -91,7 +100,7 @@
|
|
else
|
|
vbuf.memory = V4L2_MEMORY_USERPTR;
|
|
|
|
- if(ioctl(fd, VIDIOC_DQBUF, &vbuf) < 0)
|
|
+ if(v4l2_ioctl(fd, VIDIOC_DQBUF, &vbuf) < 0)
|
|
return(NULL);
|
|
|
|
if(iomode == VIDEO_MMAP) {
|
|
@@ -132,7 +141,7 @@
|
|
return(0);
|
|
|
|
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
- if(ioctl(vdo->fd, VIDIOC_STREAMON, &type) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_STREAMON, &type) < 0)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"starting video stream (VIDIOC_STREAMON)"));
|
|
return(0);
|
|
@@ -144,7 +153,7 @@
|
|
return(0);
|
|
|
|
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
- if(ioctl(vdo->fd, VIDIOC_STREAMOFF, &type) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_STREAMOFF, &type) < 0)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"stopping video stream (VIDIOC_STREAMOFF)"));
|
|
return(0);
|
|
@@ -164,7 +173,7 @@
|
|
for(i = 0; i < vdo->num_images; i++) {
|
|
zbar_image_t *img = vdo->images[i];
|
|
if(img->data &&
|
|
- munmap((void*)img->data, img->datalen))
|
|
+ v4l2_munmap((void*)img->data, img->datalen))
|
|
err_capture(vdo, SEV_WARNING, ZBAR_ERR_SYSTEM, __func__,
|
|
"unmapping video frame buffers");
|
|
img->data = NULL;
|
|
@@ -177,14 +186,14 @@
|
|
/* requesting 0 buffers
|
|
* should implicitly disable streaming
|
|
*/
|
|
- if(ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0)
|
|
err_capture(vdo, SEV_WARNING, ZBAR_ERR_SYSTEM, __func__,
|
|
"releasing video frame buffers (VIDIOC_REQBUFS)");
|
|
|
|
|
|
- /* close open device */
|
|
+ /* v4l2_close v4l2_open device */
|
|
if(vdo->fd >= 0) {
|
|
- close(vdo->fd);
|
|
+ v4l2_close(vdo->fd);
|
|
vdo->fd = -1;
|
|
}
|
|
return(0);
|
|
@@ -197,7 +206,7 @@
|
|
rb.count = vdo->num_images;
|
|
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
rb.memory = V4L2_MEMORY_MMAP;
|
|
- if(ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"requesting video frame buffers (VIDIOC_REQBUFS)"));
|
|
zprintf(1, "mapping %u buffers (of %d requested)\n",
|
|
@@ -216,7 +225,7 @@
|
|
int i;
|
|
for(i = 0; i < vdo->num_images; i++) {
|
|
vbuf.index = i;
|
|
- if(ioctl(vdo->fd, VIDIOC_QUERYBUF, &vbuf) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_QUERYBUF, &vbuf) < 0)
|
|
/* FIXME cleanup */
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"querying video buffer (VIDIOC_QUERYBUF)"));
|
|
@@ -229,7 +238,7 @@
|
|
|
|
zbar_image_t *img = vdo->images[i];
|
|
img->datalen = vbuf.length;
|
|
- img->data = mmap(NULL, vbuf.length, PROT_READ | PROT_WRITE, MAP_SHARED,
|
|
+ img->data = v4l2_mmap(NULL, vbuf.length, PROT_READ | PROT_WRITE, MAP_SHARED,
|
|
vdo->fd, vbuf.m.offset);
|
|
if(img->data == MAP_FAILED)
|
|
/* FIXME cleanup */
|
|
@@ -253,7 +262,7 @@
|
|
vpix->pixelformat = fmt;
|
|
vpix->field = V4L2_FIELD_NONE;
|
|
int rc = 0;
|
|
- if((rc = ioctl(vdo->fd, VIDIOC_S_FMT, &vfmt)) < 0) {
|
|
+ if((rc = v4l2_ioctl(vdo->fd, VIDIOC_S_FMT, &vfmt)) < 0) {
|
|
/* several broken drivers return an error if we request
|
|
* no interlacing (NB v4l2 spec violation)
|
|
* ...try again with an interlaced request
|
|
@@ -264,7 +273,7 @@
|
|
/* FIXME this might be _ANY once we can de-interlace */
|
|
vpix->field = V4L2_FIELD_INTERLACED;
|
|
|
|
- if(ioctl(vdo->fd, VIDIOC_S_FMT, &vfmt) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_S_FMT, &vfmt) < 0)
|
|
return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"setting format %x (VIDIOC_S_FMT)", fmt));
|
|
|
|
@@ -276,7 +285,7 @@
|
|
struct v4l2_pix_format *newpix = &newfmt.fmt.pix;
|
|
memset(&newfmt, 0, sizeof(newfmt));
|
|
newfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
- if(ioctl(vdo->fd, VIDIOC_G_FMT, &newfmt) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_G_FMT, &newfmt) < 0)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"querying format (VIDIOC_G_FMT)"));
|
|
|
|
@@ -322,7 +331,7 @@
|
|
else
|
|
rb.memory = V4L2_MEMORY_USERPTR;
|
|
|
|
- if(ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0) {
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0) {
|
|
if(vdo->iomode)
|
|
return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
|
|
"unsupported iomode requested (%d)",
|
|
@@ -350,7 +359,7 @@
|
|
memset(&desc, 0, sizeof(desc));
|
|
desc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
for(desc.index = 0; desc.index < V4L2_FORMATS_MAX; desc.index++) {
|
|
- if(ioctl(vdo->fd, VIDIOC_ENUM_FMT, &desc) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_ENUM_FMT, &desc) < 0)
|
|
break;
|
|
zprintf(2, " [%d] %.4s : %s%s\n",
|
|
desc.index, (char*)&desc.pixelformat, desc.description,
|
|
@@ -368,7 +377,7 @@
|
|
struct v4l2_pix_format *pix = &fmt.fmt.pix;
|
|
memset(&fmt, 0, sizeof(fmt));
|
|
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
- if(ioctl(vdo->fd, VIDIOC_G_FMT, &fmt) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_G_FMT, &fmt) < 0)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"querying current video format (VIDIO_G_FMT)"));
|
|
|
|
@@ -390,15 +399,15 @@
|
|
maxpix->height = vdo->height;
|
|
|
|
zprintf(1, "setting requested size: %d x %d\n", vdo->width, vdo->height);
|
|
- if(ioctl(vdo->fd, VIDIOC_S_FMT, &maxfmt) < 0) {
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_S_FMT, &maxfmt) < 0) {
|
|
zprintf(1, "set FAILED...trying to recover original format\n");
|
|
/* ignore errors (driver broken anyway) */
|
|
- ioctl(vdo->fd, VIDIOC_S_FMT, &fmt);
|
|
+ v4l2_ioctl(vdo->fd, VIDIOC_S_FMT, &fmt);
|
|
}
|
|
|
|
memset(&fmt, 0, sizeof(fmt));
|
|
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
- if(ioctl(vdo->fd, VIDIOC_G_FMT, &fmt) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_G_FMT, &fmt) < 0)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"querying current video format (VIDIOC_G_FMT)"));
|
|
|
|
@@ -420,7 +429,7 @@
|
|
struct v4l2_cropcap ccap;
|
|
memset(&ccap, 0, sizeof(ccap));
|
|
ccap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
- if(ioctl(vdo->fd, VIDIOC_CROPCAP, &ccap) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_CROPCAP, &ccap) < 0)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"querying crop support (VIDIOC_CROPCAP)"));
|
|
|
|
@@ -442,7 +451,7 @@
|
|
memset(&crop, 0, sizeof(crop));
|
|
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
crop.c = ccap.defrect;
|
|
- if(ioctl(vdo->fd, VIDIOC_S_CROP, &crop) < 0 && errno != EINVAL)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_S_CROP, &crop) < 0 && errno != EINVAL)
|
|
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
|
|
"setting default crop window (VIDIOC_S_CROP)"));
|
|
return(0);
|
|
@@ -453,7 +462,7 @@
|
|
/* check capabilities */
|
|
struct v4l2_capability vcap;
|
|
memset(&vcap, 0, sizeof(vcap));
|
|
- if(ioctl(vdo->fd, VIDIOC_QUERYCAP, &vcap) < 0)
|
|
+ if(v4l2_ioctl(vdo->fd, VIDIOC_QUERYCAP, &vcap) < 0)
|
|
return(err_capture(vdo, SEV_WARNING, ZBAR_ERR_UNSUPPORTED, __func__,
|
|
"video4linux version 2 not supported (VIDIOC_QUERYCAP)"));
|
|
|