--- /dev/null
+--- zbar-0.10/zbar/video/v4l2.c 2009-10-23 18:16:44.000000000 +0000
++++ zbar-0.10/zbar/video/v4l2.c 2015-03-07 05:46:36.000000000 +0000
+@@ -241,6 +241,21 @@
+ return(0);
+ }
+
++static int v4l2_request_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_USERPTR;
++ if(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)
++ vdo->num_images = rb.count;
++ return(0);
++}
++
+ static int v4l2_set_format (zbar_video_t *vdo,
+ uint32_t fmt)
+ {
+@@ -308,6 +323,8 @@
+ return(-1);
+ if(vdo->iomode == VIDEO_MMAP)
+ return(v4l2_mmap_buffers(vdo));
++ if(vdo->iomode == VIDEO_USERPTR)
++ return(v4l2_request_buffers(vdo));
+ return(0);
+ }
+
+@@ -337,8 +354,13 @@
+ else {
+ if(!vdo->iomode)
+ vdo->iomode = VIDEO_USERPTR;
+- if(rb.count)
+- vdo->num_images = rb.count;
++ /* releasing buffers
++ * lest the driver may later refuse to change format
++ */
++ rb.count = 0;
++ if (ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0)
++ zprintf(0, "WARNING: releasing video buffers failed: error %d\n",
++ errno);
+ }
+ return(0);
+ }
}
src_prepare() {
- epatch "${FILESDIR}"/${P}-no-v4l1-check.patch
- epatch "${FILESDIR}"/${P}-errors.patch
- epatch "${FILESDIR}"/${P}-python-crash.patch
+ epatch "${FILESDIR}"/${P}-no-v4l1-check.patch \
+ "${FILESDIR}"/${P}-errors.patch \
+ "${FILESDIR}"/${P}-python-crash.patch \
+ "${FILESDIR}"/${P}-v4l2-uvcvideo.patch
use python && python_fix_shebang examples/upcrpc.py test/*.py
}
src_prepare() {
- #epatch "${FILESDIR}"/${P}-no-v4l1-check.patch
- epatch "${FILESDIR}"/${PN}-0.10-errors.patch
- epatch "${FILESDIR}"/${PN}-0.10-python-crash.patch
+ epatch "${FILESDIR}"/${PN}-0.10-errors.patch \
+ "${FILESDIR}"/${PN}-0.10-python-crash.patch \
+ "${FILESDIR}"/${PN}-0.10-v4l2-uvcvideo.patch
use python && python_fix_shebang examples/upcrpc.py test/*.py