media: videodev2: Add flag to unconditionally enumerate pixel formats
authorBenjamin Gaignard <benjamin.gaignard@collabora.com>
Mon, 26 Aug 2024 17:24:09 +0000 (17:24 +0000)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Sat, 12 Oct 2024 17:56:16 +0000 (19:56 +0200)
When the index is ORed with V4L2_FMTDESC_FLAG_ENUM_ALL the
driver clears the flag and enumerate all the possible formats,
ignoring any limitations from the current configuration.
Drivers which do not support this flag yet always return an EINVAL.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: improved doc when the new flag is not supported by the driver]

Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst
Documentation/userspace-api/media/videodev2.h.rst.exceptions
include/uapi/linux/videodev2.h

index 3adb3d205531b48b58c462a46ad361124202c596..0f69aa04607f87c8ecf743f59755c7bacc5958b8 100644 (file)
@@ -85,7 +85,17 @@ the ``mbus_code`` field is handled differently:
     * - __u32
       - ``index``
       - Number of the format in the enumeration, set by the application.
-       This is in no way related to the ``pixelformat`` field.
+        This is in no way related to the ``pixelformat`` field.
+        When the index is ORed with ``V4L2_FMTDESC_FLAG_ENUM_ALL`` the
+        driver clears the flag and enumerates all the possible formats,
+        ignoring any limitations from the current configuration. Drivers
+        which do not support this flag always return an ``EINVAL``
+        error code without clearing this flag.
+        Formats enumerated when using ``V4L2_FMTDESC_FLAG_ENUM_ALL`` flag
+        shouldn't be used when calling :c:func:`VIDIOC_ENUM_FRAMESIZES`
+        or :c:func:`VIDIOC_ENUM_FRAMEINTERVALS`.
+        ``V4L2_FMTDESC_FLAG_ENUM_ALL`` should only be used by drivers that
+        can return different format list depending on this flag.
     * - __u32
       - ``type``
       - Type of the data stream, set by the application. Only these types
@@ -234,6 +244,12 @@ the ``mbus_code`` field is handled differently:
        valid. The buffer consists of ``height`` lines, each having ``width``
        Data Units of data and the offset (in bytes) between the beginning of
        each two consecutive lines is ``bytesperline``.
+    * - ``V4L2_FMTDESC_FLAG_ENUM_ALL``
+      - 0x80000000
+      - When the applications ORs ``index`` with ``V4L2_FMTDESC_FLAG_ENUM_ALL`` flag
+        the driver enumerates all the possible pixel formats without taking care
+        of any already set configuration. Drivers which do not support this flag,
+        always return ``EINVAL`` without clearing this flag.
 
 Return Value
 ============
index d67fd4038d22a47678583414d38e3be8e502aa3e..429b5cdf05c39958a9c8c45b13a3f373c1ba5ad4 100644 (file)
@@ -217,6 +217,7 @@ replace define V4L2_FMT_FLAG_CSC_YCBCR_ENC fmtdesc-flags
 replace define V4L2_FMT_FLAG_CSC_HSV_ENC fmtdesc-flags
 replace define V4L2_FMT_FLAG_CSC_QUANTIZATION fmtdesc-flags
 replace define V4L2_FMT_FLAG_META_LINE_BASED fmtdesc-flags
+replace define V4L2_FMTDESC_FLAG_ENUM_ALL fmtdesc-flags
 
 # V4L2 timecode types
 replace define V4L2_TC_TYPE_24FPS timecode-type
index 21a8aa575ea317c8fbb21b891b96780ddd04bf81..ded023edac70b56551f9db4110b9b144712e3b41 100644 (file)
@@ -907,6 +907,9 @@ struct v4l2_fmtdesc {
 #define V4L2_FMT_FLAG_CSC_QUANTIZATION         0x0100
 #define V4L2_FMT_FLAG_META_LINE_BASED          0x0200
 
+/*  Format description flag, to be ORed with the index */
+#define V4L2_FMTDESC_FLAG_ENUM_ALL             0x80000000
+
        /* Frame Size and frame rate enumeration */
 /*
  *     F R A M E   S I Z E   E N U M E R A T I O N