Message ID | 20210610113615.785359-2-hverkuil-cisco@xs4all.nl |
---|---|
State | New |
Headers | show |
Series | Dynamic arrays and read-only requests | expand |
Hi Hans, Le jeudi 10 juin 2021 à 13:36 +0200, Hans Verkuil a écrit : > 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> > --- > .../userspace-api/media/v4l/vidioc-queryctrl.rst | 8 ++++++++ > include/uapi/linux/videodev2.h | 1 + > 2 files changed, 9 insertions(+) > > diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > index 07e54029e1e9..a1a0dbff4a6f 100644 > --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > @@ -601,6 +601,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 The minimum of 1 item is indeed logical for slices (or tiles in AV1), but I think we should remove this limitation so it won't get in the way in other applications. There is otherwise no way (other then creating a "invalid entry" value) to signal that the array is now empty. The driver could erroneously endup using ancient values. Perhaps this can be waved later when we need it ? Would that be backward compatible ? > + array will change the ``elems`` field when the control is > + queried afterwards. > > Return Value > ============ > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index 9260791b8438..7222fc855d6b 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -1869,6 +1869,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
diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 07e54029e1e9..a1a0dbff4a6f 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -601,6 +601,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 ============ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 9260791b8438..7222fc855d6b 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1869,6 +1869,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
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> --- .../userspace-api/media/v4l/vidioc-queryctrl.rst | 8 ++++++++ include/uapi/linux/videodev2.h | 1 + 2 files changed, 9 insertions(+)