From patchwork Thu Oct 17 09:19:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13839677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51B44D21268 for ; Thu, 17 Oct 2024 09:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kAK5fhxZzM/TuoFldoTn4hT+Xpwz+9b4vQrEcZaryiI=; b=DD6v+BAkBX4Z0AgvfxUXmVWopV orDNQzVI4d0H6WxBOeSIEVKJAXFGHrnQKU2c605C9N9bZaOCGoXKAkCu8vNL/Ml59h3T8QkkRl4+C YULCHYY3XimD3nqWELm4EMlqqrr+HXcpdmmKZIEjewDspxKcyaNq1BdAhy+SH0eMk0yldHHLGcSDb 2MNr76K8w7eXmbIop8EsoCVyEIDdk3uoAn5wMu6N77YPfuGd7o23nQEnT/39sZBZBTJovM5Tz9fRa IatSP2cXmDtQsptTolODfki8Sf+RVJCynEMF3ORjMq0+tBGTBmpJl+Y+eh0Kn6MPUaXLCmLhMQGwx ou4kK8vA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1MjV-0000000EKQK-1fFx; Thu, 17 Oct 2024 09:23:49 +0000 Received: from mail-am6eur05on20618.outbound.protection.outlook.com ([2a01:111:f403:2612::618] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1MgU-0000000EJYk-1AbC for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2024 09:20:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K7EGl6PMsf1cXcUpG6q5wvNPUXBRoWcnzuBbSy4bvrE5D5U7MYZS4gTyxXxPuT9dHSXurFfR1iZT7Uv5tcNBh3XQ+7mo9lkGgI4yputiRFI7xtfaA0w8T8KA3djf1TwI1oDpZYVGE76JTj2IlLQITBgxb/yLXzcfwcWXEYE2Da2IXRf7LUquWJvSZDVftEgrttDfDUgJg4N3AHYuyFaWz5kGhkstKNw3H6rPxa0eqCsuBiZvEE6s/u1r8lpPvwo9P6XcwlBSqcI0MdpqaxhmHmBxccUFN9kffbbmUewuTrn+dKcvBAXP6sw139B12bbzKrQsh3MBzVK2d1gFAe0GNA== 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=kAK5fhxZzM/TuoFldoTn4hT+Xpwz+9b4vQrEcZaryiI=; b=DtBJ/sLT5QjG+WThbfqZEzI5qmTPZVKAAVO+eATXjFsp+WHmZFQEScH/lpuvcLWDo/MDIsmYzsM9QjdK/6VOOLmmhppoGr5HL9BD4S6w+unIzp+brGsNhYteKHmiTRv11CKPOz7U5lYb/TT4z4ygwVvVVoUNDsdYPKGHzej+Jb4sZbhneHZPuSo6GiKWavvEj+kTp4PfikCW3Pj9JDnCV++RKpQPKsSqGwE7tRV/wLULtH75WfywhspECgAt/VdtUF2D+xAPtef4GmvdDgUzDU7nAGU9HsOYhX8ApQLNzxXQRidqD093DqLXTixMletM3y068N8x4LMlckq3kFyCRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kAK5fhxZzM/TuoFldoTn4hT+Xpwz+9b4vQrEcZaryiI=; b=Gj2PO2N+TobfghE+90d9YaU6KQ63yaGRqjrw+SlwUZry6tt4BCdyUNE3Ji42bsrFc3jdg7sFMLar2m4oNvpfeGRRyn+8HyRNkZn4FX6EpVpJdnkYdyZmA+5ZGCOrR2+zAEuET74HFE0d7qq8o3L0r0HkcHtxlvpohJ9GWLe88lXOMEOv0rEA+Vl0b+7Az3Kes5nEuFEhHQpi8wnfNCSRRq7VisGeTqKVsX1nXobVVhEN9pxuEFp1B3eM80cqexVTayMW7TQq3Rsfts62hocKVzznVTPjZluzeCXZqkTWlbP/cIWbOTaD0JdhhSerZarsu+M3VwQ3uHnNEqJfL5Tk6g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB9061.eurprd04.prod.outlook.com (2603:10a6:20b:444::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 09:20:30 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 09:20:30 +0000 From: Ming Qian 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, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC 1/6] media: v4l2_ctrl: Add V4L2_CTRL_TYPE_RECT Date: Thu, 17 Oct 2024 18:19:46 +0900 Message-ID: <20241017091951.2160314-2-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241017091951.2160314-1-ming.qian@nxp.com> References: <20241017091951.2160314-1-ming.qian@nxp.com> X-ClientProxiedBy: SG2PR02CA0129.apcprd02.prod.outlook.com (2603:1096:4:188::19) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB9061:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ad53861-29be-4c69-c672-08dcee8cf1f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: UpcgBlpKoVGE7bVU4knx7cpOaZ17X89UZ88eRmjERdCLUSPN69rLmWmZKDfrpZoyXYr5yPXUl7BBRyubPbR8C9nEstRRwFj1JBp1hRWgSMQAQTSFXcgC7u4GGvPasI0ACLNEnmZPJn7/ND30gpHwnQOt2HNkv+E8Z8R/TB8CdP0hOH37Zab0KuIoKsbqJzXpmfIeiM5cLtRFRUNjgD3hbbcdG1hK3TjLBfMHeJPCGSMFlg460g24CauS5HtnybRMxbtq2j4BG9cpn9+F7F6GjomZ5QhEDueSYipk1RWArNA4ueTqmAAU19KexTCHmnLFGYsdJrd/eNKlzaVDp1jnXiymJE/aVAL9JA2Wdk3ajdilojeKj2UbhuU64Nu+A61aTIM7d+fNKJtC9L9TGBA5Td3jB23bxmTR1uO/x0VCOVPM74Le/Nvrm2iUEAiGDWZ/Gr2GBxKFtZFyXr8PzQcifEwIYaKHIvrmcy9k+JrLjoYfaJmDeoOub7q/FKVOn34TrLLr9PM0YhvH4ogwEDS04EZSM7zEvwkD1LgkKGiB9zRyX//LCM+Urew/h0z3Pr1RBepPVcoYn5/qz9aeW7tUFoddy3mjO0YG5KhqVNtnhPg3PLM+CPjJU+J6ktWSYTxom5SqUtVu3N252MduOh/DhoTpxt1tm1hxtwN/yJ/oYHuNlCEmxFqfavdoedqVEnLpDwBp9iysLuCAvqsw+D7JBC3MVsYhmVcxDn4+0Q6QdF5j1OIVSOwtAVV6bxKs4X+IOJPGGwx3HH6X8vH8eAu3zO6wGBCljFV5ZzkyRQTGR89mOyRMj1pAg5dMQvrwY2cMlBtXBICkDWCU9U9LQeIaCpEAhEPyKouoaxwlX1HPRz7Sa2HXWE+QZ5qriPI49WUD4C2EUbJXOHY57ofcOzghUw1kcDTVbpfHY0fpIbx+/mTeQxA1OViiXkq2TcabKKaAElijNjdu/PzN3MG5DGAwXzTNcxKBJs+qwTYjnu/dPvYHsFiyBou//MxWnwf16LWUxzn3P7w1EP7oEo1ZIWRfxcvwTSuxJIC8Md2O5mbIaSbAB+SLnv+4fXZ/0I9J3HFfzST4YYxqalLixn7IHcgFP2DWMqQCX7FHJXvPFqL6YDrt75zV9h6haplNlz1XSMbgeNQC9r7pTMc92jHKRz0cxbDejrI9/SWiM4kNL+18NTXqSvrTp/uWXBAIfCzMbexiUSnnUMD0YIP+26MmqC8fdqlkrZZTGwG52HNJO0u6b3U48s0BhOqVVboSDJYh1+MECHgDcdwWTztlnlmHFn+oqlyiw/HGzK+AxMfq27sse3B5RABPBA3LyIJ5DuDUlYTsDVQ/dv+xe4efxz2O16DlfsGIojYbxa9b+bD6o+Qq8+k= 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)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vvu/aPvKHqZFcQI38notR7o2q/aCU1b/tBeA4sGD2EGk+nJPIyAhkbIFwwckCWxF3FNDZhuddCYeqBp4/rSlV+2hj+Tz360YUN7W12yAjX2Gs8okZDlAHliAHuOgvP8nN18Kywb1nVAke5EvU35YSaoJqqAUaYUFLYOLKNk0LYyRWJ60CEvklu5m9ZM26md+4cPEnvgNyigDTUkN3MipRlUQ0lgh3PLUPSxJ35RTBOfHACqcWfH0hvAGHhQvcvaKuo2z3BhJ7jTsua0wE8nMprqt+5GRawicgVFJDECBytgGEFSycXxFWxf1WDuMt46Ict2Dy46jmFvYemWLkPiXmkaiXz70ArGrGlK8ZanyLr2jtW7/LSvLg294XG5PL4RgvA4oqEfPdHWJOf6aJ8LK7sGN1NRyEnuDgTr1SWdLZekJ7OFE5mQ7xMbmY8lYjMnRq/VJ9NRaFGRvseTxzOfKIyM21rajKG8+BAeFff0+R9OqeIo+F+nq5/LpZu8K8ZpfBIwNB1+GWSpzaFpLObFBDoe2CWbiAOblIjSAcA+3tsIgmp5eSqllTaGOYct7dcbRqBkK7jenjlfXsRiN6xP9Qbkys1mLyHXgk5BEWGlrUjHZw/pwHmaY/9T4ZCi00f2kKYe1B7oCv4VCwSagmgCDL6HZamiEh30331JNMBlWfxjf4Ql3xJ2oAy/qwksUj3oXE0UNelgRhW64lKzeldVkuDmsYNOHUyN+dl7vQMgH2AatCiSScCOKVoSczc9JhKscsFnePQ/6zC5esuqgyhIupcTRpsJ9ftWerpWWGS28RbiPubE4aOxvyqql04WsdN4Gd59kBoXnyhCUqwunhJPjeNpzsVK/B/LdUvkTOgABU5XVoapaehAzRh+9hDORoCBXu8PFoVjUmNKwYb31zPX1AQP1Lo3OeEJfPDNIh4G73cMg0CCMvfHd5Eq2XvqE3tGuBti68Zzxq7svv3o7IzaWeHvWeA5cR0VD1jgxB1mGIJH5iNlM8wDiAsQ1ABUS4zbFPz005LIzntY7hSCD6keOF9oI8BWiOlqsGIy+32w6CSsc1stu7g+a5Ap1JcDt6qcqb7caHiagPVC+tsvNZC7RQoYdn20Ki5hrHcVLR6WUwltCR0Cbdt2z84S5H8qZ176VXViZDUbGTYCzuhsqbM/Uzw+yFJOiPc8+r3A4tTxFwJQKKppi0PEP1S4N6/YAZyp41Zrom8iw2eeE3p0xwpGfJ9hI/MQXRugnvsOVK5zm3lysfsk43ERJPztIt7ZxLGbYKGspg8fb9yVTgJqA3ZeXezaCPtv2YuHWZe+DN7xgCDiX5v4k6MegtSb4sd2eiXAgZgyROC7L8j7gVIQYi/Mzfk6uKfemeuzct2bYNB/FuPKEC0hZJwq8+Jbiz9z+WQfv1s3dLgy0nmA7WKLh3liJwcqC1N1s7zHDmzDPZ3dKK+smmfUgMbwoFcyecMfHcf22IyutL9e/31Lguj4ZpVMCgjP/hUwSmJBQsY1GMJDAO9Ou0fYRbRoT7k5AZJYe5+jbM16MY5cLBAwc/+TMVAX3L80vrtj0V4hZlvT+brlo2Wi5gD3rbR7YHtQX/qooodN/ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ad53861-29be-4c69-c672-08dcee8cf1f8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:20:30.5209 (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: LcECwHSCUL3jBnr+o2yqLCCyR02jO9U6fU4qA6r/mXfZcvEHFS1bYwkxLPZ/FVDWDUVlhaGCd+lYveF15MUdSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9061 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_022042_391522_A72DD876 X-CRM114-Status: GOOD ( 16.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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/Documentation/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_ctrl_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 *ctrl) 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 = ptr.p + idx * ctrl->elem_size; unsigned int i; @@ -1172,6 +1177,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, return -EINVAL; break; + case V4L2_CTRL_TYPE_RECT: + rect = 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_ctrl_handler *hdl, case V4L2_CTRL_TYPE_AREA: elem_size = sizeof(struct v4l2_area); break; + case V4L2_CTRL_TYPE_RECT: + elem_size = sizeof(struct v4l2_rect); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size = 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 ded023edac70..4b12322be592 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1857,6 +1857,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; @@ -1927,6 +1928,7 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_U16 = 0x0101, V4L2_CTRL_TYPE_U32 = 0x0102, V4L2_CTRL_TYPE_AREA = 0x0106, + V4L2_CTRL_TYPE_RECT = 0x0107, V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110, V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111, From patchwork Thu Oct 17 09:19:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13839678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E33ED21268 for ; Thu, 17 Oct 2024 09:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=z3oKuxRFkA9yHb1hrfi99zYa7fO58IZs40h8sxAWj0U=; b=3j9TvxJIeAu5s+rOsq1o+usr4y /awAZ0N60FFqoZwFrULZfypTopZTPXjPCJruXUx/gwsOP3NIAAm5jQXJ3AOUbJ6ckxvvvL7rgXqmQ SRwuPG1UOymKlDXbzyhZnZ/mpAoZcpf/HLLQ/OesDh7OWkgDWYruSp5p+0ptDJabTIpwaxy2S1Rcw O+PS0HfFjrSt2GPgPQNZaH5raoj4Y8ERv8VEmmtAodY/4QUlcdH7EtZ2eWAFKBtEGHPC7+IkiDE/H tt0Rh1sw2MFfKG3s7yWj1n17G9DVt7aGZOeIr2Q9w8T+UKHh3IH/XMNP2VFHz5MCO4qyQg1qWZKcW V9CyRTlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mkv-0000000EKb3-2x5u; Thu, 17 Oct 2024 09:25:17 +0000 Received: from mail-am6eur05on20618.outbound.protection.outlook.com ([2a01:111:f403:2612::618] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mga-0000000EJYk-10Ee for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2024 09:20:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e64ppHKrKlyOIV+iAZ7XfDq3DSdbWay27dD4DuhLSLbluGt3rElJ2c3sgX4dTqk12u9D6+g2sPhagD0Z4SJEvfn7n8Jl24y7Bvo++IArkWQmgwn+T5A1bPD3sz5oAuSjdUIgbqIoec8jszXIrl8cl5YdD62LWiGb/fVdeFqW2EI8KbO9wzWgZvRo/0M4KXPnCbFFsa0GQu4dT8X3kKoXAFPWiAhPUKVQ244O41v/AkjjqccU0YmYKomHljIBvFm4F1g/PMJCyl11jYx6kvzFvBRN7ub5+/Co355k8BFgzUAqRWqpkBxPtDavSmn1/NpAjqDEFBOCb6Wpd8CfR8cQ+A== 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=MWhytjmWIPHDXU5LysnP6O4H6p01ViKKFMnbeQXQKJflYgn+8ZgQCfPlF+3CTWBnSuiXM6habcZO0R52Yit9XusNhv7HtCl7IHQ/CDRVVQynTONW77dMWLS9dHBmvg3J3/pRST7f+E1otCaC9EO7UvRxeXE+UjSNwIrcZx53Uj7DnL3LN87VJVrU+Hmo/GfMhK4dqZtW6JXiRqLJzXcRYucX/jRYlKbbM7+5YEIJoQaTG5fH7Cjcn7sqeDjz7Cmi+yDD2EwfwohupkwBgtucCcJaRu1lw7/kgwXBabwetClTS41xHjYmLL2eS9k5+BUtdaCLke85O82Si3hgyvYoXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z3oKuxRFkA9yHb1hrfi99zYa7fO58IZs40h8sxAWj0U=; b=M9SllDs4VJY7zqyGbKI+sghP/RvIr2UksIwBHmLTdb+/2BnklPlNfoma4drPWYM4RrRgu7l5LVfobvJz/4iXZ8+Y8k5T4UzgrnUZY+AAAcRrqTm0QEMRLqIbkrBDcMBFBwzuKu47pf3P6PvmTHKBsI2I2nkqZtw+pkaIuzCyL9nyT0cTyLR0nDU/eXGLsbsmNj6Gj9EDkTrqSafl8EA3Zuew5CDUKLOhltk1ldD76sz40d5H3o/YWm+HQIl+vncdrYRkj3afmvnHj/Ib6flj1JhW4sM/D0lgpx24t8g7SEzu2mSo0Pb21iL8AZs22rr1+VxecMtJLd2nkVUt6g/umQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB9061.eurprd04.prod.outlook.com (2603:10a6:20b:444::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 09:20:35 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 09:20:35 +0000 From: Ming Qian 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, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC 2/6] media: vivid: Add an rectangle control Date: Thu, 17 Oct 2024 18:19:47 +0900 Message-ID: <20241017091951.2160314-3-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241017091951.2160314-1-ming.qian@nxp.com> References: <20241017091951.2160314-1-ming.qian@nxp.com> X-ClientProxiedBy: SG2PR02CA0129.apcprd02.prod.outlook.com (2603:1096:4:188::19) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB9061:EE_ X-MS-Office365-Filtering-Correlation-Id: d05e3b88-eb36-4c3a-c98f-08dcee8cf4cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: ngBTSlgCZs+hrHL0CEfxET8XV5G9iggIlzaQwNOkz1NWkUcNArFP0kbxBlsaRLvVb8GNrNRMkZSoEyjMe7Ez5109nqKPdgk2zDgueJEdguEx+iPMSmNQ6pdx2lmqfde2ps0Dp3M9muX0CSXC9wR8L/1aZEsRfvtuAifyRvnx9HTdgQtAfQzyY9KIepGh9fYvxOl4dAWk1kZuyIzvIS6nw41Rf/eM8eEOO/TzD5MymSje3l/FfjwxPgpQ4lPpf0DN77kNR6Dwfe7R0QG21RR0YW3xpKoJNWhuwPDyW4q4zIgExW4D5i03wblg1ZSxoidE5FLL2x7VX14NUp4ESfUnrduGNut3nfyM8EQ5N1yapKc0kduAf//YDhri/EL0CPn3nlcMDF1Gml1ljqI4qfPiWYcwYkGKNmyz4WfNgTlc8sElpFK5oR2XyzVulH3rshOCIgX32sLoK24bSPNoASP1v0NkugvZPWSqaZXDLR5R74ngQIbHXev40+M26lOjYlMGYwTgqwVRfAyePyjsYdM57zcZjo0KxTfD2Br38kGD+bR92C67OrZuHAkNw9lC1WxnqGWTpRwc9GdGqqQfHbvA1OPbjqt8NzMGW5jT8KfOtSRyelSoXnLi9H22SNCRbHYCvnGMlCUIpsBjlz4SeVI3CGziPssnloBVTqgeaJpFsvAahj3nrcwzHHfhZcuCr2pBtIO+uh1BhGPpG6OVMpwj2zSyQgS614UY38TkuVgxrxkyBkxACABFs2ou+fyeF7kcNDZx8AZ50U4xDkXJguFJ56UZj95SU3nVjzzoR3lKjzF75AwlDqV6NlFen8UGrmoLFp/PafUWoGsyr3SzVYUEQpVm7dTeDKG7Od5aNGDeWU+OEerUWoGu/uiCvOasZ4wW9vzbMtKLEpyX55vmu1QpuYooUZ5/DiFKVyEu8Uej1uNoxOiJQEOpXqi0+MYi9DV5Kyhzcmlww2DlkKGsIjKXxPCxaPAX40lqSNcPDRkjy409MPtgkl9Z3jB/HDgd1nC/ac4kW3Mew7lWD/jBdPWPjIMUwppLvkUXLN+dOFtBdDTSiDkWYpRYc4q9fcHhOAVZQXGIaTGzEitGfB7UdTQ5dZF5REInc0iU0q/JSMNxmlA7baRkMNP8cNlYzzEDTfqvmmZCP6jH75T4KO/g0aPrtcshG7HMBKd8oU3BYZ7GTAaJii8/Xs3J4MYPiTF80Xx57SG7RfzZHDRYO6UAYlSEU4P9U74COM02A3Mf+QWjWE57oN9N6tlRXvcXp+IZwgyH7Ze1Hi79EAr1D4JGfbwUr2NH6H9ZXMlrVZepr1ZkGmAUQKC847Yx9nQAl40vtKg2+BKgQe8o/N6DAM/58fyAlH8G36C9YUzTWwokMSfk6aQ= 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)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SGLzGu4G/vb/aR0QSAOjHHcJ+MGQra6kmMAZw1xzV0LWp1laphoU4XKLvfWYufCNfrUd5goMaaB8H/7VErYB9QzMAN2x3BjfheHQ59wVxQtzVY9UZn2Br2R/SSy/CD/XNggeX2LwEzSlhBzTMn4jb2V5r4/cLvrEbwjnJAPRVyYaXdAkcY8Gk+FrOYUb2B4+0RefXsjSQ2ZsySRNi2GKpBxXq6siuTKigdLsC8xsoVjJTFUIswqtJjM1GagsfEU3wnvEpeJq113GeN0QpdYfgaEHREip1tMkrirYymCbgdji8H2eJUCMR+UabvfVwoINPP+V2I3r1MIa/0Svhb39X2B4DOSLQ3pkVVQgmALPXQ4BMX0zw4481AolGx/tooukH6O5dTj9CrPj5m9B9WCkrE+ZaGqI/BxQp9ZC+RM1U92pKQG5949z6OFnhDwTeE912f46E1A+gb9TXW+Z+a0d9u2b/VsCpUvA05gQAvrK0zQyXlFmz6BaEFt4VYAKChzNV1QpSEfuiIiuYK7WlhQ5QZhCL9b+ShVUuHaJYnmVIxHb4VSLOaJq3sUL+caU4cuXnivknCusxBtaTCGUSIX/45yxjpdphQ3Tc/21IkPdu9ac9lbKBWyPvv9hZESMRkNmgVR7Qm2vjiCwYrtmNUWLRUM5n4aqQDhEVNIAbrD1BoAPNj0kkHgqrSUD/IEwWrDdjAJhTHZ34DMOONT5wB0GuVrU0b1SEr8UPFCqpI13QIF4g02uy12aSnNBT22KriZiNN9E0F4OnVLu438I49LXT5oYXQ5nwL/O0BVu3N0LIe2vol8TvR7t2lWeJVIxMQhz5nNC7tAzSMiA4xNwPKIylRQEI3KGzzi3dgzy7RX4eThxMJaGZJWFruUqpucKe0J5Ww7xbiX+nhyaKW8eV+8cw+FxwmWaqseLmsRAGlCOBjhwra+Zx6AZNfjCpmxI0taI3tj8i2pSGURd/kt1zRVWBrv0x5R5GPZgg7Rvz7K1bMlrKiuP98nj5XyzciKFXeeE4bgru8ixk2CAcRGyCnPrraV5t+knH4xtvmthsyigBb5g5ZOTfr1ALIhSB29pJqW3LsFR7zgRWc/55oL/WQeHiD0mECQL5QF3EL7LZ07qdxw25qBwq6Wo7jMn/4wl7IUwI5HleHT9A4CugfVLUquxosfyQUnG+w/9qqLFoawlV999+Tzs65Lu+8ZIXjDcYNdII716YGeXaefr+xciXDI2PUp0pZAtUoD+arjdaQFh6pLabRVGrdIFj4GyRkhcbu0IMZEmI1a9Fv8G9mfov4prLZ6WYJ4wyhUP1Q4ZLwu1JFnyOQDIEOw5+q0QSFzOA+dzKCKmM+paAr9j/zqnBSdevoimardSKVdR1CE+Cj1S/Sf1J1etEmD6uemCblfKRV98sVRoAY7NI4r+Mp6VEZH6RHBN0rRqQuzpoRqmCcsQTKRymlH3ww8CEZZc1hPQMXdMXbdcnufQ7qEomDWxLoOyNP7sSO5/F+GRsnJOsQYPo7yVcJb37DhWZVK47BKs0u3yKfrbN+9o/osPGF17JZFM0oRCEVtWrM84Kh7CqjCudxc/Y7by1JY7Odr0ep/+R/2B X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d05e3b88-eb36-4c3a-c98f-08dcee8cf4cc X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:20:35.1503 (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: SMzgxNs9oMpG831hNkXgqt3fT9uTViIcqwgEL5C26y1eU+yvQ9P1Fc1H/XAsCxvYns68Q12ocwlg9LnUb9MYnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9061 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_022048_301490_1ECDBEE4 X-CRM114-Status: GOOD ( 11.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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) #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_int32 = { .step = 1, }; +static const struct v4l2_rect rect_def = { + .top = 100, + .left = 200, + .width = 300, + .height = 400, +}; + +static const struct v4l2_rect rect_min = { + .top = 0, + .left = 0, + .width = 1, + .height = 1, +}; + +static const struct v4l2_rect rect_max = { + .top = 0, + .left = 0, + .width = 1000, + .height = 2000, +}; + +static const struct v4l2_ctrl_config vivid_ctrl_rect = { + .ops = &vivid_user_gen_ctrl_ops, + .id = VIVID_CID_RECT, + .name = "Rect", + .type = V4L2_CTRL_TYPE_RECT, + .flags = V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX, + .p_def.p_const = &rect_def, + .p_min.p_const = &rect_min, + .p_max.p_const = &rect_max, +}; + /* Framebuffer Controls */ 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 = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int_menu, NULL); dev->ro_int32 = 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); From patchwork Thu Oct 17 09:19:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13839679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1D50D21262 for ; Thu, 17 Oct 2024 09:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nZGAeZUdmKLyhjLZN/lIyfjSbYxro+rT261gPXl3N58=; b=wHv3hCpSgnlba6i9cCuUmIe0ra eKm1ngrIHqhkaQyTKWqh2zQ5xACpNWzpuAIFxzfxJLh+Ly+kzjnHxYD6rpG2ArOMjuruKBwdOVv3i F6r/QyVkeVFOUFElrDZT3PZ4kZt9T3mjYcpnEldUybkE2T1ZkAHCIDoGV552eibDx4lPJogWePZSn lI8XwcCICVOUFwW7PkT3sbnxVt1fW+wLjioqTPXHn0dHx2Z8SBkLTHJyYmacQCAhnBpJcO6QC67mK PX07t6goU2sAILGcJg7jugyNGeH4EwJDOHT55Qiui5pQLm6KUHvt50MJNpW35/zQJHEXAQ0erW/Q3 DCrpiQmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1MmM-0000000EKre-2iP6; Thu, 17 Oct 2024 09:26:46 +0000 Received: from mail-am6eur05on20618.outbound.protection.outlook.com ([2a01:111:f403:2612::618] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mgb-0000000EJYk-3Zvv for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2024 09:20:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jFrbPwsA6jEgrE/6StD6YoEFvu+/+X3t2PuxouXKmJnGi/vofcJGM3s2xWRpPf6d1I7k7J6Fi2ci4YD12YsKZVzJK+HUbKqxV2Z66uOUucGGH0Z5ACKR7Mp4tA1IWi0xj0hlWB2o96HiIBY95v9cKJJK2cO/Nruk/syYP1aNQqU1ZmHVB9L0NOqoz6BAXM0ZLPQTfdMvNNdFLsQa2AdtXhc10X9ZAQYBs3cFz4jf/9aDW8+gKLNjsvDu1eXaQ0/Mm+B/q/rLrE6Ygewq7fRVvgxzgdbjjna8djRn88Z0aQkhrbbv2ZpdaWAOEJApOdkBCBpPpKOyGlXfl9fiWNlzsQ== 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=nZGAeZUdmKLyhjLZN/lIyfjSbYxro+rT261gPXl3N58=; b=XDbgpmAfxjeOY+9gC5Jk9GniZWVdgE8Z5UBjgjPtY2fXpWqi3UVpjkrE94APnOqTXHEd07vThcPP6UqUl1Em411CiMN/7JbtOOZdDFTNkDu8sVybcShdHgj5NK+fvbpjtlIf2cW9fT93YtCmMxLZcqLglNjQiX2Mhbudi/xvLWVydpJZr2uANMTbFxWs/2HknFj0jT2j1Mv7sTMjWiHR2//TLh+9aCl0Ps5B/zKJuI6wbGECNzOGBpcxiXmEN/SVpO0c+UpeXVRQo+sR8fuxpcSIR7Mp5mJFtzPZ4gPZT2Z2DpX2ZsUlHXWUtb1deJswLXUTREf+2rJawPVap+BbXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nZGAeZUdmKLyhjLZN/lIyfjSbYxro+rT261gPXl3N58=; b=eP77c3qAKB9Xk71AFPDyZJQODsaJuCX7DxM5UvMpG7kHy3Rr2drbltCmkjn2o6ZqyGBoMbSVC6tB5MsOglINnOYURa4l7K1d5pldBgcEHFY8o1iyOtF4QtlRvLTdQMzgfVKo/b6FFjiLCEBC18bju4PIb54/TSgeaSzbL34BW8LEWNicqTNWv0ucWFFb12wPbxTZYTQudXBx5SQt0t2+sKDXv9rnPAyrQFYsiUJ4fBlq0zyyJbpe2tQ9ppTKTI4ZzBHYGEmnpQuxLBtQuvfzbF45JM+nfv1auAvhWAIKVSH/LLHmMA/zIyxcPc2NxVqtvt8jomQbGPUKfPXsTdQdmw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB9061.eurprd04.prod.outlook.com (2603:10a6:20b:444::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 09:20:39 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 09:20:39 +0000 From: Ming Qian 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, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC 3/6] v4l2-ctrls: add support for V4L2_CTRL_WHICH_MIN/MAX_VAL Date: Thu, 17 Oct 2024 18:19:48 +0900 Message-ID: <20241017091951.2160314-4-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241017091951.2160314-1-ming.qian@nxp.com> References: <20241017091951.2160314-1-ming.qian@nxp.com> X-ClientProxiedBy: SG2PR02CA0129.apcprd02.prod.outlook.com (2603:1096:4:188::19) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB9061:EE_ X-MS-Office365-Filtering-Correlation-Id: ee4f7d63-cf73-4dae-e609-08dcee8cf77b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: OZvEJmz7EOcCIy2saNfLXb5TKh3yXlE7bi8Hz0IciKNqc5jxhfWMNU3xHW0NOglSnPHJAdDJc3R+6jc5+5qoiufItcDO0Y1hb8rjpm6Ctb7/9c1VehF/Dk035ukya5WPQyO6tKTOY6itSvHHYoM9ufMy9HrVVR8Sa+5ff67QWk2UDFqJ+NYhN6ZqigE+wTtvqBdkOuypee4GUXLpY5hsF5KGl5q0+URti7/8kHUoI8FTIs2Zhmkxb83g5XvDq1PQdArBGTcJY3OPDOVCIeJiGPMk3ZF6+V5OkDaap18IdPv6EbsNGTiKia+4rrAHBI6uDSl2LbfbPYlaALeUdqsNIKeofGWTfLZbfpX8KdT/UToKgje0hvvzl8rdGw0zseXJPeQP/Vc5JwuG05MevPsSclebcQg1N52TGfKU48DHffLH2e1TMGL8clzfse8ZiWODz1OIV3iIDwPfpS7rf+7gbqlRzJrGI8vbiNB1+44ZkqBmkQcwCPZ7Ms8IL0QjMttqXuFTGEw9G6GMPtNzdFhhOotTJx6BcssmOAPQDAb+0mUMyAqHY2AcI7kPQJpt2THRh9gKpz4hJbA4hJKFf5qCceWsYfjotH6oe0QebJWe9TKDIwXQkTAzBNhbPrzEMMx96aHbJ2dc2rNW6tZG/ToTFQPTZXtAp+287J0roE98HDSU6gVx15z3af26RWhl4/Rew+iWETyJi/wrf+DHl4bK6vX80WcPMJCjhWWXitEAnTjP16/lrGpJxUp+AGfWfFNtpsblys3hUl9vwQmM2KaxSoLCHtEd4ZPLYO98RXD4fxAAka1CcBdN24EDk3NxJdJgyGnMLjx/hNENbdp/7OYmMWGgQ0+J9KWHJZOmKDGoNiWMTOwixoBj9l0lLW9Gs9Y4Og1GxjA3Gfgx77ornItH6M+sum8EeVNrHeYHmyAnpPqr4rxTT7ZVrEx7M8J6QvxO8COJfyAH1XhYY6Z/MMpV4LE3hC/a0LvVbb87uFUGNl+F8oZ7DmMWZGnmgxym5bprUAalV0OnY5SofrYDji/FuuRmCseXLtATxocuuJeIqVVD2Cp5+1sMLI8DDBXE+sJiXYlO1K2zyxJAYhFyd0MDqJ2jMzpmP0M7Yquy/RUINQfVgDYkg9d6uzse70u8tS+WPn1VqLxex2+3zk9ZAtEV/BcYcAOIAC3cUenvAMnXJrC2RiW+X/B9ND5vi2jcHX2Y1EiCyV1kb008ItW7y6ddnt5CVsH7t8pbFpxYB9Wv5j/khnl7QK9DqAFHbgWRhPMVlIYzvqXecZcfMTs4Xl3N4tCJ3xEzZfx8+ReBkwByYgI/IsjUSp3KWSJCb55/IVNFZXgkQ24V9AonFK0Myii7c2Wtfuj27uYvdDzpmaS4w20= 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)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jEGZuv/yQc1rxl3Il4L2XOxs3kz18nt/p/90ELwNRBYK1DsLLLZgiOJQk8uOqNN93pgx3JPpzX2wKY6OdWDCKv020VNRAeVAjLMQbAT+qrr8xtQoRinEJJdfd9N/+RaihO+i2XLIhvgMEnOMbrKTSKx1Y8ekknrQFXNlvJgrcv+VC9ppQwqnv8uE2htEFNlo6M47EjL/R0wemRgiZ0PvomG4owQaq9jMEL+63fX85QHzi0RRodXGfQnC1pidDdmuXd6aBMVKonc/3S+dTALYPldUDszjQ7hG61a9nZIxhar9gcf28MOGyLcFDLdTQMWDXADpce9t8YjAvoay3gx16jBFMystt4f1oLYtz/bDl+KR1+56JpDJ+hmNdPwTgaQV0rglNgMECx2EtjRXRxEOuW6GTKHM2ajUPWovYxU2zi+azWPa2UYstCSL9ZzweiXjssVO0IKxB+VT7oH0kQIKCBmIWk6hsf7w9mo2xo6Ia2OlwU3Vzb3cINuy8j2i5dEqs1iANZ6lowk3Z7LaQ4f8Eoicvb2vBhQBG8eUsjAZELi/Zzwrz36LzPyriel5slrCPwKsOHKCDo6mOSJeQuXxXOG3Ge5gewVwachIfBvpDz1WoPsvt1kpi+5//oQ1NB712wSp9Hs39ZotIF0b4sVkWB4vxKZPqge7zvuD5lKQtH3gJMk6uU1/PqDrIMz/ckcMOff9jASRNa3OflJDUEx+oeWrW3MUr90xjwr6WfRYuHB+7ruC3esvD7rhPZnZT77oyrncx2GaFQ4QbuzK1Vo8BYki0NdX4J1lM1JxaGLmZu2KeJ6fExtlS2hnTiV4vIrMjqdboc1uZHHbik21Mms2cOvmdGMkSiSXNUFPsIwojERkOkErclSVwgcF0MjhQY4op0auYcOn0dNNXZgkbu0hCFp8++ASJ8nHd77faEIbwHwQTf360ng/A/gKo+o31gtJUDvjlmdt8e/EzSrXWJk45RTN+IiAPCDZ1F0/Jq/qFs8QH+t+w7pLAjjW2fm/AHAiNMAXbZ4yAsQXr2KAqdoJOkHhWr80adVX+yB6nJLJgcRGK3RKPya7V3tQQjvZ/+0QEEAAdga38TtTyPJwniCJS5YtEkUYHA0FdKo+uBOM0C9M8bASkvunbWwrYu/QBHgxVEBbNcANOXvPuVtTRFpwEMxFkalBxjZFq0DnyWPVRkhM4rTY4I7k+Y3Aulu4ny5bJxUKLstqA/WhgLag30seVdnr3g7Yv7r5S0gd4cngYXh5R1z8pZLZ8Zu0+HyYbr+ooGXbO0Ca/Jb4M8ZZ5Niyjwl1JxBKqj28+egXfsqNi5WFv6rn/ggRtNIYTOOck3HRoLaw0SZqIP5v9kxq9iKCISrLDAFdlTIFZafdtmF0m33GsseG+8EXiF6KVHIAX4X9W2xN8DHcIaV5XKoqAneWuPBMyrT4o4TwVzWOwM0942P9oL7WFQ5NPhtWF/+MsnYMUN45FXJaz6gEG51/Qu1Xm9gsQWHSAFHaZfBFfyyanih0S2R9VwZ7XECBtI2oCkat4umFujWwOCmUvs5cNScgctDETVK0atDVwgFQn0mtK1CyrQYFB42fckp0m4uy2a0+ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee4f7d63-cf73-4dae-e609-08dcee8cf77b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:20:39.7771 (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: cR58yYa3wcbc9XTULJvBoON2OFP1ykS8Fuc+Xrw2yrX8aEX8sOQPJ835lZyjzP4jU0EPJY2Pkfs0saZL7OMy0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9061 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_022049_988955_C5FBB795 X-CRM114-Status: GOOD ( 20.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- .../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 | 151 +++++++++++++++--- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +- include/media/v4l2-ctrls.h | 36 ++++- include/uapi/linux/videodev2.h | 3 + 10 files changed, 247 insertions(+), 48 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 value 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 maximum + 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. - 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. 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/Documentation/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. Return Value ============ 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 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 = 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)); v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &imx214_ctrl_ops, &props); 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) 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)); 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)); + 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, struct v4l2_ctrl *ctrl) return ptr_to_user(c, ctrl, ctrl->p_new); } +/* 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 value */ 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 = i; if (cs->which && - cs->which != V4L2_CTRL_WHICH_DEF_VAL && - cs->which != V4L2_CTRL_WHICH_REQUEST_VAL && + (cs->which < V4L2_CTRL_WHICH_DEF_VAL || + cs->which > V4L2_CTRL_WHICH_MAX_VAL) && V4L2_CTRL_ID2WHICH(id) != 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; } + if (!(ctrl->flags & V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX) && + (cs->which == V4L2_CTRL_WHICH_MIN_VAL || + cs->which == 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 = true; if (ctrl->cluster[0] != 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 == 0 || which == V4L2_CTRL_WHICH_DEF_VAL || - which == V4L2_CTRL_WHICH_REQUEST_VAL) + if (which == 0 || (which >= V4L2_CTRL_WHICH_DEF_VAL && + which <= 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 = helper; int ret; int i, j; - bool is_default, is_request; + bool is_default, is_request, is_min, is_max; is_default = (cs->which == V4L2_CTRL_WHICH_DEF_VAL); is_request = (cs->which == V4L2_CTRL_WHICH_REQUEST_VAL); + is_min = (cs->which == V4L2_CTRL_WHICH_MIN_VAL); + is_max = (cs->which == V4L2_CTRL_WHICH_MAX_VAL); cs->error_idx = cs->count; cs->which = V4L2_CTRL_ID2WHICH(cs->which); @@ -432,13 +459,14 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl, /* * 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 = 0; j < master->ncontrols; j++) @@ -467,6 +495,10 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl, ret = -ENOMEM; else if (is_request && ref->p_req_valid) ret = req_to_user(cs->controls + idx, ref); + else if (is_min) + ret = min_to_user(cs->controls + idx, ref->ctrl); + else if (is_max) + ret = max_to_user(cs->controls + idx, ref->ctrl); else if (is_volatile) ret = new_to_user(cs->controls + idx, ref->ctrl); else @@ -564,9 +596,11 @@ int try_set_ext_ctrls_common(struct v4l2_fh *fh, cs->error_idx = cs->count; - /* Default value cannot be changed */ - if (cs->which == V4L2_CTRL_WHICH_DEF_VAL) { - dprintk(vdev, "%s: cannot change default value\n", + /* Default/minimum/maximum values cannot be changed */ + if (cs->which == V4L2_CTRL_WHICH_DEF_VAL || + cs->which == V4L2_CTRL_WHICH_MIN_VAL || + cs->which == 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..9642a1f242e3 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -182,29 +182,66 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, } } -void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, +static void std_min_compound(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr) +{ + void *p = 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 = 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 from_idx, + u32 which, union v4l2_ctrl_ptr ptr) { unsigned int i; u32 tot_elems = ctrl->elems; u32 elems = tot_elems - from_idx; + s64 value; - if (from_idx >= tot_elems) + switch (which) { + case V4L2_CTRL_WHICH_DEF_VAL: + value = ctrl->default_value; + break; + case V4L2_CTRL_WHICH_MAX_VAL: + value = ctrl->maximum; + break; + case V4L2_CTRL_WHICH_MIN_VAL: + value = ctrl->minimum; + break; + default: return; + } switch (ctrl->type) { case V4L2_CTRL_TYPE_STRING: + if (which == V4L2_CTRL_WHICH_DEF_VAL) + value = ctrl->minimum; + for (i = from_idx; i < tot_elems; i++) { unsigned int offset = i * ctrl->elem_size; - memset(ptr.p_char + offset, ' ', ctrl->minimum); - ptr.p_char[offset + ctrl->minimum] = '\0'; + memset(ptr.p_char + offset, ' ', value); + ptr.p_char[offset + value] = '\0'; } break; case V4L2_CTRL_TYPE_INTEGER64: - if (ctrl->default_value) { + if (value) { for (i = from_idx; i < tot_elems; i++) - ptr.p_s64[i] = ctrl->default_value; + ptr.p_s64[i] = value; } else { memset(ptr.p_s64 + from_idx, 0, elems * sizeof(s64)); } @@ -214,9 +251,9 @@ void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, 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 = from_idx; i < tot_elems; i++) - ptr.p_s32[i] = ctrl->default_value; + ptr.p_s32[i] = value; } else { memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); } @@ -226,32 +263,61 @@ void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, 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 = from_idx; i < tot_elems; i++) - ptr.p_u16[i] = ctrl->default_value; + ptr.p_u16[i] = 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 = from_idx; i < tot_elems; i++) - ptr.p_u32[i] = ctrl->default_value; + ptr.p_u32[i] = value; } else { memset(ptr.p_u32 + from_idx, 0, elems * sizeof(u32)); } break; default: - for (i = from_idx; i < tot_elems; i++) - std_init_compound(ctrl, i, ptr); + for (i = 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); +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); +} + +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); +} + void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl) { union v4l2_ctrl_ptr ptr = ctrl->p_cur; @@ -1296,6 +1362,8 @@ EXPORT_SYMBOL(v4l2_ctrl_type_op_validate); static const struct v4l2_ctrl_type_ops std_type_ops = { .equal = v4l2_ctrl_type_op_equal, .init = v4l2_ctrl_type_op_init, + .minimum = v4l2_ctrl_type_op_minimum, + .maximum = v4l2_ctrl_type_op_maximum, .log = v4l2_ctrl_type_op_log, .validate = v4l2_ctrl_type_op_validate, }; @@ -1768,7 +1836,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_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_ctrl_handler *hdl, break; } + if (type < V4L2_CTRL_COMPOUND_TYPES && + type != V4L2_CTRL_TYPE_BUTTON && + type != V4L2_CTRL_TYPE_CTRL_CLASS && + type != V4L2_CTRL_TYPE_STRING) + flags |= V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX; + /* Sanity checks */ if (id == 0 || name == NULL || !elem_size || id >= V4L2_CID_PRIVATE_BASE || @@ -1900,6 +1977,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, handler_set_err(hdl, -ERANGE); return NULL; } + err = 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_ctrl_handler *hdl, if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p_const) sz_extra += elem_size; + if (type >= V4L2_CTRL_COMPOUND_TYPES && p_min.p_const) + sz_extra += elem_size; + if (type >= V4L2_CTRL_COMPOUND_TYPES && p_max.p_const) + sz_extra += elem_size; ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); if (ctrl == NULL) { @@ -2006,6 +2088,22 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, memcpy(ctrl->p_def.p, p_def.p_const, elem_size); } + if (flags & V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX) { + void *ptr = ctrl->p_def.p; + + if (p_min.p_const) { + ptr += elem_size; + ctrl->p_min.p = ptr; + memcpy(ctrl->p_min.p, p_min.p_const, elem_size); + } + + if (p_max.p_const) { + ptr += elem_size; + ctrl->p_max.p = 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); @@ -2056,7 +2154,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_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 = 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); @@ -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); @@ -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); } 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 v4l2_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); @@ -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); diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index b9a3c6b20282..77d999380c2d 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 == VIDIOC_S_EXT_CTRLS || ioctl == VIDIOC_TRY_EXT_CTRLS) { c->error_idx = c->count; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index b0db167a3ac4..9ed7be1e696f 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->elems. + * @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; 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, thanks - * 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_create() + * to convert a pointer to a const union v4l2_ctrl_ptr. + * Use v4l2_ctrl_ptr_create(NULL) if you want the default, minimum or maximum + * 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 just 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); /** * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 4b12322be592..4007041302d3 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1910,6 +1910,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 enum v4l2_ctrl_type { V4L2_CTRL_TYPE_INTEGER = 1, @@ -2017,6 +2019,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 /* Query flags, to be ORed with the control ID */ #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 From patchwork Thu Oct 17 09:19:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13839685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38EDDD21269 for ; Thu, 17 Oct 2024 09:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3M9OnD4p2ZXsp5igVRuYNX2PmQ2vcvmplBNzS4uaMBw=; b=JWk2r1sMAEkM1IbFbNQrWcPH3B wfgAvZmf4Juz5nujnXrXlaloozd4vjSpR2qSo9NBrAmIqeuIDYdZJF/JOCB9HHnPi/FQITzE5YakU ItMYN+/+EZ1LzAeZ/YAMJmmZpKEUTzoWrKmYHgvouHwzbW2FWgKaM91MjDhm06jkn5cEWi4FDeml1 EvetkzBz2ovl12ZnkvbevHojRyyNmCUwX6rzDFoTY5Dox53qD+uk9x40Ne5YY+FNMI3HfiQnQSosG iZL7eoTdHZYk89fzu7hGskNsysN9SiBdBS9vM9znKt3xqWp/mnIi6NPhix2nWDxu9gseP9TtCKhjM 7eoA9/Bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mno-0000000ELG3-0laj; Thu, 17 Oct 2024 09:28:16 +0000 Received: from mail-am6eur05on20618.outbound.protection.outlook.com ([2a01:111:f403:2612::618] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mgg-0000000EJYk-1vKO for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2024 09:20:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J/5kNGgEBynLkVAlshHlrHUXaiDBRMX9XnhVfp4s6yw+uCQEJ1GmLLSO3t/kn0+VPAGHImURcLHxAgz5kuLmnknv1yUuxppagulM4fS3yK4YcUuznQMCHeiAZlZRR08GvT8N6beRn3mRCGcXbNAZ/o0zMvrKXKM0YtEy31ewqs3YBrB17SJ/yCHPWAqgW8rbSDdI9kfQzhOcX2aRIpOqXDaLvKCNjzV+ZWLfV7FV81ns+Oj8eV8MzglMuk+/Mc3af7zSpPvYV+hvRmG7GFBsBrO6X58fg/YiwrM59/dLTlpWtH1vr+4keOVhduhm0F0Ejve1ZLRoAkC+dkwHRBkIlg== 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=3M9OnD4p2ZXsp5igVRuYNX2PmQ2vcvmplBNzS4uaMBw=; b=nXvIhik7A+juNad7CodL9zpQuQ6UzHLBqQQcCrluIrTrbWNyMq8RJ6fYRl6MMForbftbGKFj/ItJBA0Y+isQ55zlPp85BiPgVCEl4l19kCPVtA8ERGmLIA1yYRFyQ3Nk8+zxVjeT2kEzYOEb+b3w87Ba8inPfUY68ptJzVIAf2x86faU4HcgLO5PYdzkyvDYUWHvMW0Tl7xMXSWsyB7r61dsYGBZ0C3NAGeieXxNhF1jUIGTEPQ8eYXycz4RS6OJhlnLh6A1ystg+lEitG1xJ3dJ0CFtpkA2Dh4gZtI53bycIVW5NaK5r/9IhLGe4R9ia22wkd8gBtYh/GtP8+VJ0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3M9OnD4p2ZXsp5igVRuYNX2PmQ2vcvmplBNzS4uaMBw=; b=JHRrSPobddqrTEUde2YoRG+CM8MOizvS23qGc05ju57HUjcF8J/PMp76cOax+n5rCHTCag7/CCOBPvlabpN4VsGWaOtKzcLp1fzdBiMGg/ulH2FzEVx4aWVv0rxxkrlCruH4Of50/dasl9emVxqWf5bZs0P3+Uiax2xytts6XEgyWdG8/3kvpq8Pu4nRC/hSvnZcC0br1DZl1W4hhBJ81MmDyi2HL07HFunbb/Zx+whKoArdZVsKyXDX2Ujys/oqYvpLbPaiw/m7BRxsyaj7/cya++NLCq1dxfIIc0YmfcIljSsWByYNLLbPcNAJVngrvKxBHxceaoMBJc1r0b2RDw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB9061.eurprd04.prod.outlook.com (2603:10a6:20b:444::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 09:20:44 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 09:20:44 +0000 From: Ming Qian 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, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC 4/6] media: v4l2-ctrls: Add V4L2_CTRL_TYPE_REGION Date: Thu, 17 Oct 2024 18:19:49 +0900 Message-ID: <20241017091951.2160314-5-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241017091951.2160314-1-ming.qian@nxp.com> References: <20241017091951.2160314-1-ming.qian@nxp.com> X-ClientProxiedBy: SG2PR02CA0129.apcprd02.prod.outlook.com (2603:1096:4:188::19) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB9061:EE_ X-MS-Office365-Filtering-Correlation-Id: 4acd3eb8-8114-4458-e9eb-08dcee8cfa3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: /5SdIVau/c2W9oZ/uCjB7l5nMUa13mMF55usJPYPXysXa8OlT6uqKrES22QKxAPWZjj3fpSucfDMNOX/VJAuWG+qFZCx5m6y5f2XCm3r/Xh2X/L0ma7KlaWBfunF7HuMKRamsKOi4265ycRycvx7lSgNMsAi2GO+sm5gwQ8RqhEhoH4g58FyZ3kOmvsFVk4CF25cd5/2FaZSq6t9FuTso0WFt/1G3KFZYM1bORKpBw5CsnueX08AfvfzbtWQZq3cZm+Q4E4n1dz1BQ0SyIIiVuCeKJxawPQ8FleBF2YnXF3uni3jhH3BmBkvcv/OTTkwSYuiZxUcqVl8WZiMi6oHOXHiO9uLxrn0vt8edIo9gLZYQg96c0N5qlEO/ZEkzHm7Gp0gqdjSnhdTyh2r0Op1oifrwNfjXywxKFwl7zQhhpF1NwEw1ye81tC7GbmIHlgw5TrvhETVSGRNjG+xZM0pfnRP2lugoUaoVJ5llCt4N8jFyHiGlO1gq2cnC23/gadqRzJr2dDvKgc5BctlLIXjinunopsaCFuCxpHzIEJHSfplapkgsUVPBX1O/MsRFEu9InHDYQaaW05EcctLeZHIA0cQJfSFlFSPoXeNk4EA9FnfNmuBAoFkoL8oXIp6LiZHlSguCr8tnPsJGugjvdXJoP1sIAg0vK8xMMcJRTaW9zF4P/HViviq4Y7IYMbOg9lvgbeqZgTguiuTJ5f7q5+HNP9VNrsHI5eg0Q9oWeOlaLWqIRgmEGmDa5wxuhMAzCV8cxTEpS6YvU/z0V5+m/+N9xyOJYP9QosO3aXN5MRnH96R5iKjFKBIcNeL+lHtGF2skg4ZmDdalnuosnMRCAKsxCjG5/vlI8EwYX7FB6PuzxYI96m+2YAL3oc/3WoK1aaYxKHmEYflyLT+fCwOQ6LkxyGEG55mtTZl+DR4acobcvBTMXF+bogysl94uhKJRq7dI9I3EhdgOYKwVaFEannyJ/Y2Clhz811RIXGRKvy/8weDkTaDgta9Vrz2yRGZve5iE6KBAfjGXPQ/gBXw7t9W0aQu/p4NxPZgO2BTAZG0R+ccvlerYrcqWZItTYeC+h64I8SXLIpMuea7CiQnpx9AxD+sSBOY/8EzlcnxZZq70KUEmMghkvNxA4sWw4/T+qlSvFpfpSaVviCqmBAeaUt3UKjdLd668KdPWpdIGQH4lzAZNH+iUbOO/uJASADTeWoaHppZ5FNtaI3zVx0U1A5laC3sxsh1J+8jurQh0tczSSKA3EM+RFb19y7kfdP44O2zE7pTwMgso//FKAMmnSrswdB/Tfp+fJw4uqmAxNaalOGhkKD2Ap+9i28ERVYH7UGUlWcOxFhSwdCZZEAC14ss+hBM1SwyMb7YnTIfTVUFzBw= 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)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n4CJh+MGEvGa+Gvqtw/u21fJAUgknpEQ7dW8A4Lb9xHmUWZ51GSudzcC8o7JQsIeavrImC/BIpfTE7WT5TiOwh42X4lBpjTikmY6OEeRq2v1da1uQbyxuy5p8E1OaVfKslgVY4jcwWt4iQUs7gRgWEhjdb2rXUyDISDpI8WJUnVNY+icPlvkqJnfl5wNqPIbQz7Jye6xtu7NTJcixM0PmkGHUpyYb2H8ul6JOUtljbtMjj9cKRjJDkWqPHWgq1qv2pTEHXqrL7+ed7mc3A46K0v5Zi1r1/INvUrUaMycmoVMWzjiu8a7k8BY3xM5wq55EYt1AJA4WZK8INdwFTAb/FzodFgD9kzcsAuDEvdXLChZolB2DuILwuSq3Fb8/eddPft44Q3q6SXlqayNUrDu681Dc0yepd3EhkTXs9Xal7jLI1hQrOxTR1X42ljT71t8FGVOxzh9ZZ6Vywews0mJ1Ysj+QAH1akrt34YmS40bmESPfqbOOzcmdILBr/00GIrEtq6sjfiCfwPbdd9iJIdoVcHnQALL4PBqivMs+OADwucXaYIdWdicc0vK6FKL1Xmn2+MIUO/a6NY5veQLVV4IuqjKXcnkM9HK+26gxc9YPoNGKmS1BdUs+tBe5MGqBZMRLss1qZZU6QYbdnfUZrVJ9zJak16Ncr5hrbYPewljYwKD1C0OXGKJlKP01FKcGH2GZdYNmT8A+m2p3zOBBMD2wH95hlwZe8jswFz3qtE9hy3Na6A9tpeS+fXkmFeMsBHvHEuombV61fO8WgESiIDmNeoz/rWs0zNSgmOK2EKB7ByhTLq3rbzljV6ARH+k+SR3a/WJuDRig5rXfgaNlKHPC7q3ADfuR6owWXz05mCiWWZSmlpJsgeO2qOCsIlm/vaY/p9Pvu6KXp5PH0gH2r6NlaTYKSODg+GHGXEoEnSiyj+0Ecd7Rx4mNHJLTKmHezCa19if4HCOkGC5WOZVqRQRQyxVWjMIM9IDAzcU3d/SlMedGzr4j0qQs+pMQ30QpQIHmP4+tVFFEEU5H7a9csBn/Yd6AD8aBaNFvWGSOdrK6H3Ybk2lGJsFdzXg1STHuDJVPVGYTEquTLarZr9kRAkFFCAHR0pJDuMAUpPYC2DWxZlCorM+3S5N5p873VK0fnctnj9EOsi8bAfZO2/bjGG2dgG8jmSrvhLsfiW1vOOO/OsRzweHQ+E1j/xwROMt8XoB5hgtQ8TnV9TyyjofV4tSw4h11dZW5dRPYQyaqs0Vmq7LIDF6xF+JzF6TI+wfwQV4DRG3VWR99oCEehOwqMwMf+gw4oo9LsmnUoKTLO9ucebevmG8D80OFpjV0VkM+vMKOukdngaIod6k1T9sEHuexOfSSQHwn3b0YC2tLjOuMGYpL0jWZVQ/XMxDWnGv01OKrBoLSfQU8GcBit1mNLdj7UIHgAsMEoNijEZ/ySErcooJLrmvNULNyhghS86KXrG1XBVzsJKnuXgjgn9aFwB/G3ibYJ1hrgA3EgdLavibso4vz9fMTRQLdUApkJzmUn6IjkZiUH9+xSkjgMKktQ0hIS3rAQsymYqkU8CNZ59U6T6qwBqjrLkTfsa9y62zowH X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4acd3eb8-8114-4458-e9eb-08dcee8cfa3c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:20:44.2921 (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: o0n92O3FYS7HLp8EpNr8AuK+h+VQfDPVoVzic/UzyBQ+x73icM5LPl3pXUXNWu9j39xEoOtdEiUJ/a/vJcaPQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9061 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_022054_537824_AE98D994 X-CRM114-Status: GOOD ( 18.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add p_region to struct v4l2_ext_control with basic support in v4l2-ctrls. Signed-off-by: Ming Qian Signed-off-by: TaoJiang --- .../userspace-api/media/v4l/vidioc-g-ext-ctrls.rst | 4 ++++ .../userspace-api/media/v4l/vidioc-queryctrl.rst | 12 ++++++++++++ .../userspace-api/media/videodev2.h.rst.exceptions | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 14 +++++++++++++- include/media/v4l2-ctrls.h | 2 ++ include/uapi/linux/videodev2.h | 8 ++++++++ 6 files changed, 40 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 b8698b85bd80..f00c6d1f7784 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst @@ -203,6 +203,10 @@ still cause this situation. - ``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_video_region_param` * + - ``p_region`` + - A pointer to a struct :c:type:`v4l2_ctrl_video_region_param`. Valid if + this control is of type ``V4L2_CTRL_TYPE_REGION``. * - 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/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 3815732f6a9b..df3cd36b67ab 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -451,6 +451,18 @@ See also the examples in :ref:`control`. ``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_REGION`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_video_region_param`, containing a rectangle + described by the position of its top-left corner, the width and the height. + And a parameter for detailed purpose, for example, it's QP offset for video + encoder ROI. Units 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 diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions index 35d3456cc812..22307e029883 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -151,6 +151,7 @@ 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_REGION :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 9642a1f242e3..8235e681acb1 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -441,6 +441,11 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl) ptr.p_rect->width, ptr.p_rect->height, ptr.p_rect->left, ptr.p_rect->top); break; + case V4L2_CTRL_TYPE_REGION: + pr_cont("%ux%u@%dx%d, %d", + ptr.p_rect->width, ptr.p_rect->height, + ptr.p_rect->left, ptr.p_rect->top, ptr.p_region->parameter); + break; default: pr_cont("unknown type %d", ctrl->type); break; @@ -886,6 +891,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; struct v4l2_area *area; struct v4l2_rect *rect; + struct v4l2_ctrl_video_region_param *p_region; void *p = ptr.p + idx * ctrl->elem_size; unsigned int i; @@ -1248,7 +1254,10 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, if (!rect->width || !rect->height) return -EINVAL; break; - + case V4L2_CTRL_TYPE_REGION: + p_region = p; + zero_reserved(*p_region); + break; default: return -EINVAL; } @@ -1957,6 +1966,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_RECT: elem_size = sizeof(struct v4l2_rect); break; + case V4L2_CTRL_TYPE_REGION: + elem_size = sizeof(struct v4l2_ctrl_video_region_param); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size = sizeof(s32); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 9ed7be1e696f..299451b33e7f 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -57,6 +57,7 @@ struct video_device; * @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_region: Pointer to a video region * @p: Pointer to a compound value. * @p_const: Pointer to a constant compound value. */ @@ -91,6 +92,7 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_av1_frame *p_av1_frame; struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; struct v4l2_rect *p_rect; + struct v4l2_ctrl_video_region_param *p_region; void *p; const void *p_const; }; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 4007041302d3..503cbb884734 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -448,6 +448,12 @@ struct v4l2_area { __u32 height; }; +struct v4l2_ctrl_video_region_param { + struct v4l2_rect rect; + __s32 parameter; + __u32 reserved[2]; +}; + /** * struct v4l2_capability - Describes V4L2 device caps returned by VIDIOC_QUERYCAP * @@ -1858,6 +1864,7 @@ struct v4l2_ext_control { __s64 __user *p_s64; struct v4l2_area __user *p_area; struct v4l2_rect __user *p_rect; + struct v4l2_ctrl_video_region_param __user *p_region; 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; @@ -1931,6 +1938,7 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_U32 = 0x0102, V4L2_CTRL_TYPE_AREA = 0x0106, V4L2_CTRL_TYPE_RECT = 0x0107, + V4L2_CTRL_TYPE_REGION = 0x0108, V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110, V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111, From patchwork Thu Oct 17 09:19:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13839686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A438BD21262 for ; Thu, 17 Oct 2024 09:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UVQIg1NtixnAym91jG7PkhCcVeo4YiC9WHQhU8FXYOA=; b=pkbTpo1smnX+luAQv3Qn7TIPtV zBL63zAYXs3LnO2Ke2zI8UHn3VroYEfgWss3o8J5Urn6/O+YLGpYiJn9+q26AFTzI8aztsAj9xQHw Nkv9328btauKKzgxyUV8lejrb7dBG58SwrwmdGxKfIRRiO1HcAVAaaKd0P7Vw+rEuVje0FLPZ3pmX 7GwV40Cdd/6hvA58u9KcAMg/pccl405ey06uP6RVbkum+izw8K6x0z1tO+3S7B9f4pYf1qwvmIbkC 0oTv/RpOmWgPMnWEeEHYLTaedGnR61Daqmo7htzZe8UVcTRdggVCFD1PNjG1GSME6FauVmyf7Dbfp XtBWlKxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1MpG-0000000ELZ3-3wPS; Thu, 17 Oct 2024 09:29:46 +0000 Received: from mail-am6eur05on20618.outbound.protection.outlook.com ([2a01:111:f403:2612::618] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mgl-0000000EJYk-02Fv for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2024 09:21:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sk2YwWDL4B0R9e/y+5DiU9q9KPWMnb1zLdL8aV283X1kEEKCObPKz76Ux5yWOCll5VNY49f1mJzTKA2ZM+BqNL9bGC+5obpQLUX8dOb+3iQgwvfuGEc1kdMrTGE9yC8CzNcssVycTEHY9e+JN1RgfJsR6rm9D3BPa8YFKgvUi2jFMYWjvBqAVHFXjLr9sjNHX+/JdG4SspjSsI1/RwbsGzyb2L+zhtk3o5WbGRZ/yVBQ+xfD8rag9aeKFKtTla3MJ8xOy6zPrL8DeHRuMbFp6SVpiqVOOmweQjTJMAzFWomNhiyw2OaTRF+SSnI3kmy7IxeEmw+Rg340JTnUQEewfQ== 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=UVQIg1NtixnAym91jG7PkhCcVeo4YiC9WHQhU8FXYOA=; b=e9/7VZJWldTVmVHcspkvKz6UgP37/+G+P0lPjGQC/NRCOoJBhnOHP92lL1fnAbi+feB+MhVdPT1ppoweGmw8M93VRvTBwjRneywBflFKM7Ig8KIu9z9nTVWohHYf1tgecVLtoP5zBH/3/KK0LMlhh625vXqB9MXVfTh2lk5ST8wNPFijubIHzniwdeHre1zV0X3yjp3vl0O1VP5CrfeSieNQgMqxH1K+AC04RgvJvs2FsEzjMYKXfC+94HIMdALw2nXg3DZ8dq2TxnGr196CUa3OAFyziH5n4vqrjzKAJ1qeSCzVIZNFv9q9VIYooKq8oQoFeo+ovcL9yyePuF0Ycg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UVQIg1NtixnAym91jG7PkhCcVeo4YiC9WHQhU8FXYOA=; b=LxogGT2fp88ZgAdQTMQAqYeo1ImpXB/kJ1RAjXyusS0zgIsaOoJcFBPC8kvq7uWSj1UpQSuKGdqD6O/zYACwFGQ3lwTGQnGvfqVkAcT/jwc4d4qC22uaTsH3L9YZGsCOypgRHPWAgYX9CuhQRG61cqaPykYmUvNdFzkP9O6BK4bxyFH4avDFVdk0BDEvv46QguzWn7KgOf/jMqnUT7MUU4RayBOgJQo1nEO8MIcC/DDyOEmixQ414uxnkYQcy/OrYGiJ09iyGQmYfaENXHDO/tA+UrTDZU8sveRMjMM5ek5MwmLDJmITBZb6Up/8ac6W1zuxBnjg9n4TXjdZ9ravWQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB9061.eurprd04.prod.outlook.com (2603:10a6:20b:444::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 09:20:48 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 09:20:48 +0000 From: Ming Qian 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, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC 5/6] media: v4l2-ctrls: Add video roi ctrls Date: Thu, 17 Oct 2024 18:19:50 +0900 Message-ID: <20241017091951.2160314-6-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241017091951.2160314-1-ming.qian@nxp.com> References: <20241017091951.2160314-1-ming.qian@nxp.com> X-ClientProxiedBy: SG2PR02CA0129.apcprd02.prod.outlook.com (2603:1096:4:188::19) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB9061:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c9b58f6-b9f6-4821-1c60-08dcee8cfcf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: CwsiRQWVmKoBnia5lG0+idq5Zhj4UqOyNK30+JctBr0HQIud0eWplF7Z16wtSLgnrTRj4WFu2NSKjebJZ2JkL7Fga7Ei5Z6cc8GudxlfxWjEfhlnHDnvB21SlEHA7YuP4s8V1EAlqJdHBR3Z7c1mc3B9bNs+8s2heIcZpg7a0/wrQIQVoaeD2RwEXai82j9pqbgG8vDjq1H/BfXsxm7VrFP2kh940C8kz0eGU8W9xdh6j+az7G7eWmhx1yjQX4e/e1eCG7Ccj5EIRDVkm5RVw+qA0lLO1rPOadN7bbYAZKzDwyxqLZ1WRh2TzM7O1v4fQaR1XN7KVJx3HsOLmvFa2LlQ5AxbOORoQBLTMEWb1aZ21Jv+zg520COra0bSrfcaPzMWV/EyO+HVEdCBG4/K5FPQ1dMr13sKNdIUa+clBbwWZq0uRp49YvixRPcs9SAATVstSl4d+alzFZFHee0lfEcbry6+0/tJkAma3buV3sAmIU1BlDoxIubrVyUeZ7WvWy9CbUTV7PgCDz6gQq92jZ1rfg+N1qxrfDj2yGk6MF4EB/mSAecFRDrSzE6QFOhkHlHcStQ5JBp56lL8I7mkbiK9GHBd+zmSriv1hZbkjMAQ597b8Xwg5BTITToechk9S8Lqgy4QMIysoFHf1qdOA9fqDpigS3j5KhkhTN+CvW8Owp1uRdatI1GSI6rbEwSoivOSgfFx1HNtmaYFM/mLPBdbnfFsJEse5a6dY+Z8ZTWu3nvYJPT3cHyaJNSGFs1xFW5YPWYoYL7lB3CDzbHrP8xA/UJkrxYtGlAGf93/fFJ+CLd2Z14BF+zgcDZrvB4e674C7h4esZOugIqrptv2T4BSOMbOqrX68uilNAwTT92y994JfY97rR9zm+2AAIXofdP9w4pBUCgTCLprhJjZUfJZRA83pQeEBVKgWU8PJAIn+TqEBXm1xAkLYOe1qDF2641j+OEiIHchZVk2g88DlD4Hvaq0Tg6+ZCkvZWCbDqG03dft7f4UYKinyKYE0xVPSTtPa9uKHddXkRFqYKJ86wlbnkw9Cz+2CrBSYO9RZwq7JYbzALo5EVw1KONO6Xi1w2rLSSGmdHmCXcExxP8IBJ4Izk1ZLO9pqLjkxXCol+Zmb6WQ2j9xESWIx/ugjB8gBG4iEhuxcWOTs+sIvcNiwdB7nkltFfxX9WZEH11V1IMd1eaL3nBH4mKwSO1wURPOWpgqpa7TUfldOmT1nHAY3ZgK8VN+fcTEn7vetjPd933Ts0tf7s1TowCgEJj2VvjnfZrQ8AMvGBf03AzU50nhZBs2q+LEOtxUKSTzN38LmaBfJLQ7QCoZAg3Db4213Q4zqoGJ5NFvL85yRNe4mHdgBM3ZNYkyODnfGPgPUFEwT/s= 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)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mcLdnghg3vAoGlEdISG20UQVOAxB5+G1sMCLaDrjqx2MLkEwz9ztO6FTOBJLlilpFkL6Lu/IWORP2QB8t5/+yb/ofDyLrcu5SHBlppY7H0pIPjTZ5Ti04BpLP4OwA2C35L5sx3cnmFz7skwUf5jyPGjV4h/Pc7nY+Icus4gyxQlWRQ3E1f0UzfQNvFTz6c/V0ATBPtSIParcsawszTF33wD4q506liF0Y0xkIVZ3p2NydgYBuH07I6TqsiNlGAmgnP1tEMfJHpr4vDNbIqEO551/qpCWMKLCH3ZOfCiyJ1FuPsq1lhp6H5Z277/F6nyj2wmcPZ2CHaIvlaJAfmcpXq8EkGlZFVTJq9vo78szWzOX7v2MAVSNJCgyUOqXeQ8RLnbtQlU4zLkV6tQuWdi1y9W4th3ELHIutlAAO8T1+pLvy1qcssQgYdR3tj7HmGrswViGh566G8LqNNyXV10lmNhUBp/cFeLwP6XkLq0iCFZC4SoyLPBl29zkt1Cyr3/fP59g3X6XJ9m8yzTG5qMPmUXsKmmXdtgn0IBi5YmLRbF2suAfxY1bqAQ2MM51ZUwkTUgO3kHSOfzlETyX4GZOWkhetRezbyWkY7zydYTOzwbZuz5OnoakWBFIIM2yKQdCGDsNV1v9EuC7kTYvKGFT8T75CpNF4VoK1AsjB6BbD5Hv28dLFhwaXq40xzL66pkbgXEDdFQOYbNISnEnrvkmyBBaVIBSO/7WpyvmebRNfBZw1YpHABlV+cxkKRbv0XnqqAP1Ge6qW6Dw8ib2y/0L/IEr/Y1Bp7Rb5ly/5/nA6Ht+Ok3AOJRvPjGH5ooCrg0Qv+vOK/3ejaGkU3PunozbVw9FVUoUM+P5su9H9P73CxXmfQANeXVF2EfMV8MukVMgwFxOM+36m8KCkfIljE5KOJi/ZYaHuhtWp9mS/+C1tab5t23Q385IBDB2giBSfuhLknWrWFqCmweqZlBJU2C/zt49dxqHYSI1gdJW3ZcY/XaZrZ+agJQgkSSX/RX78Hokv8jaeqk9ywIo7tSzjAA8NfQfR9A444pNbHHN4fgSb9dnOsZVWQQRjVMqSHt/htDkJKqGp5bg4U33wlYBPJcELid2P4wkL27e320dUTNit8Z+gMJqJfpfnO5E47rf584IGBO1NNCvVWCnHS27VIc+pJ6/A0mXtole7pK3c+H7sqB0yC3qzWDxoZrxKblmngm/a2iHKmp8MrvKpkdwKHjJXt/qcY72DT20xcsOSIQQfIoiv65T+DorR4i89hcO+XpjJGDs0L9HANRc8Sf2/gYRdQeq3SL6CzNLXxhtLS+7ZTazIJGT+sHfRr+bye7+0jUMJAExsp15WqqAGAL+/Ft/UJA4IzTAgtbNHFwiAwDOFA7XipECRReWIRTeicMzM4Su7TmKRPLSpmXD0K+ab/edfnfHigyiETksOh6ZcMVH5zg8KL3bVfxQr2QHmFn+e+vfXowXFbjxgtvgyqpqrcykDnSgnqPNbwqp3kzXlmdplufpQ77kz4iYkmnDTeG4mv8rApYHOqRlQX3Eh4CrgazJLRnI23OzVc0rppEUfmsI3vqswSEJ5QTXEWUEZIVBTH+N X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c9b58f6-b9f6-4821-1c60-08dcee8cfcf2 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:20:48.8110 (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: nC5dd2QdlxhljMcGyDLkhtbpwkCUsdsMkx548O91SSBXZ13vP6KSYxmGJ1ht5DqVVHF4xeRsEzGx7XtaDbVwdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9061 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_022059_141527_C1392D8F X-CRM114-Status: GOOD ( 17.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add some ctrls to support the video encoder ROI feature. Support 2 encoder ROI configurations that are rectangular region and QP map Signed-off-by: Ming Qian Signed-off-by: TaoJiang --- .../media/v4l/ext-ctrls-codec.rst | 73 +++++++++++++++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 29 ++++++++ include/uapi/linux/v4l2-controls.h | 10 +++ 3 files changed, 112 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 4a379bd9e3fb..6b972247778c 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1667,6 +1667,79 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - Codecs need to always use the specified range, rather then a HW custom range. Applicable to encoders +``V4L2_CID_MPEG_VIDEO_ROI_MODE`` + (enum) + +enum v4l2_mpeg_video_roi_mode - + Video roi mode. Possible values are: + + + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - ``V4L2_MPEG_VIDEO_ROI_MODE_NONE`` + - No ROI in the MPEG stream + * - ``V4L2_MPEG_VIDEO_ROI_MODE_RECT`` + - Rectangle ROI mode + * - ``V4L2_MPEG_VIDEO_ROI_MODE_MAP`` + - Map ROI mode + +``V4L2_CID_MPEG_VIDEO_ROI_RECT (struct)`` + Select rectangular regions and specify the QP offset. The + struct :c:type:`v4l2_ctrl_video_region_param` provides the + rectangular region and the parameter to describe QP offset. + 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``. Applicable to + encoders. + +.. c:type:: v4l2_ctrl_video_region_param + +.. raw:: latex + + \small + +.. tabularcolumns:: |p{4.0cm}|p{4.0cm}|p{4.0cm}| + +.. flat-table:: struct v4l2_ctrl_video_region_param + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 1 + + * - struct :c:type:`v4l2_rect` + - ``rect`` + - The rectangular region + * - __s32 + - ``parameter`` + - + * - __u32 + - ``reserved[2]`` + - + +.. raw:: latex + + \normalsize + +``V4L2_CID_MPEG_VIDEO_ROI_MAP (integer)`` + Specifies the QP offset for each block. This control is a + dynamically sized array. The array size can be calculated + from video resolution and the roi map block size which can + be got from ``V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE``. This + control is applicable when ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` + value is ``V4L2_MPEG_VIDEO_ROI_MODE_MAP``. Applicable to + encoders. + +``V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE (struct)`` + This control returns the roi block size in pixels. The struct + :c:type:`v4l2_area` provides the width and height in separate + fields. This control is applicable when + ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` value is + ``V4L2_MPEG_VIDEO_ROI_MODE_MAP``. This control depends on the + encoding format. Applicable to encoders. + .. raw:: latex \normalsize diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 1ea52011247a..54219a3b215a 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -612,6 +612,13 @@ const char * const *v4l2_ctrl_get_menu(u32 id) NULL, }; + static const char * const mpeg_video_roi_mode[] = { + "None", + "Rectangle", + "Map", + NULL, + }; + switch (id) { case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: return mpeg_audio_sampling_freq; @@ -750,6 +757,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 +980,10 @@ 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_RECT: return "Video ROI Rectangle"; + case V4L2_CID_MPEG_VIDEO_ROI_MAP: return "Video ROI Map"; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE: return "Video ROI Map Block Size"; 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"; @@ -1512,6 +1525,22 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *type = V4L2_CTRL_TYPE_INTEGER; *flags |= V4L2_CTRL_FLAG_READ_ONLY; break; + case V4L2_CID_MPEG_VIDEO_ROI_MODE: + *type = V4L2_CTRL_TYPE_MENU; + *flags |= V4L2_CTRL_FLAG_UPDATE; + break; + case V4L2_CID_MPEG_VIDEO_ROI_RECT: + *type = V4L2_CTRL_TYPE_REGION; + *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_MAP: + *type = V4L2_CTRL_TYPE_INTEGER; + *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE: + *type = V4L2_CTRL_TYPE_AREA; + *flags |= V4L2_CTRL_FLAG_READ_ONLY; + break; case V4L2_CID_PIXEL_RATE: *type = V4L2_CTRL_TYPE_INTEGER64; *flags |= V4L2_CTRL_FLAG_READ_ONLY; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 974fd254e573..f6ed8e2f2de6 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -900,6 +900,16 @@ enum v4l2_mpeg_video_av1_level { #define V4L2_CID_MPEG_VIDEO_AVERAGE_QP (V4L2_CID_CODEC_BASE + 657) +enum v4l2_mpeg_video_roi_mode { + V4L2_MPEG_VIDEO_ROI_MODE_NONE, + V4L2_MPEG_VIDEO_ROI_MODE_RECT, + V4L2_MPEG_VIDEO_ROI_MODE_MAP +}; +#define V4L2_CID_MPEG_VIDEO_ROI_MODE (V4L2_CID_CODEC_BASE + 658) +#define V4L2_CID_MPEG_VIDEO_ROI_RECT (V4L2_CID_CODEC_BASE + 659) +#define V4L2_CID_MPEG_VIDEO_ROI_MAP (V4L2_CID_CODEC_BASE + 660) +#define V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE (V4L2_CID_CODEC_BASE + 661) + /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ #define V4L2_CID_CODEC_CX2341X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000) #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_CODEC_CX2341X_BASE+0) From patchwork Thu Oct 17 09:19:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13839687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99A13D21262 for ; Thu, 17 Oct 2024 09:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZsrsilQB6hYf/CppEdLlZz46gXU+VJmSX74tnVqkasg=; b=AgODLgFm3QusgilPLO7cG0revR hdCKVqiGYT8h4/WZvFf2JdcRIXmmBcDK9MvR12SRHyxT8gMQ42qSo4wb+no5vQS9KDcCOgEb9RWUj OYVC5/swV1sEjEaU50Bz7MGwtTUdifUmapymqIjNBg4p2qjtj6J5PIQmb+CYe7nJrebSTHl/c5u40 4Wdigp1UGOIf3jSfP9LOwXRxTQhmQtPFQ6gvgsQdENgwCs19hsaupoBq9iBjacLRabgOz7oxvGksa xuH0u6B3UTHjEOV6iEpUdwGhq1HM7FzDnp9ywM6eHl9cXAZDZiqH359XgPeZQUSUSvKuP/j1LQbJL jjrTBxmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mqj-0000000ELve-3CXd; Thu, 17 Oct 2024 09:31:17 +0000 Received: from mail-am6eur05on20618.outbound.protection.outlook.com ([2a01:111:f403:2612::618] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1Mgn-0000000EJYk-12NR for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2024 09:21:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XV2OKcx/FKhb7SgYqR+0euKbdYZIowN4W2IWY5GZVMnY21NsuzSDgwzFwyONT2yza62jPY3r0rf+e70QPbs7U9aBZcEhd5nMjk3oSXe1m8OzcgEZT0231G+ekU+o4+a6dm2/noAEWkVkxOCd+8//MwktnNF5gVMWoRTUBhemjJ2mIFt0bndaM/ByemMf15howivXodWgYIjKOHcigdqJr8vNoGhux7ct2YHF3o8Q+/WbEmFIMyv5APEP01VNe1tOOtVQeTZZf3qHYj+B4bqGpaS4EFUI7w9nOAvjoct3O8tSLDNBqWYm0f+6VUMACsPYexvx81Q7V8fgeGSRxMa6vw== 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=ZsrsilQB6hYf/CppEdLlZz46gXU+VJmSX74tnVqkasg=; b=Y2wJfwNizD3lfP3/ONRm1gRkajqVkV5uqe6QU2BnY51GTCdwTgY74u/a+lvyS9SOb4h6IqAQPbQSv0HXKqpfaA9i+KSQQIw8Wn6Khbv/HF3AzMk2h5mAkNtsL3yVNFR3l+MS1r0fWVrwa5PUibT887cu5/cVHIVhjvPvg1uPkXV5hWgTwT3c7opA+CuNyj+VakbNR/No3EjoSFN3gpKqaMmbVNZ3Zx53aXyft0gd50RySQO4HghPndTVtMGdUc1yvjEGgq01/Zw3NAXul0m5pvJFq2xeWJahv2dnyhICoFyTHKpmodsOdKrDfqAbIMSF88ORKV/6SJy8lHtat4NGTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZsrsilQB6hYf/CppEdLlZz46gXU+VJmSX74tnVqkasg=; b=CoeDfK2T2IfQ8XbrjZN4+Sb1YVpmHabcXUShjEukKhRPirsuA5A6Mx0TGBVahYVBd4DubTxKLb8aVVAUaNkw3PMX3YkZn3lG/raJlTkShCqH7T85rjzOBF7JzZtVkPnUrfyLJBf5ur2ZJszX7G0O69NXAl2H36RlZnlR8T3lHstYQhsWS3L3uTtrhcp8MOtpQGU8bIVMuZRZwekM+BeW5Xt9d/0YsLqUjeq3TQjbyEoZ66gsuNN1tq2H92Kk8aYDdMk/XkCX7BzRRiwxufp6gK9bOWQzuCiAU/f1lrhfHktXHb0oPNJgTPiay0UCPZFgj+S9VqgAfrgOr84V2Q18uQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AS8PR04MB9061.eurprd04.prod.outlook.com (2603:10a6:20b:444::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 09:20:54 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 09:20:54 +0000 From: Ming Qian 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, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC 6/6] media: vivid: Add a video region ctrl Date: Thu, 17 Oct 2024 18:19:51 +0900 Message-ID: <20241017091951.2160314-7-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241017091951.2160314-1-ming.qian@nxp.com> References: <20241017091951.2160314-1-ming.qian@nxp.com> X-ClientProxiedBy: SG2PR02CA0129.apcprd02.prod.outlook.com (2603:1096:4:188::19) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AS8PR04MB9061:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c79d7d8-c2b2-4ca9-219d-08dcee8cffa6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: Ds/78agqoIlNAiOhoZ5Q+HxhZuZq7ER1GHxM5EBV3Nrif7PrebEYpmZ/Gm+MX9twJLULk8S5HGcIXmr+ySLGWfQVpW0e7gwvXndL5PbHBeX6BNx1BKyvgRbNiRqL22YvtxzsXcm/hWqa2GWlk8UHMu6wobMdlOH0DGlIG3Q2REhGmykA4wB4HphViK9lIOiH0ekdqn/A1XEE3v3bYTFKVPoBlQSuOUtZk9r5vFDKWnSJ1lKd4nAtD/LKSTWTxnU/FV4rxLH8WBX0sFoSZgHw0JYmq9c7f1lYgHLLK6JDUwWtcbQDin7cV3WjYqdPrcqZs7i3pLLAbVjy9ELHdiHSiocnbUWL8w3pJiPFBbq0/6XPNufx0N9W9Zbv+4OMTjsBDPrXoAiFnwr3ZRb80wvpyOToHmMQLoUQHydLPZvBQAfFqDnGE5Q8AnHUs6M9NTlCoy0e6pBwxYMSuTDDoXs9hjlexHgk2/dYTkmE5Fz5irbo/UpWtdJJ6N6c3+vi4UPvx85ypt1Q5qeayBGC6nhT37xTUH1SSDBL1ppxB7y+aGLtkWsbROgTjLUdyJGcka6zQYExXiDgNaqvCcFl2q39hwSlv/mWvboN0uXC0dM4q7mQrbFFu21DEGnyIso4zV5aHsccLGZvvBGM7clBcLqlGxI22U+sKtDnm0Q6eoYyaHL7ebdWXUw8q85vxVqUO7bl/+53MqNCIAgYzzpX8qhHnhM5HMQUxoLBrT4sI3XUk3Zjg7QMfqX9OvVeQXvT0mA0muLdZ/wPQh49OmOu9ogAvU+pRdcze1ibnLy+sRs0jPu1AE4ugCIVA4bHMnnnZ4cRgg1NCoLfDwwa0oIvNtnLrkUzTDu0PrXAFwlnl+hAXipfokui9jZ9EPFcMax7XOhKpNv4WVLp97BC6+2wjxY32xt9nnwzVN/bRl4Y49CEG254iLeu39xHcDjFPidNMvFsth29xyFav7Cd+D2cC01cfQVYqYQ/txH5teSzyYwbB0aiq/1XlyBvEgdU5eGjmbkA3y7SjfB1bV86s8ZcOqfrj9zQvBFYh9E8KApChGSXcC5mvvvbIizVztTG2D9o0zlkjnxrCduCDX5aUSmZaS7aU4cS+VsmKJOpIe7GEfBaARla7G99ijpWujyTI6xPKkOwHKSJ95EHany2evmLPjP+1/sJ0BvtaSJAhc/mGdm2GqSSdEAWqxCHE8kQzFou3wWysrIMkwi4buHk3HHWmm7tckLDJChOgXqL2HcvqotRFuSTOY2LyptogXgM3ea6MPjQU8vj1iiBbSV1gF23It/J/SdY0Am2LYrxo1PrzD4vIeWm6QyYig+56n8Sq2x0exXy2iJDMsUj6KW28S+nApd1l01JqyL1LX3VTEpf7JmGn2w= 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)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wqMyBIiSEoKZDdx91ID3tw8Kuy+1OzkT2ORy7BeY9Uo2VSSL+MlXOXIBqmWwmjul3R+B7GLbXfhmTu/mLSc1C8hXiEXnfrMYE2p3aJOzb5ZfzP2wzVApu901R3pMZGV1dvHA/PV3IKlKmaffS20Z3XGzL0fRAvhDLTbo5+mltLeMkuw/uk5r1wDuPfItTv2Lx0vxYWbzywQKrXhdn7vgB9OK9WcdmEBNlYbw3jGJJF3bEuySUWu3CZKPWYVAQEdxNLHjX5/aWSGCt+ZZT/stes3CRu9IW4SaUF+S+YjhWKB2EnHyG7wUT7z7r/5oN93URhHvT1HZRxJrYKwd0VIZM4g/zngcbB1V0mg18N8Dti1iTtXtWdIJsXvIHLk5AvQ0eubn2+OMI2OZ9L0QoufJqeYYS6S9qPj0TCEFTM39kSqLmy2TOqDjEUKo9aiBWGBazMT3cTJ9IpFMLCr8yegbfpFNUrRQ/MZFbT4pegrDLc8ByUYC1znlDPBT6tNiCwzy4P7fH3NlIxUhLrXM6hbu5x7Ti7XfHzpNYq9NfDFOxmFsH44tWuHSwn1QGTTl2DWbCiR4JGvzyII+Ebg2s6zV7n+JVSV/mwVpG0cp1EHBtiN+V4FvpU2c6vdqHMoatYuCDRZ5ZQ2iDMJxiq9PTBCQ0gN3ijg1b7rRVTUI21X/db786+CUpe5Vnptdgz22TZPWPtPPrBlfflm4y+oH6nYgtP8Hs0NbNJvBm5c9fas4oBcwxNPRcdRF0yskyizOQAPXf973xzoQyDRI2rAKFfv8tn98uNpA4mQ6BRo8DYsTeQonMEuhoAWBkBllbKnfQ9cQYzt3UAmKkLlLtl7UCYhCDMsA3wUO1NQiOLLCv37dTs6SjvozbdF+yWq70WVHEdV0ZV8i55OA3ucq5H4WLV4QRJJV/yJflYELvBRJVSCFn2/9YltoUOzeLDT2x5MB8BPftLcW+JVB6fDjcuGvfS04oMkrVxoMXhG07Gs/EeLwqXdN3fgcTLgdWjZaagP+GXGq6VBK3QxEDeFLJWk+j3/UKU8NV92ktfAqW2JsSza4VjPuvt/CI7MwRflR752RouKFLHhpqMz5JSM9rZbsNx48kymAQy9+Vnj3VJ2QnrNhDyK+xPtI6X+C7+iwICA901ymcO8AS8xz3Ywa7eNQye1YAnhlpzNoH3VzupWUsAXZLV7n2Ru9APP8ol+FRvSCL8nYuMA37ppFDGiHjhgDjqv9xoyH+eapHjvLKxDlW7O7iHNj7OUZ2J0Fd06zDnDQDmO5MoFo5VdM0zlD9SR6ohbzy25TgFn8eJGGv/qf9KKEX3IPXYbxxXhw4XO65WtEXiPegigkVX4L7V2RenLPBNyvKWW2Ka4e8msBeJCjskGtmT4oTH0YvzUFKraVZ1/7UlAIyIwXT8I+Ej3wEZMrDyzIfN+6hynSVvU9AyuZ9IKFEzUFpmKjekyXv1I2LCwaKsDxRyx62yByRj3L8ZABHAdCnGQ7m2OBeL1WZZz8szh0kCfUpxGYtiffXl9F8q8dvdxncmgKq0TixaqE+RFJ/xrpSSFsyJ8pL9mSZDIldltCFeR9liozHl7Ai6ca6ffds1ck X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c79d7d8-c2b2-4ca9-219d-08dcee8cffa6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:20:53.9269 (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: LHWKERgcjRNW1oVN7NE9PegOdHyfAq0IiUJjkq2vJgw156ewuerO12stkcmnUkvthyNSBIAdYLNN8y7M/GjsEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9061 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_022101_308137_7B2CA775 X-CRM114-Status: GOOD ( 10.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This control represents a generic read/write region. It supports V4L2_CTRL_WHICH_MIN/MAX_VAL. Signed-off-by: Ming Qian Signed-off-by: TaoJiang --- .../media/test-drivers/vivid/vivid-ctrls.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/media/test-drivers/vivid/vivid-ctrls.c b/drivers/media/test-drivers/vivid/vivid-ctrls.c index bed5f4fb0c69..6ea64bea13de 100644 --- a/drivers/media/test-drivers/vivid/vivid-ctrls.c +++ b/drivers/media/test-drivers/vivid/vivid-ctrls.c @@ -38,6 +38,7 @@ #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) +#define VIVID_CID_REGION (VIVID_CID_CUSTOM_BASE + 18) #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000) #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1) @@ -393,6 +394,32 @@ static const struct v4l2_ctrl_config vivid_ctrl_rect = { .p_max.p_const = &rect_max, }; +static const struct v4l2_ctrl_video_region_param region_def = { + .rect = { 0, 0, 0, 0 }, + .parameter = 0, +}; + +static const struct v4l2_ctrl_video_region_param region_min = { + .rect = { 0, 0, 0, 0 }, + .parameter = -51, +}; + +static const struct v4l2_ctrl_video_region_param region_max = { + .rect = { 0, 0, 1920, 1080 }, + .parameter = 51, +}; + +static const struct v4l2_ctrl_config vivid_ctrl_region = { + .ops = &vivid_user_gen_ctrl_ops, + .id = VIVID_CID_REGION, + .name = "Region", + .type = V4L2_CTRL_TYPE_REGION, + .flags = V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX, + .p_def.p_const = ®ion_def, + .p_min.p_const = ®ion_min, + .p_max.p_const = ®ion_max, +}; + /* Framebuffer Controls */ static int vivid_fb_s_ctrl(struct v4l2_ctrl *ctrl) @@ -1719,6 +1746,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap, dev->ro_int32 = 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_region, 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);