e313ace8955ab9ab0aca5a961c68e4fe68c0d122
[openwrt/staging/rmilecki.git] /
1 From e9ec6de11c358ff3bc389cfa0003544c60f859ef 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 697/703] media: videodev2.h: add new capabilities for buffer
5 types
6
7 Upstream commit f35f5d72e70e6b91389eb98fcabf43b79f40587f
8
9 VIDIOC_REQBUFS and VIDIOC_CREATE_BUFFERS will return capabilities
10 telling userspace what the given buffer type is capable of.
11
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>
16 ---
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(-)
21
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.
25 - ``format``
26 - Filled in by the application, preserved by the driver.
27 * - __u32
28 - - ``reserved``\ [8]
29 + - ``capabilities``
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
35 + capabilities.
36 +
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.
40 + * - __u32
41 + - ``reserved``\ [7]
42 - A place holder for future extensions. Drivers and applications
43 must set the array to zero.
44
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`.
50 * - __u32
51 - - ``reserved``\ [2]
52 + - ``capabilities``
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
57 + capabilities.
58 +
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.
64 + * - __u32
65 + - ``reserved``\ [1]
66 - A place holder for future extensions. Drivers and applications
67 must set the array to zero.
68
69 +.. tabularcolumns:: |p{6.1cm}|p{2.2cm}|p{8.7cm}|
70 +
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:
76 +
77 +.. cssclass:: longtable
78 +
79 +.. flat-table:: V4L2 Buffer Capabilities Flags
80 + :header-rows: 0
81 + :stub-columns: 0
82 + :widths: 3 1 4
83 +
84 + * - ``V4L2_BUF_CAP_SUPPORTS_MMAP``
85 + - 0x00000001
86 + - This buffer type supports the ``V4L2_MEMORY_MMAP`` streaming mode.
87 + * - ``V4L2_BUF_CAP_SUPPORTS_USERPTR``
88 + - 0x00000002
89 + - This buffer type supports the ``V4L2_MEMORY_USERPTR`` streaming mode.
90 + * - ``V4L2_BUF_CAP_SUPPORTS_DMABUF``
91 + - 0x00000004
92 + - This buffer type supports the ``V4L2_MEMORY_DMABUF`` streaming mode.
93 + * - ``V4L2_BUF_CAP_SUPPORTS_REQUESTS``
94 + - 0x00000008
95 + - This buffer type supports :ref:`requests <media-request-api>`.
96
97 Return Value
98 ============
99 --- a/include/uapi/linux/videodev2.h
100 +++ b/include/uapi/linux/videodev2.h
101 @@ -872,9 +872,16 @@ struct v4l2_requestbuffers {
102 __u32 count;
103 __u32 type; /* enum v4l2_buf_type */
104 __u32 memory; /* enum v4l2_memory */
105 - __u32 reserved[2];
106 + __u32 capabilities;
107 + __u32 reserved[1];
108 };
109
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)
115 +
116 /**
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
125 */
126 struct v4l2_create_buffers {
127 @@ -2325,7 +2333,8 @@ struct v4l2_create_buffers {
128 __u32 count;
129 __u32 memory;
130 struct v4l2_format format;
131 - __u32 reserved[8];
132 + __u32 capabilities;
133 + __u32 reserved[7];
134 };
135
136 /*