[PATCH v12 11/86] media: uapi: Add V4L2_CID_METADATA_LAYOUT control

Sakari Ailus
2026-04-09T20:15:31Z

The metadata layout control defines the layout of the metadata on the bus.
It is used on sub-devices that use generic metadata mbus codes on at least
one of the pads.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-source.rst | 6 ++++++
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 7 +++++++
include/uapi/linux/v4l2-controls.h | 1 +
3 files changed, 14 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index e1f96987ad59..e369978c2b50 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -152,3 +152,9 @@ Image Source Control IDs
is provided as well.

This is a read-only control.
+
+``V4L2_CID_METADATA_LAYOUT (integer)``
+ The metadata layout control defines the metadata layout on the device's data
+ interface for metadata streams. The control is used in conjunction with
+ :ref:`generic metadata formats <media-bus-format-generic-meta>` formats to
+ specify the layout of the data.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index 32a4b1b3fc0e..4618252d24f2 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -1159,6 +1159,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_NOTIFY_GAINS: return "Notify Gains";
case V4L2_CID_CFA_PATTERN: return "Color Filter Array Pattern";
case V4L2_CID_CFA_PATTERN_FLIP: return "CFA Pattern Flip";
+ case V4L2_CID_METADATA_LAYOUT: return "Metadata Layout";

/* Image processing controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1322,6 +1323,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
*min = 0;
*max = *step = 1;
break;
+ case V4L2_CID_METADATA_LAYOUT:
+ *type = V4L2_CTRL_TYPE_INTEGER;
+ *flags |= V4L2_CTRL_FLAG_READ_ONLY;
+ *min = 0;
+ *step = 1;
+ break;
case V4L2_CID_ROTATE:
*type = V4L2_CTRL_TYPE_INTEGER;
*flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index d5cedb28a564..2f0bd33bbc3d 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1247,6 +1247,7 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CFA_PATTERN_FLIP_BOTH \
(V4L2_CFA_PATTERN_FLIP_HORIZONTAL | V4L2_CFA_PATTERN_FLIP_VERTICAL)

+#define V4L2_CID_METADATA_LAYOUT (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12)

/* Image processing controls */

--
2.47.3