summaryrefslogtreecommitdiff
path: root/v4l2.h
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 /v4l2.h
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 'v4l2.h')
-rw-r--r--v4l2.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/v4l2.h b/v4l2.h
index 4a22ecc..2dad4c1 100644
--- a/v4l2.h
+++ b/v4l2.h
@@ -147,9 +147,10 @@ int v4l2_set_crop(struct v4l2_device *dev, struct v4l2_rect *rect);
* will be stored in the @dev::nbufs field.
*
* When @memtype is set to V4L2_MEMORY_MMAP the buffers are allocated by the
- * driver and mapped to userspace. When @memtype is set to V4L2_MEMORY_USERPTR
- * the driver only allocates buffer objects and relies on the application to
- * provide memory storage for video frames.
+ * driver. They can then be mapped to userspace by calling v4l2_mmap_buffers().
+ * When @memtype is set to V4L2_MEMORY_USERPTR the driver only allocates buffer
+ * objects and relies on the application to provide memory storage for video
+ * frames.
*
* Return 0 on success or a negative error code on failure.
*/
@@ -172,6 +173,24 @@ int v4l2_alloc_buffers(struct v4l2_device *dev, enum v4l2_memory memtype,
int v4l2_free_buffers(struct v4l2_device *dev);
/*
+ * v4l2_mmap_buffers - Map buffers to application memory space
+ * @dev: Device instance
+ *
+ * Map all the buffers previously allocated by v4l2_alloc_buffers() to the
+ * application memory space. The buffer memory can be accessed through the mem
+ * field of each entry in the @dev::buffers array.
+ *
+ * Buffers will be automatically unmapped when freed with v4l2_free_buffers().
+ *
+ * This function can only be called when buffers have been allocated with the
+ * memory type set to V4L2_MEMORY_MMAP. If the memory type is different, or if
+ * no buffers have been allocated, it will return -EINVAL.
+ *
+ * Return 0 on success or a negative error code on failure.
+ */
+int v4l2_mmap_buffers(struct v4l2_device *dev);
+
+/*
* v4l2_queue_buffer - Queue a buffer for video capture/output
* @dev: Device instance
* @buffer: Buffer to be queued