From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 171433D76 for ; Thu, 15 Jan 2026 00:20:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768436458; cv=none; b=RKHgBqsNZ/bpiQba8M7lLi61xwUshBByz4MsOE04MxTABCt3B8NHQtOYMicCZRXXJV4BVZzPkFGn+oeQzlNLIlNCVlBpDv32QUu3X+qit1KRWNFDETSta5oQwatH7CzxWeAU3OBQMg/uaWeKbXq/CTdgv7FWQBr0W11j8+QRgWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768436458; c=relaxed/simple; bh=WU6TTWstatUD1H6ggDH5RSyRcREd9nTuVHet71V+1YE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JvJfbUZHzu4p2GRacLhkcKbJoLVgQBHg7wjpn8iNR7FRp3fp8vo5g/bJiCe25BaIpwFKexGcOWDxZubqDOtLo/mJVrNlJ3Y8dYiFg6LiKE1ugy4A241BoqbuXnGgkTc+cVke1oCJh4WflZFHiDO3Ok1n8CeFDRSQ2ofXkUPNn1U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=eDx7re6I; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=NUyBJH38; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="eDx7re6I"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="NUyBJH38" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60EKpsg1494876 for ; Thu, 15 Jan 2026 00:20:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 131X5QUwDFZmhjmYsknf4+3HMILLz8IAS/UGgKzJ1EE=; b=eDx7re6IlDnLBwd9 xcn0PNAS9nt4w9WDO0wDP3/gzwBfmFkfgdDapXQeMLoJNcRPqbaucqhVpdLIHckz N1M9SX/WnqKkUUACWqUzq2diyhZrGcTnH8rr8Ub4cKE/70/2MxPNsjzL2gmaukgR sGWNEY7nM9bABDbcvJ6ErezEkGk16rET85D6P0NWHmG22EZLpSJhxkdW8nUJaco2 iJjzuhVnHaOccjewzjTULuX5+c6ptvdvFPHA5P5Y7PZ/dhNHaHIF19tjW8QHXl/r X+ZrSuShPtIHnQwRaitpUM1nHl2W4QYM8uPuFa1eviYqzOSll9yz0UOi2LLj3ZFl UnWpCA== Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bpjj9gher-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 15 Jan 2026 00:20:55 +0000 (GMT) Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-1233424ed24so74430c88.2 for ; Wed, 14 Jan 2026 16:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1768436454; x=1769041254; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=131X5QUwDFZmhjmYsknf4+3HMILLz8IAS/UGgKzJ1EE=; b=NUyBJH388sCskMihxrBsvYV+B9WBLjHqDWm8R7MCo458Kf6CqKPJRil+KrkTCPP7Rb T4hSMRprRWwiD/50LpC3klEdaT0V+Dez1CA4XO0d0cBnIH8WKPvbkYpdX3mIN/yyX97y 1EosY+3avg8xlzyxkJ2dsrigFKMLFtQXayjL/6i4WUOHr53Q3Dro08Loi/UEgg3dY0Jy +hmT0gsCB8IzllEpAMeYr2Gaie7TuRK8r33l4O+ZgUuH8DI+xoYgdKi7rWM8NqKcFwI0 45LHRQyQs/Kut/ZAEaFuKtkp+DGRbXZv+XDXrqINMYc2yf6WN+4bWUnlymikncwNH9K/ 4S2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768436454; x=1769041254; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=131X5QUwDFZmhjmYsknf4+3HMILLz8IAS/UGgKzJ1EE=; b=rl70CSswXnCm4oXgNzKoC1Yo57pv9Sz5/IX8b3q3WJ//TFB/l5FNsWtdNjPgqTkmaf C/yHHlnt6ES7O9x9p4Net1Tc8qd/aGs8iiSIB5XosyF5msTg1EP78pa5w9Hy1UvKtf2T penZGlnbO3ehywY477pQy970bLX6RtuKYZ7CDLmvwwYU/KGDhj5NLCA13KqJeJPkWfV3 spQhyC7nmT0Cdxts8Jn3q0dkHuLzYq55ATq1Ibz+8faZXcoJvRGVIHBXJNeanu/QCIZx MNLEw8MjqbZw9apdf1ysSBjqan6R045l8Qck5hfjlS0IBW0ZoGHkmuylaDdi6E+3oi7O 6xTg== X-Forwarded-Encrypted: i=1; AJvYcCVErKZ/XsbUeskinkexYfFJ/k4SvTMnYPeVa/L4f6O2oebgO0oG4NXdrxdPjF0zq91ddLoiriYKKvTMm+M=@vger.kernel.org X-Gm-Message-State: AOJu0Ywm9TQylbvg4t2wPmK94+bd24Po3782IjVh3hfZPBdRbgiu9g9G wvi35NAwrp11rA7ofVPBhIWExRBG+NPVPCwgZx24Uv0KUB3TcgZQukhDRsJb0h7oZN6KVuWnwyd uO8ZiPIZixcFwKOuJ9fRxzwIE5dwyaN+k3qMam7UeJS7GtQOP+fpGPs9Hh5t40rwLXps= X-Gm-Gg: AY/fxX4ukfNLKGD9JUVepFqBYgVNVefIgaqlVvYBFmOI+JBjib5J6FQJgrCpesVmCV9 Wxpsn2QLbL5HpV6GbZQMXimtf5a+/3b+009fvZOHBemHgCpCcBuzQYMMZxXobcSxYjTwfws32aX YNv3+WjH6uqUQK0P89vQqpwKNjvkt8jcYSP9laga7LrEqHkoXvu+XojmZRJm/2+yClU00krf/pg vv4WfifxWbGunZ8DbwnK0IR2hp65mV8Im0ou+IhWsq6ut3oCdKs7QBIIrobqo+I+Ph7+ETx4/pr k/ZZevEV1Aoo2/t+sLT8xcSFguGOLDCchhDndlt5+B7xNl74KhHhOo5mtQzatV0tJK11bBKaKt3 Tuef0dTKg1LoOWtNE/V4JYCAFrnaYCGw6IajBENcdP339VQYhnNOkt8/agN8kD6CKUGvH78Sr X-Received: by 2002:a05:7301:1f09:b0:2ae:5e96:9d1b with SMTP id 5a478bee46e88-2b487086c53mr2907826eec.5.1768436454418; Wed, 14 Jan 2026 16:20:54 -0800 (PST) X-Received: by 2002:a05:7301:1f09:b0:2ae:5e96:9d1b with SMTP id 5a478bee46e88-2b487086c53mr2907805eec.5.1768436453796; Wed, 14 Jan 2026 16:20:53 -0800 (PST) Received: from [10.110.121.92] (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b170673266sm21358040eec.1.2026.01.14.16.20.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jan 2026 16:20:53 -0800 (PST) Message-ID: <763b6cdd-514c-4aff-b7db-8c0a17fdb645@oss.qualcomm.com> Date: Wed, 14 Jan 2026 16:20:52 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 1/3] media: uapi: Introduce new control for video encoder ROI To: Nicolas Dufresne , Mauro Carvalho Chehab , Vikash Garodia , Dikshita Agarwal , Abhinav Kumar , Bryan O'Donoghue Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20260113-iris_enc_roi-v1-0-6c86eba38587@oss.qualcomm.com> <20260113-iris_enc_roi-v1-1-6c86eba38587@oss.qualcomm.com> <08ff44d8907c72b7599fa4599477d78bcecb440a.camel@ndufresne.ca> Content-Language: en-US From: Deepa Guthyappa Madivalara In-Reply-To: <08ff44d8907c72b7599fa4599477d78bcecb440a.camel@ndufresne.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: 4GIzWYUsDdGpycDw88MUEyoYtSwNf26W X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTE1MDAwMCBTYWx0ZWRfXwS2aOHSmOVuv F7ejGTgxubafo+PjvtPsCcJbCV7l8x9E+end1AHMwsS7OCcpkIOM0dd10UhyKz9ReSVotEzV7/U 1To8gRxiEJ+g2kicjchmqPbpv87YizS1mBZxrNJKeb9zvfofjDhm9Z5ejbSyYdTn3iw3FaEuSgL 9RxgL21qYsqeQqNqeUBkRTPHe1lqAjReLZ2HlatOFSOW7TASfZPbgeazFWwV8aGEuqqIRSoZBRv g8o4SkJx+NT8osAygIGZHsRfEDUo9tHAyFl/wPWU5gwRp0IBNyz1VObuMBbWKSywm/4SxXIZLU/ yeSzbC7hAmn9erDZ9OXuDCGBS3egfD4JOdGd/Fc3BD6X7NuCs86lVPWlQDaV6nRTy03tAzubIJP g24Y/ubEv9PQDfxwnafSQCkRvvYaKNX8BelMaOcvKo8FeVVqgMiRLROWXd+YPd94Si5t8c+x8oJ cSue98/qqQHmSwWEXmg== X-Authority-Analysis: v=2.4 cv=dcCNHHXe c=1 sm=1 tr=0 ts=696832e7 cx=c_pps a=JYo30EpNSr/tUYqK9jHPoA==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=nO6hRiE8Sj2kV28_dfAA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=Fk4IpSoW4aLDllm1B1p-:22 X-Proofpoint-GUID: 4GIzWYUsDdGpycDw88MUEyoYtSwNf26W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-14_07,2026-01-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2601150000 On 1/14/2026 8:14 AM, Nicolas Dufresne wrote: > Hi, > > Le mardi 13 janvier 2026 à 12:33 -0800, Deepa Guthyappa Madivalara a écrit : >> 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 >> --- >>  .../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 > Any justification for this range ? Also, I believe I've seen hardware support > both delta and absolute values. Since it meant to be generic, some research is > needed. If we delibaritly ignore absolute, perhaps the CID should be named > accordingly ? Something like V4L2_CID_MPEG_VIDEO_ENC__DELTAQP_ROI ? As per Android ROI API - MediaCodec API QP from the app is an offset QP, meaning userspace will received offset Qp and it converts it to deltaQp before passing onto the driver in Android HAL. I have used the same idea. Delta MbQP = frame QP + Offset Qp. This is clamped to -31 to 30 currently and set to driver as delta QP, hence I have it as -31 to 30. Absolute values are mostly for frame QP, I would say. All the information out there for ROI kind of implies to deltaQP, but we could be more precise as well. Let me know if it is a must to change to CID. >> + >>  .. 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 > Let's not hardcode hardware spececific constraints in the API. We have dynamic > arrays now in compount controls, and you can define the maximum dimension and > all. > > >> + >> +struct v4l2_roi_param { >> + struct v4l2_rect roi_rect; >> + __s32 delta_qp; >> +}; >> + >> +struct v4l2_ctrl_enc_roi_params { >> + __u32 num_roi_regions; > With the dynamic arrays, this will not be needed. > > cheers, > Nicolas > >> + struct v4l2_roi_param roi_params[VIDEO_MAX_ROI_REGIONS]; >> +}; >> + >>  /* >>   * E V E N T S >>   */