Get rid of old patches that aren't needed anymore

None of those patches are needed, as they got merged at the
zbar 0.20 version.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
epel9
Mauro Carvalho Chehab 7 years ago
parent 9c48b8c57a
commit b61f85891f

@ -1,140 +0,0 @@
diff --git a/configure.ac b/configure.ac
index dbd7153fb13b..7bcb18219853 100644
--- a/configure.ac
+++ b/configure.ac
@@ -476,18 +476,33 @@ AM_CONDITIONAL([HAVE_PYTHON], [test "x$with_python" = "xyes"])
dnl Qt
AC_ARG_WITH([qt],
[AS_HELP_STRING([--without-qt],
- [disable support for Qt4 widget])],
+ [disable support for Qt widget])],
[],
[with_qt="yes"])
+dnl Qt5
+AC_ARG_WITH([qt5],
+ [AS_HELP_STRING([--without-qt5],
+ [disable support for Qt5 widget. if --with-qt, it will seek only for Qt4])],
+ [],
+ [with_qt5="yes"])
+
AC_ARG_VAR([MOC], [full path to Qt moc program])
AS_IF([test "x$with_qt" != "xno"],
- [PKG_CHECK_MODULES([QT], [QtCore >= 4 QtGui >= 4])
- MOC=`$PKG_CONFIG QtGui --variable=moc_location`
- AC_MSG_NOTICE([using moc from $MOC])
- QT_VERSION=`$PKG_CONFIG QtGui --modversion`
- AC_MSG_NOTICE([using Qt version $QT_VERSION])])
+ AS_IF([test "x$with_qt5" != "xno"],
+ [PKG_CHECK_MODULES([QT], [Qt5Core >= 5 Qt5Gui >= 5 Qt5Widgets >= 5.0 Qt5X11Extras >= 5.0])
+ AC_CHECK_PROGS(MOC, [moc-qt5 moc])
+ AC_MSG_NOTICE([using moc from $MOC])
+ QT_VERSION=`$PKG_CONFIG Qt5Gui --modversion`
+ CPPFLAGS="$CPPFLAGS $QT_CPPFLAGS -fPIC"
+ AC_MSG_NOTICE([using Qt version $QT_VERSION])],
+
+ [PKG_CHECK_MODULES([QT], [QtCore >= 4 QtGui >= 4])
+ MOC=`$PKG_CONFIG QtGui --variable=moc_location`
+ AC_MSG_NOTICE([using moc from $MOC])
+ QT_VERSION=`$PKG_CONFIG QtGui --modversion`
+ AC_MSG_NOTICE([using Qt version $QT_VERSION])]))
AM_CONDITIONAL([HAVE_QT], [test "x$with_qt" = "xyes"])
@@ -596,9 +611,9 @@ AS_IF([test "x$with_gtk" != "xyes"],
[echo " => the GTK+ widget will *NOT* be built"],
[AS_IF([test "x$with_python" != "xyes"],
[echo " => the PyGTK widget wrapper will *NOT* be built"])])
-echo "Qt4 --with-qt=$with_qt"
+echo "Qt${QT_VERSION} --with-qt=$with_qt"
AS_IF([test "x$with_qt" != "xyes"],
- [echo " => the Qt4 widget will *NOT* be built"])
+ [echo " => the Qt widget will *NOT* be built"])
echo "Java --with-java=$with_java"
AS_IF([test "x$with_java" != "xyes"],
[echo " => the Java interface will *NOT* be built"])
diff --git a/include/zbar/QZBar.h b/include/zbar/QZBar.h
index 104449928e2d..1a4716565047 100644
--- a/include/zbar/QZBar.h
+++ b/include/zbar/QZBar.h
@@ -26,7 +26,12 @@
/// @file
/// Barcode Reader Qt4 Widget
-#include <qwidget.h>
+#include <QtGui>
+#if QT_VERSION >= 0x050000
+# include <QtWidgets>
+#else
+# include <qwidget.h>
+#endif
namespace zbar {
diff --git a/include/zbar/QZBarImage.h b/include/zbar/QZBarImage.h
index 1505177e07a9..b862c8085576 100644
--- a/include/zbar/QZBarImage.h
+++ b/include/zbar/QZBarImage.h
@@ -54,7 +54,11 @@ public:
unsigned height = qimg.height();
set_size(width, height);
set_format(zbar_fourcc('B','G','R','4'));
+#if QT_VERSION >= 0x050000
+ unsigned long datalen = qimg.byteCount();
+#else
unsigned long datalen = qimg.numBytes();
+#endif
set_data(qimg.bits(), datalen);
if((width * 4 != bpl) ||
diff --git a/qt/QZBar.cpp b/qt/QZBar.cpp
index e1001b09cff5..a5b956b342ad 100644
--- a/qt/QZBar.cpp
+++ b/qt/QZBar.cpp
@@ -23,7 +23,7 @@
#include <qevent.h>
#include <qurl.h>
-#include <qx11info_x11.h>
+#include <QX11Info>
#include <zbar/QZBar.h>
#include "QZBarThread.h"
@@ -49,7 +49,11 @@ QZBar::QZBar (QWidget *parent)
thread = new QZBarThread;
if(testAttribute(Qt::WA_WState_Created)) {
+#if QT_VERSION >= 0x050000
+ thread->window.attach(QX11Info::display(), winId());
+#else
thread->window.attach(x11Info().display(), winId());
+#endif
_attached = 1;
}
connect(thread, SIGNAL(videoOpened(bool)),
@@ -204,7 +208,12 @@ void QZBar::changeEvent(QEvent *event)
try {
QMutexLocker locker(&thread->mutex);
if(event->type() == QEvent::ParentChange)
+#if QT_VERSION >= 0x050000
+ thread->window.attach(QX11Info::display(), winId());
+#else
thread->window.attach(x11Info().display(), winId());
+#endif
+
}
catch(Exception) { /* ignore (FIXME do something w/error) */ }
}
@@ -215,7 +224,11 @@ void QZBar::attach ()
return;
try {
+#if QT_VERSION >= 0x050000
+ thread->window.attach(QX11Info::display(), winId());
+#else
thread->window.attach(x11Info().display(), winId());
+#endif
_attached = 1;
_videoEnabled = !_videoDevice.isEmpty();

@ -1,128 +0,0 @@
diff -r 60f92d860a1f zbar/convert.c
--- a/zbar/convert.c Sat Dec 25 08:29:33 2010 -0200
+++ b/zbar/convert.c Sat Dec 25 14:36:04 2010 -0200
@@ -1157,6 +1157,42 @@
break;
}
}
+ if(!min_fmt && vdo->emu_formats) {
+ /* As vdo->formats aren't compatible, just free them */
+ free(vdo->formats);
+ vdo->formats = vdo->emu_formats;
+ vdo->emu_formats = NULL;
+
+ /*
+ * Use the same cost algorithm to select emulated formats.
+ * This might select a sub-optimal conversion, but, in practice,
+ * it will select a conversion to YUV at libv4l, and a YUY->Y8
+ * in zbar, with it is OK. Yet, it is better to not select the
+ * most performatic conversion than to not support the webcam.
+ */
+ for(fmt = _zbar_formats; *fmt; fmt++) {
+ /* only consider formats supported by video device */
+ uint32_t win_fmt = 0;
+ int cost;
+ if(!has_format(*fmt, srcs))
+ continue;
+ cost = _zbar_best_format(*fmt, &win_fmt, dsts);
+ if(cost < 0) {
+ zprintf(4, "%.4s(%08" PRIx32 ") -> ? (unsupported)\n",
+ (char*)fmt, *fmt);
+ continue;
+ }
+ zprintf(4, "%.4s(%08" PRIx32 ") -> %.4s(%08" PRIx32 ") (%d)\n",
+ (char*)fmt, *fmt, (char*)&win_fmt, win_fmt, cost);
+ if(min_cost > cost) {
+ min_cost = cost;
+ min_fmt = *fmt;
+ if(!cost)
+ break;
+ }
+ }
+ }
+
if(win)
(void)window_unlock(win);
diff -r 60f92d860a1f zbar/video.c
--- a/zbar/video.c Sat Dec 25 08:29:33 2010 -0200
+++ b/zbar/video.c Sat Dec 25 14:36:04 2010 -0200
@@ -111,6 +111,9 @@
free(vdo->buf);
if(vdo->formats)
free(vdo->formats);
+ if(vdo->emu_formats)
+ free(vdo->emu_formats);
+
err_cleanup(&vdo->err);
_zbar_mutex_destroy(&vdo->qlock);
diff -r 60f92d860a1f zbar/video.h
--- a/zbar/video.h Sat Dec 25 08:29:33 2010 -0200
+++ b/zbar/video.h Sat Dec 25 14:36:04 2010 -0200
@@ -69,6 +69,7 @@
uint32_t format; /* selected fourcc */
unsigned palette; /* v4l1 format index corresponding to format */
uint32_t *formats; /* 0 terminated list of supported formats */
+ uint32_t *emu_formats; /* 0 terminated list of emulated formats */
unsigned long datalen; /* size of image data for selected format */
unsigned long buflen; /* total size of image data buffer */
diff -r 60f92d860a1f zbar/video/v4l2.c
--- a/zbar/video/v4l2.c Sat Dec 25 08:29:33 2010 -0200
+++ b/zbar/video/v4l2.c Sat Dec 25 14:36:04 2010 -0200
@@ -347,6 +347,8 @@
static inline int v4l2_probe_formats (zbar_video_t *vdo)
{
+ int n_formats = 0, n_emu_formats = 0;
+
zprintf(2, "enumerating supported formats:\n");
struct v4l2_fmtdesc desc;
memset(&desc, 0, sizeof(desc));
@@ -354,17 +356,39 @@
for(desc.index = 0; desc.index < V4L2_FORMATS_MAX; desc.index++) {
if(v4l2_ioctl(vdo->fd, VIDIOC_ENUM_FMT, &desc) < 0)
break;
- zprintf(2, " [%d] %.4s : %s%s\n",
+ zprintf(2, " [%d] %.4s : %s%s%s\n",
desc.index, (char*)&desc.pixelformat, desc.description,
- (desc.flags & V4L2_FMT_FLAG_COMPRESSED) ? " COMPRESSED" : "");
- vdo->formats = realloc(vdo->formats,
- (desc.index + 2) * sizeof(uint32_t));
- vdo->formats[desc.index] = desc.pixelformat;
+ (desc.flags & V4L2_FMT_FLAG_COMPRESSED) ? " COMPRESSED" : "",
+ (desc.flags & V4L2_FMT_FLAG_EMULATED) ? " EMULATED" : "");
+ if (desc.flags & V4L2_FMT_FLAG_EMULATED) {
+ vdo->emu_formats = realloc(vdo->emu_formats,
+ (n_emu_formats + 2) * sizeof(uint32_t));
+ vdo->emu_formats[n_emu_formats++] = desc.pixelformat;
+ } else {
+ vdo->formats = realloc(vdo->formats,
+ (n_formats + 2) * sizeof(uint32_t));
+ vdo->formats[n_formats++] = desc.pixelformat;
+ }
}
if(!desc.index)
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
"enumerating video formats (VIDIOC_ENUM_FMT)"));
- vdo->formats[desc.index] = 0;
+ if(vdo->formats)
+ vdo->formats[n_formats] = 0;
+ if(vdo->emu_formats)
+ vdo->emu_formats[n_emu_formats] = 0;
+ if(!vdo->formats && vdo->emu_formats) {
+ /*
+ * If only emu formats are available, just move them to vdo->formats.
+ * This happens when libv4l detects that the only available fourcc
+ * formats are webcam proprietary formats or bayer formats.
+ */
+ vdo->formats = vdo->emu_formats;
+ vdo->emu_formats = NULL;
+ }
+
+ zprintf(2, "Found %d formats and %d emulated formats.\n",
+ n_formats, n_emu_formats);
struct v4l2_format fmt;
struct v4l2_pix_format *pix = &fmt.fmt.pix;

@ -1,11 +0,0 @@
--- a/configure.ac 2015-08-14 16:26:09.661856984 -0300
+++ b/configure.ac 2015-08-14 16:26:20.209851076 -0300
@@ -4,7 +4,7 @@
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
AM_INIT_AUTOMAKE([1.10 -Werror foreign subdir-objects std-options dist-bzip2])
-AM_PROG_AR
+m4_pattern_allow([AM_PROG_AR])
AC_CONFIG_HEADERS([include/config.h])
AC_CONFIG_SRCDIR(zbar/scanner.c)
LT_PREREQ([2.2])

@ -1,148 +0,0 @@
From 76a286fd34d5159b55de4d4f276dcbf69d1b263e Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Date: Sun, 26 Mar 2017 09:43:07 -0300
Subject: [PATCH] zbarcam: add qt and gtk variants
The original zbarcam use standard X11 libraries to display
video. That provides an ugly interface, and could be
slow on high resolutions.
As Zbar has already test examples for qt and gtk, let's
promote them to real applications. One advantage is that
both qt and gtk libraries will be tested when building
those.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
diff --git a/qt/Makefile.am.inc b/qt/Makefile.am.inc
index dc1525e0d52a..5f860bfa31bc 100644
--- a/qt/Makefile.am.inc
+++ b/qt/Makefile.am.inc
@@ -7,6 +7,7 @@ qt_libzbarqt_la_SOURCES = qt/QZBar.cpp qt/QZBarThread.h qt/QZBarThread.cpp
nodist_qt_libzbarqt_la_SOURCES = qt/moc_QZBar.cpp qt/moc_QZBarThread.cpp
BUILT_SOURCES += $(nodist_qt_libzbarqt_la_SOURCES)
DISTCLEANFILES += $(nodist_qt_libzbarqt_la_SOURCES)
+CLEANFILES += qt/moc_%.cpp
qt/moc_%.cpp: qt/%.h
$(MOC) $(qt_libzbarqt_la_CPPFLAGS) $< -o $@
diff --git a/test/Makefile.am.inc b/test/Makefile.am.inc
index 7340a7f2f61f..8496eb30f3cc 100644
--- a/test/Makefile.am.inc
+++ b/test/Makefile.am.inc
@@ -45,26 +45,6 @@ test_dbg_scan_CPPFLAGS = $(MAGICK_CFLAGS) $(AM_CPPFLAGS)
test_dbg_scan_LDADD = $(MAGICK_LIBS) -lMagick++ zbar/libzbar.la $(AM_LDADD)
endif
-if HAVE_GTK
-check_PROGRAMS += test/test_gtk
-test_test_gtk_SOURCES = test/test_gtk.c test/scan_video.c
-test_test_gtk_CPPFLAGS = $(GTK_CFLAGS) $(AM_CPPFLAGS)
-test_test_gtk_LDADD = $(GTK_LIBS) gtk/libzbargtk.la $(AM_LDADD)
-endif
-
-if HAVE_QT
-check_PROGRAMS += test/test_qt
-test_test_qt_SOURCES = test/test_qt.cpp test/scan_video.c
-nodist_test_test_qt_SOURCES = test/moc_test_qt.h
-test_test_qt_CPPFLAGS = -Itest $(QT_CFLAGS) $(AM_CPPFLAGS)
-test_test_qt_LDADD = $(QT_LIBS) qt/libzbarqt.la $(AM_LDADD)
-BUILT_SOURCES += $(nodist_test_test_qt_SOURCES)
-DISTCLEANFILES += $(nodist_test_test_qt_SOURCES)
-
-test/moc_%.h: test/%.cpp
- $(MOC) -i $(test_test_qt_CPPFLAGS) $< -o $@
-endif
-
EXTRA_DIST += test/test_pygtk.py test/test_perl.pl
# automake bug in "monolithic mode"?
diff --git a/zbarcam/Makefile.am.inc b/zbarcam/Makefile.am.inc
index ea869bcd2e11..5aa788a23da5 100644
--- a/zbarcam/Makefile.am.inc
+++ b/zbarcam/Makefile.am.inc
@@ -2,7 +2,32 @@ bin_PROGRAMS += zbarcam/zbarcam
zbarcam_zbarcam_SOURCES = zbarcam/zbarcam.c
zbarcam_zbarcam_LDADD = zbar/libzbar.la
# automake bug in "monolithic mode"?
-CLEANFILES += zbarcam/.libs/zbarcam
+CLEANFILES += zbarcam/.libs/zbarcam zbarcam/moc_zbarcam_qt.h
+
+if HAVE_GTK
+bin_PROGRAMS += zbarcam/zbarcam-gtk
+check_PROGRAMS += zbarcam/zbarcam-gtk
+zbarcam_zbarcam_gtk_SOURCES = zbarcam/zbarcam-gtk.c zbarcam/scan_video.c
+zbarcam_zbarcam_gtk_CPPFLAGS = $(GTK_CFLAGS) $(AM_CPPFLAGS)
+zbarcam_zbarcam_gtk_LDADD = $(GTK_LIBS) gtk/libzbargtk.la $(AM_LDADD)
+endif
+
+if HAVE_QT
+bin_PROGRAMS += zbarcam/zbarcam-qt
+check_PROGRAMS += zbarcam/zbarcam-qt
+
+zbarcam_zbarcam_qt_SOURCES = zbarcam/zbarcam-qt.cpp zbarcam/scan_video.c
+nodist_zbarcam_zbarcam_qt_SOURCES = zbarcam/moc_zbarcam_qt.h
+zbarcam_zbarcam_qt_CPPFLAGS = -Izbarcam $(QT_CFLAGS) $(AM_CPPFLAGS)
+zbarcam_zbarcam_qt_LDADD = $(QT_LIBS) qt/libzbarqt.la $(AM_LDADD)
+BUILT_SOURCES += $(nodist_zbarcam_zbarcam_qt_SOURCES)
+DISTCLEANFILES += $(nodist_zbarcam_zbarcam_qt_SOURCES) zbarcam/moc_zbarcam_qt.h
+
+
+zbarcam/moc_zbarcam_qt.h: zbarcam/zbarcam-qt.cpp
+ $(MOC) -i $(zbarcam_zbarcam_qt_CPPFLAGS) $< -o $@
+endif
+
if WIN32
zbarcam_zbarcam_SOURCES += zbarcam/zbarcam.rc
diff --git a/test/scan_video.c b/zbarcam/scan_video.c
similarity index 100%
rename from test/scan_video.c
rename to zbarcam/scan_video.c
diff --git a/test/test_gtk.c b/zbarcam/zbarcam-gtk.c
similarity index 100%
rename from test/test_gtk.c
rename to zbarcam/zbarcam-gtk.c
diff --git a/test/test_qt.cpp b/zbarcam/zbarcam-qt.cpp
similarity index 97%
rename from test/test_qt.cpp
rename to zbarcam/zbarcam-qt.cpp
index 96d2f9541453..3a39a338b59d 100644
--- a/test/test_qt.cpp
+++ b/zbarcam/zbarcam-qt.cpp
@@ -40,7 +40,7 @@ int scan_video(void *add_device,
const char *default_device);
}
-class TestQZBar : public QWidget
+class ZbarcamQZBar : public QWidget
{
Q_OBJECT
@@ -52,7 +52,7 @@ protected:
}
public:
- TestQZBar (const char *default_device)
+ ZbarcamQZBar (const char *default_device)
{
// drop-down list of video devices
QComboBox *videoList = new QComboBox;
@@ -142,7 +142,7 @@ private:
zbar::QZBar *zbar;
};
-#include "moc_test_qt.h"
+#include "moc_zbarcam_qt.h"
int main (int argc, char *argv[])
{
@@ -152,7 +152,7 @@ int main (int argc, char *argv[])
if(argc > 1)
dev = argv[1];
- TestQZBar window(dev);
+ ZbarcamQZBar window(dev);
window.show();
return(app.exec());
}

File diff suppressed because it is too large Load Diff

@ -1,124 +0,0 @@
From a8ed8c04c119e5a323a2c79fcd0d28b4d29fc28a Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Date: Thu, 23 Apr 2015 22:56:09 -0300
Subject: [PATCH] v4l2: use REQBUFS properly
There are two issues on this driver with regards to buffer
request:
1) it is not calling VIDIOC_REQBUFS for USERPTR;
2) It is calling VIDIOC_REQBUFS at probe, to check the max
number of supported buffers, but it doesn't deallocate
the buffers at the end of the probe function.
Fix those issues. Also, improve the error/warning messages
associated with possible problems.
This is based on the issues detected by the patch proposed
to fix this bug:
https://bugs.archlinux.org/task/44091
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/zbar/video/v4l2.c b/zbar/video/v4l2.c
index aabd16643ddc..f6662d3707f9 100644
--- a/zbar/video/v4l2.c
+++ b/zbar/video/v4l2.c
@@ -201,21 +201,6 @@ static int v4l2_cleanup (zbar_video_t *vdo)
static int v4l2_mmap_buffers (zbar_video_t *vdo)
{
- struct v4l2_requestbuffers rb;
- memset(&rb, 0, sizeof(rb));
- rb.count = vdo->num_images;
- rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- rb.memory = V4L2_MEMORY_MMAP;
- 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",
- rb.count, vdo->num_images);
- if(!rb.count)
- return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
- "driver returned 0 buffers"));
- if(vdo->num_images > rb.count)
- vdo->num_images = rb.count;
struct v4l2_buffer vbuf;
memset(&vbuf, 0, sizeof(vbuf));
@@ -313,8 +298,32 @@ static int v4l2_set_format (zbar_video_t *vdo,
static int v4l2_init (zbar_video_t *vdo,
uint32_t fmt)
{
+ struct v4l2_requestbuffers rb;
if(v4l2_set_format(vdo, fmt))
return(-1);
+
+ memset(&rb, 0, sizeof(rb));
+ rb.count = vdo->num_images;
+ rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if(vdo->iomode == VIDEO_MMAP)
+ rb.memory = V4L2_MEMORY_MMAP;
+ else
+ rb.memory = V4L2_MEMORY_USERPTR;
+
+ 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)"));
+
+ if(!rb.count)
+ return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
+ "driver returned 0 buffers"));
+
+ if(vdo->num_images > rb.count)
+ vdo->num_images = rb.count;
+
+ zprintf(1, "using %u buffers (of %d requested)\n",
+ rb.count, vdo->num_images);
+
if(vdo->iomode == VIDEO_MMAP)
return(v4l2_mmap_buffers(vdo));
return(0);
@@ -324,7 +333,7 @@ static int v4l2_probe_iomode (zbar_video_t *vdo)
{
struct v4l2_requestbuffers rb;
memset(&rb, 0, sizeof(rb));
- rb.count = vdo->num_images; /* FIXME workaround broken drivers */
+ rb.count = vdo->num_images;
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(vdo->iomode == VIDEO_MMAP)
rb.memory = V4L2_MEMORY_MMAP;
@@ -340,14 +349,31 @@ static int v4l2_probe_iomode (zbar_video_t *vdo)
return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
"querying streaming mode (VIDIOC_REQBUFS)"));
#ifdef HAVE_SYS_MMAN_H
+ err_capture(vdo, SEV_WARNING, ZBAR_ERR_SYSTEM, __func__,
+ "USERPTR failed. Falling back to mmap");
vdo->iomode = VIDEO_MMAP;
+#else
+ return err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__,
+ "Userptr not supported, and zbar was compiled without mmap support"));
#endif
}
else {
if(!vdo->iomode)
- vdo->iomode = VIDEO_USERPTR;
+ rb.memory = V4L2_MEMORY_USERPTR;
+ /* Update the num_images with the max supported by the driver */
if(rb.count)
vdo->num_images = rb.count;
+ else
+ err_capture(vdo, SEV_WARNING, ZBAR_ERR_SYSTEM, __func__,
+ "Something is wrong: number of buffers returned by REQBUF is zero!");
+
+ /* requesting 0 buffers
+ * This cleans up the buffers allocated previously on probe
+ */
+ rb.count = 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)");
}
return(0);
}

@ -1,305 +0,0 @@
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)"));
Loading…
Cancel
Save