From nobody Sun Nov 24 08:37:48 2024 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2085.outbound.protection.outlook.com [40.107.20.85]) (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 B06A1191F86; Wed, 6 Nov 2024 06:08:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730873312; cv=fail; b=PXwn/Vy8VpVMW3gVvbSqzq4MLjr18ewIJlJ7tCUpI2lqp46Le+a+FdgU0wXmKj5uJnStGraMlny7Md+inv7pYViG5VEiN2+h95YCw5MCGgC19HAKYonZ8hyr8hNT1lEaz8uhqe9r6HYbQZi8aN3Nvc/JGEr3igSMhRASjgqn2+g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730873312; c=relaxed/simple; bh=tCVlQ3w2V9I1KlogmSlRSJ4thYZGT3jxrO9w+HxkGxQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qeQd8LN1j1+32JZfN6TipayXYChxT0ZPYNA8fD/Wf0hu7ZXfqapGWRp+DlHexVIohti8iGBDOMdPZbv+ix7sTBFNdVY7sm2nfDthC7+kLfCpLK2i5yGJvFgyqYSPmLVKO1OVHHnvvjcl57Q5L9R0Mpen0f3dd3pneGJkLUN8gb8= 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=gsBaj9iv; arc=fail smtp.client-ip=40.107.20.85 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="gsBaj9iv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W4oV/g3OSs1cLSEsL3RpONTSjx0EvqvjvKmgSDat1wOoYFkXYNVJYnJxeurdgqBPhEyx+Ml/y6pwIw0wWEfJf5sA/iL4NLZ2vQKGh0E0NrJcLf/6BeuD5DjvoGpBQewE8Di82R3lo5/huC7fTAAQqal+HxYt14pOhV1NfuiQWWmLARs276GenMz2UUTkJhttrZufFDFnS94wKndsco6pQJTafQP8jWTujcdI03r/yPXH4o5PubDtRMM3wCvwItVMfLPLV7+cm9ybqo6m8+jBvd2VGR1w8QXQGYdzntIGs66kihvLwOI0qv0Jgz49zwSUpw7zldhE/Wx8IjZIoZeZ+w== 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=t1KBz4blLYJUSN1vn0vSjwuM6Lv08zEmF9YUkX1Ekd4=; b=i85Iyx4v3Xfy2wnxB25rjfhcH3uYuCw/UgzPgpA4/6Kv+XHsLzAVGvESQSZVAPm3CX29MtJKHjX53hYZTuiZv9IQqeb/UDVb4jN8ZZyJvo0Uq3wwf+ipw1cOI/DESx96ov7Yv3jdt+JAtTmlIzTWyvx8hhdrzfu1zIsBmZNuJ/42qJkG7TEutLdqjHXSWBGOunybmAdMpvOThKZE80OpYxy1ijeT7KMO0IEZRz0SCU9aWlK6TfRCGR2HMRXgsfP6QZwqVAya/I3S8e4RyEJ0iVmZLqJNNP0APvPjLfE8xK5aqDr61ysQ3goI3lsBQc862CbAVd7H+SUq82OTv8uumA== 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=t1KBz4blLYJUSN1vn0vSjwuM6Lv08zEmF9YUkX1Ekd4=; b=gsBaj9iv7RyoD46eqbukoP0z1WGionqGym4TsEN56yu7uUu4f/C5fqKzSYU6ry7sWA+Ht5ge5BSmLHGnVRQUNCYhWVfCuFEzXEbq+VleJWx6Bsh123YvVTOet/b+IIKVQuHrpQtNDIWHA4bhK7T2eqW0AeSWuLomeyqCo+lXKf7es1IJJVX6SHRKGRs/YKtD6DseSb1JhHHN40X8m5hwsCXcspCZ/sPFDQe+3BdBLkzZ6l+iu+Ef4fB0Kj9w1y3rIEYiiZvgf6EJAfkzCs7/+Nelv1g0qqJWqNXQsdBiFICqdshfG1XlJRNpPXvTBPSORLgUD13udvmyYtHF3nPI/g== 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 PA2PR04MB10506.eurprd04.prod.outlook.com (2603:10a6:102:41e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Wed, 6 Nov 2024 06:08:28 +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.8114.031; Wed, 6 Nov 2024 06:08:28 +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: [PATCH v5 1/4] media: v4l2_ctrl: Add V4L2_CTRL_TYPE_RECT Date: Wed, 6 Nov 2024 15:07:49 +0900 Message-ID: <20241106060752.205074-2-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241106060752.205074-1-ming.qian@oss.nxp.com> References: <20241106060752.205074-1-ming.qian@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0013.apcprd01.prod.exchangelabs.com (2603:1096:4:191::9) 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_|PA2PR04MB10506:EE_ X-MS-Office365-Filtering-Correlation-Id: cecb7cd1-ad32-40bf-208a-08dcfe296e56 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|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9dgZVtxU1CFQTmGbLJx3Ft88+BmTYYVlZlGb5AE1EuR7VWC/OUPlkT78uB3x?= =?us-ascii?Q?jmXKxzufcKtp203yuWkhVrVSzas6lRbzuh9+bjt37ZeKa1wG8ptruEAZ7/iy?= =?us-ascii?Q?HfoWExB/ZySZYOvKEMJC6yE9y+v4/6eWq+QlEZ4lyeihJcVNzdwNJZkk4uxv?= =?us-ascii?Q?/PjZ+tqdrNRPV7YZ+ws1eDMdflI4EkOLVETCOI+Rdct0oZwYPrAEUMUd5alp?= =?us-ascii?Q?gUodRvCf/yqaTAbbGsXEd+YyvBx4hX+/NJ1lUIGeKpNWCEUe6LcEJxV49Xwj?= =?us-ascii?Q?eeOzZf6N0435SYy9QngcBXYroRjbsarjR/lQqVXmAk0TyWKgE0tDnBhkFnKy?= =?us-ascii?Q?14ymoRYfJN64WVQMylYag98vFy6PQeOCCHYYPDWqtmwXXVf3gYikCD0xMjY5?= =?us-ascii?Q?4WVp3+zn/1eQF1mS0jb6fkwGD30sYiaopb00HDeDUWsJljzwQp6yvsJ/sIEk?= =?us-ascii?Q?P/jfXQrRH4hbl+p3H0CuV5aUQCW6QtUrUvRlMgDpArIo8WnBXt1SlaPiZ6rX?= =?us-ascii?Q?u03t49IScX22ajZLf3zikZc5XtRKgXUR2xRCiHNiJr13eMqEu4qmFAwFeZEd?= =?us-ascii?Q?RIebx4npKFNTgt2RcCQ6ddCdecn1DVSLPDEzE797uGjZG2B4gTbgkNduM7UV?= =?us-ascii?Q?pMY1UR0v/6KuyUA9/s0X9DDova5/aLWtzj/HbTkuNa3IeliZBpUiziAvjZU6?= =?us-ascii?Q?Z9vbZ7BzC1sNwCHGfvYzWSzdtKatbPbsbtjHCk/0YUlu31SdgZHX0KP4szKE?= =?us-ascii?Q?miit+HTG2F6AriZzi7cr2anEGddSxFOqc1Ro48MDUuPdS/35GUEyK1uk12ML?= =?us-ascii?Q?tGABxbAfbZpywUJfzwXdLHrwz8C0AzlVrbbmXLe85ABZKdhoGmYCf4oJZE+B?= =?us-ascii?Q?CQg1hW5/NgLv7lFTQjDKJziqG7TPrr1E7p0Y2Ub/nTp3JEiWAT4wOhHYv2n/?= =?us-ascii?Q?dBFR5APFfQ1mjgFKP4kyDE1FZkpFwl2GTnDTzPhRf/oZcSIAM4/dxWVduLbp?= =?us-ascii?Q?X1dEeRhI5XRrcnENcJZ6Qs4ahE6iVc5na2EhGxV7XUTrLHC6MkruVQ+WIwlt?= =?us-ascii?Q?SmLpvxxphhuma9+G2Jcdq0qnzmzAN91nkLd9ZI5fOBLN/spbdj39DSeSwYIS?= =?us-ascii?Q?W3FqyQ+S+IyKEN7druVP9A3VPiOh+FFgZDoL7Jm9mRHv0McjerBvJUQEqxQo?= =?us-ascii?Q?/MziWVjjRW7L59wm0HpFNkgrLw/p7TQDPBBuZpqDATjkk7sM6SnaFAEziMQ9?= =?us-ascii?Q?5k8qz9C/LMOm8OuQl9DmGU81LaCtODDI4zUYAZ7P/LowcPsemRBzjnGjSg6J?= =?us-ascii?Q?J+k5ERT7ayyKLpzih7l/JzltkuPOmck6IYrbzoHrJQoDKYIr/4FnF6nNN/uT?= =?us-ascii?Q?6qQ6oQ4=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)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?W1kKz28sHjWk0utY3ZDGfglNVR8vUeCRJRMU2NZo2qpC9IHiUIw7XxCL1ybz?= =?us-ascii?Q?oPN4VAJaz8JxMMxX/TDFrghroCcMuXlQOBfa2Fc3fiqbIqoTT/e45y1/DiCs?= =?us-ascii?Q?+4QqSm0TgvhBDqgEH5BJbU+p5P4EFhRParitA0cPjeMNLZ8Kj2jBzShhaI7l?= =?us-ascii?Q?wr69xxDWA+T/wBdlm0q8b3NbUYAbUKMVt88v3efknwO6hazuZZGCSQQXN2Kj?= =?us-ascii?Q?xPYJXKkw6RSmP647f3gjwfHB+4h0Fp2YtwPzv0x/IVSvyO7dJNQys9MpL0/X?= =?us-ascii?Q?6LIuYeiTvc2dVhZt2TBH5SJQXbMhECVgvrWqifde/cj8vjlu3TtdxLI/FwRd?= =?us-ascii?Q?YunZFpR66SxsStQ/xntGMJdj6ai0el0WPujZHTRqIT0kva4e0dChx1QyOzEJ?= =?us-ascii?Q?yt/EmFMDxFZ2mC5K0hMxowlEQHoSAud2SIcyXIXvu4KOXlLwVIzVwMFgq9EQ?= =?us-ascii?Q?3T/bMi38UytmXtxWd8Qqctn3CgxyBoCnX1+TgqMDrZva3L88WGoygPXw9ysb?= =?us-ascii?Q?NZI76S/65cOLn7Z4zLonCKBztaefpTbqjPm6z5DtID84Tc5tzRdH/9i+qGc2?= =?us-ascii?Q?AY3qzm1BLudRSRrHjMel3qG3X+YRUfFdYQEqj3j2jwVf5fdKWlPiimHcF2wN?= =?us-ascii?Q?mUMfEag9gauY/JoCUEGAMwYEJjMHcRhVWiHLGHE5xqA13a5Xq950noC+m/FW?= =?us-ascii?Q?hk7xFxmiB33nxUmIhwOmLD1vECgt8dvyx7rx3VOPJXc5NS0n++Hio3bFvzFV?= =?us-ascii?Q?u9hgpRX0oKo/mVvNa4udtQ0cQWLPrE0K+yGgfU51DrjxW8LDcXoaGNxSlLYI?= =?us-ascii?Q?+0iuW3duaAnAsJxTuQwWTka3Zl2wQwSioU0w2IMRl+I6ElV+QsAicgF8dSEx?= =?us-ascii?Q?Gct7/OY4wre4lihny02qJLVEFCL+GsG+z3BDbrsyoD35hNECPYTMo5sSzPFs?= =?us-ascii?Q?LkWlDwg50b/1oJVYSAwtu4FKfSSz9xS+0k3aD8sIVtYPGllA3Qoicvm4ll3Q?= =?us-ascii?Q?rVFWHvOLOK6G2A3CZ1B8cB39fApLi99QotNdsKhi+dz+ZPzKncV4yp/SI0eO?= =?us-ascii?Q?8xOMirR3FK5QR27QTjPqbCUsah/5xIGh5YSFuCnWbIgOujSnNO6+G6508fB1?= =?us-ascii?Q?8mTF1kBRSIxaq1CSDRlKAh8iqtebWq2TRrTeiETGP3+diAN0JB3n4KYm9WEe?= =?us-ascii?Q?r4MvppMgMtXWAQcTuFC+NNfLgR0EUN/4mTLcqS2ZvqX1+WRKoQQ41qCINvRm?= =?us-ascii?Q?0aW2O3YteQWT9mh9GwxBFNNL5h1ApZgQXfxpVLBiFE2mmbweC/6grWSqkgAG?= =?us-ascii?Q?WXJyhHXo6B/pGadMxPRQ6S0lGbThsRQfN8Am167rFuOboDEABedccdgOx7KM?= =?us-ascii?Q?SWSzoyDK1E4gRZPvbMA8j7Tsnz4XFsJ8U++nApb5yDyse0WGMzMEphARp6ZH?= =?us-ascii?Q?B5eDAF7dCT5vzMFML/1zsve60ZyfTIEXZfKxudGRbJmbdqyEmzIq+QNPH1Kc?= =?us-ascii?Q?/FTdNbWcd8wcYEyCawbvXNj+t363qj3ILWSINiW/+8QSjPa/sttZh7A4GnwW?= =?us-ascii?Q?aAr9eo/Q5GKf5NS/3gE8loDDWAeWYOPrf+BLWITJ?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cecb7cd1-ad32-40bf-208a-08dcfe296e56 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 06:08:28.0863 (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: Wr9f8reWy9YU2IJZBGF0jscsLpm9cZMytNqUe0wJrI5gEfLLhDlzgXh+2qzvFt+kwc9tfjCxdZu/BBbWty/YRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA2PR04MB10506 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 | 15 ++++++++++++++- include/media/v4l2-ctrls.h | 2 ++ include/uapi/linux/videodev2.h | 2 ++ 6 files changed, 30 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..d07869d55a96 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -370,7 +370,10 @@ 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("(%d,%d)/%ux%u", + ptr.p_rect->left, ptr.p_rect->top, ptr.p_rect->width, ptr.p_rect->heigh= t); + break; default: pr_cont("unknown type %d", ctrl->type); break; @@ -815,6 +818,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 +1176,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 +1882,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 Sun Nov 24 08:37:48 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2044.outbound.protection.outlook.com [40.107.105.44]) (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 88322192D63; Wed, 6 Nov 2024 06:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730873320; cv=fail; b=GhzBRe+RI1Y9MS4Xn0hGMaZzB2fmuzkTbn5uifuX0UdcMDj58KbKv6clu9ATy4SkmSiU5mSU4DvDpNyfs+uN5kxLiHbp+DYTf57OzwYcTBkEBBrXs5LRwzv0CzaHAAzJ0o8zXG+l5Bfp6f1+QtU7hw2Mipp2K5918dWPEKOH9Uk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730873320; c=relaxed/simple; bh=faucyX2jhUUN4ehVFeh2YsKNuKC5PYyRuA4f0W2KQIM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=jXX/myk60I6J4MqcvQu4DRIPN3GfvT/QorXxTRiAdcZDaAUHBJl361EVPNn5VzJynOVPk324xZrjguWNY8fmzw46Gji266fr7uCPfa/plUjZM64o6e1rxZ4MlUNBcuedgYDyYRfFD/4MO4T6BYDZfw3G59yiPQOWH45rPODjKU4= 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=kt1/U7AP; arc=fail smtp.client-ip=40.107.105.44 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="kt1/U7AP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q5vd6wMdcZ/sS1v3XgNdgs8criFDSs/+k7SAyJJYqdm93BqWGtu+WtN+75PWJrNTYdaRpNYpxT6e737wuLMAuCS7gGHOB5wb8xLtHJ7OWoXK85weBM8NANbxczyPym/lDHT0PReKch3mzw9h6plFtslEHficwiII2TYlPcQzUVKRzhirdpsWQRFq6O45oK7mTmjDnv9Qm28IdPiq5fR7wCMKpFwYuH8jOHR+MGwH0TF27tSl0tPZ4V3lInFm7pi0D7Fv6jv1UKbwRCgHvi43mHHQ4fCklFtYCEf5KLk6oktUutKBrA1lXY9bWUVrKWd8EuzGAljU02UJ8XOa1qYlVw== 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=dx5lYA0ReCxWFHzK4S0lpN4nFFe/Wfs0DXCctS0XOGs=; b=rJIfvrIg9xw3y4ak9vIb7YAHfvQsaCj9oIXWDbJ/nx8eNrm9wtlb/3jHE0FXaj7mAjIIoRjCwHq/PRxfdasNyudrq3hLEZmC78cf8JeygI4pia3IxU0tQHzSFQX/s0XJkm81kJ2Nrged2SU2PsTRwLon9jgDGiJNT/JhzFjocay4xRuoVkmlhERucEnIO+r2WneJx7Uj0RReokq8tIolTjv9TcinkKTralFwu3ht4Gg6Bu/gF0dX8IkdoLFy2t/P+lQNjvb7GldwVKHfXgJCnagXLWVgdbLxbjsJIdaPDnWR+/o3nIXtpluS3kkDBHub7YXolq6ABFtGVzKEppwYjg== 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=dx5lYA0ReCxWFHzK4S0lpN4nFFe/Wfs0DXCctS0XOGs=; b=kt1/U7APeEQD1sSVi9/C90r/HB2ON8LrgQQOHF7Xxnq6qz7RQQZn6cBwg7FUGIN/efD0W1lQtGj9R4sy2yxEtaugcMVmSsGOw/O00XcM8ToMQ6AfeILCVv4uzDEo7aKta2vv8+jLLEMXrRS6tXlSnln92rgC2CdDdTXVV//1tuODkX3+gTYBS5cEWkBE/Ibgpucyq987atkSKhr6K/PLqoRXMN9ZWUAWpJUxVcgdVn0J85cs6oGDr7PT+eHJCTARowZu9fMXWYRhIb4yH5cNZjaISVQtvJGudMr3wBFUkUW5wJmmkApZFx9bzryCl8ElPupQBPkX7hgQrSCtkjd4hw== 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 PA2PR04MB10506.eurprd04.prod.outlook.com (2603:10a6:102:41e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Wed, 6 Nov 2024 06:08:32 +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.8114.031; Wed, 6 Nov 2024 06:08:32 +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: [PATCH v5 2/4] media: v4l2-ctrls: add support for V4L2_CTRL_WHICH_MIN/MAX_VAL Date: Wed, 6 Nov 2024 15:07:50 +0900 Message-ID: <20241106060752.205074-3-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241106060752.205074-1-ming.qian@oss.nxp.com> References: <20241106060752.205074-1-ming.qian@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0013.apcprd01.prod.exchangelabs.com (2603:1096:4:191::9) 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_|PA2PR04MB10506:EE_ X-MS-Office365-Filtering-Correlation-Id: 4fb15b11-cc70-4d42-0118-08dcfe29711c 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|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?jPocKpd8cT9Si5yJ0O22ngkubVi9dYVNRfCm8FAmN2iJroiI8Fkw3vdZyLdZ?= =?us-ascii?Q?wDuLE2WlB896s2J2uiirEC5LU/HUxpau3LwnsyMLGnSCA9w6u+v7/VzB6MHp?= =?us-ascii?Q?0M19Wa8MMEtADOyCffU18TSnYtOQwx5AMVk/9AP8dcMwohjup0A63R4eOaRI?= =?us-ascii?Q?2ZBSeOMpctjhJOK6PLmdG0OMmL4NFA2cH6UK6rSwgVK3mxgPZZkAz/wImb2K?= =?us-ascii?Q?gr2mziZeD30lzO0iV3A2mdykOnnRXBQ3A8BAkW+VCpxY1UpC2WvCC13iQH6n?= =?us-ascii?Q?ONSi1HBj1PMZ29IVkPX5l6Sq5LfA8Zj29LDHl5fiJm02B0MR0CoW07Xsa1mh?= =?us-ascii?Q?Gq05UaWKYQWG25uNUeFoPIB+gr55PzF9kTdzfEm2YBtDFc4QOeWF7jYAunUB?= =?us-ascii?Q?ucJGWTHX4IQDAsOtLucK2cHrceuBT13Lv5k5qv6/5MKdSoekTJAZIUZs41Eh?= =?us-ascii?Q?ugotT2fFnNawFhjUSOWU4o5WuPKWLr0AiqZdoRhh4p4TfK6FbvKGyHe/L/c/?= =?us-ascii?Q?uQSbOYubGGX0KK3PnGGsugCaxhFaAzh1jF1eBIwSbpDZ2UqK7C5y1K3U0xu1?= =?us-ascii?Q?Y14wMaYsqyYM3FqsV799yW5sLtebX1OY8z1cfX+HSvvjlvYgdX8NR0wxdN4I?= =?us-ascii?Q?f2EvLn4tJlWamtqxLsw2tdpp1HOC/K1xjckW8/PkZLo8bVeHCrtJVMyGjwXD?= =?us-ascii?Q?kmEVu2Y5/9IRro/MXEb5JIyYmnpjZfKt9IYFmgp2VDuYFuPa6kZ1aRt7XUtO?= =?us-ascii?Q?n8flBNkt/hHJL0Cd1ekIFtm2f3odFWLj9IibFeG3ug+AXKv+cITAn9othh7w?= =?us-ascii?Q?/Z9JYL82ha6dwjD2H3eTWzcGJYWXvHdtyQc0opVSeex70wRAqQMbNVyBHg/R?= =?us-ascii?Q?Wlgt37+1MdFHvVmAEoc2ShV2qSjjDTNb1cd8/cirhlJTrwyVQ7hpfZrU8VBL?= =?us-ascii?Q?nUH1D2a9dU4qI6sq2aGPxrSu9gVZebCFv5LDtoV95E5rbd83xY/v+uyEePCo?= =?us-ascii?Q?XjP9p5fi/g+lahLGjWbNcoqGID2ZzNlWZgmV07FrxVVYNSaKfAOpi+Ue7Kdc?= =?us-ascii?Q?GY1CVfVLVoiTYH6NSixGHbDtoX/1ANjMfNuZylnviMbch2zzIXvoSeT8IHe5?= =?us-ascii?Q?MPa+umi4l2S3Q+2It7u4UMRae0VYwN5Xq9ZLftlqDm/qVwtTcfKD+0UHS94Z?= =?us-ascii?Q?ieRn/q9xTVxLrzAz0sfaIQr6Z/N8Yb4z/PN1WRV1Gk0/5AyfNNYO8uW8OQmf?= =?us-ascii?Q?IBAU1xPMks14ytLiJQMnyeG12gNER68uo71PIs38VMC4otVdB/Y7kBKsTG7x?= =?us-ascii?Q?iiBAeIa+1c7NlfocdyTF9cjQ1JvMsg6m80rhsO43ogAkKKjwoDmLoYtadVcL?= =?us-ascii?Q?/ip/CUs=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)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?MOfmwydFe8td1l5xg2qNH+Y2lSaL3KdXCcx0O46wjoYQ6LWzickC6JWX2Udc?= =?us-ascii?Q?geeV1KDdYRIXR+3LeMr6kQY4IQ56Uenc+kn+RvJJ3zPWJDIpxMsFP6qYfMlq?= =?us-ascii?Q?Hvy0dDitO2qAAq7jBshjDAfnu8zAUx9KLnPiWPePTNc5Y8MHTmRMZe/UKDxt?= =?us-ascii?Q?nIV0wwXXJQ1irStTX2ITznw/mknK+55l/O7JQgDEMEqetP3svlw+06vQ4rft?= =?us-ascii?Q?ZyeW/Am7YjajaKXf1xNd7x7QYr+vVWj8nGvvpNsbzwgC2XioTW67/FcD8niZ?= =?us-ascii?Q?aRtSUBToCMX8JXBy7izc96LoVZ08BojXhV6xVqN1pbRvhIpxQp4o0aWCbj3Q?= =?us-ascii?Q?vjweDbZ+JvDSiHy4+6BZWbu7JBf/5l+Ow7BVKxR6ZgTc10X/kc3zZOLrzHGN?= =?us-ascii?Q?qrgsmbLWcPL7n8CHoa1giDcgyPfRjnsb00C58SCj3qw7TocElBcBzYzfA8/u?= =?us-ascii?Q?eWbrgCCgv3tVhNMkvNc6E89uqC0sIqYQ9qK174J7YFlkih0sFTyER38aJAHT?= =?us-ascii?Q?zfBFn9VmCAiacz/AvnJ9b0VioI3zOjX7Khi54Rt+HOzZLoL692b/BNHUKMBV?= =?us-ascii?Q?MFhRDQQc/msvDo2An8uXrIbba7n4lY0Vd0O9PF6L7P0U7zxulACvxmuyX0+7?= =?us-ascii?Q?KlDKJT4/AFiEbxpbQZnDoGeggcRBqprANtlMSKomzfQXB21FztougHaYU6p/?= =?us-ascii?Q?0frzJKGOuzBPFnRYPHSEC6jl3HvTcyWZjQcIJlM7zsUSeOD6F1FmA3qZnH35?= =?us-ascii?Q?YD0BNyYOY4MllCy6j4EbkJt2gRfTwF8AUhgQkmS5XvaF6XjnUh3a2XQKApeJ?= =?us-ascii?Q?tH744uETrBZafWM6lupTGU+zU+uh5QpxgRCPb6O/HFP7AE835XPHMGYxfTM8?= =?us-ascii?Q?SzlKCErfVaPmVWGoTr7M2I1v0i5R9tWvTVtKyqSHaP2IS406IqAULj7KVvx4?= =?us-ascii?Q?kqGZ4hmBBNs/T1zbDEAxZNL5wLEudVQr3LAcdvoQlBw8quXms2dvWnM2xOxx?= =?us-ascii?Q?22YGH6aIJo89XXZVpxDKjW7c1McNvb3UQiEz1H3QVNG2SdGiI0UAmKv0TjbQ?= =?us-ascii?Q?JdUjJm/5UX4fFnyFMzl5h0uRtQMIY5NAZsLKsySFSjKYB2gmXfN98VulGjpe?= =?us-ascii?Q?ts022s5nhnn+1gZ2+0L1kDeDWTjLNwGYk0XnmHVOnZl0avQb67prQhG8UBHp?= =?us-ascii?Q?rWonkmJw4hsk6fdBzVLtWHGKA4MI0YdhKTKsRUukXLxb7E06QNChQy+3HVTi?= =?us-ascii?Q?SB1d6KQ9CRJjv0lHQrsOMs6EW7Q0ehmvqUFZDAuvezhC1Q6lNJOOL5LatQ8g?= =?us-ascii?Q?omE6HDGs/1Wz+MP1vj+Qj9aN+poaV9FVshXu0/+dtd6w/B54QeK61mhZm0UM?= =?us-ascii?Q?wGOvju6764RmJZWdL0r7BMyB0jimXWuqVqldeBvoS3VrbrJ3ZbZXX5qza3iV?= =?us-ascii?Q?Fo+iIkHgwHW6e0OJhbYyBiTTN8JHCkkSjQ75wNVBxYXaMqTAr0QvYMuGrflu?= =?us-ascii?Q?v+ZdKyp2CEJCY8JnYt4SfsrRQFtkLf12C+2zkZbYiFN2xD7S80AV9ybyQkx/?= =?us-ascii?Q?8P1FTFlsxP5Pg0BctWqY/Ah7fDL5BsGWnJYKGy0c?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4fb15b11-cc70-4d42-0118-08dcfe29711c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 06:08:32.8050 (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: EfZhYE4ShwoXfmLqjemoE+6acegq2P9i5kWok6savBdm6/+NYxJuj9VJ+9eJigLqsRQYHeIc3Cmrm5lM9dr43w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA2PR04MB10506 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 d07869d55a96..47455a649523 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; @@ -1295,6 +1361,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, }; @@ -1767,7 +1835,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; @@ -1891,6 +1962,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 || @@ -1899,6 +1976,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); @@ -1940,6 +2018,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) { @@ -2005,6 +2087,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 @@ -2055,7 +2153,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; @@ -2080,7 +2179,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 @@ -2113,7 +2213,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 @@ -2145,7 +2246,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); @@ -2153,7 +2255,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; @@ -2167,7 +2271,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 @@ -2191,7 +2295,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 Sun Nov 24 08:37:48 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2044.outbound.protection.outlook.com [40.107.105.44]) (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 546081922D0; Wed, 6 Nov 2024 06:08:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730873322; cv=fail; b=Z2JD6BNBRdSbWi94EvyZzbAeXflje2cSqJxi32ps9IVgiakWFdJP9oekCNLdSZjI2nzG4eRSKMV/tlAmgiNdrUNtztd4L9BL/LHqgOe9ozpo0IeQeivfN9vqNdqtBw7Rl+hP9iHEZR7eVlYCdKqb56+eOJe65DZZHaz5Qg2Ets4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730873322; 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=f1kZuc73GcbzL0rsNrCk4bB3LF/QZR6b/kdgnucxijibpKP5zakn2FqKiu2UHRK4g1uFkAUkfxtLOddlVW1QPNPnbgNgESeelwwKl91q6/EDu4h6sfPibPsmGpxoWP9eGBHWQd7btFVe8urh7Lw3Hn1ZE0De+bBIlt4JQmgYG08= 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=aZe6zRz2; arc=fail smtp.client-ip=40.107.105.44 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="aZe6zRz2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gdjw9ly8B8kPyf5KH75DC9CqJU3feyB9uR+65iK9X6is44tfPsccYZvRIZjsOJ3inG8J61scZwgKRoHeYvluMJ/Q4tKU5B61vVHeMKSugLX//cIdJW+8ZAvyIElA+5nq/SOIlJIP27mZqyJmnFPCLcNHyrrymSGAJKAvnx4gvYSu3iurb0mO2q2qmcEzkALphgTWNdTAazckVww7pk6d4UKM3wyzgg3MEXDAh1QiS9J4cajglaYBgY517LHZlnOs3M7OGzqVDEKtcBEhYq7nk9bkAZVpgcrevLllvLx77Ih+1Zcyn08jzOatwdHroyJgC+Nljexrs6sJBHwc36j8/w== 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=nPdiPrnb8fon063dJIfc1eAOfer9ip/d5yi5D2vhUlFODQKuEmje1BYyUxMp2EkITK2RoVxDNeFNMY95uMkmGx79duzn8JlUHdoJJdfuZuJ6q4VmCsXX5hvV4p1myGErduBrrlTDYianDap1agRqGgZlsMdvPMfPHyNl1GKxghrzJeiXJMWl3qaEq0VBePVTPQmtA5hkFS6vO2JeLM3ACLAeqs1/jEHOQPeqEBkx0iB7OHHeD4mar8mL4PcnzUaiZBxUKd0jT88cnza2y2Fsm3E2EJB5cmWyJHnaw0AcsNUrztNyH7FhX1t22vXY4TfNc2R64xv7TFtyi4xUy+4RTw== 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=aZe6zRz25BnyL99xSzmk4gbC3Zhw+b786qY4Z+bwaRQXkl/gbN1xWDwNjjQc4WWcLbE3bGnaSTEApS6r+04PtFCA2epHpDP3goymvtuj3mqapmhSomU3K7uX/tafK57elDpXZIe3rHPsG95/LpANT3IVPf6XdWSo8mMJ1ms8iy1b7/EBZbNSXTwb7NSRaUFtd6N9A9n+5hd1XYPKVUFx9vLXcx1ph3nm04oZC3/COn1Crbc3aezgTkD5QrVmK1G1DMxskJiLADlhaKgxn9YUGWcw/S7UGOXlecLr20exTY/aiQNGokQlhp2WnUKr51GLnLF7GdLR04PZfgdUQ2rX5Q== 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 PA2PR04MB10506.eurprd04.prod.outlook.com (2603:10a6:102:41e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Wed, 6 Nov 2024 06:08:37 +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.8114.031; Wed, 6 Nov 2024 06:08:37 +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: [PATCH v5 3/4] media: vivid: Add an rectangle control Date: Wed, 6 Nov 2024 15:07:51 +0900 Message-ID: <20241106060752.205074-4-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241106060752.205074-1-ming.qian@oss.nxp.com> References: <20241106060752.205074-1-ming.qian@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0013.apcprd01.prod.exchangelabs.com (2603:1096:4:191::9) 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_|PA2PR04MB10506:EE_ X-MS-Office365-Filtering-Correlation-Id: ec54c818-56e6-49d7-7dd6-08dcfe297411 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|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TR6XBap2c8sgr9e8Tlfiopmx7iADuAnYFs8bOlu8sgbFZLzLSWJkKTKqMt+l?= =?us-ascii?Q?nfnXByzW93bKazwnguL0OzyKHyeT98nb0r/VPGS4KHl/gLid0rNM/JOmkNHT?= =?us-ascii?Q?0sYX8v5DdBSbj4cLmUQmepgUagIAFZyLnXcwUikoyD1ijaeDnu9PgmRPpBPD?= =?us-ascii?Q?1lqDD5yZMwgw8XJb1Vzz7OewyZmhWW7vRb7tZZxfslMwci3SOAZj5vkizIjo?= =?us-ascii?Q?XcXnYt9qb8pFLImqPJcAvof0nepifMFeRQ09DA2pF4kOAUvtWEF5U3MctPkx?= =?us-ascii?Q?1y7bRteGbwWk3tJkEd574bSAEpfzTQOmmk7FuZB+UXfPXnY7J50kG2gPpmpQ?= =?us-ascii?Q?0nfH7eGROshrAcuBJ+3+sSDJGUHUmplcTQ3Oge0M5WVTEm1aFKi74Now3wud?= =?us-ascii?Q?hWIutkJxELJYKku8fLdvrfTL/1iyTyHyeh87yOlTBB+gtqvZWu1bdy9ITbkK?= =?us-ascii?Q?Zh0xjV2kqyz06FvDeVkqP27GN2Wx+eYgFogJkcOKcKzg8tM379c9fSE0rYni?= =?us-ascii?Q?rQH0bzqamd8VEAOc2NdQmQ431aPRbuX8NtX0Nfzoj2iluXDPdQbDQ4Yz4FdD?= =?us-ascii?Q?geY7bADN0Of46VS2SCi2WcnOGKWUoG3gGploZBniQBRHW2EJ1L6XZS1XUQJ/?= =?us-ascii?Q?e7aa/QJKq6i+pE8KDskkDKZqbFVsCk5bybQ9aR4B7gKI1k5Og7rJ4C+c0gfR?= =?us-ascii?Q?svn5RLh7zArCK2WFye2PMRvoTiVNehooORf0X4cmVXD3Kh0pMZsszfbyb5FH?= =?us-ascii?Q?ZhkFgK/nD48mh5CODFP+TNu1+iZttAmV2nbGE1B7vj0MPiIrtTYi9DFOnrm/?= =?us-ascii?Q?ny8Qvnp16w9+Kh58SVpKxdRmOIYn81rRE7DP9t3yMQIaQ7GWp2owiesEgEzE?= =?us-ascii?Q?xOou0vjECPm4R75Fe2fSlkj6lzs3ab/i4tWwrjE8pNrgARCGeGyhVINW166j?= =?us-ascii?Q?KLtMgu/YN1moQ994C4uYXQxiuvMfLBKINWZ9vVXpr1RK9kBa8r44fq4TROmM?= =?us-ascii?Q?UVA+wMKKcNL/k5fUDICt5Ackq/VDODSr1pkipmp1AO6hfRyc0SAdmW2gmhb2?= =?us-ascii?Q?JGZfrFQEypYVmENJ+ZP2HTMAyu4E7SMTIafxtVtUBLAP7suGD+4JFGicQzGN?= =?us-ascii?Q?asoORwyijB0m7qpxjfwVa7PDF1qaYeOrvRr5a2Ixt6E8D3jIamtMaE5nLAJo?= =?us-ascii?Q?WKYCcVvMdV6RbrBuWPD3P9fa9MQLGSfo/JpdD0bIO42uwn+lBdDSqprNv7jA?= =?us-ascii?Q?NUVxhC+OFot2Be7lyAfxWeTuRvE/IJzC16dEhfOI/oLQd1BKSTTWQRyP2axY?= =?us-ascii?Q?1Lg6xgyEWcZBW7T6nIJykA4+eQsyLxGTH61ybNm+xPHnPRDtrkXVHLEnKCAk?= =?us-ascii?Q?wymyVXs=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)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+H+MkrcnwkQdXqsGYqHwSnjGVVKa428gP6WIsLnddeRg3o/HJx2CcmFDVfxz?= =?us-ascii?Q?jvFPjerJAqj1cmoWlufxV5Amz5GM/xGZiUCiiAknW8AtCf1l5mkEneoJpyNA?= =?us-ascii?Q?wbuzYkLRT4m0kikcXqHBAH28b104mwtg2HE9gC/tKqH7WpGUAAzFMFMxdW6w?= =?us-ascii?Q?Hi6TDEdIabC/pLQOo88SazCdYINASMnBNUJLmQ5S2CuruPD/9htMyCZsQNXh?= =?us-ascii?Q?2MLzhlUYugp+CFee0XbqlCHwkZMY4e1h55rzhwpb7qcOpU6Ylv60RvYh9iDl?= =?us-ascii?Q?auCXbVMMye9I87FqicsSpQC07VG7PmDJEqBoklm+ns8TZzSycb+DwVIDDnvR?= =?us-ascii?Q?cH/PuI7CgRAm+/X+hyIZsV35+6ojJKrfTYd3dF14aTmf76IDs+i664j+dBqJ?= =?us-ascii?Q?omvoCXmQMXSwWEcUgkZXysdqFOGaqR+070g+PxyZIHCHkxWxKbf4ql+oXFVw?= =?us-ascii?Q?xKZCPVmxuixcQIGGJpzP33VDCwoikc6MksXZO6krzr4Dinxwxnuye3Gz8nIz?= =?us-ascii?Q?k7WXsJue9gI7ZsM7Kb11Zjc/qaGdV6kkkUxn5ytDwHox/3j5SX8cpfphhppO?= =?us-ascii?Q?arF2GKG9iY0E7fwVJXf0IK5bbgE9V0M8tNXdBmggCxmsHdyu880cEaLgxdhZ?= =?us-ascii?Q?gECteqaqoLrkeY+1ENOkPuYpiCkITebTCYmmdMGGSA1SyggpBejkEeWD0dz/?= =?us-ascii?Q?JEiDN9De95sbGSmYtipr9kbjpBD9g285LijrZA6g0iF1xPRf2BV0+m11Hgc6?= =?us-ascii?Q?KZWuD83MMnvkipbpNZQJ00X2aB+pvVNA82uV6clhd7EnY0CNcAgeZ017jOFH?= =?us-ascii?Q?GAhXLNIVeBJpKdvLSuRXiBmF6yJUI4f/uGMCHdoKeLB/07wrsyPBvWNoC70l?= =?us-ascii?Q?Py2D6lsBovvagcm593d1YwAYix5TyM1t8wG6EL5c5jPQj/wQ9sIdPe6Ay9UG?= =?us-ascii?Q?Shx5KAo+0Dqv9dWiWP2ltTaoBO6wCeyQde9vRi3s3H7a+HFH6eaE7hELuA/S?= =?us-ascii?Q?WyigDAjBAoyrjjpi0UROgUs8yTNYlA9td5s6FRO9swrx3sW+95/BxUhqJmzM?= =?us-ascii?Q?5Q5t6F4iyFd4cEshLqRniSqXDR4ZjDTJqVEwtBjtZKg4MXxAj78qTvRbzA62?= =?us-ascii?Q?wlwz9F6aKHg2haZYSBnCeQiRbdHJ/uO8AWTpLDbBYaHv2JmRIE7sOaMpiMrl?= =?us-ascii?Q?fStMImmBIRMvRuyXR75pdLL8Z5UfncfBJUoygvolat9SorxOthxHJWmwHZDW?= =?us-ascii?Q?KVYeuvEDroA7Kv5k4N0tkvaOz7GzCAfrJy02/kcvxdpuqqKaH9vXzA7GLXDq?= =?us-ascii?Q?RjkwcktYvgt3VNbNt7qxCLgacQi7atdHYAkJaMoHhkmrEV4/8V6x/p1+vLSr?= =?us-ascii?Q?+lkXycXlvrYfhtGtlU8jzmFjcREh/FCmh4Det5FA0vwhLH5E0DlBXHjiqA33?= =?us-ascii?Q?sVwe5kyClniHKcot0rWLtm43SosOPZZZo0qV0YHPdz5W9adnWLeREELvJMsY?= =?us-ascii?Q?m7tUnwAjiHYgInlyxGvOVCHSYIEN8n6wWfZ8C5/kC5HhCE+NTMhK8qwDjTk0?= =?us-ascii?Q?CreY/4oW5GoT8a17E0HCxNjqn1I+trWWsD6FiQfg?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec54c818-56e6-49d7-7dd6-08dcfe297411 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 06:08:37.6056 (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: FLLElCa8QRSa5oyt5D92HInnt/mjGbScv8kBIRY63b7DTAUnqJ9aKVu6O3eMagfmh8vvum4POpP1EFAfqoVoCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA2PR04MB10506 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 Sun Nov 24 08:37:48 2024 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2066.outbound.protection.outlook.com [40.107.20.66]) (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 6A2291A2647; Wed, 6 Nov 2024 06:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730873328; cv=fail; b=JJM1LUHpndPobsw1FhT0cTk6SF+vVBqv/399qyxLcp7OoKPr7D2VrDaInmqwLzNXywb6JMr5zT7kY2zu8OvEhfFMgkXPQyVyfp7JZ9OyvLoBvp2nJEj6NAvAMPc03/Op8nEycCnn17hwxcHvlt846GsOReSeSqDp7b4aE/B3ROI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730873328; c=relaxed/simple; bh=8TmkSyEh8mPOvw8vWrXALSOqGcZ1thlhOQ+VFpBiQqc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=icp1+xFCC+MFmPZGOnr5RfysSsFZCQNEfZyyw5jpVkz8dPVm3C52POKj1zKAP38s64w+R8z6HVQeUFFHd+uD7/I2z0Lzq50J2352k+hTsveuz0DQj1LpuXiz5oNoprIMRhhJ6JWYUFQdJF/Rjj18g/C1L7VzaqKri+OtsWPhYyI= 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=h+0gmSrD; arc=fail smtp.client-ip=40.107.20.66 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="h+0gmSrD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MzNsBLwgRGU5cWh3EtpR9CK2+BI6PcFukH2RTREgSKCUhXpRMihjbYME/CdmBDuOg6n803IbOpqviZMxuEojj2isFxi5B0p4vqLwYw+IVdye0R6tq2va97MzI7zoO43oLBpGU1qU70pIhfHpnVlBv48TbK74W6psxRD1pMPJDqpZ6H+OK8+ig0d2Q4y37Rq+nTkSEdOuuafnGebGgi9wgM/owQ1TOU2fQ9g2Rd2pT2UT86gOgJOr5lEgXLa9HNY18VKDAvd/FAv9Kmsfcryq81pyHL0DavwC6N594u14EKhXpufFHoikOQIKIItTihuqsJFB/IpAdNvJ7syUswQk4A== 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=rprtpvc1zdDrvybk3c/IlucgvRa5Vsy9qlFEqM2UhjA=; b=g2Hp0r0cd9j72tDI7+tHW69cPTm6bQiFvDpX4t8eEm2n9B4HX6hJ103HWid2yjPPawOdhjXEpyab24fXCkjLg5cg/km+Vyw6HR9Ue3saCM4H3jXGQpoXLzsuXFVEwDBjMKLIpdq9w5k1SmjBC8f1rAfCaqocnJDGAq3/vMNSW/V8iGnHXrt3yrUs2p2ZualyBZnyKvXUqr9xKGn7gxtYR3Mv+x7jeM6U9VGNcwDPfm3NKwWzKQpaMWrJBJCNgeYbxgYFURbCrBmpa+zqRRu64w0xj+wRjEPLgGv9gaHZf8mPXMNfk5fYHhmS0CMmATDR7cHwLGyVthzuX18xWed9Pw== 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=rprtpvc1zdDrvybk3c/IlucgvRa5Vsy9qlFEqM2UhjA=; b=h+0gmSrDNljGYVkcSbTK8PtWBE8Tgy229o7HN1trRFq7KJRtdcQFKdw8ZDuPk7QBTHkBlRTTmvbUp0Yj6Hb43oTNbAd2LoJRiNZETCzcfjQktaEvjZ0f6BMW1au2V5LcFs1nNmmLVMW0QJ2pl/8cKco9soE2TqNg1FUcEnW21x64r+XN4Ix5ZJK6foyRQC4ffbNHpm94tCp29Kljm8zznRa4C2x3Fe1E1gv0ChRzFh7+70IQ202AV7sCF1nWvQADEfzKYB2F6GGX1XZi85bHf3pYOnvhIbFVTl2E87y1Qa4YHyNRQiaULSXtT755+Erd3xanBKJIJtBmumnk/mJnEw== 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 PA2PR04MB10506.eurprd04.prod.outlook.com (2603:10a6:102:41e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Wed, 6 Nov 2024 06:08:42 +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.8114.031; Wed, 6 Nov 2024 06:08:42 +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: [PATCH v5 4/4] media: v4l2-ctrls: Add video encoder ROI ctrls Date: Wed, 6 Nov 2024 15:07:52 +0900 Message-ID: <20241106060752.205074-5-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241106060752.205074-1-ming.qian@oss.nxp.com> References: <20241106060752.205074-1-ming.qian@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0013.apcprd01.prod.exchangelabs.com (2603:1096:4:191::9) 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_|PA2PR04MB10506:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b8be844-503b-49bc-6b40-08dcfe2976cf 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|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Nj7mKANf0/KR2QjzXzGgC9+pP7eVXSQ2aHZnQ2Ts2ApbTI46KRcs0AQOKUJT?= =?us-ascii?Q?MLpcE+hL1yTtcwfKh1nkAImFtw1RmHbjtbIuvnwKcjG6G5hT+kkNgHS0JbaP?= =?us-ascii?Q?UOP+Q/t6nMHgNEwxMADkIspgVNmn/7TeNj88VL9oiIVw5bXmMP0lW1somCl3?= =?us-ascii?Q?37U6C/oY7U1T+urD/ksajX4lAg1sqYyto6eczw93uVzr5HQ0VYDjRQLb5Tt+?= =?us-ascii?Q?PThoW7JLiJmTGet0yEgnqVZXc2qg6HO68J04b8Nt8JpzV8Sr05O8xzbSiV/i?= =?us-ascii?Q?75zJt/XlxesHNeVm3qVDcVD4jkthUpNvFLWP2YsSyqFh9hEmqoy6m5NxJ6tM?= =?us-ascii?Q?+liluFf/I9fgqGCSA1CvYLDF5ptCGs2JFRBmDeHuS5rm7JdPCeD1maE0JLE+?= =?us-ascii?Q?hunE1KDVPOseMb7kzHFSHsXhxchkwJGY7sySQe7cNG4tj7ut6nqBe1hgd3nR?= =?us-ascii?Q?DRUW0wZFWoLUIENs2w707WQUh9m9rFIP4IkO6q0z1nPnyjREazbzkuyV50cw?= =?us-ascii?Q?IpX9SeJsXHg/8nXEOY89RMgVK21gBc9fNB5WUzLEczckDRa/lelDYDpuDvjg?= =?us-ascii?Q?gQ60ejywJIFB/g9rzpGegKrGO/tKNU58V5iTZ6Kg69i5ZFc8QiUD7Ky9S+bq?= =?us-ascii?Q?TZwoAQYNUNr/6M6bt+3ZHOdJovMLzUEI01C4BS3oXonbha4YhlnuhEQPKoV6?= =?us-ascii?Q?mUxzdoDq87OfBPBPCfOyyc2cB2zPt/WJJhoixP9KN8ldBBlVz0zG7ulLqd1L?= =?us-ascii?Q?N/QCUQcP6B00qFpI31lEULG7GRL7MI4CFIrBMv/IQxcE74u9yrj8LeC4Y6P0?= =?us-ascii?Q?Zo1SzOa/60S9QpnhQOuk2XFj5MiCviZ6JIgW3L46yG39e9EY6iqRHoKrbu9N?= =?us-ascii?Q?xjFuMtIpivTniwU1wpdI5hKnng2ykZmtCHlwboL+uBhVn8jPkOoVpRRItSvV?= =?us-ascii?Q?A9mE3le1sK33EgmLisdXUTC3sKsQJojR29VLOeWBdYiMRt85jjCm5f6CYxq8?= =?us-ascii?Q?1DoYxe8pNqEln6RcqkhyDDLxi2cvATxpJl0hjDjWZhplsR3aWCMlZmQnzB0z?= =?us-ascii?Q?vPQ235i5HQiejIMafwS2qr6u5NbObKcU8vNVkm/P4dLrT1FgsKl2BY5Qi2Vx?= =?us-ascii?Q?6x35Hux1v90IFmiuaHXpnYBmeyF6tdFsFakOC3uPn8aLW3oVAtRpxlSYUBV9?= =?us-ascii?Q?R4Uit5f30nYGT+i1LPJkZs+tXqq4V/9WzHYNyPMANTOYK65uXwvCvaV1wUpI?= =?us-ascii?Q?+PLABim1+bycQgL8Y5x8fWgORRrRrYxqXClBau0Tyj+/HVVn+AKqImjMI9/f?= =?us-ascii?Q?ziueN4xShQ3dAOCnZb+T9JSyOljbDQsY8Rk52Vqisi0kVhmWt7986egjgrGN?= =?us-ascii?Q?Z6wSlIM=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)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?o+Y3NiHgveFHzmiz1jIMOHCgqSK//jt3i9HymrnQ/Jk3rGz8ypFjc3J6h15A?= =?us-ascii?Q?AWDlb4XqDXN1YJardz9TZXCkueQ0NSVTRB02lXlLqTYVgFNW31P5i36G2U1T?= =?us-ascii?Q?i2zH2NnwiFfT5mw7trDfYuTP307y+VcCP6XE2hNLT7tblpCoqoGxKpv0K4JL?= =?us-ascii?Q?NFt2zck7E3HPgVip5E+hGM6DRVtPEFwWggX9z8JI7c0XQKrhVAS0jZ5mYSDo?= =?us-ascii?Q?j96dnMkJRyVO7VfTIl544fRZhQ8JxpS6w6eB+KIL+iTQn891HGb9rVR+XvXF?= =?us-ascii?Q?+8n3iORS50SVs4bSLwHXP26m2vwj2YnEt5SnDzBqIPHjaVMLr0hGPuGo31LM?= =?us-ascii?Q?ucDe3IghmMYgYV/8LJvcN6HJvNTv8yrWhFtosee9i776gqENzOPPMCttf5sx?= =?us-ascii?Q?RFydbL6RgiodkS753uz4eG+c1nfWBZDDwf7YxrirYwEFM/qDQxnQJo0zdD8f?= =?us-ascii?Q?jMtHRkOPtGZSTwE85qQMGLdpB+7EM30SDa8tKsld4/jEPcCwCHDgTFB90IFv?= =?us-ascii?Q?UiJEyxsrei6oEtSmJVHncY7IfwJUhTBK66V68O3obVBXqQp0R2mnttjGNCdW?= =?us-ascii?Q?LVyAl2EpBvqVT7cLU3ZjCfJTlMTjGR2ewlsP8hU7dJcwU1ZeY6PW4NC2jL9j?= =?us-ascii?Q?MVaS3YmnK8cYcqrUwp1Ws0aspuXw0Ua2qfRqK8oqHtce7d0lZs0ASLwalBrD?= =?us-ascii?Q?FkGzLKTajkwpDX4UiWPM2PwXD7bO1Ju3+h+pD6dQYjCkSD7vWb15MZcqDljT?= =?us-ascii?Q?DdWbajeqiRFV6E2osWR6mSpdr7FI/GjK65yQGwltWsPy9mJ4eh9msOWIgWSR?= =?us-ascii?Q?ceUy0sMW6XjLZiISDxi77rD8m/nA1APlNmZPwdimheRppro/TTP6kzs//aUm?= =?us-ascii?Q?aPp93E6wUEdWxMBfHw/fjzQIgaWzApHsYhERgpeSUkPB3H9ATm193lK9Ebwp?= =?us-ascii?Q?zIEl9yPKB6+BvCNF4JcQ4jOQBsWmJlD5qNf4ktfseUVVkTscA7vf7WuecTA/?= =?us-ascii?Q?6MK7dI81W7vAgjTZb4RY4A/RfIZ6vXaBglTg7ocMmrall4kDZDmYyWrnOIPj?= =?us-ascii?Q?TGz9UiKWPT4u6xDcBl64TZPjsyRTExPB4mh/YHmeMKnJczgCK9sIgMW4Hypi?= =?us-ascii?Q?Ng7GiGT+EPYVchFB/ulcL+A6gf0nVDc+n48TxlrsZiPJqw6Hm9rzk1u8JT6r?= =?us-ascii?Q?9Fh4D6GJe/VPpVQRljDL8E8uF5p/2nOmJ9XwSA3eHUlTJ5XagTn2CZO/g18P?= =?us-ascii?Q?tMRPgtc9NU2TttqjyHRRhc0oHCBPeEu9Ff4iVisTdCGQQSoYnrqJtHTnb57G?= =?us-ascii?Q?WPzrJQ2esOBsBHE62oMNLzcs3MrWBIUqBPeShRAlogzw+W3Rfd7aLFQiyU7T?= =?us-ascii?Q?Aj4N4RUctqmUD3lQvch2IhWKfncEa+9X2j8VVRaEIxNBYS+xk9gFf7qfbzc2?= =?us-ascii?Q?qSSh0MYtdmw59InTsfUWk/HV59tdQ/p/3fyH6eKQ72iUwOcRy5DP43k8SuNd?= =?us-ascii?Q?p49vZG2nf3NUI79r+sWAUaZUEmeermkf/AZrTNgeUcJ9W4leoEJ6GBWsnASg?= =?us-ascii?Q?FZl0taiMvbGnLyD/qJbkD37qnfGDyHg9hUyspmWY?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b8be844-503b-49bc-6b40-08dcfe2976cf X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 06:08:42.1963 (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: IQC8GSM8d+UlOgJn0P2/BPIAerAP3I4XrXX2AVcduszmAl6MQnF6iuW5TlGlTYbXOaSHb1dSboPUev4MpaTGsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA2PR04MB10506 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 | 136 ++++++++++++++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 46 ++++++ include/uapi/linux/v4l2-controls.h | 16 +++ 3 files changed, 198 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..be0ce3e2f081 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1667,6 +1667,142 @@ 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. + If the rectangle is outside the frame, then it will be ignored. + 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 the array sizes + do not match, then use the smallest size for both controls and + ignore the remaining elements in the larger array. + 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 the array sizes + do not match, then use the smallest size for both controls and + ignore the remaining elements in the larger array. + 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 mismatch with the frame resolution, + the encoder should ignore the control completely. + 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 mismatch with the frame resolution, + the encoder should ignore the control completely. + 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