summaryrefslogtreecommitdiff
path: root/uvc-gadget.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-05-22 11:42:47 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-05-22 11:42:47 +0300
commit117cd47e08db4e31d2f966cb4b22987d3e5d6bb7 (patch)
tree4fb5396cd3c3d063aec59ef1e9e1066325f33a71 /uvc-gadget.c
parentab92702a44f8521d5deef3e2ac9f35514bbe7c9a (diff)
v4l2: Split buffer allocation and mapping
Not all use cases of V4L2_MEMORY_MMAP require mapping buffers to userspace. Separate the allocation and mapping to allow usage of unmapped buffers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'uvc-gadget.c')
-rw-r--r--uvc-gadget.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/uvc-gadget.c b/uvc-gadget.c
index a0d8004..df9d80a 100644
--- a/uvc-gadget.c
+++ b/uvc-gadget.c
@@ -163,6 +163,12 @@ uvc_video_stream(struct uvc_device *dev, int enable)
return ret;
}
+ ret = v4l2_mmap_buffers(dev->vdev);
+ if (ret < 0) {
+ printf("Failed to mmap buffers.\n");
+ goto error;
+ }
+
for (i = 0; i < dev->vdev->nbufs; ++i) {
struct v4l2_video_buffer *buf = &dev->vdev->buffers[i];
@@ -170,13 +176,17 @@ uvc_video_stream(struct uvc_device *dev, int enable)
ret = v4l2_queue_buffer(dev->vdev, buf);
if (ret < 0)
- return ret;
+ goto error;
}
v4l2_stream_on(dev->vdev);
events_watch_fd(&dev->events, dev->vdev->fd, EVENT_WRITE,
uvc_video_process, dev);
+ return 0;
+
+error:
+ v4l2_free_buffers(dev->vdev);
return ret;
}