videodev2.h: add V4L2_CTRL_FLAG_DYNAMIC_ARRAY
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 14 Apr 2021 13:01:16 +0000 (15:01 +0200)
committerDom Cobley <popcornmix@gmail.com>
Mon, 21 Mar 2022 16:04:20 +0000 (16:04 +0000)
Add a new flag that indicates that this control is a dynamically sized
array. Also document this flag.

Currently dynamically sized arrays are limited to one dimensional arrays,
but that might change in the future if there is a need for it.

The initial use-case of dynamic arrays are stateless codecs. A frame
can be divided in many slices, so you want to provide an array containing
slice information for each slice. Typically the number of slices is small,
but the standard allow for hundreds or thousands of slices. Dynamic arrays
are a good solution since sizing the array for the worst case would waste
substantial amounts of memory.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
(cherry picked from commit c095ad310b223b9de38d491c9f66533d05586b45)

Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst
include/uapi/linux/videodev2.h

index f9ecf62..819a70a 100644 (file)
@@ -607,6 +607,14 @@ See also the examples in :ref:`control`.
        ``V4L2_CTRL_FLAG_GRABBED`` flag when buffers are allocated or
        streaming is in progress since most drivers do not support changing
        the format in that case.
+    * - ``V4L2_CTRL_FLAG_DYNAMIC_ARRAY``
+      - 0x0800
+      - This control is a dynamically sized 1-dimensional array. It
+        behaves the same as a regular array, except that the number
+       of elements as reported by the ``elems`` field is between 1 and
+       ``dims[0]``. So setting the control with a differently sized
+       array will change the ``elems`` field when the control is
+       queried afterwards.
 
 Return Value
 ============
index 12f356c..272761a 100644 (file)
@@ -1882,6 +1882,7 @@ struct v4l2_querymenu {
 #define V4L2_CTRL_FLAG_HAS_PAYLOAD     0x0100
 #define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE        0x0200
 #define V4L2_CTRL_FLAG_MODIFY_LAYOUT   0x0400
+#define V4L2_CTRL_FLAG_DYNAMIC_ARRAY   0x0800
 
 /*  Query flags, to be ORed with the control ID */
 #define V4L2_CTRL_FLAG_NEXT_CTRL       0x80000000