[PATCH v12 26/86] media: uapi: Add V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR

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

Add V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR client capability bit to
signal the userspace's support for the common raw sensor model and
document it. A specific capability bit is required for the purpose of
adding support for the common raw sensor model to existing drivers that
already have a well-established UAPI that cannot be modified without
breaking the userspace.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-process.rst | 2 ++
.../userspace-api/media/v4l/subdev-config-model.rst | 5 ++++-
.../userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst | 6 ++++++
drivers/media/v4l2-core/v4l2-subdev.c | 3 ++-
include/uapi/linux/v4l2-subdev.h | 6 ++++++
5 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
index 51188e7febae..983c7412c9f4 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
@@ -59,6 +59,8 @@ Image Process Control IDs
digital gain the control value needs to be 0x100. The no-gain
configuration is also typically the default.

+.. _v4l2-cid-config-model:
+
``V4L2_CID_CONFIG_MODEL (bitmask)``
Which configuration models the sub-device supports. Please see
:ref:`media_subdev_config_model`. This is a read-only control.
diff --git a/Documentation/userspace-api/media/v4l/subdev-config-model.rst b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
index 3011643d58cf..0fb01bf6c825 100644
--- a/Documentation/userspace-api/media/v4l/subdev-config-model.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
@@ -41,7 +41,10 @@ necessarily offered by all drivers.

A sub-device complies with the common raw sensor model if the
``V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR`` bit is set in the
-``V4L2_CID_CONFIG_MODEL`` control of the sub-device.
+``V4L2_CID_CONFIG_MODEL`` control of the sub-device. A client supporting the
+common raw sensor model shall set the
+``V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR`` :ref:`sub-device client capability
+<VIDIOC_SUBDEV_G_CLIENT_CAP>` bit.

The common raw camera sensor model is aligned with
:ref:`media_using_camera_sensor_drivers`. Please refer to that regarding aspects
diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
index da4a358ce762..50ac223e10db 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
@@ -91,6 +91,12 @@ is unknown to the kernel.
``which`` field. If this is not set (which is the default), the
``which`` field is forced to ``V4L2_SUBDEV_FORMAT_ACTIVE`` by the
kernel.
+ * - ``V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR``
+ - The client is aware of the :ref:`common raw sensor model
+ <media_subdev_config_model_common_raw_sensor>` and expects it where it
+ is supported, as indicated by the :ref:`V4L2_CID_CONFIG_MODEL
+ <v4l2-cid-config-model>` control bit
+ ``V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR``.

Return Value
============
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index c6d8399c2252..4b7830f705a2 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1200,7 +1200,8 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,

/* Filter out unsupported capabilities */
client_cap->capabilities &= (V4L2_SUBDEV_CLIENT_CAP_STREAMS |
- V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH);
+ V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH |
+ V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR);

subdev_fh->ci.client_caps = client_cap->capabilities;

diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index 477d3ce3ddb4..9d5ba062be19 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -270,6 +270,12 @@ struct v4l2_subdev_routing {
*/
#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH (1ULL << 1)

+/*
+ * The client is aware of the common raw sensor model and expects that on camera
+ * sensor UAPI where supported.
+ */
+#define V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR (1ULL << 2)
+
/**
* struct v4l2_subdev_client_capability - Capabilities of the client accessing
* the subdev
--
2.47.3