1 From 237e15f3caec01b144b2409829a731b734972539 Mon Sep 17 00:00:00 2001
2 From: Hans Verkuil <hansverk@cisco.com>
3 Date: Thu, 23 Aug 2018 09:56:22 -0400
4 Subject: [PATCH 693/725] media: videodev2.h: add new capabilities for buffer
7 Upstream commit f35f5d72e70e6b91389eb98fcabf43b79f40587f
9 VIDIOC_REQBUFS and VIDIOC_CREATE_BUFFERS will return capabilities
10 telling userspace what the given buffer type is capable of.
12 Signed-off-by: Hans Verkuil <hansverk@cisco.com>
13 Reviewed-by: Tomasz Figa <tfiga@chromium.org>
14 Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
15 Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
17 .../media/uapi/v4l/vidioc-create-bufs.rst | 14 ++++++-
18 .../media/uapi/v4l/vidioc-reqbufs.rst | 42 ++++++++++++++++++-
19 include/uapi/linux/videodev2.h | 13 +++++-
20 3 files changed, 65 insertions(+), 4 deletions(-)
22 --- a/Documentation/media/uapi/v4l/vidioc-create-bufs.rst
23 +++ b/Documentation/media/uapi/v4l/vidioc-create-bufs.rst
24 @@ -102,7 +102,19 @@ than the number requested.
26 - Filled in by the application, preserved by the driver.
30 + - Set by the driver. If 0, then the driver doesn't support
31 + capabilities. In that case all you know is that the driver is
32 + guaranteed to support ``V4L2_MEMORY_MMAP`` and *might* support
33 + other :c:type:`v4l2_memory` types. It will not support any others
34 + capabilities. See :ref:`here <v4l2-buf-capabilities>` for a list of the
37 + If you want to just query the capabilities without making any
38 + other changes, then set ``count`` to 0, ``memory`` to
39 + ``V4L2_MEMORY_MMAP`` and ``format.type`` to the buffer type.
42 - A place holder for future extensions. Drivers and applications
43 must set the array to zero.
45 --- a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
46 +++ b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
47 @@ -88,10 +88,50 @@ any DMA in progress, an implicit
48 ``V4L2_MEMORY_DMABUF`` or ``V4L2_MEMORY_USERPTR``. See
49 :c:type:`v4l2_memory`.
53 + - Set by the driver. If 0, then the driver doesn't support
54 + capabilities. In that case all you know is that the driver is
55 + guaranteed to support ``V4L2_MEMORY_MMAP`` and *might* support
56 + other :c:type:`v4l2_memory` types. It will not support any others
59 + If you want to query the capabilities with a minimum of side-effects,
60 + then this can be called with ``count`` set to 0, ``memory`` set to
61 + ``V4L2_MEMORY_MMAP`` and ``type`` set to the buffer type. This will
62 + free any previously allocated buffers, so this is typically something
63 + that will be done at the start of the application.
66 - A place holder for future extensions. Drivers and applications
67 must set the array to zero.
69 +.. tabularcolumns:: |p{6.1cm}|p{2.2cm}|p{8.7cm}|
71 +.. _v4l2-buf-capabilities:
72 +.. _V4L2-BUF-CAP-SUPPORTS-MMAP:
73 +.. _V4L2-BUF-CAP-SUPPORTS-USERPTR:
74 +.. _V4L2-BUF-CAP-SUPPORTS-DMABUF:
75 +.. _V4L2-BUF-CAP-SUPPORTS-REQUESTS:
77 +.. cssclass:: longtable
79 +.. flat-table:: V4L2 Buffer Capabilities Flags
84 + * - ``V4L2_BUF_CAP_SUPPORTS_MMAP``
86 + - This buffer type supports the ``V4L2_MEMORY_MMAP`` streaming mode.
87 + * - ``V4L2_BUF_CAP_SUPPORTS_USERPTR``
89 + - This buffer type supports the ``V4L2_MEMORY_USERPTR`` streaming mode.
90 + * - ``V4L2_BUF_CAP_SUPPORTS_DMABUF``
92 + - This buffer type supports the ``V4L2_MEMORY_DMABUF`` streaming mode.
93 + * - ``V4L2_BUF_CAP_SUPPORTS_REQUESTS``
95 + - This buffer type supports :ref:`requests <media-request-api>`.
99 --- a/include/uapi/linux/videodev2.h
100 +++ b/include/uapi/linux/videodev2.h
101 @@ -872,9 +872,16 @@ struct v4l2_requestbuffers {
103 __u32 type; /* enum v4l2_buf_type */
104 __u32 memory; /* enum v4l2_memory */
106 + __u32 capabilities;
110 +/* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */
111 +#define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0)
112 +#define V4L2_BUF_CAP_SUPPORTS_USERPTR (1 << 1)
113 +#define V4L2_BUF_CAP_SUPPORTS_DMABUF (1 << 2)
114 +#define V4L2_BUF_CAP_SUPPORTS_REQUESTS (1 << 3)
117 * struct v4l2_plane - plane info for multi-planar buffers
118 * @bytesused: number of bytes occupied by data in the plane (payload)
119 @@ -2318,6 +2325,7 @@ struct v4l2_dbg_chip_info {
120 * return: number of created buffers
121 * @memory: enum v4l2_memory; buffer memory type
122 * @format: frame format, for which buffers are requested
123 + * @capabilities: capabilities of this buffer type.
124 * @reserved: future extensions
126 struct v4l2_create_buffers {
127 @@ -2325,7 +2333,8 @@ struct v4l2_create_buffers {
130 struct v4l2_format format;
132 + __u32 capabilities;