[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260113-iris_enc_roi-v1-1-6c86eba38587@oss.qualcomm.com>
Date: Tue, 13 Jan 2026 12:33:32 -0800
From: Deepa Guthyappa Madivalara <deepa.madivalara@....qualcomm.com>
To: Mauro Carvalho Chehab <mchehab@...nel.org>,
Vikash Garodia <vikash.garodia@....qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@....qualcomm.com>,
Abhinav Kumar <abhinav.kumar@...ux.dev>,
Bryan O'Donoghue <bod@...nel.org>
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-msm@...r.kernel.org,
Deepa Guthyappa Madivalara <deepa.madivalara@....qualcomm.com>
Subject: [RFC PATCH 1/3] media: uapi: Introduce new control for video
encoder ROI
Add compound control, V4L2_CID_MPEG_VIDEO_ENC_ROI, for
video encoder Region of Interest to allow applications to specify
different quality levels for specific regions in video frames. Define
struct v4l2_ctrl_enc_roi_params to hold up to 10 rectangular ROI,
regions and their corresponding delta_qp value (v4l2_roi_param)
that adjust quantization relative to the frame's base value.
This enables use cases like prioritizing quality for faces in video
conferencing or important objects in surveillance footage while reducing
bitrate for less critical areas.
Signed-off-by: Deepa Guthyappa Madivalara <deepa.madivalara@....qualcomm.com>
---
.../userspace-api/media/v4l/ext-ctrls-codec.rst | 7 +++++++
include/media/v4l2-ctrls.h | 1 +
include/uapi/linux/v4l2-controls.h | 1 +
include/uapi/linux/videodev2.h | 17 +++++++++++++++++
4 files changed, 26 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
index c8890cb5e00ac05649e6c344c2a6b938b2ec1b24..0eecb46bb356c01411dfc313b92376593bcd86f6 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
@@ -1668,6 +1668,13 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
Codecs need to always use the specified range, rather then a HW custom range.
Applicable to encoders
+``V4L2_CID_MPEG_VIDEO_ENC_ROI (struct)``
+ Defines the control id to configure specific delta QP for one or more
+ rectangular regions of interest. The struct v4l2_ctrl_enc_roi_params
+ is defined to hold up to 10 v4l2_rect regions and their corresponding
+ delta_qp with a range of -31 to 30.
+ Applicable to encoders
+
.. raw:: latex
\normalsize
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 31fc1bee3797bfe532931889188c8f7a9dedad39..c44fad7f51db45a437dd3287aa16830585ac42f3 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -91,6 +91,7 @@ union v4l2_ctrl_ptr {
struct v4l2_ctrl_av1_frame *p_av1_frame;
struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
struct v4l2_rect *p_rect;
+ struct v4l2_ctrl_enc_roi_params *p_enc_roi_params;
void *p;
const void *p_const;
};
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index f84ed133a6c9b2ddc1aedbd582ddf78cb71f34e5..5f2621365593ee19a7792fb25ea29acf6a7860f1 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -918,6 +918,7 @@ enum v4l2_mpeg_video_av1_level {
};
#define V4L2_CID_MPEG_VIDEO_AVERAGE_QP (V4L2_CID_CODEC_BASE + 657)
+#define V4L2_CID_MPEG_VIDEO_ENC_ROI (V4L2_CID_CODEC_BASE + 658)
/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
#define V4L2_CID_CODEC_CX2341X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000)
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index add08188f06890182a5c399a223c1ab0a546cae1..18a5ae34842721c2647a7a76365e4d299d2b8a44 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1909,6 +1909,7 @@ struct v4l2_ext_control {
struct v4l2_ctrl_av1_film_grain __user *p_av1_film_grain;
struct v4l2_ctrl_hdr10_cll_info __user *p_hdr10_cll_info;
struct v4l2_ctrl_hdr10_mastering_display __user *p_hdr10_mastering_display;
+ struct v4l2_ctrl_enc_roi_params __user *p_enc_roi_params;
void __user *ptr;
} __attribute__ ((packed));
} __attribute__ ((packed));
@@ -1990,6 +1991,8 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281,
V4L2_CTRL_TYPE_AV1_FRAME = 0x282,
V4L2_CTRL_TYPE_AV1_FILM_GRAIN = 0x283,
+
+ V4L2_CTRL_TYPE_ENC_ROI_PARAMS = 0x284,
};
/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
@@ -2540,6 +2543,20 @@ struct v4l2_streamparm {
} parm;
};
+/* Roi format
+ */
+#define VIDEO_MAX_ROI_REGIONS 10
+
+struct v4l2_roi_param {
+ struct v4l2_rect roi_rect;
+ __s32 delta_qp;
+};
+
+struct v4l2_ctrl_enc_roi_params {
+ __u32 num_roi_regions;
+ struct v4l2_roi_param roi_params[VIDEO_MAX_ROI_REGIONS];
+};
+
/*
* E V E N T S
*/
--
2.34.1
Powered by blists - more mailing lists