From nobody Mon Nov 25 04:43:19 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013054.outbound.protection.outlook.com [52.101.67.54]) (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 3C2A7194AF4; Wed, 30 Oct 2024 02:22:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730254938; cv=fail; b=iumb5+bufrVknFNrwDQdxge9ehEeJ/PfnfOwDox2sUM5RoftLcfJ0j2EQR5OiQg7LBPLREvbu9IYGT4J0DHNKp6fU9N9/Kl70/eRbwjGpniyeR+VToZP40dAfB80S10KyCh7ncWCi1nJqJws4IfJhcMJG00mdDRqCmxlHFa8uFc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730254938; c=relaxed/simple; bh=3J7HQukrMTz6WCskrPZNpBJysph2+T+IN+yd5cJXGsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=cnihryUNxSWCJDgt9rLHgBLBlxru09fD6DflOysmAbMwXbX4OgdFlpAHWB8tro3iMmHfdGABkk1RnT59nguTaNAc0JUH02Aq/KiNkd3B6DmGrkpktTznUh1SpbGSn3r6UHyBnNlLnG4Tae0r+BIByKaD3lZWYgd1jZoOslOZ/I0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=FHxJ8Cgr; arc=fail smtp.client-ip=52.101.67.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="FHxJ8Cgr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JESyYHUFAYBkz8gc6XXkV1yCfHu3sP141bQ5n4bQ7k4PXSwDXl553mULT575D3Nsck7nKakatJesU33SwPdUR50DitpUnil4q29GswiEqq4uyXJ1yXOqt8ymbzaqbpglnJC0Ua2fCZ+vYiDkkXlQJVBii/tSkxIbGWS1QRQ1ZG9mPfCk7RwpvPpa6kcSTexXQSvOlC8F9/eXreNTSwc2Uqt72gSsWVGUVLXPZNQO2us2gP7abvXQwL/Rdz+Mi4rsNaUP3qU0qgHMYwFksTFmiEnfAYR2xQ+FZGfY9zrdDaY8PFW/QXfZBT/uJqoBxmYox405ok/SL9h9vqReaueLNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3co966d8lg7YhJGpW2PyDhINGAAkGT+8kwYcfIKNyhI=; b=rSKI0FCOR5+C87fvaDK1U9MZgU5OwnsgnjwFQxpi+CAv1LG1NBJmiFCZuKiAQTffHe4Uj4jO9hpyLFnQDTvGmLoS4+ReQCPzjyvkWIaO+UJGWvuZP2zMnArO4A+sWKJsXyvarFpEMysUX34CBqKPjFe2epQtXnhZVbqEs7angLYghzRixeJAki43zHApxzro36gMvIx0bLBOCTDyi47DFKNZhLaqnjBdhVN7O9qgV+iIQS9ZZjQ/0flPxSDXUUkG+gX4i5u7teTNodT5xaN8y+GsxJLrahB7YE0YErybuEaRg8lN3D/Gcdy7l0EvQZOL2rJD/OJI2gLdiZ21luPWCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3co966d8lg7YhJGpW2PyDhINGAAkGT+8kwYcfIKNyhI=; b=FHxJ8CgrGGjVDz+Tovixfd0ByDDxiTXcR3fbC+dVGhXGLlqYrykxwtY4hP7ODxY/OYFqh06JhjQl4CaRbCgiakqF6K1ZTtvx2qi2iywVtiHrVMdbs0+VE0H6e16k7mj6RFBAaxQc0O0BKiYaxzgmvQNPfopMjvo/qFxkfS+PvzBAUgFqicsDA9i+h8p8pktzpjSID9Lnhnnl8pg7aa/23t5yW97gM6spi84ccljVwGng22VOlyTyNcZ6UhS9pI7vuSnY0PCK6QhRbwG1MoVk6rY3I5Zlf+/MpgKKX/SF3ZgK3OxH70DpLtFAbz1EAhThZz0vR3UP6WlTv3PpjEB7tw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB8705.eurprd04.prod.outlook.com (2603:10a6:20b:428::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 02:22:12 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%3]) with mapi id 15.20.8093.027; Wed, 30 Oct 2024 02:22:12 +0000 From: ming.qian@oss.nxp.com To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: yunkec@google.com, nicolas@ndufresne.ca, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, ming.zhou@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v4 1/4] media: v4l2_ctrl: Add V4L2_CTRL_TYPE_RECT Date: Wed, 30 Oct 2024 11:21:31 +0900 Message-ID: <20241030022134.1098589-2-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241030022134.1098589-1-ming.qian@oss.nxp.com> References: <20241030022134.1098589-1-ming.qian@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0044.apcprd02.prod.outlook.com (2603:1096:4:1f6::6) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB8705:EE_ X-MS-Office365-Filtering-Correlation-Id: 57d3479e-5b05-4e7d-54cb-08dcf889a99d X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rPBRfGzRV47S+ZncHkF0sj8ztewRk6DClfSpXaAV+tiN4KsjGbSGArqbtuzK?= =?us-ascii?Q?bWXfPpYx5FLHsPquOtmHA9N8plckEnZx9b+kQGP+AGy+chUCx7jFKRjmEk4c?= =?us-ascii?Q?q9erfICtK9yU0iw1eNRUfIRglj1FVLTkzbw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cS65B1pM6vbI1Cm3ugafo2387/VCgdS8cxgqv0doiQEr4+aVgCyssY660?= =?us-ascii?Q?BDpW+vmYS/vIr+kIzso4UioPwbw0Fvznyxubh944hf0gwn6ZUR/HVcajVKbP?= =?us-ascii?Q?MJ3gNezNTW1L8a8EIdg4VOhn1I3FpmZL6Y44Iqi2zkvAdCj2Pl8ByGSHaD6W?= =?us-ascii?Q?xa8ADNBaVzBr4/CAXtXAppNQd7yEVPpmnxLXYwofz9HEp/ovK1+zrZQO2/Wl?= =?us-ascii?Q?MMQ0nFSSB/yiOileSrIlNo7S8Te4r/EtGENtcn19vIXxI/VHPAPpA6ZHhO+w?= =?us-ascii?Q?jJwrAZbHkeQinvmmfDGVuRnAg+rN/yew2kgUMj8QvUZtP1unuWbsCo7wd0s3?= =?us-ascii?Q?YUgTAR4=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ht8oHghF8bpiNic38NtZZD1AGfBW16SvTFeyaCOcgn3ubrBG3IS5RcmBw5cP?= =?us-ascii?Q?ltwrKF+XiFcLX5IpqVf5Gxxsw6VB+bb3ERtAaBEKCj7Ese4iNG+Om0CmNdUy?= =?us-ascii?Q?Flu7k+ZvqSFsgKl6w6Uj3wQdVxELC4wDhv3MY6U8TUgTcZbjXEWJLTWCzLM0?= =?us-ascii?Q?TGSK6p8vt9iIuvde/tPLmHVpgCz80zMXydzeaNCzeP3w8WGssomONBryIIcl?= =?us-ascii?Q?w5ch7XZN4+OJOH8qfCrO0l0chqAoNmqU5bwzQAj3tus9/8ZXkKc2Az+UAbLM?= =?us-ascii?Q?hWPzxsp6/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9bdY4Sks0AnOgLWCfWR?= =?us-ascii?Q?WPalVHtoJZF3V7A3hr2RRvtF0ntsY/l6sY4mccq3uUCBNu6X8q+oJgq231H2?= =?us-ascii?Q?98j3taLMZRrNikG1z6cAuLUdLIWyXuiVEGfOzruMMsIf4QZWAd6a5MDBxIal?= =?us-ascii?Q?g0IdaeUwhO1vxJ5DakLrOM1On9xc75JiSDmZrBib0adbmCLYMVXisBpgUy2j?= =?us-ascii?Q?JU08eUo1+ts9OUolzVFJ+1FHMi1dq9WEgI1uvnXruXyno5LUY9gAuGDjc9io?= =?us-ascii?Q?KMdD9mDM+3hhhCsAmHyOIIb8Bg2OpWg+LICm3hW6FSOLD+kHVcotN3KkY9h+?= =?us-ascii?Q?AqUE/HY19api467zPqSsahud6Yh1rmWhkiGU1KqdkVjEJeCLuOl2DNdbCTpp?= =?us-ascii?Q?92Cl8IilJSJ+/F4E6PFynERPq42nKdYzKOtAuzpX?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57d3479e-5b05-4e7d-54cb-08dcf889a99d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 02:22:12.1662 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4j8kY2QVM0yTFLRF8jffYfTu1bUUjiBHGmxra5e42TJIXVc5+KM3TGWLr/5qwU9EaBJCb69yS0xU4bDCiwBxtw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8705 Content-Type: text/plain; charset="utf-8" From: Yunke Cao Add p_rect to struct v4l2_ext_control with basic support in v4l2-ctrls. Reviewed-by: Laurent Pinchart Reviewed-by: Ricardo Ribalda Reviewed-by: Sergey Senozhatsky Reviewed-by: Daniel Scally Signed-off-by: Yunke Cao Reviewed-by: Hans Verkuil --- .../media/v4l/vidioc-g-ext-ctrls.rst | 4 ++++ .../userspace-api/media/v4l/vidioc-queryctrl.rst | 7 +++++++ .../media/videodev2.h.rst.exceptions | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 16 +++++++++++++++- include/media/v4l2-ctrls.h | 2 ++ include/uapi/linux/videodev2.h | 2 ++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b= /Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst index 4d56c0528ad7..b74a74ac06fc 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst @@ -199,6 +199,10 @@ still cause this situation. - ``p_area`` - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is of type ``V4L2_CTRL_TYPE_AREA``. + * - struct :c:type:`v4l2_rect` * + - ``p_rect`` + - A pointer to a struct :c:type:`v4l2_rect`. Valid if this control is + of type ``V4L2_CTRL_TYPE_RECT``. * - struct :c:type:`v4l2_ctrl_h264_sps` * - ``p_h264_sps`` - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this = control is diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/D= ocumentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 4d38acafe8e1..56d5c8b0b88b 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -441,6 +441,13 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_area`, containing the width and the height of a rectangular area. Units depend on the use case. + * - ``V4L2_CTRL_TYPE_RECT`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_rect`, containing a rectangle described by + the position of its top-left corner, the width and the height. Units + depend on the use case. * - ``V4L2_CTRL_TYPE_H264_SPS`` - n/a - n/a diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b= /Documentation/userspace-api/media/videodev2.h.rst.exceptions index 429b5cdf05c3..3cf1380b52b0 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -150,6 +150,7 @@ replace symbol V4L2_CTRL_TYPE_HEVC_SPS :c:type:`v4l2_ct= rl_type` replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_RECT :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR :c:type:`v4l2_ctrl_type` diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2= -core/v4l2-ctrls-core.c index eeab6a5eb7ba..4c8744c8cd96 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -370,7 +370,11 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctr= l) case V4L2_CTRL_TYPE_AV1_FILM_GRAIN: pr_cont("AV1_FILM_GRAIN"); break; - + case V4L2_CTRL_TYPE_RECT: + pr_cont("%ux%u@%dx%d", + ptr.p_rect->width, ptr.p_rect->height, + ptr.p_rect->left, ptr.p_rect->top); + break; default: pr_cont("unknown type %d", ctrl->type); break; @@ -815,6 +819,7 @@ static int std_validate_compound(const struct v4l2_ctrl= *ctrl, u32 idx, struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; struct v4l2_area *area; + struct v4l2_rect *rect; void *p =3D ptr.p + idx * ctrl->elem_size; unsigned int i; =20 @@ -1172,6 +1177,12 @@ static int std_validate_compound(const struct v4l2_c= trl *ctrl, u32 idx, return -EINVAL; break; =20 + case V4L2_CTRL_TYPE_RECT: + rect =3D p; + if (!rect->width || !rect->height) + return -EINVAL; + break; + default: return -EINVAL; } @@ -1872,6 +1883,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ct= rl_handler *hdl, case V4L2_CTRL_TYPE_AREA: elem_size =3D sizeof(struct v4l2_area); break; + case V4L2_CTRL_TYPE_RECT: + elem_size =3D sizeof(struct v4l2_rect); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size =3D sizeof(s32); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 59679a42b3e7..b0db167a3ac4 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -56,6 +56,7 @@ struct video_device; * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure. * @p_av1_frame: Pointer to an AV1 frame structure. * @p_av1_film_grain: Pointer to an AV1 film grain structure. + * @p_rect: Pointer to a rectangle. * @p: Pointer to a compound value. * @p_const: Pointer to a constant compound value. */ @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry; struct v4l2_ctrl_av1_frame *p_av1_frame; struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; + struct v4l2_rect *p_rect; void *p; const void *p_const; }; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index e7c4dce39007..c1c2ae150d30 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1859,6 +1859,7 @@ struct v4l2_ext_control { __s32 __user *p_s32; __s64 __user *p_s64; struct v4l2_area __user *p_area; + struct v4l2_rect __user *p_rect; struct v4l2_ctrl_h264_sps __user *p_h264_sps; struct v4l2_ctrl_h264_pps __user *p_h264_pps; struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix; @@ -1929,6 +1930,7 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_U16 =3D 0x0101, V4L2_CTRL_TYPE_U32 =3D 0x0102, V4L2_CTRL_TYPE_AREA =3D 0x0106, + V4L2_CTRL_TYPE_RECT =3D 0x0107, =20 V4L2_CTRL_TYPE_HDR10_CLL_INFO =3D 0x0110, V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY =3D 0x0111, --=20 2.43.0-rc1 From nobody Mon Nov 25 04:43:19 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013051.outbound.protection.outlook.com [52.101.67.51]) (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 4736A1991BD; Wed, 30 Oct 2024 02:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730254944; cv=fail; b=YyJ8qJJMq4Vf47zqWJujr2ViYasAF/kvIHfZ3jF4r8/hCRiGcMTphxs5/PJAWEB6K16B3vmIcC7EK6p1AQiMPHu42IOIlAQb1dwUH/kFY5rwqNwH1hTBR2Ls0gcZ7r62lEnOhHM9P6/lGlXOz3f+IX40+zp4kke42nvReazuctE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730254944; c=relaxed/simple; bh=Q249qcROMKLF1grc6bN9/23JwNByrYyjw+ixGk9KOPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=WVJDjHQ6GLt4Sk5GFNv4GcvXtC7fg59ldhsk8LWaeOkipIWezy20wl0wDcVs5LtRln37L4CuNd94nUFZzUE+IoAk7IQ9LmLKI7ZbktWg9NOIBB5mOBL+nvBfICiT+jGekEM0Dq3tVX0OhU7sC2vv/9fFjHOZTxgWTCiot48dXlI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=bOBgeVRb; arc=fail smtp.client-ip=52.101.67.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="bOBgeVRb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SZKwMWH70COJdHyok8tALWo5gL5R1mAk01P52G1CNDZ9IDlygPsyfg8Djd0HyA7/fqi2YP/Dcj3RzKUZ8rYOYCKvRzrbMTVEcbOYZP/h/0sXOfErR0tQbGiV3Ff7Qpu9ddwolcVcIz3xnevxw0DjzPbc1Ok01A+JtDIwrSu+Y6cT+nlhrYJ+8l7SwEPB6duhk+d9YvU2n/COGEewmIaBv87jf4FnWZ3SBW+fbZ0T0+cTmpkhJVMn+i8H8W6ir4hyA2UcXtlLbpQBciZhLOv0Yo3SIwDqWORAHh1v7ZskVfbZs8c6o2+FTezAEPlW1SQTUAUxH5gWHU7tMgSYClD+bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wCbepeNg5bUGuvQ8pE2dwsEeKpIwNwNOTWxgIB3MnUw=; b=mxtocyX6TAAmN+OvTYSvBSWJbJA8UoOq+ChGDxyn3FqMLMjexxE8UOxpl2chZYeSawVhhQ9EQephJjvJbi8p6oVtmQloV3ZRnIgvoyyLSO5XM8P/EETGXkUA7R+weKn/IdyFtxEirBbyakQ1kR32fSFAdlsvgYk1oS/X7YQ/JUxklJryY8kXMOSP28xmbHGlXWZC1ImZBZRqxxxt5OVlh8X2BTPdyYshA3XcubGZsxnaBJRl6camoTWqPg+AfBIJoRQgLqZAHgIMZVYullUlQ4Yc0orYH213DZ6xRmEvCDBPYymPsbfZXorqfo17I0XKhi6NdS9TCSsP8N3vD4tZ2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wCbepeNg5bUGuvQ8pE2dwsEeKpIwNwNOTWxgIB3MnUw=; b=bOBgeVRbY0XKUXqiDZjUUtJmOBcUh/6CGMUJhAdRrWrLWHd+i1145/SpvK1vwlMrLF8ajZZD57kVdN+PuDCWgZ8CGraA2sQVqhDfKaEaxLnoLMNCtp3Z/WKScZajpyVKi6CGoWmQAKB3NX8uFhu2MbEmd5Uj3zSO1uGrnnhO4fYuDrK3qB/UgbD/X4TECWd40JmXR3vsRxaO+leBmtsn2FOb2ZGPaVPmo27h7XAZ5TL8Lv449TNVAbj7PRmAfVLhbid+SEcJXOC8iuUDGnoRPmBsKlqoIOB5BfbHjvT7TuZ1z/kPrvUVSJlKHFuzSG+0r2iSGDnbqzSnNMIS8h2jrw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB8705.eurprd04.prod.outlook.com (2603:10a6:20b:428::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 02:22:17 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%3]) with mapi id 15.20.8093.027; Wed, 30 Oct 2024 02:22:17 +0000 From: ming.qian@oss.nxp.com To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: yunkec@google.com, nicolas@ndufresne.ca, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, ming.zhou@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v4 2/4] media: v4l2-ctrls: add support for V4L2_CTRL_WHICH_MIN/MAX_VAL Date: Wed, 30 Oct 2024 11:21:32 +0900 Message-ID: <20241030022134.1098589-3-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241030022134.1098589-1-ming.qian@oss.nxp.com> References: <20241030022134.1098589-1-ming.qian@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0044.apcprd02.prod.outlook.com (2603:1096:4:1f6::6) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB8705:EE_ X-MS-Office365-Filtering-Correlation-Id: 9272d97f-40d1-4bbd-b62e-08dcf889ac6d X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lOdWheNwPH55f1mqG87FHiryMp9pq4yvvAuvK1nNa+daS5R63Ui2lvGkPWq1?= =?us-ascii?Q?L6jo7xxXcGFrSI34K4qbfIHdic/mLZ7JKkZS02YAc6OiljnTBmKBYK3+Lfj4?= =?us-ascii?Q?NydviW5ei2hCy+GlHi0Qtw/c6reC+u+lVQNGknhYxzqjMuZyCQC3OSrSTMVm?= =?us-ascii?Q?klKPLsHpCXpj3llursuz8nFh/oSHy6DncCtFe0k1QZGSleRINwv6dVMdxPeN?= =?us-ascii?Q?MkR2CBZEC5ltKd2RCXbZPPBngj8xRunV1TeFy5NF3guF3ljLaYAE7aZyQ13D?= =?us-ascii?Q?Pc67EZZnKxkn4U3fZV+Tn2W3+RvruurBk8bJVSSSSUleDWUQXAR/8OU8Tr9n?= =?us-ascii?Q?Oq0yzKMzQE5kRobZN50XEc87UHYSUA8XS9mlSA1Di7dRXI5kTIqHQ7e5dNxd?= =?us-ascii?Q?Qk91ockw/FPNV3uXU0zGcILKBjgMup/ub74fUrwzsmE2/3D/5tGdcyYjrGy4?= =?us-ascii?Q?sZBIIUIAeonU4sX2thEWW4d5PzO59tiQOqpey/NO8JoVFhYTJMCOGzWJJhSJ?= =?us-ascii?Q?0DLKt4O1A2WNmjL89FlgJ+Qr5k9+PINmFC4ONb9pdGE/HPxRB18TuuuU5v2U?= =?us-ascii?Q?213jxyhrggx4tijeRkLdgRpb0Mpkro9OrBYWrbTPvkukr/m1PLsxI0lB9UlK?= =?us-ascii?Q?OQjZSuF0oUZjj8ZjWCYmIJFz6N4K1Z4ciD1PEvzB/SnPRhuhfvZO31I/5Yzi?= =?us-ascii?Q?ENq7MEw72XTpmWNHaXRGtfy4OuggYzNooG29v6O0rYCW8v9LVlOLVXT+7nVW?= =?us-ascii?Q?juKypCSOb+qdbuaJIdQm81/0vTE4X2HToOTnMgE2W22ygrhrk1yxoAvyhXiW?= =?us-ascii?Q?/LBK6kzeTFtiFTv1/TEvSDpDkDXzOjJFw952os5GNKDPcAIHvDa1pRFnEt9o?= =?us-ascii?Q?5ufeZQF76iz17t9ulfzO/52l7ytBAMTOMGZEUp9njWI3gKi33l9fyE3abtza?= =?us-ascii?Q?zhoirJCMpwYZdY7jAqdAex9Ux+DuLI+ECJudzGaUa9YYHdPywJPcc6Ndp9K5?= =?us-ascii?Q?Z6SWuUWKItiTdXuRHMXcdtGYQIYobOiv1jNDf1E+7rART4gPjIdFp2VwZl8Q?= =?us-ascii?Q?iGXiXeWec90ZMABSfg433bJG3uS3jpvEInSI/4KcnhqaF37+lIxTJLt9RADD?= =?us-ascii?Q?ztNInlgA/l5GncaNBVkXoYNWQgTGMvR9O2sP7TOmD51YzhhOZ0odOA3yixq4?= =?us-ascii?Q?YIsIyjYjmNFMgeVUWE6etMe1X/MEgD8rvDdKkQHPQPMxtn0LhfZB6YWdGr1m?= =?us-ascii?Q?fgG/KZWR2Yp+Amrau0Xbp7dXS3oE41SixjyDmUNCvgf18j/m2sulKD018hYI?= =?us-ascii?Q?TOnH5++3QtLa9+yt+UKjw8vasS/qZ1EXiqgfjAxdk1TqL1IGA4Kfoa9cUIbW?= =?us-ascii?Q?jWFKYw4=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange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RTciQlqti9Tak4IDEdW72S54Waw6E6yAHW0jizua6FXhUnPKgezx?= =?us-ascii?Q?4mSOfW5mslagPdvDqeV4bylE4UEJPrEH6kggnC7poVyhvvZU1mS7dIT4+oYA?= =?us-ascii?Q?eiVuni5AbAocNwLpL4n4cpUQ6weNEVB1jLn0rHI4SYdGegJ0GVH0aTS4YAG0?= =?us-ascii?Q?edeE4VccZAfC06VSBCDeXMZzwILLyxS+IY9h+lQj4lqA+tWTBnMm/xsYtU4V?= =?us-ascii?Q?9M0CPkBX3q5Es4rqsYiI6n+I335EZL9cIZL7yohFpQtiW1EgymIL/BRURw5m?= =?us-ascii?Q?rH1eOW/C02HPCYI5zlL8rUgYOf7vpUAJR3Elin+ErEwXkLSIigpqe1oqiYly?= =?us-ascii?Q?kbyKj/2BSoqvTT0TNwwqGC1oZKCqZ8UG64hAYAwkKsqueGvoxJKSpqAQjrAf?= =?us-ascii?Q?Y+6KfHeNJ2HOFpKSZvR1CQXuxy26L9u0iA7rdJUf24o3sGX2uF0tzhuLnSm+?= =?us-ascii?Q?X4MLt+H+mVUFr4Lkg+hbyD80yQWmuP4rMN1szW07UE6Ckb8771Su05HlOkwG?= =?us-ascii?Q?wbVfk6XX/gA8HXl+DwIYB5MXEsbk3pEVD9RlA1KO7c4qj7qjiTqCExIPp0z5?= =?us-ascii?Q?2lreepSm4Q9MJAngmF1mO+rQUzKGdFWp41VyCnW4NHirh2vBV5H/M5LhEgT+?= =?us-ascii?Q?J+4proV6HdAHSkmtRpFKSoAsyZq9Wlmc+19RUxY5IMIOh9C3gS+3vdNxx61f?= =?us-ascii?Q?7Xft7qnq8I2V3gI3oiMHsUQWqNS13uFdFKUTmvEs?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9272d97f-40d1-4bbd-b62e-08dcf889ac6d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 02:22:17.0755 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9mLKeJclKe2CphdgM1JGbwy6oJMo0wcFjrOJUQBj6Q4nZ1+VM5an2u9yID5rFN0B5u4GiQJfXpLoBy05Pd5+/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8705 Content-Type: text/plain; charset="utf-8" From: Hans Verkuil Add the capability of retrieving the min and max values of a compound control. Signed-off-by: Hans Verkuil Signed-off-by: Yunke Cao Signed-off-by: Ming Qian --- .../media/v4l/vidioc-g-ext-ctrls.rst | 22 ++- .../media/v4l/vidioc-queryctrl.rst | 9 +- .../media/videodev2.h.rst.exceptions | 3 + drivers/media/i2c/imx214.c | 4 +- .../media/platform/qcom/venus/venc_ctrls.c | 9 +- drivers/media/v4l2-core/v4l2-ctrls-api.c | 54 +++++-- drivers/media/v4l2-core/v4l2-ctrls-core.c | 153 +++++++++++++++--- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +- include/media/v4l2-ctrls.h | 60 ++++++- include/uapi/linux/videodev2.h | 3 + 10 files changed, 272 insertions(+), 49 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b= /Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst index b74a74ac06fc..b8698b85bd80 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst @@ -338,14 +338,26 @@ still cause this situation. - Which value of the control to get/set/try. * - :cspan:`2` ``V4L2_CTRL_WHICH_CUR_VAL`` will return the current val= ue of the control, ``V4L2_CTRL_WHICH_DEF_VAL`` will return the default - value of the control and ``V4L2_CTRL_WHICH_REQUEST_VAL`` indicates that - these controls have to be retrieved from a request or tried/set for - a request. In the latter case the ``request_fd`` field contains the + value of the control, ``V4L2_CTRL_WHICH_MIN_VAL`` will return the minimum + value of the control, and ``V4L2_CTRL_WHICH_MAX_VAL`` will return the max= imum + value of the control. ``V4L2_CTRL_WHICH_REQUEST_VAL`` indicates that + the control value has to be retrieved from a request or tried/set for + a request. In that case the ``request_fd`` field contains the file descriptor of the request that should be used. If the device does not support requests, then ``EACCES`` will be returned. =20 - When using ``V4L2_CTRL_WHICH_DEF_VAL`` be aware that you can only - get the default value of the control, you cannot set or try it. + When using ``V4L2_CTRL_WHICH_DEF_VAL``, ``V4L2_CTRL_WHICH_MIN_VAL`` + or ``V4L2_CTRL_WHICH_MAX_VAL`` be aware that you can only get the + default/minimum/maximum value of the control, you cannot set or try it. + + Whether a control supports querying the minimum and maximum values using + ``V4L2_CTRL_WHICH_MIN_VAL`` and ``V4L2_CTRL_WHICH_MAX_VAL`` is indicated + by the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. Most non-compound + control types support this. For controls with compound types, the + definition of minimum/maximum values are provided by + the control documentation. If a compound control does not document the + meaning of minimum/maximum value, then querying the minimum or maximum + value will result in the error code -EINVAL. =20 For backwards compatibility you can also use a control class here (see :ref:`ctrl-class`). In that case all controls have to diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/D= ocumentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 56d5c8b0b88b..3815732f6a9b 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -447,7 +447,10 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_rect`, containing a rectangle described by the position of its top-left corner, the width and the height. Units - depend on the use case. + depend on the use case. Support for ``V4L2_CTRL_WHICH_MIN_VAL`` and + ``V4L2_CTRL_WHICH_MAX_VAL`` is optional and depends on the + ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. See the documentation of + the specific control on how to interpret the minimum and maximum values. * - ``V4L2_CTRL_TYPE_H264_SPS`` - n/a - n/a @@ -664,6 +667,10 @@ See also the examples in :ref:`control`. ``dims[0]``. So setting the control with a differently sized array will change the ``elems`` field when the control is queried afterwards. + * - ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` + - 0x1000 + - This control supports getting minimum and maximum values using + vidioc_g_ext_ctrls with V4L2_CTRL_WHICH_MIN/MAX_VAL. =20 Return Value =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b= /Documentation/userspace-api/media/videodev2.h.rst.exceptions index 3cf1380b52b0..35d3456cc812 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -396,6 +396,7 @@ replace define V4L2_CTRL_FLAG_HAS_PAYLOAD control-flags replace define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE control-flags replace define V4L2_CTRL_FLAG_MODIFY_LAYOUT control-flags replace define V4L2_CTRL_FLAG_DYNAMIC_ARRAY control-flags +replace define V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX control-flags =20 replace define V4L2_CTRL_FLAG_NEXT_CTRL control replace define V4L2_CTRL_FLAG_NEXT_COMPOUND control @@ -570,6 +571,8 @@ ignore define V4L2_CTRL_DRIVER_PRIV ignore define V4L2_CTRL_MAX_DIMS ignore define V4L2_CTRL_WHICH_CUR_VAL ignore define V4L2_CTRL_WHICH_DEF_VAL +ignore define V4L2_CTRL_WHICH_MIN_VAL +ignore define V4L2_CTRL_WHICH_MAX_VAL ignore define V4L2_CTRL_WHICH_REQUEST_VAL ignore define V4L2_OUT_CAP_CUSTOM_TIMINGS ignore define V4L2_CID_MAX_CTRLS diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 4962cfe7c83d..b0439005ec71 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -774,7 +774,9 @@ static int imx214_ctrls_init(struct imx214 *imx214) imx214->unit_size =3D v4l2_ctrl_new_std_compound(ctrl_hdlr, NULL, V4L2_CID_UNIT_CELL_SIZE, - v4l2_ctrl_ptr_create((void *)&unit_size)); + v4l2_ctrl_ptr_create((void *)&unit_size), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); =20 v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &imx214_ctrl_ops, &props); =20 diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media= /platform/qcom/venus/venc_ctrls.c index d9d2a293f3ef..7f370438d655 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -607,11 +607,16 @@ int venc_ctrl_init(struct venus_inst *inst) =20 v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_COLORIMETRY_HDR10_CLL_INFO, - v4l2_ctrl_ptr_create(&p_hdr10_cll)); + v4l2_ctrl_ptr_create(&p_hdr10_cll), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); =20 v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY, - v4l2_ctrl_ptr_create((void *)&p_hdr10_mastering)); + v4l2_ctrl_ptr_create((void *)&p_hdr10_mastering), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); + =20 v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE, diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-= core/v4l2-ctrls-api.c index e5a364efd5e6..d44fbad95c11 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-api.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c @@ -94,6 +94,22 @@ static int def_to_user(struct v4l2_ext_control *c, struc= t v4l2_ctrl *ctrl) return ptr_to_user(c, ctrl, ctrl->p_new); } =20 +/* Helper function: copy the minimum control value back to the caller */ +static int min_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) +{ + ctrl->type_ops->minimum(ctrl, 0, ctrl->p_new); + + return ptr_to_user(c, ctrl, ctrl->p_new); +} + +/* Helper function: copy the maximum control value back to the caller */ +static int max_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) +{ + ctrl->type_ops->maximum(ctrl, 0, ctrl->p_new); + + return ptr_to_user(c, ctrl, ctrl->p_new); +} + /* Helper function: copy the caller-provider value as the new control valu= e */ static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) { @@ -229,8 +245,8 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *= hdl, cs->error_idx =3D i; =20 if (cs->which && - cs->which !=3D V4L2_CTRL_WHICH_DEF_VAL && - cs->which !=3D V4L2_CTRL_WHICH_REQUEST_VAL && + (cs->which < V4L2_CTRL_WHICH_DEF_VAL || + cs->which > V4L2_CTRL_WHICH_MAX_VAL) && V4L2_CTRL_ID2WHICH(id) !=3D cs->which) { dprintk(vdev, "invalid which 0x%x or control id 0x%x\n", @@ -259,6 +275,15 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler = *hdl, return -EINVAL; } =20 + if (!(ctrl->flags & V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX) && + (cs->which =3D=3D V4L2_CTRL_WHICH_MIN_VAL || + cs->which =3D=3D V4L2_CTRL_WHICH_MAX_VAL)) { + dprintk(vdev, + "invalid which 0x%x or control id 0x%x\n", + cs->which, id); + return -EINVAL; + } + if (ctrl->cluster[0]->ncontrols > 1) have_clusters =3D true; if (ctrl->cluster[0] !=3D ctrl) @@ -368,8 +393,8 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *= hdl, */ static int class_check(struct v4l2_ctrl_handler *hdl, u32 which) { - if (which =3D=3D 0 || which =3D=3D V4L2_CTRL_WHICH_DEF_VAL || - which =3D=3D V4L2_CTRL_WHICH_REQUEST_VAL) + if (which =3D=3D 0 || (which >=3D V4L2_CTRL_WHICH_DEF_VAL && + which <=3D V4L2_CTRL_WHICH_MAX_VAL)) return 0; return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL; } @@ -389,10 +414,12 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler = *hdl, struct v4l2_ctrl_helper *helpers =3D helper; int ret; int i, j; - bool is_default, is_request; + bool is_default, is_request, is_min, is_max; =20 is_default =3D (cs->which =3D=3D V4L2_CTRL_WHICH_DEF_VAL); is_request =3D (cs->which =3D=3D V4L2_CTRL_WHICH_REQUEST_VAL); + is_min =3D (cs->which =3D=3D V4L2_CTRL_WHICH_MIN_VAL); + is_max =3D (cs->which =3D=3D V4L2_CTRL_WHICH_MAX_VAL); =20 cs->error_idx =3D cs->count; cs->which =3D V4L2_CTRL_ID2WHICH(cs->which); @@ -432,13 +459,14 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler = *hdl, =20 /* * g_volatile_ctrl will update the new control values. - * This makes no sense for V4L2_CTRL_WHICH_DEF_VAL and + * This makes no sense for V4L2_CTRL_WHICH_DEF_VAL, + * V4L2_CTRL_WHICH_MIN_VAL, V4L2_CTRL_WHICH_MAX_VAL and * V4L2_CTRL_WHICH_REQUEST_VAL. In the case of requests * it is v4l2_ctrl_request_complete() that copies the * volatile controls at the time of request completion * to the request, so you don't want to do that again. */ - if (!is_default && !is_request && + if (!is_default && !is_request && !is_min && !is_max && ((master->flags & V4L2_CTRL_FLAG_VOLATILE) || (master->has_volatiles && !is_cur_manual(master)))) { for (j =3D 0; j < master->ncontrols; j++) @@ -467,6 +495,10 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *= hdl, ret =3D -ENOMEM; else if (is_request && ref->p_req_valid) ret =3D req_to_user(cs->controls + idx, ref); + else if (is_min) + ret =3D min_to_user(cs->controls + idx, ref->ctrl); + else if (is_max) + ret =3D max_to_user(cs->controls + idx, ref->ctrl); else if (is_volatile) ret =3D new_to_user(cs->controls + idx, ref->ctrl); else @@ -564,9 +596,11 @@ int try_set_ext_ctrls_common(struct v4l2_fh *fh, =20 cs->error_idx =3D cs->count; =20 - /* Default value cannot be changed */ - if (cs->which =3D=3D V4L2_CTRL_WHICH_DEF_VAL) { - dprintk(vdev, "%s: cannot change default value\n", + /* Default/minimum/maximum values cannot be changed */ + if (cs->which =3D=3D V4L2_CTRL_WHICH_DEF_VAL || + cs->which =3D=3D V4L2_CTRL_WHICH_MIN_VAL || + cs->which =3D=3D V4L2_CTRL_WHICH_MAX_VAL) { + dprintk(vdev, "%s: cannot change default/min/max value\n", video_device_node_name(vdev)); return -EINVAL; } diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2= -core/v4l2-ctrls-core.c index 4c8744c8cd96..a3abbde5379b 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -182,29 +182,64 @@ static void std_init_compound(const struct v4l2_ctrl = *ctrl, u32 idx, } } =20 -void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, - union v4l2_ctrl_ptr ptr) +static void std_min_compound(const struct v4l2_ctrl *ctrl, u32 idx, union = v4l2_ctrl_ptr ptr) +{ + void *p =3D ptr.p + idx * ctrl->elem_size; + + if (ctrl->p_min.p_const) + memcpy(p, ctrl->p_min.p_const, ctrl->elem_size); + else + memset(p, 0, ctrl->elem_size); +} + +static void std_max_compound(const struct v4l2_ctrl *ctrl, u32 idx, union = v4l2_ctrl_ptr ptr) +{ + void *p =3D ptr.p + idx * ctrl->elem_size; + + if (ctrl->p_max.p_const) + memcpy(p, ctrl->p_max.p_const, ctrl->elem_size); + else + memset(p, 0, ctrl->elem_size); +} + +static void __v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 fro= m_idx, + u32 which, union v4l2_ctrl_ptr ptr) { unsigned int i; u32 tot_elems =3D ctrl->elems; u32 elems =3D tot_elems - from_idx; + s64 value; =20 - if (from_idx >=3D tot_elems) + switch (which) { + case V4L2_CTRL_WHICH_DEF_VAL: + value =3D ctrl->default_value; + break; + case V4L2_CTRL_WHICH_MAX_VAL: + value =3D ctrl->maximum; + break; + case V4L2_CTRL_WHICH_MIN_VAL: + value =3D ctrl->minimum; + break; + default: return; + } =20 switch (ctrl->type) { case V4L2_CTRL_TYPE_STRING: + if (which =3D=3D V4L2_CTRL_WHICH_DEF_VAL) + value =3D ctrl->minimum; + for (i =3D from_idx; i < tot_elems; i++) { unsigned int offset =3D i * ctrl->elem_size; =20 - memset(ptr.p_char + offset, ' ', ctrl->minimum); - ptr.p_char[offset + ctrl->minimum] =3D '\0'; + memset(ptr.p_char + offset, ' ', value); + ptr.p_char[offset + value] =3D '\0'; } break; case V4L2_CTRL_TYPE_INTEGER64: - if (ctrl->default_value) { + if (value) { for (i =3D from_idx; i < tot_elems; i++) - ptr.p_s64[i] =3D ctrl->default_value; + ptr.p_s64[i] =3D value; } else { memset(ptr.p_s64 + from_idx, 0, elems * sizeof(s64)); } @@ -214,9 +249,9 @@ void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctr= l, u32 from_idx, case V4L2_CTRL_TYPE_MENU: case V4L2_CTRL_TYPE_BITMASK: case V4L2_CTRL_TYPE_BOOLEAN: - if (ctrl->default_value) { + if (value) { for (i =3D from_idx; i < tot_elems; i++) - ptr.p_s32[i] =3D ctrl->default_value; + ptr.p_s32[i] =3D value; } else { memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); } @@ -226,32 +261,63 @@ void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *c= trl, u32 from_idx, memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); break; case V4L2_CTRL_TYPE_U8: - memset(ptr.p_u8 + from_idx, ctrl->default_value, elems); + memset(ptr.p_u8 + from_idx, value, elems); break; case V4L2_CTRL_TYPE_U16: - if (ctrl->default_value) { + if (value) { for (i =3D from_idx; i < tot_elems; i++) - ptr.p_u16[i] =3D ctrl->default_value; + ptr.p_u16[i] =3D value; } else { memset(ptr.p_u16 + from_idx, 0, elems * sizeof(u16)); } break; case V4L2_CTRL_TYPE_U32: - if (ctrl->default_value) { + if (value) { for (i =3D from_idx; i < tot_elems; i++) - ptr.p_u32[i] =3D ctrl->default_value; + ptr.p_u32[i] =3D value; } else { memset(ptr.p_u32 + from_idx, 0, elems * sizeof(u32)); } break; default: - for (i =3D from_idx; i < tot_elems; i++) - std_init_compound(ctrl, i, ptr); + for (i =3D from_idx; i < tot_elems; i++) { + switch (which) { + case V4L2_CTRL_WHICH_DEF_VAL: + std_init_compound(ctrl, i, ptr); + break; + case V4L2_CTRL_WHICH_MAX_VAL: + std_max_compound(ctrl, i, ptr); + break; + case V4L2_CTRL_WHICH_MIN_VAL: + std_min_compound(ctrl, i, ptr); + break; + } + } break; } } + +void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr) +{ + __v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_DEF_VAL, ptr); +} EXPORT_SYMBOL(v4l2_ctrl_type_op_init); =20 +void v4l2_ctrl_type_op_minimum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr) +{ + __v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MIN_VAL, ptr); +} +EXPORT_SYMBOL(v4l2_ctrl_type_op_minimum); + +void v4l2_ctrl_type_op_maximum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr) +{ + __v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MAX_VAL, ptr); +} +EXPORT_SYMBOL(v4l2_ctrl_type_op_maximum); + void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl) { union v4l2_ctrl_ptr ptr =3D ctrl->p_cur; @@ -1296,6 +1362,8 @@ EXPORT_SYMBOL(v4l2_ctrl_type_op_validate); static const struct v4l2_ctrl_type_ops std_type_ops =3D { .equal =3D v4l2_ctrl_type_op_equal, .init =3D v4l2_ctrl_type_op_init, + .minimum =3D v4l2_ctrl_type_op_minimum, + .maximum =3D v4l2_ctrl_type_op_maximum, .log =3D v4l2_ctrl_type_op_log, .validate =3D v4l2_ctrl_type_op_validate, }; @@ -1768,7 +1836,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_c= trl_handler *hdl, s64 min, s64 max, u64 step, s64 def, const u32 dims[V4L2_CTRL_MAX_DIMS], u32 elem_size, u32 flags, const char * const *qmenu, - const s64 *qmenu_int, const union v4l2_ctrl_ptr p_def, + const s64 *qmenu_int, + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max, void *priv) { struct v4l2_ctrl *ctrl; @@ -1892,6 +1963,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_c= trl_handler *hdl, break; } =20 + if (type < V4L2_CTRL_COMPOUND_TYPES && + type !=3D V4L2_CTRL_TYPE_BUTTON && + type !=3D V4L2_CTRL_TYPE_CTRL_CLASS && + type !=3D V4L2_CTRL_TYPE_STRING) + flags |=3D V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX; + /* Sanity checks */ if (id =3D=3D 0 || name =3D=3D NULL || !elem_size || id >=3D V4L2_CID_PRIVATE_BASE || @@ -1900,6 +1977,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ct= rl_handler *hdl, handler_set_err(hdl, -ERANGE); return NULL; } + err =3D check_range(type, min, max, step, def); if (err) { handler_set_err(hdl, err); @@ -1941,6 +2019,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_c= trl_handler *hdl, =20 if (type >=3D V4L2_CTRL_COMPOUND_TYPES && p_def.p_const) sz_extra +=3D elem_size; + if (type >=3D V4L2_CTRL_COMPOUND_TYPES && p_min.p_const) + sz_extra +=3D elem_size; + if (type >=3D V4L2_CTRL_COMPOUND_TYPES && p_max.p_const) + sz_extra +=3D elem_size; =20 ctrl =3D kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); if (ctrl =3D=3D NULL) { @@ -2006,6 +2088,22 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_c= trl_handler *hdl, memcpy(ctrl->p_def.p, p_def.p_const, elem_size); } =20 + if (flags & V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX) { + void *ptr =3D ctrl->p_def.p; + + if (p_min.p_const) { + ptr +=3D elem_size; + ctrl->p_min.p =3D ptr; + memcpy(ctrl->p_min.p, p_min.p_const, elem_size); + } + + if (p_max.p_const) { + ptr +=3D elem_size; + ctrl->p_max.p =3D ptr; + memcpy(ctrl->p_max.p, p_max.p_const, elem_size); + } + } + ctrl->type_ops->init(ctrl, 0, ctrl->p_cur); cur_to_new(ctrl); =20 @@ -2056,7 +2154,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ct= rl_handler *hdl, type, min, max, is_menu ? cfg->menu_skip_mask : step, def, cfg->dims, cfg->elem_size, - flags, qmenu, qmenu_int, cfg->p_def, priv); + flags, qmenu, qmenu_int, cfg->p_def, cfg->p_min, + cfg->p_max, priv); if (ctrl) ctrl->is_private =3D cfg->is_private; return ctrl; @@ -2081,7 +2180,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_= handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, min, max, step, def, NULL, 0, - flags, NULL, NULL, ptr_null, NULL); + flags, NULL, NULL, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std); =20 @@ -2114,7 +2214,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_= ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, mask, def, NULL, 0, - flags, qmenu, qmenu_int, ptr_null, NULL); + flags, qmenu, qmenu_int, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); =20 @@ -2146,7 +2247,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct= v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, mask, def, NULL, 0, - flags, qmenu, NULL, ptr_null, NULL); + flags, qmenu, NULL, ptr_null, ptr_null, + ptr_null, NULL); =20 } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); @@ -2154,7 +2256,9 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); /* Helper function for standard compound controls */ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, - const union v4l2_ctrl_ptr p_def) + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max) { const char *name; enum v4l2_ctrl_type type; @@ -2168,7 +2272,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v= 4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, min, max, step, def, NULL, 0, - flags, NULL, NULL, p_def, NULL); + flags, NULL, NULL, p_def, p_min, p_max, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_compound); =20 @@ -2192,7 +2296,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_= ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, 0, def, NULL, 0, - flags, NULL, qmenu_int, ptr_null, NULL); + flags, NULL, qmenu_int, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_int_menu); =20 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core= /v4l2-ioctl.c index 0304daa8471d..bfdba96e938c 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -893,7 +893,9 @@ static bool check_ext_ctrls(struct v4l2_ext_controls *c= , unsigned long ioctl) return false; break; case V4L2_CTRL_WHICH_DEF_VAL: - /* Default value cannot be changed */ + case V4L2_CTRL_WHICH_MIN_VAL: + case V4L2_CTRL_WHICH_MAX_VAL: + /* Default, minimum or maximum value cannot be changed */ if (ioctl =3D=3D VIDIOC_S_EXT_CTRLS || ioctl =3D=3D VIDIOC_TRY_EXT_CTRLS) { c->error_idx =3D c->count; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index b0db167a3ac4..4bce1af5259a 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -133,6 +133,8 @@ struct v4l2_ctrl_ops { * * @equal: return true if all ctrl->elems array elements are equal. * @init: initialize the value for array elements from from_idx to ctrl->e= lems. + * @minimum: set the value to the minimum value of the control. + * @maximum: set the value to the maximum value of the control. * @log: log the value. * @validate: validate the value for ctrl->new_elems array elements. * Return 0 on success and a negative value otherwise. @@ -142,6 +144,10 @@ struct v4l2_ctrl_type_ops { union v4l2_ctrl_ptr ptr1, union v4l2_ctrl_ptr ptr2); void (*init)(const struct v4l2_ctrl *ctrl, u32 from_idx, union v4l2_ctrl_ptr ptr); + void (*minimum)(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr); + void (*maximum)(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr); void (*log)(const struct v4l2_ctrl *ctrl); int (*validate)(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr ptr); }; @@ -247,6 +253,12 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl = *ctrl, void *priv); * @p_def: The control's default value represented via a union which * provides a standard way of accessing control types * through a pointer (for compound controls only). + * @p_min: The control's minimum value represented via a union which + * provides a standard way of accessing control types + * through a pointer (for compound controls only). + * @p_max: The control's maximum value represented via a union which + * provides a standard way of accessing control types + * through a pointer (for compound controls only). * @p_cur: The control's current value represented via a union which * provides a standard way of accessing control types * through a pointer. @@ -306,6 +318,8 @@ struct v4l2_ctrl { } cur; =20 union v4l2_ctrl_ptr p_def; + union v4l2_ctrl_ptr p_min; + union v4l2_ctrl_ptr p_max; union v4l2_ctrl_ptr p_new; union v4l2_ctrl_ptr p_cur; }; @@ -425,6 +439,8 @@ struct v4l2_ctrl_handler { * @step: The control's step value for non-menu controls. * @def: The control's default value. * @p_def: The control's default value for compound controls. + * @p_min: The control's minimum value for compound controls. + * @p_max: The control's maximum value for compound controls. * @dims: The size of each dimension. * @elem_size: The size in bytes of the control. * @flags: The control's flags. @@ -454,6 +470,8 @@ struct v4l2_ctrl_config { u64 step; s64 def; union v4l2_ctrl_ptr p_def; + union v4l2_ctrl_ptr p_min; + union v4l2_ctrl_ptr p_max; u32 dims[V4L2_CTRL_MAX_DIMS]; u32 elem_size; u32 flags; @@ -723,17 +741,25 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct= v4l2_ctrl_handler *hdl, * @ops: The control ops. * @id: The control ID. * @p_def: The control's default value. + * @p_min: The control's minimum value. + * @p_max: The control's maximum value. * - * Sames as v4l2_ctrl_new_std(), but with support to compound controls, th= anks - * to the @p_def field. Use v4l2_ctrl_ptr_create() to create @p_def from a - * pointer. Use v4l2_ctrl_ptr_create(NULL) if the default value of the - * compound control should be all zeroes. + * Same as v4l2_ctrl_new_std(), but with support for compound controls. + * To fill in the @p_def, @p_min and @p_max fields, use v4l2_ctrl_ptr_crea= te() + * to convert a pointer to a const union v4l2_ctrl_ptr. + * Use v4l2_ctrl_ptr_create(NULL) if you want the default, minimum or maxi= mum + * value of the compound control to be all zeroes. + * If the compound control does not set the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN= _MAX`` + * flag, then it does not has minimum and maximum values. In that case jus= t use + * v4l2_ctrl_ptr_create(NULL) for the @p_min and @p_max arguments. * */ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, - const union v4l2_ctrl_ptr p_def); + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max); =20 /** * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu cont= rol. @@ -1571,6 +1597,30 @@ bool v4l2_ctrl_type_op_equal(const struct v4l2_ctrl = *ctrl, void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, union v4l2_ctrl_ptr ptr); =20 +/** + * v4l2_ctrl_type_op_minimum - Default v4l2_ctrl_type_ops minimum callback. + * + * @ctrl: The v4l2_ctrl pointer. + * @from_idx: Starting element index. + * @ptr: The v4l2 control value. + * + * Return: void + */ +void v4l2_ctrl_type_op_minimum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr); + +/** + * v4l2_ctrl_type_op_maximum - Default v4l2_ctrl_type_ops maximum callback. + * + * @ctrl: The v4l2_ctrl pointer. + * @from_idx: Starting element index. + * @ptr: The v4l2 control value. + * + * Return: void + */ +void v4l2_ctrl_type_op_maximum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr); + /** * v4l2_ctrl_type_op_log - Default v4l2_ctrl_type_ops log callback. * diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index c1c2ae150d30..c8cb2796130f 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1912,6 +1912,8 @@ struct v4l2_ext_controls { #define V4L2_CTRL_WHICH_CUR_VAL 0 #define V4L2_CTRL_WHICH_DEF_VAL 0x0f000000 #define V4L2_CTRL_WHICH_REQUEST_VAL 0x0f010000 +#define V4L2_CTRL_WHICH_MIN_VAL 0x0f020000 +#define V4L2_CTRL_WHICH_MAX_VAL 0x0f030000 =20 enum v4l2_ctrl_type { V4L2_CTRL_TYPE_INTEGER =3D 1, @@ -2019,6 +2021,7 @@ struct v4l2_querymenu { #define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200 #define V4L2_CTRL_FLAG_MODIFY_LAYOUT 0x0400 #define V4L2_CTRL_FLAG_DYNAMIC_ARRAY 0x0800 +#define V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX 0x1000 =20 /* Query flags, to be ORed with the control ID */ #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 --=20 2.43.0-rc1 From nobody Mon Nov 25 04:43:19 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013051.outbound.protection.outlook.com [52.101.67.51]) (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 06CE7199E9B; Wed, 30 Oct 2024 02:22:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730254947; cv=fail; b=pUSFvbtZ9W4A0sja4eG2XY8Lyz0b077/EVyCD4aKC2utry/5uaEEWNZ+gMtxSlM/o4fPq0opU7pYpSRqJNtnnVQ1Gdo9M70nFD76Sf/SsnqdMfG7zyCd3xirYJP2IW9mIx3iavablp/tKE3x+EtZI98L5ouxXPGCd35CNiXdXNY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730254947; c=relaxed/simple; bh=V9uQS5qYmiXssOXx3/jo+h9bUk3tmEJA4+u5KYczP+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Ez+Sa3izy2TAtU4zGrL+4iqoBPFEYPVmMG06JqmhKcZ67U+HoPUR1JvpdSJJYNVom2Q/IjP4UaLt+wQuzIWQS0f0vriy933TQcbkMF+0lMGbbFINvuuVZ6M7xc0xhzPGEF8ajrA1dBLPTfKCwq3jOIXnoNxAMRvFmwUsAD4/xPo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=utRL81S/; arc=fail smtp.client-ip=52.101.67.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="utRL81S/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lSQssZqXqbI0qDOyM8uzpTIi0iMbHxFYzdwWUug2S5keewRsfPablThDV9AfzOpkhYDu/qc86Lb8JpdYd9Zpo+gZWH8UFSUCHrz8ERH9l0SigoyR7vgSK6KmHQunOzB06Hq6ow5vRiQSW5bPkAFNxauQTjhShXzy6zfWfaVfk46IqTqpLVMq2hkfBIYBCxMhQPsW8xxvBrQWGA3qbX3v+OQud2zvzVqt98NdmJ4xGr39xMezQeVgMbEs55R8K248IF53T0NyejT7E8InZAl/m/2zxzMc36HsTu+GaS8FyDKZexdh5f1OAXSjMYwPRjrvV6PPsbaJaMfMD/ApOmIwjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z3oKuxRFkA9yHb1hrfi99zYa7fO58IZs40h8sxAWj0U=; b=NWPrOAzOoBLZVMXcb4KOkGMSTqXs99TYjBV9xXaBE6e6RjBIqDvboJKKPRAUosils/cagfiTIigVRenGCElqv8gjcE3+R/8Kk6SobM1n3kltyZ8YAnHt/Zt8Rn5QO7tgrk+H+Nwsx4v0/mJIjWxxI0G6LQgdqanzFTbXcpLWy1PWv4958fAWczfVwMk/rPKBm8/UVxkOsDcFjE9Y78AXxIly9aJYf7PJQigciGReCckpdh9XveofIBaKA6dktBhVPrYlkXgRIoaCEsaSx0xe8pVIrGxMvxYgOmyiGMDbqHXkdjg0ycIeTwJ5cmD7fDvQnR/KWX2O6SxoU7SqqhukdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z3oKuxRFkA9yHb1hrfi99zYa7fO58IZs40h8sxAWj0U=; b=utRL81S/CDciQlwdCk0JpR+BsYHUd+GtXi7PjFIStnJPxnxMIeVgYM7plDEjh7r0M4GeYjocXe87OjDrHeZrBc0AFWupOxaXUmZlgqvOzALCgk1GoVISlNiWgCWSL9DtLhf5lB9Rz54Z4P0KPGw/kUCcW12Y4T1q2VYwkhYoACtmBxXcSaBVic/b6IKdemfkIYZYnhevhci24Gje0098KEqY3/Oli9hi2kscJWUpnrjKLDc0YJJ9XiZdhD4UxKkRMh7MC/7u1+IkIbJzf1YIeztiCVjpaUrrn44Srs8X2+xo/r8ua4pWiVSBmcEq25XXcvB1Jj7VPlN2zPnByOI8aw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB8705.eurprd04.prod.outlook.com (2603:10a6:20b:428::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 02:22:21 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%3]) with mapi id 15.20.8093.027; Wed, 30 Oct 2024 02:22:21 +0000 From: ming.qian@oss.nxp.com To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: yunkec@google.com, nicolas@ndufresne.ca, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, ming.zhou@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v4 3/4] media: vivid: Add an rectangle control Date: Wed, 30 Oct 2024 11:21:33 +0900 Message-ID: <20241030022134.1098589-4-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241030022134.1098589-1-ming.qian@oss.nxp.com> References: <20241030022134.1098589-1-ming.qian@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0044.apcprd02.prod.outlook.com (2603:1096:4:1f6::6) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB8705:EE_ X-MS-Office365-Filtering-Correlation-Id: b6b259d3-a7c4-4326-73ad-08dcf889af52 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DnE7m6fKGAvxhC1Cd2dDosy3qwvuef1CJi4CpgIYgzlJf25I4SLLAW7U+TFZ?= =?us-ascii?Q?zhl1DtxJJLuRtDNGEtWjZvEcG+sdlM6vqU1pCX3Utx5dO50Cg9/pzxAdHyWb?= =?us-ascii?Q?A6GtRwxh9rhfFSJz/aWCgB1pvlxGV4VNuX+NGNRhCmoqC94fwFugJN7tmA8B?= =?us-ascii?Q?dBkgxAysqICFPT/1+SorrFl1GQEcih5Sik5yB5PIuTzUmuvJ1hrhJ+yTLNwd?= =?us-ascii?Q?Y+bi37Ps609BK6k5Jfv1H2xj3FZsXNT5poLNoKlT0W5fjFEPrybf2wQ5i5VX?= =?us-ascii?Q?Y2eHFaCakAw8tlMlStnfhmsfYlWJ2Pki/xJzMGImkbBZZcuhEy/OMYnLPTAN?= =?us-ascii?Q?91Gc/VhsRP33y9D0jb5GvUkR+TTXe/t6qOm0PHvfQIk8zy8+SxEtzKtkjaAA?= =?us-ascii?Q?/kwCklnkP5pWVlFuIScCrq0Mz4mPfKxnDzdJff6bgZ9TiShFKAq/aY094f9+?= =?us-ascii?Q?OnAYvM3fwa6rAQMDOTdp/CCDkicII55KDukMW4Tnxcll/MRvFvT9nKdPSEHT?= =?us-ascii?Q?44tauaMKVU22PIK7GGeOvd+TsSnLz5YAn9XvGmVbiVXFXvJHx2m1DJ7/d6+T?= =?us-ascii?Q?gtATCqZbk9E28WI3BOlgNTWY9VMnOAM92pOVMudi9eoejUa8mxkH5fWLlAEs?= =?us-ascii?Q?6IMzTHxi07C72+KiOVOUxANX9pgUR102/ePpxigek4kOwcloMssbhsIum/12?= =?us-ascii?Q?Dv0ea6cnSCvq330KsEUXi5z8n/nYoBddGx3U5Y8xOq8RYS4fWFGeyQ8/06uF?= =?us-ascii?Q?JicAj3XVPcwx80Difojmy61gkCknFWoNnrja9GniUGn+3SA/FIQd7JIUMzHH?= =?us-ascii?Q?deFpaMq2hLtz3vPoCTLSwKEDgeSYgFNhXjvMZ2Nh4byZ0/6pugdRa/CvSRyC?= =?us-ascii?Q?CUG7+9rmHVex/wB1pYLMAACDP6+0fCL+IF7DNv5UxShXsGLrqkTDWb09Tao+?= =?us-ascii?Q?TOBaHLctjY/yFXu36SEUTDpfrOEb4JBNgvqHF2crF6XCF6Wgw4kHjhsJSOmf?= =?us-ascii?Q?LgdSuAxk6ntSc3iLtB0c8qbQviyRIxTaVs5lktEhzBX5c7PEgdqykWcwCcz9?= =?us-ascii?Q?U1B++BqtoC5al6YvylKF3LoJWA7MzDyWY/ev4kP+fBX8Ox5E/uFGcNfFz3DC?= =?us-ascii?Q?BmO1ZB3G3722sh1FTbilNfd0BQo9DfECeUpo01ej7XrjNRi5CylPHQqKJMgg?= =?us-ascii?Q?fUAmZHAZtf4xNdw1LGtoJrhwxGEXXuFHInPnpeRSNLndkKTqhOL7GrPxSt56?= =?us-ascii?Q?cG8uCV2pB9W8OEe5KCOpntNnEeSgDYy2n0jIDao30kPM12Ia93wqgJciJzWL?= =?us-ascii?Q?K+mKuZJHn0t0HWLemB+yTGinc8FyrnelnErnGMYp+IBYgYrzbFnabS/G372K?= =?us-ascii?Q?CHR0pC4=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pC3LessNBM22pYsIS0Kz+wFbkhIh3nX07yACUtuvNKPnwzwlAez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eMxBOgDveXiSHKHlluwo3VSQ0cmK1ssxZjzZ27TEqG0q?= =?us-ascii?Q?cNSqAl1Q+6FV1vrrKqBdX3mzQJbwJfHyHhdk47VXXeY9/E888wrb8CvqMZ2K?= =?us-ascii?Q?xn2/5Iy6Kt6FeQVwNZ4rJzHXczFkOGpeqBpPfqAP9SVN4LeKhADEkVSwOC/l?= =?us-ascii?Q?xiEmjMy/0FVZrLgqDmTCo6nlS9bGzCcH71Edg0ksj+UIMySosechpgbno7EY?= =?us-ascii?Q?SPMqCoPqSCjycY6jezO2ZWYv9l+cCYur+DQABvv46cw16+B1hJJa9LJ0uAYs?= =?us-ascii?Q?8adj+OcuIF/MXMds8YFsQG4cu4H26oNyLRR1YCfk3h1FQrWSfbGMWBRqUiR/?= =?us-ascii?Q?Fy48n6853wEsN2dsfVOADQfJwJzBBMkNvPItoP6+mJl0gphnksSe230c7siJ?= =?us-ascii?Q?P18UiKBxjzw3sNzMO4jZzzDZK5/ELktre4phEGl6Y2kwaYMc+OIFqUNR8+bY?= =?us-ascii?Q?AeMNRswV7rlUnjo7t01DijPlaMM+u0uCuIfZuwH40QM9VvBSK9Y8OXVrkD2L?= =?us-ascii?Q?EgusvFrjSTGyYDzlaszPrr73/WLInCpA975AqoFXNDlJZVnsQAGjn6Za9fzz?= =?us-ascii?Q?Jx4rc5JIIVw/gBLntOvLYD8VNPY73w7RG8iXyS6MG4MGm+dUCKfYOMWmBDcf?= =?us-ascii?Q?nbcHYlH7KBjvWeCX1R32JiKE/OJ4gvdTfAHWotew?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6b259d3-a7c4-4326-73ad-08dcf889af52 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 02:22:21.6994 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rl3atW0zDSEgAuFrzTYG5gMMAqckHmx3wCvNqEDfHI8MXPKKeG3PyLroaclVrNS0z4uNl8HYPz00AeJiFz/10w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8705 Content-Type: text/plain; charset="utf-8" From: Yunke Cao This control represents a generic read/write rectangle. It supports V4L2_CTRL_WHICH_MIN/MAX_VAL. Signed-off-by: Yunke Cao Reviewed-by: Hans Verkuil --- .../media/test-drivers/vivid/vivid-ctrls.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/media/test-drivers/vivid/vivid-ctrls.c b/drivers/media= /test-drivers/vivid/vivid-ctrls.c index 8bb38bc7b8cc..bed5f4fb0c69 100644 --- a/drivers/media/test-drivers/vivid/vivid-ctrls.c +++ b/drivers/media/test-drivers/vivid/vivid-ctrls.c @@ -37,6 +37,7 @@ #define VIVID_CID_U8_PIXEL_ARRAY (VIVID_CID_CUSTOM_BASE + 14) #define VIVID_CID_S32_ARRAY (VIVID_CID_CUSTOM_BASE + 15) #define VIVID_CID_S64_ARRAY (VIVID_CID_CUSTOM_BASE + 16) +#define VIVID_CID_RECT (VIVID_CID_CUSTOM_BASE + 17) =20 #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000) #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1) @@ -360,6 +361,38 @@ static const struct v4l2_ctrl_config vivid_ctrl_ro_int= 32 =3D { .step =3D 1, }; =20 +static const struct v4l2_rect rect_def =3D { + .top =3D 100, + .left =3D 200, + .width =3D 300, + .height =3D 400, +}; + +static const struct v4l2_rect rect_min =3D { + .top =3D 0, + .left =3D 0, + .width =3D 1, + .height =3D 1, +}; + +static const struct v4l2_rect rect_max =3D { + .top =3D 0, + .left =3D 0, + .width =3D 1000, + .height =3D 2000, +}; + +static const struct v4l2_ctrl_config vivid_ctrl_rect =3D { + .ops =3D &vivid_user_gen_ctrl_ops, + .id =3D VIVID_CID_RECT, + .name =3D "Rect", + .type =3D V4L2_CTRL_TYPE_RECT, + .flags =3D V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX, + .p_def.p_const =3D &rect_def, + .p_min.p_const =3D &rect_min, + .p_max.p_const =3D &rect_max, +}; + /* Framebuffer Controls */ =20 static int vivid_fb_s_ctrl(struct v4l2_ctrl *ctrl) @@ -1685,6 +1718,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool= show_ccs_cap, dev->int_menu =3D v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int_menu= , NULL); dev->ro_int32 =3D v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_ro_int32= , NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_area, NULL); + v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_rect, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_dyn_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u16_matrix, NULL); --=20 2.43.0-rc1 From nobody Mon Nov 25 04:43:19 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013008.outbound.protection.outlook.com [52.101.67.8]) (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 6AC0D1C3F0D; Wed, 30 Oct 2024 02:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.8 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730254952; cv=fail; b=a6Agf4esoZ4aeLUrbtW80vib2LtOylCpexj8xH9MNdRQW4EBNUc2+kKwxtLgyy+r/wi/VMzvmJbJO8CvyUzBG6oSdDpdhvnrsQGJ6Kiy+2vLF1GZMvhqeqyqbXi/D6lQMut63vgLLdeE7rK1Q4NV0o+6dxqHlheRXiU6g6zEUJE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730254952; c=relaxed/simple; bh=SY0GV+c/N+VDgcZRcsaREGLlZn5wHMFCW9SHvdpgAvM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qeaKEWDUTVP2YfGuPNJlvRt6O+m8ykRNzZfYk7qSzpTsqmXEwSwGSrzxfnDx8LMAsbXMmH3ipRcj4GaDp73oIFoj6REhYSUv3FyFszHnYTuyZjOH8JDX27xtxn9SkvOo9z+onCZ5ITd9cy79iQIMAztARxpyGpGGSf+aaVsXn4g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=pb2RA2YZ; arc=fail smtp.client-ip=52.101.67.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="pb2RA2YZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BkrC/jTYZF5at5M4lT4igD8NcUTzbJpGj5Ca9kuSdlmAWWisu7nD9DMjgDRXOWPhlyBNMvlVGllhTjXHLKMFyAtnagDwdMY6PTAttEFaZ1f8XENxL2Uh9hvMhSrvJDLREaMZMkf4yW9U/4FKRyU0kyawJIuMPeOwK4xIHAVqTMA5Bo8Ls/z7NcdwU6sAGAZkOP5L+qbT9r1Fqznp6+yKEjmtXGS+rNhKU5NOtGFBDDqSTLCGY3hOd/SJHA07rI5PKQ0OtUCzm+wdiqtqa3nlAISAfFKmShMTm9DeN05pnOU7/T2piCOxsLGZgcFMLJbhrIyxg4Z+jamph6ImHVCuzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h5TvcF8N9GZyht/lUPnUCnLWkfK2hUkPwF3iS5kuBe4=; b=hvS+9mq2mCEAQunRsvxgs9ly1kzZ5RkUdSyn9PH4Ojaq41BAlg4d2921COpHOuDAD5xdoc+Vyz+qavsCWzv7kYSNBCktZrTqcyIFX3ZEvYJDoFyTJR021160xKWZPUUt3MfcA7EpMQvHtYkznrdDrDpvzS7Uzh/hud+i/1G6Y7z+vllcTEEAid0CZL6Va3V6ghZDFXcCJsWawvgOGaBKHb/3BRDoE8Sh808+QOndy93a84+x1pRzgOTTMRHVNTzrUQbr76crcMibwq/JQZN0HL/6vzHti4Sx2raMEKYENTdwQoLV9uy870MQoqw5RPCWi8OldRteaZr/RMT6AUEG8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h5TvcF8N9GZyht/lUPnUCnLWkfK2hUkPwF3iS5kuBe4=; b=pb2RA2YZ8kKsf3pkTGxPJaP7rTnaGUq5maEIE4qnX2hhV8y+BYxywBNnfdku31FH3whHmvosoXHyC2bzhC43ouluNZdd+6Z1xW7UKmUl5bT/kvA/PSHppyxS7nye62n1RxFb68xpsEeSG6YwpP+ep1Q5PHKSWUf9Y8r4DRaE3QXvdso82ZAyltupMgLTnVaUkcw50QsVItJfwS27FBpqMWoRozqKfbseMjAzGyOffa3k3v9BP0nnWQlZCCafqHmkqUQ6QaWLB1ogRXvD/P+88UgMUBshO/A1eozWN2lhFszv4Pms1TXIGa6K7rV8YaMM6LbFw47ygcJSkcOdNLxjRQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB8705.eurprd04.prod.outlook.com (2603:10a6:20b:428::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 02:22:26 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%3]) with mapi id 15.20.8093.027; Wed, 30 Oct 2024 02:22:26 +0000 From: ming.qian@oss.nxp.com To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: yunkec@google.com, nicolas@ndufresne.ca, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, ming.zhou@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v4 4/4] media: v4l2-ctrls: Add video encoder ROI ctrls Date: Wed, 30 Oct 2024 11:21:34 +0900 Message-ID: <20241030022134.1098589-5-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241030022134.1098589-1-ming.qian@oss.nxp.com> References: <20241030022134.1098589-1-ming.qian@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0044.apcprd02.prod.outlook.com (2603:1096:4:1f6::6) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB8705:EE_ X-MS-Office365-Filtering-Correlation-Id: 5216e4d7-ee99-4f89-cc40-08dcf889b20a X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?LSXjkSrc1ZHXxmBVHKt4Sa68OIf7jxNC50ikU37SGI1RhqkNrowsfTEbGics?= =?us-ascii?Q?UtXAAz7rghLKBtXC51tA/vd0dbdA6wro+Gk+EUnjNOgMAqoCeXTfCyV6Q/Mq?= =?us-ascii?Q?OpNVEe4mq5KtuvljyfxoNfO20nc3+JkMfkIE2hF64MZNeS0VNguskA8KkdIB?= =?us-ascii?Q?1ogkgTIc4uIZUWIt7/zxATSkjNyeQ1c8pKWMAmfI9Vre6LhyypkZqNxSv84g?= =?us-ascii?Q?QDU4ZA843Tp54xvrq5TwRNqEsRpbdKbC+zfmDP5HJH4IuAPDv6RhFneHOiOi?= =?us-ascii?Q?AOSV+q//o4UsTyGA/mUUJGF3dwI8bCZTYHjuMa4aOufvkMjErWXCAH7OfAEz?= =?us-ascii?Q?TvmgjC0y+45+2mbaTnDxmneoqr70eZsALVdIViR5L09CyC8/EDn5AioWO5gV?= =?us-ascii?Q?0XM5jJZubKB/PQdoWfcFEkUmPYnXSvasqStER2oW/e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UehERXEMlxA0Xug/2sKFBnqlvMz5ECPNAOsvTQc/+noJ?= =?us-ascii?Q?LcHuN8I=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Eff69SYj1zwU8Qkx31WirkRDswxHPW1UiEYCHeQzOZXYpvUoRuh30fdgJViE?= =?us-ascii?Q?2YXwhJweMUsDmO/W9JFLKzhalgPH5CqKozzL/Ym0NRj4a8BJ+2d619wyRK+F?= =?us-ascii?Q?oaM3gIRtBUZLT9c0tGVx7mETrslW6hDzIjteXWztHrBQGlzTg4w75g3XXwA7?= =?us-ascii?Q?rmGQc51CCgnz88sLqCsfoPmGpJ8C46+kFwYcdZGLxt2/q1HidkiXt57jRn4t?= =?us-ascii?Q?KZ5B6ZsvkRkScKW820/Ht6h6im1IPvICZSc1POCiG69YUDc+yDg3VrRnOTJT?= =?us-ascii?Q?l5PXYAweqTwW37z2ua60ZxnSM6PmYcd31FDDEpFNgAKYoN3T0sp+gkue7Qce?= =?us-ascii?Q?HLBt78w+6kv1xu7AVweukOjDq6Xyu2l51zgTFfe7ATKgMS3cbA/8BhiHxu/p?= =?us-ascii?Q?Nyl38NN70aa9o5XJaQEOzoAqXOKShkw+sShMJxD3rcwj5fl014/Orjsf1KRj?= =?us-ascii?Q?ljmb1pFJgDKIfyt/3ZMrezo+zQbSLIlSfuGSAcpWzMYJ/MXVbtsnzQk4+lGQ?= =?us-ascii?Q?il3nwZ27LLMzfasByfkrtL1pBrRgaSrpbCC2mnR9dP/S/uiIGoOsxheez8h2?= =?us-ascii?Q?aw+VOBPp5TdXqpFAqcp8dwKQ+n94TA9TeU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XWyYx5lZzK/zqPIt5DCSioYAbVdH0ef3RyYBaWWkpWC+X/0M?= =?us-ascii?Q?rDrIFWZwMpvKahSHKZkbjLK7lKK+wZH3eWxaFWyt?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5216e4d7-ee99-4f89-cc40-08dcf889b20a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 02:22:26.2743 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nL76osGuNcNLhkd0vJK2y1JoQD/d57fD7rY5F7shs10qtTkOvDSE86X7dRx7PpRRi4jinATkudAXzs6dKcY7+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8705 Content-Type: text/plain; charset="utf-8" From: Ming Qian Add some ctrls to support the video encoder region-of-interest(ROI) feature. The ROI QP Map and rectangular configuration are supported. Signed-off-by: Ming Qian Signed-off-by: TaoJiang --- .../media/v4l/ext-ctrls-codec.rst | 131 ++++++++++++++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 46 ++++++ include/uapi/linux/v4l2-controls.h | 16 +++ 3 files changed, 193 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Do= cumentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 4a379bd9e3fb..7b4327c4a14e 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1667,6 +1667,137 @@ 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 =20 +``V4L2_CID_MPEG_VIDEO_ROI_MODE`` + (enum) + +enum v4l2_mpeg_video_roi_mode - + Indicates Video Encoding region-of-interest (ROI) Mode, enable differe= nt + encoding strategies based on selected areas within a frame. Choosing a + specific mode activates corresponding control or combinations of contr= ols + to configure the ROI, e.g. for rectangle delta QP mode, you need to pr= ovide + V4L2_CID_MPEG_VIDEO_ROI_RECT and V4L2_MPEG_VIDEO_ROI_MODE_RECT_DELTA_Q= P. + Applicable to encoders. + + Possible values are: + + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - ``V4L2_MPEG_VIDEO_ROI_MODE_NONE`` + - No ROI in the MPEG stream. Default mode. + * - ``V4L2_MPEG_VIDEO_ROI_MODE_RECT_DELTA_QP`` + - Rectangle ROI mode and specifies ROI delta QP. + When enabled, define one or more rectangular ROI areas + where QP delta is applied. The control + V4L2_CID_MPEG_VIDEO_ROI_RECT is used to set ROI areas + and V4L2_MPEG_VIDEO_ROI_MODE_RECT_DELTA_QP is used to + set QP delta value. + * - ``V4L2_MPEG_VIDEO_ROI_MODE_RECT_PRIORITY`` + - Rectangle ROI mode and specifies ROI priority. + When enabled, define one or more rectangular ROI areas + where priority is applied. The control + V4L2_CID_MPEG_VIDEO_ROI_RECT is used to set ROI areas + and V4L2_MPEG_VIDEO_ROI_MODE_RECT_PRIORITY is used to + set priority. + * - ``V4L2_MPEG_VIDEO_ROI_MODE_MAP_DELTA_QP`` + - Map ROI mode and specifies ROI delta QP. + When enabled, the whole frame is configured into a grid map + according to the ROI block region size in raster scan order, + and each region can have a QP delta applied. + The control V4L2_CID_MPEG_VIDEO_ROI_MAP_DELTA_QP + is used to configure the ROI Map with QP delta values. + * - ``V4L2_MPEG_VIDEO_ROI_MODE_MAP_ABSOLUTE_QP`` + - Map ROI mode and specifies ROI absolute QP value. + When enabled, configure a grid ROI map where each region + has an absolute QP value assigned. The control + V4L2_CID_MPEG_VIDEO_ROI_MAP_ABSOLUTE_QP is used to + configure the ROI Map with absolute QP values. + +``V4L2_CID_MPEG_VIDEO_ROI_BLOCK_SIZE (struct)`` + This read-only control returns the ROI block size in pixels. The struct + :c:type:`v4l2_area` provides the width and height in separate + fields. The resolution of the frame will be rounded up to be + aligned to this value when it's partitioned in blocks for QP + maps and the number of QP values in those maps will be the + number of blocks of these indicated pixel size that comprise + a full frame. This control depends on the encoding format, + and the detailed encoder hardware. + Applicable to encoders. + +``V4L2_CID_MPEG_VIDEO_ROI_RECT (struct)`` + A struct :c:type:`v4l2_rect` provides the rectangular region + described by the position of its top-left corner, the width + and the height. The unit is in pixels. And it should be aligned + to the ROI block size, which can be queried from + ``V4L2_CID_MPEG_VIDEO_ROI_BLOCK_SIZE``. If it is not aligned to + the ROI block size, then X,Y gets rounded down, and width/height up. + The maximum number of rectangular regions depends on the hardware. + This control is a dynamically sized array. + This control is applicable when ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` + value is ``V4L2_MPEG_VIDEO_ROI_MODE_RECT_DELTA_QP`` or + ``V4L2_MPEG_VIDEO_ROI_MODE_RECT_PRIORITY``. For overlapping + regions, the value that is first in the ROI array will have priority. + Applicable to encoders. + +``V4L2_MPEG_VIDEO_ROI_MODE_RECT_DELTA_QP (integer)`` + Specifies the ROI delta QP of a rectangular region. The delta QP + is the value that will be added on top of the frame level QP. + It can be positive (more distortion) or negative (less distortion) + values. This control is applicable when + ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` value is + ``V4L2_MPEG_VIDEO_ROI_MODE_RECT_DELTA_QP``, and must be used + in combination with ``V4L2_CID_MPEG_VIDEO_ROI_RECT``. + This control is a dynamically sized array, and the array size + should match ``V4L2_CID_MPEG_VIDEO_ROI_RECT``. If not match, + the number of configured regions is the minimum value. + Applicable to encoders. + +``V4L2_MPEG_VIDEO_ROI_MODE_RECT_PRIORITY (integer)`` + Specifies the ROI priority of a rectangular region. it can + be positive (more important) or negative (less important) + values and is compared with non-ROI region (taken as value 0). + This control is applicable when ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` + value is ``V4L2_MPEG_VIDEO_ROI_MODE_RECT_PRIORITY``, and must + be used in combination with ``V4L2_CID_MPEG_VIDEO_ROI_RECT``. + This control is a dynamically sized array, and the array size + should match ``V4L2_CID_MPEG_VIDEO_ROI_RECT``. If not match, + the number of configured regions is the minimum value. + Applicable to encoders. + +``V4L2_CID_MPEG_VIDEO_ROI_MAP_DELTA_QP (integer)`` + Configure a frame-wide grid map that divides the entire + frame into blocks of the ROI block size, where each + region will have a QP delta applied. The ROI map is + arranged in raster scan order, and it's configured + as an integer array. The block size can be got from + ``V4L2_CID_MPEG_VIDEO_ROI_BLOCK_SIZE``. This control is a + dynamically sized array, the array size can be calculated + from video resolution and the ROI block size, and the + width and height should be rounded up to be aligned to + the block size. This control is applicable when + ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` value is + ``V4L2_CID_MPEG_VIDEO_ROI_MAP_DELTA_QP``. + If the array size is too small, the control should + return error. Applicable to encoders. + +``V4L2_CID_MPEG_VIDEO_ROI_MAP_ABSOLUTE_QP (integer)`` + Configure a frame-wide grid map that divides the entire + frame into blocks of the ROI block size, where each + region will have an absolute QP applied. The ROI map is + arranged in raster scan order, and it's configured + as an integer array. The block size can be got from + ``V4L2_CID_MPEG_VIDEO_ROI_BLOCK_SIZE``. This control is a + dynamically sized array, the array size can be calculated + from video resolution and the ROI block size, and the + width and height should be rounded up to be aligned to + the block size. This control is applicable when + ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` value is + ``V4L2_CID_MPEG_VIDEO_ROI_MAP_ABSOLUTE_QP``. + If the array size is too small, the control should + return error. Applicable to encoders. + .. raw:: latex =20 \normalsize diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2= -core/v4l2-ctrls-defs.c index 1ea52011247a..4d89309bf8d0 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -612,6 +612,15 @@ const char * const *v4l2_ctrl_get_menu(u32 id) NULL, }; =20 + static const char * const mpeg_video_roi_mode[] =3D { + "None", + "Rectangle Delta QP", + "Rectangle Priority", + "Map Delta QP", + "Map Absolute QP", + NULL, + }; + switch (id) { case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: return mpeg_audio_sampling_freq; @@ -750,6 +759,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id) return camera_orientation; case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE: return intra_refresh_period_type; + case V4L2_CID_MPEG_VIDEO_ROI_MODE: + return mpeg_video_roi_mode; default: return NULL; } @@ -971,6 +982,13 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX: return "Frame LTR Index"; case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES: return "Use LTR Frames"; case V4L2_CID_MPEG_VIDEO_AVERAGE_QP: return "Average QP Value"; + case V4L2_CID_MPEG_VIDEO_ROI_MODE: return "Video ROI Mode"; + case V4L2_CID_MPEG_VIDEO_ROI_BLOCK_SIZE: return "Video ROI Block Size"; + case V4L2_CID_MPEG_VIDEO_ROI_RECT: return "Video ROI Rectangle Region"; + case V4L2_CID_MPEG_VIDEO_ROI_RECT_DELTA_QP: return "Video ROI Rectangle D= elta QP"; + case V4L2_CID_MPEG_VIDEO_ROI_RECT_PRIORITY: return "Video ROI Rectangle P= riority"; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_DELTA_QP: return "Video ROI Delta QP Map= "; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_ABSOLUTE_QP: return "Video ROI Absolute = QP Map"; 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"; =20 @@ -1512,6 +1530,34 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum = v4l2_ctrl_type *type, *type =3D V4L2_CTRL_TYPE_INTEGER; *flags |=3D V4L2_CTRL_FLAG_READ_ONLY; break; + case V4L2_CID_MPEG_VIDEO_ROI_MODE: + *type =3D V4L2_CTRL_TYPE_MENU; + *flags |=3D V4L2_CTRL_FLAG_UPDATE; + break; + case V4L2_CID_MPEG_VIDEO_ROI_BLOCK_SIZE: + *type =3D V4L2_CTRL_TYPE_AREA; + *flags |=3D V4L2_CTRL_FLAG_READ_ONLY; + break; + case V4L2_CID_MPEG_VIDEO_ROI_RECT: + *type =3D V4L2_CTRL_TYPE_RECT; + *flags |=3D V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_= MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_RECT_DELTA_QP: + *type =3D V4L2_CTRL_TYPE_INTEGER; + *flags |=3D V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_= MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_RECT_PRIORITY: + *type =3D V4L2_CTRL_TYPE_INTEGER; + *flags |=3D V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_= MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_DELTA_QP: + *type =3D V4L2_CTRL_TYPE_INTEGER; + *flags |=3D V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_= MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_ABSOLUTE_QP: + *type =3D V4L2_CTRL_TYPE_INTEGER; + *flags |=3D V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_= MAX; + break; case V4L2_CID_PIXEL_RATE: *type =3D V4L2_CTRL_TYPE_INTEGER64; *flags |=3D V4L2_CTRL_FLAG_READ_ONLY; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-c= ontrols.h index 974fd254e573..bf67d53af737 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -900,6 +900,22 @@ enum v4l2_mpeg_video_av1_level { =20 #define V4L2_CID_MPEG_VIDEO_AVERAGE_QP (V4L2_CID_CODEC_BASE + 657) =20 +enum v4l2_mpeg_video_roi_mode { + V4L2_MPEG_VIDEO_ROI_MODE_NONE, + V4L2_MPEG_VIDEO_ROI_MODE_RECT_DELTA_QP, + V4L2_MPEG_VIDEO_ROI_MODE_RECT_PRIORITY, + V4L2_MPEG_VIDEO_ROI_MODE_MAP_DELTA_QP, + V4L2_MPEG_VIDEO_ROI_MODE_MAP_ABSOLUTE_QP +}; + +#define V4L2_CID_MPEG_VIDEO_ROI_MODE (V4L2_CID_CODEC_BASE + 658) +#define V4L2_CID_MPEG_VIDEO_ROI_BLOCK_SIZE (V4L2_CID_CODEC_BASE + 659) +#define V4L2_CID_MPEG_VIDEO_ROI_RECT (V4L2_CID_CODEC_BASE + 660) +#define V4L2_CID_MPEG_VIDEO_ROI_RECT_DELTA_QP (V4L2_CID_CODEC_BASE + 661) +#define V4L2_CID_MPEG_VIDEO_ROI_RECT_PRIORITY (V4L2_CID_CODEC_BASE + 662) +#define V4L2_CID_MPEG_VIDEO_ROI_MAP_DELTA_QP (V4L2_CID_CODEC_BASE + 663) +#define V4L2_CID_MPEG_VIDEO_ROI_MAP_ABSOLUTE_QP (V4L2_CID_CODEC_BASE + 66= 4) + /* MPEG-class control IDs specific to the CX2341x driver as defined by V4= L2 */ #define V4L2_CID_CODEC_CX2341X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000) #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_CODEC_C= X2341X_BASE+0) --=20 2.43.0-rc1