From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Deepa Guthyappa Madivalara <deepa.madivalara@oss.qualcomm.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Bryan O'Donoghue <bod@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v7 2/5] media: uapi: Introduce new control for video encoder ROI
Date: Wed, 30 Sep 2026 09:15:31 +0200 [thread overview]
Message-ID: <1353b159-24ef-43e8-ab44-94346990aeeb@kernel.org> (raw)
In-Reply-To: <20260924-enc_roi_enable-v7-2-6fa7413af23c@oss.qualcomm.com>
On 25/09/2026 02:28, Deepa Guthyappa Madivalara wrote:
> Add array control, V4L2_CID_MPEG_VIDEO_ROI_MB_DELTA_QP for
> video encoder Region of Interest to allow applications to specify
> different quality levels for specific regions in video frames. Define
> V4L2_CID_MPEG_VIDEO_ROI_MB_SIZE to retrieve supported MB size based on
> codec from the hardware encoder and set the corresponding ROI MB delta_qp
> map that adjusts quantization relative to the frame QP'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@oss.qualcomm.com>
Reviewed-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Regards,
Hans
> ---
> .../userspace-api/media/v4l/ext-ctrls-codec.rst | 26 ++++++++++++++++++++++
> drivers/media/v4l2-core/v4l2-ctrls-core.c | 3 +++
> drivers/media/v4l2-core/v4l2-ctrls-defs.c | 10 +++++++++
> include/uapi/linux/v4l2-controls.h | 2 ++
> 4 files changed, 41 insertions(+)
>
> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> index ab865a1a6ba929f1725ce2ab0fd3aeee4a69329a..a02ec20ec18f0e684973964d2de1759ad179b819 100644
> --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> @@ -1674,6 +1674,32 @@ 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_ROI_MB_DELTA_QP (__s8 array)``
> + This control is a dynamically sized 1-dimensional array,
> + V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it.
> + This array control is used to set ROI MB map delta_Qp for the whole frame.
> + The frame is divided into a grid of MB Size by MB Size pixels (MB Size is
> + obtained from querying ``V4L2_CID_MPEG_VIDEO_ROI_MB_SIZE``). Each block
> + is configured with delta_Qp in raster order. The valid range for delta_Qp
> + is encoder dependent.
> + Applicable to encoders.
> +
> +``V4L2_CID_MPEG_VIDEO_ROI_MB_SIZE`` (integer)
> + A read-only control that reports the MB Size used for the ROI delta_QP map.
> + The supported MB Size depends on the encoder codec.
> + Only square MBs are supported. The value returned represents the
> + width and height of each block in pixels. The ROI delta_QP map provided
> + through the ROI control must use the MB Size reported by this control.
> + The number of entries in the ROI delta_QP array is determined by the
> + frame resolution and the reported MB Size. If frame_width or frame_height
> + is not MB Size aligned, they must be ceiled using ceil(frame_width/MB Size)
> + ceil(frame_height/MB Size) for calculating the array size.
> + For example, for a QCIF frame if reported MB Size is 16,
> + the delta_QP array must contain 99 entries, ceil(176/16) * ceil(144/16) = 99.
> + For frame resolutions that are not aligned to the MB size, for example
> + 1920x1080, if the reported MB size is 32, the delta_qp array
> + must contain ceil(1920/32) * ceil(1080/32) = 2040 entries.
> +
> .. raw:: latex
>
> \normalsize
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> index c5df0e0a54f81c73975f427957b7c99fd421d5ad..2318a548f16ebc1ec582f829c7945a8998b96708 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> @@ -1410,6 +1410,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
> return -EINVAL;
> break;
>
> + case V4L2_CID_MPEG_VIDEO_ROI_MB_DELTA_QP:
> + break;
> +
> default:
> return -EINVAL;
> }
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
> index e062f2088490470c42d6c579ff7675be454a29b0..8f895060799ea13443143edd398dfb97f4ba0085 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
> @@ -974,6 +974,8 @@ const char *v4l2_ctrl_get_name(u32 id)
> case V4L2_CID_MPEG_VIDEO_AVERAGE_QP: return "Average QP Value";
> case V4L2_CID_FWHT_I_FRAME_QP: return "FWHT I-Frame QP Value";
> case V4L2_CID_FWHT_P_FRAME_QP: return "FWHT P-Frame QP Value";
> + case V4L2_CID_MPEG_VIDEO_ROI_MB_DELTA_QP: return "Encoder ROI MB Delta QP";
> + case V4L2_CID_MPEG_VIDEO_ROI_MB_SIZE: return "Encoder ROI MB Size";
>
> /* VPX controls */
> case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS: return "VPX Number of Partitions";
> @@ -1622,6 +1624,14 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
> case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
> *type = V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY;
> break;
> + case V4L2_CID_MPEG_VIDEO_ROI_MB_DELTA_QP:
> + *type = V4L2_CTRL_TYPE_S8;
> + *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY;
> + break;
> + case V4L2_CID_MPEG_VIDEO_ROI_MB_SIZE:
> + *type = V4L2_CTRL_TYPE_U8;
> + *flags |= V4L2_CTRL_FLAG_READ_ONLY;
> + break;
> default:
> *type = V4L2_CTRL_TYPE_INTEGER;
> break;
> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> index d17e41d51d2ec1ccb9e8ceb3ccc89ebc4381a4cd..be484156ed35a19229be23ad24fd224cb5a8a0cc 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -941,6 +941,8 @@ enum v4l2_mpeg_video_av1_level {
> };
>
> #define V4L2_CID_MPEG_VIDEO_AVERAGE_QP (V4L2_CID_CODEC_BASE + 657)
> +#define V4L2_CID_MPEG_VIDEO_ROI_MB_DELTA_QP (V4L2_CID_CODEC_BASE + 658)
> +#define V4L2_CID_MPEG_VIDEO_ROI_MB_SIZE (V4L2_CID_CODEC_BASE + 659)
>
> /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
> #define V4L2_CID_CODEC_CX2341X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000)
>
next prev parent reply other threads:[~2026-09-30 7:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 0:28 [PATCH v7 0/5] Implement Region of Interest(ROI) support Deepa Guthyappa Madivalara
2026-09-25 0:28 ` [PATCH v7 1/5] media: v4l2-core: add new control type V4L2_CTRL_TYPE_S8 Deepa Guthyappa Madivalara
2026-09-30 7:14 ` Hans Verkuil
2026-09-30 9:53 ` Vishnu Reddy
2026-09-25 0:28 ` [PATCH v7 2/5] media: uapi: Introduce new control for video encoder ROI Deepa Guthyappa Madivalara
2026-09-28 14:32 ` Nicolas Dufresne
2026-09-28 21:11 ` Deepa Guthyappa Madivalara
2026-09-30 7:15 ` Hans Verkuil [this message]
2026-09-25 0:28 ` [PATCH v7 3/5] media: iris: Add ROI delta QP control support for HFI Gen2 encoders Deepa Guthyappa Madivalara
2026-09-25 0:28 ` [PATCH v7 4/5] media: iris: Add HFI metadata buffer delivery support for " Deepa Guthyappa Madivalara
2026-09-30 10:32 ` Vishnu Reddy
2026-09-25 0:28 ` [PATCH v7 5/5] media: iris: Add BUF_ROIMB_DELTAQP metadata buffer for ROI delta QP Deepa Guthyappa Madivalara
2026-09-30 10:58 ` Vishnu Reddy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353b159-24ef-43e8-ab44-94346990aeeb@kernel.org \
--to=hverkuil+cisco@kernel.org \
--cc=abhinav.kumar@linux.dev \
--cc=bod@kernel.org \
--cc=deepa.madivalara@oss.qualcomm.com \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mchehab@kernel.org \
--cc=vikash.garodia@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®