From nobody Tue Nov 26 10:43:58 2024 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39F5617B50A; Fri, 18 Oct 2024 05:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230334; cv=fail; b=P3Oy66Fwqt1FkW8dffvvcn0RdWJ2l0gQaiJmNQEeDOUjgYWqmVELOg9SAWt2rH8p4fWynmemiNqgJsmiJwsDBa+vCPXbH6egSRvnBIwMQpfhkBKSZ9/M5p8OtxzhrqwqLZ6tdabzclxhC5aQcpD/r+bxLnTHaFD0QEfqtJuwitU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230334; c=relaxed/simple; bh=eEIY+eIg/YSUi/78YoKXcW1GY61OT8DPIdwv0d0IZYs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=UcqvBNCvEgO1XTtJcoxR3SS36QznAviyFV82QDEO5+ua0Klj7ShUYhtIGzNl4pXROwHtvWeW0Tw6Hl3pz/2uK5TkRDHpEJfmtyO4O1rsDv9W5rO7veUrbl6WqcQnArF9dkBHr9GZUr17anYKXzdS5E3wrXdkxSR1eomr/xkuJjw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ff1RSGWi; arc=fail smtp.client-ip=40.107.20.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ff1RSGWi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qQ/i2J9jwlzOYzgXrfyWUtHJpX56EjA50ufAFzL2evswHFlvSFBwoSzD3vfikRfW40WUjUhj8Q0Q2KBkEJrwuNMt6FWm7Ypgzc2NrRLJT+2VyGajTM83CdH7GlLavkQEIN3fUcgH42jKPSK+kmArDig5EEDzhvRpo9LvUFxlbBKwcr8jJdVrgY6ql94ZgRUOzKhjF7eyHvpYtHTIsfTKiE4scZItgV7qocXNxjoBX683ugypHmBDFA3Vgos2p38SnKCw27H/dwXn4APc7zHpXTKDAAHgYLjB9UCImIeeJcvvFHSNe6KtNXAd8O3+s2W1vxk6trhiy2n8GOM57VGqvQ== 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=GlyiRzh/3ihpEBXSlF2+tkkXxa2dym+jUAboQFUTmTC0QhAJLiGyW8NAKz5tFPQA85sWpl0uEejMW09OgtfNMgClI0xcv/Q/GE5Iz9FKJRQKVu0Nt2GdbRClT2uF1pdhRtf3sAYWmNCDdU+02QNAavEoIQFz4auSXls2IWU9H/G9t2bwu5WLXqdiWVHgQE4xZkEFCY2HSVMeQmpSNoHFFa47IIL2bIoABUByNHFzTgv6aCwQy8fsLN3a4VxPw6tCZOZdi9LklafRehE55BjL/QJFcC2kNGw96KVBV8TaFOL48zOtHiVu9AmM73ygDvPFhm/8gw/iMpIbLZlD2jAbpw== 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=ff1RSGWiuL6Te5ZLW87wUPrq7fvjFDv5xp4Jksiprn2bOP9/GjK3s7SX49LbKOqg6zTDMry+SeI/QP+Ns1PDWHkLXunkHqxHrBEs33VueaZnZfUdyON+0ptWyjXEdY0spHXnmwh2dMIHkPG4pvD6+SHkq5yORihBhvgxDRBIdB+SriHc/WYRJ1zdnX10NTocVh3Yy+DkYG85Cohb/f4C5iTGtrRulylH+oxizFdoqQkoVKLtMXvHK8phhVjvoxRC+4cO4Gy7WNASEoJ637g7r2krGIYs5sWMhABzy97ZRqnZYv9ukFB+kc1tDj0E9z37yElQU36K9TdMsQISuzES2w== 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 VE1PR04MB7312.eurprd04.prod.outlook.com (2603:10a6:800:1a5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Fri, 18 Oct 2024 05:45:28 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.020; Fri, 18 Oct 2024 05:45:28 +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, ming.zhou@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 v2 1/6] media: v4l2_ctrl: Add V4L2_CTRL_TYPE_RECT Date: Fri, 18 Oct 2024 14:44:43 +0900 Message-ID: <20241018054448.3190423-2-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241018054448.3190423-1-ming.qian@nxp.com> References: <20241018054448.3190423-1-ming.qian@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::15) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|VE1PR04MB7312:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e66f146-675e-4eb1-62bf-08dcef3811e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9K8X8m80kXHxG9u74PuBW91Dy8J7lJcdY+TDixzCi/QX3KAOO+zRKFpDezVc?= =?us-ascii?Q?7q7DgbHtxyvRc+eKrmyff1JC09Sq8sH7UDxTFDyray+yCXTAo7ixQvWOAvSn?= =?us-ascii?Q?HCWJDmHmTMGq6BaQPLGuNpJu2JQFF+PsfsLhuMZXBh81rhP2G+gARdN3B+Cz?= =?us-ascii?Q?NErLg2omHdsXLhV2S9b3TIUbk01cwTLabOb7AtipgDNr5d1X9FH3mRKZ7KJT?= =?us-ascii?Q?kTSGi6e0O0NjYPdk0AmH04j4Pn1367Xbb50P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us-ascii?Q?zIebt7LUD30fCJVDb6kLq3rlUv+D7s6N0l+h3+vEc/nwz4SOuYxd6IVoxPTD?= =?us-ascii?Q?Ds8f4UssKAbL9aj4oGxtnrElM7jkOK9udg4XlhRdIakLZfsfWNUH+twGS5/Y?= =?us-ascii?Q?KpXmy5QzjPjUx+jq5wHDlTkgS7AGfmOt0GJ2pB1wHSbeORnv8pTSBl517Mqh?= =?us-ascii?Q?H3FWyqqzPdR/Zm4uQSmUq3/2Ql+Yi3HHY1GH856aUnFkOETq4Mv/tYAmM08s?= =?us-ascii?Q?r5bq7zQ=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+DRhV38qRprBFsyh8MlXCvwGoBmvv/3sSRBYYzbD+hwyUX5syp2hn9H27bfB?= =?us-ascii?Q?yFL3cZDYUO0Cxitb1YyjycmdxOMO5xhKbrp0hatrsLeixCtAVPGK/DQPB9r9?= =?us-ascii?Q?xPkA6RnqfcLlK1XPphtahWs7VY33BYaGda0rSDx3MGej1c71gIf2ZF06Pk7T?= =?us-ascii?Q?FX7d67YbU+AXCY7QKANPyt4yXbR4DH0j4ZZlnd1R5744mFwcHN+k7VhzVJRO?= =?us-ascii?Q?lPnQikbTc/k2Icc0CpP14LhZXgaxPJGQd46VAWtuRv4Vy7n9WaqUH/Uj0uE7?= =?us-ascii?Q?rkdVhzA97Zh3yY6Qf2Y7vWRe/qwcHPDwO4DKX+5SXVd2BxlDP0WEfQlMl7Mq?= =?us-ascii?Q?xbBE8QANnncYLBL5riwnQD1/AwAH8T+9WRXqBNLLiSZ1S4Z0EOGgJ/Xbyddb?=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8n1wDp8fd/H4jwpPdG+NS5CatbA/HzM8aQrf8y+CIv44?= =?us-ascii?Q?NvX/xTqa7cFrRj1yYvqJgZpbVThEnNO1fLGoDR0d2Yn5y+1mss8vhzBrJvcc?= =?us-ascii?Q?OSSz1znNj/l3kj1PpDwTiLx+IGRzQ1l7SfRWziZOBG7cbU61GeSAWCQUED5W?= =?us-ascii?Q?yIwbTk6U0T3+GH3Cle0E/BmRvqQqOYH5FPIPngcbjhm5cnsqVnwG/TzmWx8S?= =?us-ascii?Q?3EhOA41EN6+nr3qA00N5awaxmUpzbRaddX5tEuEJxz5HcSNe/XpHLJ91GwGf?= =?us-ascii?Q?e96o7RLrSxtW3D3dPjgAJsz7LHwwuLCHcFmSkNlx?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e66f146-675e-4eb1-62bf-08dcef3811e8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 05:45:27.9214 (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: LRhnQrqsmq5U8G29FsMrsRSvsKlCeIL8dOkUhAL2H4CfvDo1UWA3VzH6ho0KfUQc+vKqSuE+QaMk+f1eKNfZKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7312 Content-Type: text/plain; charset="utf-8" From: Yunke Cao Add p_rect to struct v4l2_ext_control with basic support in v4l2-ctrls. Reviewed-by: Laurent Pinchart Reviewed-by: Ricardo Ribalda Reviewed-by: Sergey Senozhatsky Reviewed-by: Daniel Scally Signed-off-by: Yunke Cao Reviewed-by: Hans Verkuil --- .../media/v4l/vidioc-g-ext-ctrls.rst | 4 ++++ .../userspace-api/media/v4l/vidioc-queryctrl.rst | 7 +++++++ .../media/videodev2.h.rst.exceptions | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 16 +++++++++++++++- include/media/v4l2-ctrls.h | 2 ++ include/uapi/linux/videodev2.h | 2 ++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b= /Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst index 4d56c0528ad7..b74a74ac06fc 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst @@ -199,6 +199,10 @@ still cause this situation. - ``p_area`` - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is of type ``V4L2_CTRL_TYPE_AREA``. + * - struct :c:type:`v4l2_rect` * + - ``p_rect`` + - A pointer to a struct :c:type:`v4l2_rect`. Valid if this control is + of type ``V4L2_CTRL_TYPE_RECT``. * - struct :c:type:`v4l2_ctrl_h264_sps` * - ``p_h264_sps`` - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this = control is diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/D= ocumentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 4d38acafe8e1..56d5c8b0b88b 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -441,6 +441,13 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_area`, containing the width and the height of a rectangular area. Units depend on the use case. + * - ``V4L2_CTRL_TYPE_RECT`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_rect`, containing a rectangle described by + the position of its top-left corner, the width and the height. Units + depend on the use case. * - ``V4L2_CTRL_TYPE_H264_SPS`` - n/a - n/a diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b= /Documentation/userspace-api/media/videodev2.h.rst.exceptions index 429b5cdf05c3..3cf1380b52b0 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -150,6 +150,7 @@ replace symbol V4L2_CTRL_TYPE_HEVC_SPS :c:type:`v4l2_ct= rl_type` replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_RECT :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR :c:type:`v4l2_ctrl_type` diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2= -core/v4l2-ctrls-core.c index eeab6a5eb7ba..4c8744c8cd96 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -370,7 +370,11 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctr= l) case V4L2_CTRL_TYPE_AV1_FILM_GRAIN: pr_cont("AV1_FILM_GRAIN"); break; - + case V4L2_CTRL_TYPE_RECT: + pr_cont("%ux%u@%dx%d", + ptr.p_rect->width, ptr.p_rect->height, + ptr.p_rect->left, ptr.p_rect->top); + break; default: pr_cont("unknown type %d", ctrl->type); break; @@ -815,6 +819,7 @@ static int std_validate_compound(const struct v4l2_ctrl= *ctrl, u32 idx, struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; struct v4l2_area *area; + struct v4l2_rect *rect; void *p =3D ptr.p + idx * ctrl->elem_size; unsigned int i; =20 @@ -1172,6 +1177,12 @@ static int std_validate_compound(const struct v4l2_c= trl *ctrl, u32 idx, return -EINVAL; break; =20 + case V4L2_CTRL_TYPE_RECT: + rect =3D p; + if (!rect->width || !rect->height) + return -EINVAL; + break; + default: return -EINVAL; } @@ -1872,6 +1883,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ct= rl_handler *hdl, case V4L2_CTRL_TYPE_AREA: elem_size =3D sizeof(struct v4l2_area); break; + case V4L2_CTRL_TYPE_RECT: + elem_size =3D sizeof(struct v4l2_rect); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size =3D sizeof(s32); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 59679a42b3e7..b0db167a3ac4 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -56,6 +56,7 @@ struct video_device; * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure. * @p_av1_frame: Pointer to an AV1 frame structure. * @p_av1_film_grain: Pointer to an AV1 film grain structure. + * @p_rect: Pointer to a rectangle. * @p: Pointer to a compound value. * @p_const: Pointer to a constant compound value. */ @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry; struct v4l2_ctrl_av1_frame *p_av1_frame; struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; + struct v4l2_rect *p_rect; void *p; const void *p_const; }; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 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 =3D 0x0101, V4L2_CTRL_TYPE_U32 =3D 0x0102, V4L2_CTRL_TYPE_AREA =3D 0x0106, + V4L2_CTRL_TYPE_RECT =3D 0x0107, =20 V4L2_CTRL_TYPE_HDR10_CLL_INFO =3D 0x0110, V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY =3D 0x0111, --=20 2.43.0-rc1 From nobody Tue Nov 26 10:43:58 2024 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EA2917D358; Fri, 18 Oct 2024 05:45:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230336; cv=fail; b=RksEmJdktMHLRvEm7P+2w2o+Su7qRoeYUA8lnC7vyHy8DuyUuS4wcSgBPNK1fxmR4dGRdERe/IWIKtStL5QtOfEgA4dIBEBfNZZt4OENdkbmdORLnTp/0v1UIuI/DCwQG3PY7QPPXDKtutq1Ugw3G324ULPKIcVBlgQOFWVJD34= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230336; c=relaxed/simple; bh=V9uQS5qYmiXssOXx3/jo+h9bUk3tmEJA4+u5KYczP+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Yo5K7R5rtf5WTay2JZKAUlyyndvCWFVXqRWykNR3s68pe2IOAgngABgz1uW2kRl02HXnnQ2Y4LljKq3BMIJ2EiRKJwM75Jow4AlwpQjiuO6dS09ZD6+ayH6RE463E25gAllQxfymSujbqobomrpNbFJojTr8ntLSyhJiFX2pd+Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Y+yYgOoz; arc=fail smtp.client-ip=40.107.20.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Y+yYgOoz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l/vm5o79Hh8mIXo3SSB4Ww2ESqySFMLS4aX0iAcX4bv8Xxpe9boAPHpOTemKLjB7W/5AUm6Cwf9VB1cqRlRrjqSv87hQs9CHAMoOtQwG2qFfCCv6IzGuYWxolcSq0o2S9mbLslF2bkUrTsxg9uMKxFh4+4/gWN5EW68FLk4ZKoxTJuXgOBeo3IAFL/56mfF5/M5Phv1o3Q0wX0cjdU5prNzB3f6JEUWV+2UDhdWcJ5tAsU/57Fg0UL9XI6H+Nf/qoBLh3xQDtkCobFMdELKe4cCDLXwv6mgi/bsOdBhE6On+cqLzLdEF6MK0czo1/CR3WCi+19V7kTNgMj/0LsJ6Gw== 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=i+nVJMXuBI7w+AfZwfAehKNVqGY0t6gWXspHANczKe1M5T2SNq7x4vNvoQx6OrOY7vpTWQdQmOgxJuWZcLNn61lQfxUcrZELQJxQW9mRJFsjlq9IlsXhozIbAaUzX/RllPExU/RaY5jwRUf3HeLMxO8BRzCBi+c8misqkfU7tlHs6EWh+f/5NdFFiqWA5xdiJSbwpD0n7fUV+NIHsaROCiW2R4YylFDs/912heiEMAUHnnoJ0CVnSIs0aOQTa1gQxFfNa1ClxAcXaIYBrlU5r30cT/xz9d3lmNbmYIMaTYaNCVf9A5TaBHxv7WgKovZgjw9Yyaf3Pa6KEF+Q/AshMg== 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=Y+yYgOozV1yrRMyT9jRbrBMfpyqvLWubAOpMpB/2rEVQgFtoBbsGnev3wn9IN7tlAi4S4lUkL9oPMdslTC5Zh/wKoMmSORzjIqhkpTF7hxQ8Sh6WF3fHsapgcEyeOmoGxgkbpRdhFded8Aq91YyL9tVIkzK73R7p5uqdQlz3YtI9RCSVFZL2cs3gK5cLNTJ163ZdLtGbg6MnL9pB4xws414EpHQLPVoa5DVRQTn9wYTaGHZwrJNmlERTISuJpTpNGh1Jqv5g1V+jewr0FgdphW5ewpPzOV66JExqn2/QvX0vuCZiDmQRHwMPT0Y14ZnhsAx5p9ZRlWNCiUdEgUlojw== 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 VE1PR04MB7312.eurprd04.prod.outlook.com (2603:10a6:800:1a5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Fri, 18 Oct 2024 05:45:32 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.020; Fri, 18 Oct 2024 05:45:32 +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, ming.zhou@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 v2 2/6] media: vivid: Add an rectangle control Date: Fri, 18 Oct 2024 14:44:44 +0900 Message-ID: <20241018054448.3190423-3-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241018054448.3190423-1-ming.qian@nxp.com> References: <20241018054448.3190423-1-ming.qian@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::15) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|VE1PR04MB7312:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b7f151b-c5da-4703-98d9-08dcef3814a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?O0+7Qypc+lwmS8+k82ForojsUIcBf10cCOexPnQeeypps3tyNm3W3BYLg9Hm?= =?us-ascii?Q?1f/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XsEC+kY8pjRhn9n4AU3?= =?us-ascii?Q?ExXPyRqHq+T1x6ciwm4mOCUf9TQi3KvMXJ5hRbIaTHqXtkcFJWA8fDswr69h?= =?us-ascii?Q?2SitdtsS18hijR3FUc1CT6LI7aqk98+4vmJ4h/JtJNCGtPQDr4IR/2d3xy40?= =?us-ascii?Q?rOYltMJrxR+41ygmLlRHDXXk5eK3cMQFi1ChCWwJBF3hO62UahbyYbtRkOGL?= =?us-ascii?Q?InAP9NGCnPWF0hPoaUdXu3W/TLmvL3PcwBABM3E+7L6nAn4k6+DwjndT/wO1?= =?us-ascii?Q?v76ovAnrIyw7lcfPK/gtQOJIxrT3xEmPYdEJFcD+5D/VKdaxFfG8U5rHPDKY?= =?us-ascii?Q?NBvaPyJIKTe+ATGQJhNpYXeIE+XsmXM4dHmaYOMq9IBO3d1FVL+ooCZm6yYR?= =?us-ascii?Q?1nMiyma1ohkr/hIuElfxkWoBMuwW3B9mF4oP/8hIA5mEEDyixDDawsAZHe24?= =?us-ascii?Q?8WCZ0Fk=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?1ORZruj46Q/jr+6qrW6nP5npdTU4poY3kbZ5wvyPSIr10oKMyyEMsvmsi1bE?= =?us-ascii?Q?3L1Y1HFvntLP4wXwr5udCOQb3JG9/o2V0tp14zzsF35ZIFe5fbWR5xj0o0qX?= =?us-ascii?Q?Sy6mAQztmn5C0IYz4jUp/wK5hn0/jBe2plRIQsDVDZ2Da/QZ7sMuY87bEi4i?= =?us-ascii?Q?223gw40XD+L0Z+LyQfghr5VNAg8+VGLrupwk4ijdDTk1gQ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idCnb6W6cdCOvEeuxiJMXS+YS0pjag7?= =?us-ascii?Q?wqoIWVvPIE/UKVKT88A97yJKYTXQNjHyZJIsx8MZohAXojU+DJndYPaZC1eK?= =?us-ascii?Q?RK8CMAxh50s0XAEWCTr0omvJ/VOb9Gb1PFzts9PUR6gMaFSBPwmQZgUkHMP3?= =?us-ascii?Q?2P7nNkTaUV45tCe0T1HRuAVgDGSRXQP4D1S/eRxadkm7USi2NBPSeA7LSfuV?= =?us-ascii?Q?Os8PvpC2CfkFg8/hPFCBwXv304SHkgI5Bs3Av5c+TzOlHygVtTUbRc6Wzthc?= =?us-ascii?Q?xZe4/dG6HU5G+ATBv/unxklg+nZ6Uq3epArWrCXNLBFHQkVhJoH+MBbiF1q+?= =?us-ascii?Q?yK0UDT6gZXjviq6QDCgW61rKkjRQ7UzmzIaunuwl6wfBUg1O/Lgj+E4lXI9W?= =?us-ascii?Q?e0fvJQ22MHSCE/xFknbALNUB0n4zvQg5tJnYh2tdOEk1V3XnceIidkDOVoJa?= =?us-ascii?Q?9zp5tmaSwRuGE9hwQCT80+4NKZqlTqdgp/pBO+fK?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b7f151b-c5da-4703-98d9-08dcef3814a4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 05:45:32.5503 (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: v2N2kMCkgZtixJLW8UTDrmJaDdmzH4dKU8MLSRNGEaAW4NLDRDdpXXSO39hFUnGmv3YJ+/7FEUOP8khknTZ++A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7312 Content-Type: text/plain; charset="utf-8" From: Yunke Cao This control represents a generic read/write rectangle. It supports V4L2_CTRL_WHICH_MIN/MAX_VAL. Signed-off-by: Yunke Cao Reviewed-by: Hans Verkuil --- .../media/test-drivers/vivid/vivid-ctrls.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/media/test-drivers/vivid/vivid-ctrls.c b/drivers/media= /test-drivers/vivid/vivid-ctrls.c index 8bb38bc7b8cc..bed5f4fb0c69 100644 --- a/drivers/media/test-drivers/vivid/vivid-ctrls.c +++ b/drivers/media/test-drivers/vivid/vivid-ctrls.c @@ -37,6 +37,7 @@ #define VIVID_CID_U8_PIXEL_ARRAY (VIVID_CID_CUSTOM_BASE + 14) #define VIVID_CID_S32_ARRAY (VIVID_CID_CUSTOM_BASE + 15) #define VIVID_CID_S64_ARRAY (VIVID_CID_CUSTOM_BASE + 16) +#define VIVID_CID_RECT (VIVID_CID_CUSTOM_BASE + 17) =20 #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000) #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1) @@ -360,6 +361,38 @@ static const struct v4l2_ctrl_config vivid_ctrl_ro_int= 32 =3D { .step =3D 1, }; =20 +static const struct v4l2_rect rect_def =3D { + .top =3D 100, + .left =3D 200, + .width =3D 300, + .height =3D 400, +}; + +static const struct v4l2_rect rect_min =3D { + .top =3D 0, + .left =3D 0, + .width =3D 1, + .height =3D 1, +}; + +static const struct v4l2_rect rect_max =3D { + .top =3D 0, + .left =3D 0, + .width =3D 1000, + .height =3D 2000, +}; + +static const struct v4l2_ctrl_config vivid_ctrl_rect =3D { + .ops =3D &vivid_user_gen_ctrl_ops, + .id =3D VIVID_CID_RECT, + .name =3D "Rect", + .type =3D V4L2_CTRL_TYPE_RECT, + .flags =3D V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX, + .p_def.p_const =3D &rect_def, + .p_min.p_const =3D &rect_min, + .p_max.p_const =3D &rect_max, +}; + /* Framebuffer Controls */ =20 static int vivid_fb_s_ctrl(struct v4l2_ctrl *ctrl) @@ -1685,6 +1718,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool= show_ccs_cap, dev->int_menu =3D v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int_menu= , NULL); dev->ro_int32 =3D v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_ro_int32= , NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_area, NULL); + v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_rect, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_dyn_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u16_matrix, NULL); --=20 2.43.0-rc1 From nobody Tue Nov 26 10:43:58 2024 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2055.outbound.protection.outlook.com [40.107.22.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8BEA185B5F; Fri, 18 Oct 2024 05:45:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230343; cv=fail; b=CBUZX0M3WrATrcg0I2GZs6KPHbEK3XmnYf64mK6WynaxY/jn+BkNxSdq+GJdIrjV2U77z0/bJunpLNTu9yKXStI4v1oQDzIYc+P46gNEKmB66Pjh9gXMAHxZfuB0xRuo/4ABjr5hEp+kO+cyjcj9aDmbyOW2ujZtynhFXbMKflQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230343; c=relaxed/simple; bh=Jq8lblQML35Dds+bnO5KgLfE+H+HlP4a7EFb9RLK4SY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=t4Lf16tvE9bANa7biP2zBAwwwOXuTWV9GfQQBJ6+xH+6/U0iaedhHskY9L3BEiJsQFEa+7hqu8xZrRdGDAi/LbUPI7pWamUqe5O2ZaM62equ6A4JOc6vMFUc8rfr6xf52Mnsf5E2gW35EfkeSP6Sl5FU7x9kLNLR/tbzcuWB0+Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=mPl83Yf1; arc=fail smtp.client-ip=40.107.22.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="mPl83Yf1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hrFGuIVEdC+OYJ0OedE9mYd2JEEbohXxlyhnDDP/TdBz9oV+hQADXhh6qFONC2oFpAC+G8ba+aTtc99Z351mU/q7GQp72OnCFW/9ZlN4rff8w3mtBIpMsPZ1Seew/VFGRnZC1m1CA/A3jJHhSS24mAiBLA/ee/fydmhJuCA5E2s+WLeIFKqcLyOYs/08LX/T6E3lUkXXNtXPahnrSSNz2lviAdW7iNCSzC3xpA4fStM6sj4rJoK7dgiY8YDANYzHkWTShDLtOr72Ib1h8cQ4tAQ1gWjqR4pKRJn0GHsZvKMpLz9RS4r7DLgHchEYzkfZwGIXkxOhirQYN0MtizYf6g== 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=qvsynQF8VVK71701sFf8HsCW6S8mbO1IdG3lm0npjo0=; b=EIbtyJT03uQ5PXZdtdWJjm952n+15FZLAN1kYS6VkKGmWdMWyazHRSFUkQ0EJjIg+CYaY2AIBrVN/vAZ8HiOwkaeCUkcR8CC6VtUFw1qIGQ8dcivEfVo/YYPwrFdxzWh7EnMNWP3zNfoepo2WC7FbxEhObI8AcorS3TqTqmTCRqWvxmgyYZHz2nonZwxqegokhSfyc1aevL8QnN7x4w9qJHR4Nypv3AAgTDVjAy3exvKJhoJnePJeNgcvf8bFVTyWByp692F1YL+FdnCqnbzv47n4/WYp87iORbEl8Ghl7l3gqDkNt3ikGjWn6bL+2NIUkedns6iJjwMa4itwwS4gA== 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=qvsynQF8VVK71701sFf8HsCW6S8mbO1IdG3lm0npjo0=; b=mPl83Yf1ggQio5xzzskoAgjW8xZkok4QwWBhv2TboMMn9gtwTnX5j19OyvjlpI7Riv9GtorMW95pfKFcfrHeXJLTfsjp3Fc+xrQvOYn5qhBIF2dl9Fhd9cX2iyUMjpiFpEzEhWS6UcSoZRgh0dOrpELH+zK8fQmvgUY1o+wC59XQGWgmpZVMU01fbjMW7itc8yVWCABzVrPeJBJZblZCZ0hwEP18Gt2tp++4U4rxIjYpbjT9Y3ZWvOMMsOvxj1m8I+2PrB5F6XZiH85PvGejn+Cc9aE026nOT/Ytpthw8vU6d0/ZL07M7MkxL6CLiOg2WY88QgUiN8I+a6EJbSfABg== 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 VE1PR04MB7312.eurprd04.prod.outlook.com (2603:10a6:800:1a5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Fri, 18 Oct 2024 05:45:37 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.020; Fri, 18 Oct 2024 05:45:37 +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, ming.zhou@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 v2 3/6] media: v4l2-ctrls: add support for V4L2_CTRL_WHICH_MIN/MAX_VAL Date: Fri, 18 Oct 2024 14:44:45 +0900 Message-ID: <20241018054448.3190423-4-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241018054448.3190423-1-ming.qian@nxp.com> References: <20241018054448.3190423-1-ming.qian@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::15) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|VE1PR04MB7312:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ecd1ea8-92c5-44a5-dffc-08dcef38176a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TDMmkpsVgtbHcCMcIylpmilDho8QDl+dM5ldEfXniELPM0kipGCay8bCy6Ks?= =?us-ascii?Q?XpKjiHc3ZyKo1BMSnlDXboB4n60cL9Y130wO5SoyVIDb66GMBvk3XGBdIUAX?= =?us-ascii?Q?NMgFDmL4bi3EQi+zHAmj9HFizQlrSufQIN+5S2I8xQx4IN46bfrr8CNV2iFu?= =?us-ascii?Q?rUmjC6GZaBvQ03GYTR+pDNj435GgCK7LzgZYcGxHtojQ9OuJfKaNpeSXLiPn?= =?us-ascii?Q?vwAXWKocTftyK6HDEQVoyZG/al/wXJdIjo09y24zrFyXZKV2iCHx0QyVoqrQ?= =?us-ascii?Q?RAFPNJJsKZTCvBPXu5BmjUgAToz/cRVQzTS7Gc2k+kKoLft3+IXppcEM8aRX?= =?us-ascii?Q?80iuKY9FzS17GaxNRiydo3pNPQbhyC2fx5g3lGd2DCadt3aPUIyzW2x+awNa?= =?us-ascii?Q?WFCil8d74ce4IM2ZcU7Nya+yfvySqhXLHEJ+2teuPB9D7obozvymm2DpwiG1?= =?us-ascii?Q?ocmBJ/Z1IWVKcWpRoKn2ktfu4JCPj/xbEtz+qSO9QSOqyaLxOZkxo9O6xknZ?= =?us-ascii?Q?Las4Q9zCaxXwzq3VQNkxSIZo6KgeuFAzAGgpalMRUbzOW7jbQTNOLt9mMJSc?= =?us-ascii?Q?aKYevMZsS9U+tl14AIw+IYhgR5rZLOSMxbGTiZ5tdmJCgV7pZxJ7nAaw6QbJ?= =?us-ascii?Q?/dQA4x7+tZiuUavRgEC1vkRXWn380fOTibFNvdQBxKe4zHmi9f6sp9+6RcY2?= =?us-ascii?Q?rAbOcSoWR86srcjKGIkgrq1HEV1G6z7+zk5Z1qTw9w44myqQE2xH8VDm1eBX?= =?us-ascii?Q?NKIpG1ZO2MxYgKm4qOZyMof/2CgYCP1uyDRlj7mkjmuz1CMSpDocWeMy+RcD?= =?us-ascii?Q?YgFLN+WRnx4gZ4qv/eLBBeVtJ86rTW9L7RB3KGoRPEEr+nTcScaVD0HspZmd?= =?us-ascii?Q?bDDiGHSfVCSOP28YszHTGQ9OnfP8e3HLE1gkpUBubCkYtakpmVWqTIj76kCV?= =?us-ascii?Q?mLfgCBG/o5NzIxQo2zKoouZ4CX+39/dc/sgEOGqPIN0vltIA7PVbAt3ixbX9?= =?us-ascii?Q?u8eRTnkMYQn7hwuQtya5TLKHk4GsuBd1fkP58RWop/hImfxPjF37/EsRpt7D?= =?us-ascii?Q?4YD53zt53VJSTcRWmwxR2BboI0ogf7wGWe7qtVs4b7uYDYB/6THioS2YOg5+?= =?us-ascii?Q?3D0lULP2vf6RoOs8i7+Gwwypv8SqEWk7B9inTWVz2UaSDaWo7CM0kUyaQYJq?= =?us-ascii?Q?bJCGyIbKWecwNVt+FX+MxPSLSGAQJ/AAFGmtXu3rXXd0gJDn5Us0Aeuy61KI?= =?us-ascii?Q?edhRlgrFwovoU1LANhCnRoqjjArLZ87Ia3YthxNelWoDN3pc7IRQF+yQHZQZ?= =?us-ascii?Q?je/dvO+586vmOCn1wM/1HEHVauzb4ILTvdEXfmrrTim5ET/VT/Ien4thJjNF?= =?us-ascii?Q?1x72qMY=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0+/THK0xsFlTQcX1U5yR+Vpl1qHSRjCTePUoXic/a3fplQRKNtkht+3kYcub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sz09gpJ/v2ZxIw/frowmuTemyH?= =?us-ascii?Q?992/yeBQPhSt9I+r3iVVYXT30Hz8Yp7MFSEYGdLdgTRxajE+6glMtpEVRD2m?= =?us-ascii?Q?CGhDQcNT+PwQIlNEYoy5QfgEAr63uolMUsIOBxoy4YBVik1ZN506eOMWmH8/?= =?us-ascii?Q?Oxaxm327nqN9ZcjR4fiBIVImIwVNhC8MyFArqq8lRewcamBNGF+oMv1b2ICy?= =?us-ascii?Q?wjIAJYsV4uK9m113TA/bcEm+mqSiTtG/ttrVsc0mIqvuGm7WvrtTsVwjaweZ?= =?us-ascii?Q?maVOwdB7HsMNONIpedvD8naA5Ari/VukCoACpLvwcCqKnSuDeakMLqv568Lj?= =?us-ascii?Q?cQ+P7X7j3mlNLJtaacya/71TBDD6G9Pwh1Ih7B/mbNofx7U+Awr8gq++dUnA?= =?us-ascii?Q?ziYMAE/g2bIsrO0zr7ZViL7PWTnVbysPJthbA1laIdDtFCVACFThafz6++v9?= =?us-ascii?Q?stdarWqL4VQOkVvh05qZSr0zk6l4qeR5BgcjGWwK61gKs2ZgMxA/sC55naR3?= =?us-ascii?Q?kr7X5Rr6q7uYH6O3uh8KijNu4qdG9EKL3A7oTX1I154yvaGc0T8BcOI0lAwH?= =?us-ascii?Q?OkWr1nQkmYO/TubHr8mQkyVElWjJcWAEcVZKtF+tOtVXTWBu+VIRVLaOfARO?= =?us-ascii?Q?aHj4vB+Jrb5il6Uwtx/uF0hOvH1HaQUBbLNz6od6?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ecd1ea8-92c5-44a5-dffc-08dcef38176a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 05:45:37.2914 (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: VtCc760yg3DqVFgYifrMCuOFW/k8QWGBGzHllD5BSS73A25U+OR/6RPS3+ZcvWIpaNruvBoe6fpEkrEizDbpzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7312 Content-Type: text/plain; charset="utf-8" From: Hans Verkuil Add the capability of retrieving the min and max values of a compound control. Signed-off-by: Hans Verkuil Signed-off-by: Yunke Cao Signed-off-by: Ming Qian --- v2 - export symbol of v4l2_ctrl_type_op_minimum - export symbol of v4l2_ctrl_type_op_maximum .../media/v4l/vidioc-g-ext-ctrls.rst | 22 ++- .../media/v4l/vidioc-queryctrl.rst | 9 +- .../media/videodev2.h.rst.exceptions | 3 + drivers/media/i2c/imx214.c | 4 +- .../media/platform/qcom/venus/venc_ctrls.c | 9 +- drivers/media/v4l2-core/v4l2-ctrls-api.c | 54 +++++-- drivers/media/v4l2-core/v4l2-ctrls-core.c | 153 +++++++++++++++--- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +- include/media/v4l2-ctrls.h | 60 ++++++- include/uapi/linux/videodev2.h | 3 + 10 files changed, 272 insertions(+), 49 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b= /Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst index b74a74ac06fc..b8698b85bd80 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst @@ -338,14 +338,26 @@ still cause this situation. - Which value of the control to get/set/try. * - :cspan:`2` ``V4L2_CTRL_WHICH_CUR_VAL`` will return the current val= ue of the control, ``V4L2_CTRL_WHICH_DEF_VAL`` will return the default - value of the control and ``V4L2_CTRL_WHICH_REQUEST_VAL`` indicates that - these controls have to be retrieved from a request or tried/set for - a request. In the latter case the ``request_fd`` field contains the + value of the control, ``V4L2_CTRL_WHICH_MIN_VAL`` will return the minimum + value of the control, and ``V4L2_CTRL_WHICH_MAX_VAL`` will return the max= imum + value of the control. ``V4L2_CTRL_WHICH_REQUEST_VAL`` indicates that + the control value has to be retrieved from a request or tried/set for + a request. In that case the ``request_fd`` field contains the file descriptor of the request that should be used. If the device does not support requests, then ``EACCES`` will be returned. =20 - When using ``V4L2_CTRL_WHICH_DEF_VAL`` be aware that you can only - get the default value of the control, you cannot set or try it. + When using ``V4L2_CTRL_WHICH_DEF_VAL``, ``V4L2_CTRL_WHICH_MIN_VAL`` + or ``V4L2_CTRL_WHICH_MAX_VAL`` be aware that you can only get the + default/minimum/maximum value of the control, you cannot set or try it. + + Whether a control supports querying the minimum and maximum values using + ``V4L2_CTRL_WHICH_MIN_VAL`` and ``V4L2_CTRL_WHICH_MAX_VAL`` is indicated + by the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. Most non-compound + control types support this. For controls with compound types, the + definition of minimum/maximum values are provided by + the control documentation. If a compound control does not document the + meaning of minimum/maximum value, then querying the minimum or maximum + value will result in the error code -EINVAL. =20 For backwards compatibility you can also use a control class here (see :ref:`ctrl-class`). In that case all controls have to diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/D= ocumentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 56d5c8b0b88b..3815732f6a9b 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -447,7 +447,10 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_rect`, containing a rectangle described by the position of its top-left corner, the width and the height. Units - depend on the use case. + depend on the use case. Support for ``V4L2_CTRL_WHICH_MIN_VAL`` and + ``V4L2_CTRL_WHICH_MAX_VAL`` is optional and depends on the + ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. See the documentation of + the specific control on how to interpret the minimum and maximum values. * - ``V4L2_CTRL_TYPE_H264_SPS`` - n/a - n/a @@ -664,6 +667,10 @@ See also the examples in :ref:`control`. ``dims[0]``. So setting the control with a differently sized array will change the ``elems`` field when the control is queried afterwards. + * - ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` + - 0x1000 + - This control supports getting minimum and maximum values using + vidioc_g_ext_ctrls with V4L2_CTRL_WHICH_MIN/MAX_VAL. =20 Return Value =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b= /Documentation/userspace-api/media/videodev2.h.rst.exceptions index 3cf1380b52b0..35d3456cc812 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -396,6 +396,7 @@ replace define V4L2_CTRL_FLAG_HAS_PAYLOAD control-flags replace define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE control-flags replace define V4L2_CTRL_FLAG_MODIFY_LAYOUT control-flags replace define V4L2_CTRL_FLAG_DYNAMIC_ARRAY control-flags +replace define V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX control-flags =20 replace define V4L2_CTRL_FLAG_NEXT_CTRL control replace define V4L2_CTRL_FLAG_NEXT_COMPOUND control @@ -570,6 +571,8 @@ ignore define V4L2_CTRL_DRIVER_PRIV ignore define V4L2_CTRL_MAX_DIMS ignore define V4L2_CTRL_WHICH_CUR_VAL ignore define V4L2_CTRL_WHICH_DEF_VAL +ignore define V4L2_CTRL_WHICH_MIN_VAL +ignore define V4L2_CTRL_WHICH_MAX_VAL ignore define V4L2_CTRL_WHICH_REQUEST_VAL ignore define V4L2_OUT_CAP_CUSTOM_TIMINGS ignore define V4L2_CID_MAX_CTRLS diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 4962cfe7c83d..b0439005ec71 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -774,7 +774,9 @@ static int imx214_ctrls_init(struct imx214 *imx214) imx214->unit_size =3D v4l2_ctrl_new_std_compound(ctrl_hdlr, NULL, V4L2_CID_UNIT_CELL_SIZE, - v4l2_ctrl_ptr_create((void *)&unit_size)); + v4l2_ctrl_ptr_create((void *)&unit_size), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); =20 v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &imx214_ctrl_ops, &props); =20 diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media= /platform/qcom/venus/venc_ctrls.c index d9d2a293f3ef..7f370438d655 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -607,11 +607,16 @@ int venc_ctrl_init(struct venus_inst *inst) =20 v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_COLORIMETRY_HDR10_CLL_INFO, - v4l2_ctrl_ptr_create(&p_hdr10_cll)); + v4l2_ctrl_ptr_create(&p_hdr10_cll), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); =20 v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY, - v4l2_ctrl_ptr_create((void *)&p_hdr10_mastering)); + v4l2_ctrl_ptr_create((void *)&p_hdr10_mastering), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); + =20 v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE, diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-= core/v4l2-ctrls-api.c index e5a364efd5e6..d44fbad95c11 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-api.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c @@ -94,6 +94,22 @@ static int def_to_user(struct v4l2_ext_control *c, struc= t v4l2_ctrl *ctrl) return ptr_to_user(c, ctrl, ctrl->p_new); } =20 +/* Helper function: copy the minimum control value back to the caller */ +static int min_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) +{ + ctrl->type_ops->minimum(ctrl, 0, ctrl->p_new); + + return ptr_to_user(c, ctrl, ctrl->p_new); +} + +/* Helper function: copy the maximum control value back to the caller */ +static int max_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) +{ + ctrl->type_ops->maximum(ctrl, 0, ctrl->p_new); + + return ptr_to_user(c, ctrl, ctrl->p_new); +} + /* Helper function: copy the caller-provider value as the new control valu= e */ static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) { @@ -229,8 +245,8 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *= hdl, cs->error_idx =3D i; =20 if (cs->which && - cs->which !=3D V4L2_CTRL_WHICH_DEF_VAL && - cs->which !=3D V4L2_CTRL_WHICH_REQUEST_VAL && + (cs->which < V4L2_CTRL_WHICH_DEF_VAL || + cs->which > V4L2_CTRL_WHICH_MAX_VAL) && V4L2_CTRL_ID2WHICH(id) !=3D cs->which) { dprintk(vdev, "invalid which 0x%x or control id 0x%x\n", @@ -259,6 +275,15 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler = *hdl, return -EINVAL; } =20 + if (!(ctrl->flags & V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX) && + (cs->which =3D=3D V4L2_CTRL_WHICH_MIN_VAL || + cs->which =3D=3D V4L2_CTRL_WHICH_MAX_VAL)) { + dprintk(vdev, + "invalid which 0x%x or control id 0x%x\n", + cs->which, id); + return -EINVAL; + } + if (ctrl->cluster[0]->ncontrols > 1) have_clusters =3D true; if (ctrl->cluster[0] !=3D ctrl) @@ -368,8 +393,8 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *= hdl, */ static int class_check(struct v4l2_ctrl_handler *hdl, u32 which) { - if (which =3D=3D 0 || which =3D=3D V4L2_CTRL_WHICH_DEF_VAL || - which =3D=3D V4L2_CTRL_WHICH_REQUEST_VAL) + if (which =3D=3D 0 || (which >=3D V4L2_CTRL_WHICH_DEF_VAL && + which <=3D V4L2_CTRL_WHICH_MAX_VAL)) return 0; return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL; } @@ -389,10 +414,12 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler = *hdl, struct v4l2_ctrl_helper *helpers =3D helper; int ret; int i, j; - bool is_default, is_request; + bool is_default, is_request, is_min, is_max; =20 is_default =3D (cs->which =3D=3D V4L2_CTRL_WHICH_DEF_VAL); is_request =3D (cs->which =3D=3D V4L2_CTRL_WHICH_REQUEST_VAL); + is_min =3D (cs->which =3D=3D V4L2_CTRL_WHICH_MIN_VAL); + is_max =3D (cs->which =3D=3D V4L2_CTRL_WHICH_MAX_VAL); =20 cs->error_idx =3D cs->count; cs->which =3D V4L2_CTRL_ID2WHICH(cs->which); @@ -432,13 +459,14 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler = *hdl, =20 /* * g_volatile_ctrl will update the new control values. - * This makes no sense for V4L2_CTRL_WHICH_DEF_VAL and + * This makes no sense for V4L2_CTRL_WHICH_DEF_VAL, + * V4L2_CTRL_WHICH_MIN_VAL, V4L2_CTRL_WHICH_MAX_VAL and * V4L2_CTRL_WHICH_REQUEST_VAL. In the case of requests * it is v4l2_ctrl_request_complete() that copies the * volatile controls at the time of request completion * to the request, so you don't want to do that again. */ - if (!is_default && !is_request && + if (!is_default && !is_request && !is_min && !is_max && ((master->flags & V4L2_CTRL_FLAG_VOLATILE) || (master->has_volatiles && !is_cur_manual(master)))) { for (j =3D 0; j < master->ncontrols; j++) @@ -467,6 +495,10 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *= hdl, ret =3D -ENOMEM; else if (is_request && ref->p_req_valid) ret =3D req_to_user(cs->controls + idx, ref); + else if (is_min) + ret =3D min_to_user(cs->controls + idx, ref->ctrl); + else if (is_max) + ret =3D max_to_user(cs->controls + idx, ref->ctrl); else if (is_volatile) ret =3D new_to_user(cs->controls + idx, ref->ctrl); else @@ -564,9 +596,11 @@ int try_set_ext_ctrls_common(struct v4l2_fh *fh, =20 cs->error_idx =3D cs->count; =20 - /* Default value cannot be changed */ - if (cs->which =3D=3D V4L2_CTRL_WHICH_DEF_VAL) { - dprintk(vdev, "%s: cannot change default value\n", + /* Default/minimum/maximum values cannot be changed */ + if (cs->which =3D=3D V4L2_CTRL_WHICH_DEF_VAL || + cs->which =3D=3D V4L2_CTRL_WHICH_MIN_VAL || + cs->which =3D=3D V4L2_CTRL_WHICH_MAX_VAL) { + dprintk(vdev, "%s: cannot change default/min/max value\n", video_device_node_name(vdev)); return -EINVAL; } diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2= -core/v4l2-ctrls-core.c index 4c8744c8cd96..a3abbde5379b 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -182,29 +182,64 @@ static void std_init_compound(const struct v4l2_ctrl = *ctrl, u32 idx, } } =20 -void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, - union v4l2_ctrl_ptr ptr) +static void std_min_compound(const struct v4l2_ctrl *ctrl, u32 idx, union = v4l2_ctrl_ptr ptr) +{ + void *p =3D ptr.p + idx * ctrl->elem_size; + + if (ctrl->p_min.p_const) + memcpy(p, ctrl->p_min.p_const, ctrl->elem_size); + else + memset(p, 0, ctrl->elem_size); +} + +static void std_max_compound(const struct v4l2_ctrl *ctrl, u32 idx, union = v4l2_ctrl_ptr ptr) +{ + void *p =3D ptr.p + idx * ctrl->elem_size; + + if (ctrl->p_max.p_const) + memcpy(p, ctrl->p_max.p_const, ctrl->elem_size); + else + memset(p, 0, ctrl->elem_size); +} + +static void __v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 fro= m_idx, + u32 which, union v4l2_ctrl_ptr ptr) { unsigned int i; u32 tot_elems =3D ctrl->elems; u32 elems =3D tot_elems - from_idx; + s64 value; =20 - if (from_idx >=3D tot_elems) + switch (which) { + case V4L2_CTRL_WHICH_DEF_VAL: + value =3D ctrl->default_value; + break; + case V4L2_CTRL_WHICH_MAX_VAL: + value =3D ctrl->maximum; + break; + case V4L2_CTRL_WHICH_MIN_VAL: + value =3D ctrl->minimum; + break; + default: return; + } =20 switch (ctrl->type) { case V4L2_CTRL_TYPE_STRING: + if (which =3D=3D V4L2_CTRL_WHICH_DEF_VAL) + value =3D ctrl->minimum; + for (i =3D from_idx; i < tot_elems; i++) { unsigned int offset =3D i * ctrl->elem_size; =20 - memset(ptr.p_char + offset, ' ', ctrl->minimum); - ptr.p_char[offset + ctrl->minimum] =3D '\0'; + memset(ptr.p_char + offset, ' ', value); + ptr.p_char[offset + value] =3D '\0'; } break; case V4L2_CTRL_TYPE_INTEGER64: - if (ctrl->default_value) { + if (value) { for (i =3D from_idx; i < tot_elems; i++) - ptr.p_s64[i] =3D ctrl->default_value; + ptr.p_s64[i] =3D value; } else { memset(ptr.p_s64 + from_idx, 0, elems * sizeof(s64)); } @@ -214,9 +249,9 @@ void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctr= l, u32 from_idx, case V4L2_CTRL_TYPE_MENU: case V4L2_CTRL_TYPE_BITMASK: case V4L2_CTRL_TYPE_BOOLEAN: - if (ctrl->default_value) { + if (value) { for (i =3D from_idx; i < tot_elems; i++) - ptr.p_s32[i] =3D ctrl->default_value; + ptr.p_s32[i] =3D value; } else { memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); } @@ -226,32 +261,63 @@ void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *c= trl, u32 from_idx, memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); break; case V4L2_CTRL_TYPE_U8: - memset(ptr.p_u8 + from_idx, ctrl->default_value, elems); + memset(ptr.p_u8 + from_idx, value, elems); break; case V4L2_CTRL_TYPE_U16: - if (ctrl->default_value) { + if (value) { for (i =3D from_idx; i < tot_elems; i++) - ptr.p_u16[i] =3D ctrl->default_value; + ptr.p_u16[i] =3D value; } else { memset(ptr.p_u16 + from_idx, 0, elems * sizeof(u16)); } break; case V4L2_CTRL_TYPE_U32: - if (ctrl->default_value) { + if (value) { for (i =3D from_idx; i < tot_elems; i++) - ptr.p_u32[i] =3D ctrl->default_value; + ptr.p_u32[i] =3D value; } else { memset(ptr.p_u32 + from_idx, 0, elems * sizeof(u32)); } break; default: - for (i =3D from_idx; i < tot_elems; i++) - std_init_compound(ctrl, i, ptr); + for (i =3D from_idx; i < tot_elems; i++) { + switch (which) { + case V4L2_CTRL_WHICH_DEF_VAL: + std_init_compound(ctrl, i, ptr); + break; + case V4L2_CTRL_WHICH_MAX_VAL: + std_max_compound(ctrl, i, ptr); + break; + case V4L2_CTRL_WHICH_MIN_VAL: + std_min_compound(ctrl, i, ptr); + break; + } + } break; } } + +void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr) +{ + __v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_DEF_VAL, ptr); +} EXPORT_SYMBOL(v4l2_ctrl_type_op_init); =20 +void v4l2_ctrl_type_op_minimum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr) +{ + __v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MIN_VAL, ptr); +} +EXPORT_SYMBOL(v4l2_ctrl_type_op_minimum); + +void v4l2_ctrl_type_op_maximum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr) +{ + __v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MAX_VAL, ptr); +} +EXPORT_SYMBOL(v4l2_ctrl_type_op_maximum); + void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl) { union v4l2_ctrl_ptr ptr =3D ctrl->p_cur; @@ -1296,6 +1362,8 @@ EXPORT_SYMBOL(v4l2_ctrl_type_op_validate); static const struct v4l2_ctrl_type_ops std_type_ops =3D { .equal =3D v4l2_ctrl_type_op_equal, .init =3D v4l2_ctrl_type_op_init, + .minimum =3D v4l2_ctrl_type_op_minimum, + .maximum =3D v4l2_ctrl_type_op_maximum, .log =3D v4l2_ctrl_type_op_log, .validate =3D v4l2_ctrl_type_op_validate, }; @@ -1768,7 +1836,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_c= trl_handler *hdl, s64 min, s64 max, u64 step, s64 def, const u32 dims[V4L2_CTRL_MAX_DIMS], u32 elem_size, u32 flags, const char * const *qmenu, - const s64 *qmenu_int, const union v4l2_ctrl_ptr p_def, + const s64 *qmenu_int, + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max, void *priv) { struct v4l2_ctrl *ctrl; @@ -1892,6 +1963,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_c= trl_handler *hdl, break; } =20 + if (type < V4L2_CTRL_COMPOUND_TYPES && + type !=3D V4L2_CTRL_TYPE_BUTTON && + type !=3D V4L2_CTRL_TYPE_CTRL_CLASS && + type !=3D V4L2_CTRL_TYPE_STRING) + flags |=3D V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX; + /* Sanity checks */ if (id =3D=3D 0 || name =3D=3D NULL || !elem_size || id >=3D V4L2_CID_PRIVATE_BASE || @@ -1900,6 +1977,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ct= rl_handler *hdl, handler_set_err(hdl, -ERANGE); return NULL; } + err =3D check_range(type, min, max, step, def); if (err) { handler_set_err(hdl, err); @@ -1941,6 +2019,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_c= trl_handler *hdl, =20 if (type >=3D V4L2_CTRL_COMPOUND_TYPES && p_def.p_const) sz_extra +=3D elem_size; + if (type >=3D V4L2_CTRL_COMPOUND_TYPES && p_min.p_const) + sz_extra +=3D elem_size; + if (type >=3D V4L2_CTRL_COMPOUND_TYPES && p_max.p_const) + sz_extra +=3D elem_size; =20 ctrl =3D kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); if (ctrl =3D=3D NULL) { @@ -2006,6 +2088,22 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_c= trl_handler *hdl, memcpy(ctrl->p_def.p, p_def.p_const, elem_size); } =20 + if (flags & V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX) { + void *ptr =3D ctrl->p_def.p; + + if (p_min.p_const) { + ptr +=3D elem_size; + ctrl->p_min.p =3D ptr; + memcpy(ctrl->p_min.p, p_min.p_const, elem_size); + } + + if (p_max.p_const) { + ptr +=3D elem_size; + ctrl->p_max.p =3D ptr; + memcpy(ctrl->p_max.p, p_max.p_const, elem_size); + } + } + ctrl->type_ops->init(ctrl, 0, ctrl->p_cur); cur_to_new(ctrl); =20 @@ -2056,7 +2154,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ct= rl_handler *hdl, type, min, max, is_menu ? cfg->menu_skip_mask : step, def, cfg->dims, cfg->elem_size, - flags, qmenu, qmenu_int, cfg->p_def, priv); + flags, qmenu, qmenu_int, cfg->p_def, cfg->p_min, + cfg->p_max, priv); if (ctrl) ctrl->is_private =3D cfg->is_private; return ctrl; @@ -2081,7 +2180,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_= handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, min, max, step, def, NULL, 0, - flags, NULL, NULL, ptr_null, NULL); + flags, NULL, NULL, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std); =20 @@ -2114,7 +2214,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_= ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, mask, def, NULL, 0, - flags, qmenu, qmenu_int, ptr_null, NULL); + flags, qmenu, qmenu_int, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); =20 @@ -2146,7 +2247,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct= v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, mask, def, NULL, 0, - flags, qmenu, NULL, ptr_null, NULL); + flags, qmenu, NULL, ptr_null, ptr_null, + ptr_null, NULL); =20 } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); @@ -2154,7 +2256,9 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); /* Helper function for standard compound controls */ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, - const union v4l2_ctrl_ptr p_def) + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max) { const char *name; enum v4l2_ctrl_type type; @@ -2168,7 +2272,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v= 4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, min, max, step, def, NULL, 0, - flags, NULL, NULL, p_def, NULL); + flags, NULL, NULL, p_def, p_min, p_max, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_compound); =20 @@ -2192,7 +2296,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_= ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, 0, def, NULL, 0, - flags, NULL, qmenu_int, ptr_null, NULL); + flags, NULL, qmenu_int, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_int_menu); =20 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core= /v4l2-ioctl.c index 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 =3D=3D VIDIOC_S_EXT_CTRLS || ioctl =3D=3D VIDIOC_TRY_EXT_CTRLS) { c->error_idx =3D c->count; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index b0db167a3ac4..5c38d6d5ae5b 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -133,6 +133,8 @@ struct v4l2_ctrl_ops { * * @equal: return true if all ctrl->elems array elements are equal. * @init: initialize the value for array elements from from_idx to ctrl->e= lems. + * @minimum: set the value to the minimum value of the control. + * @maximum: set the value to the maximum value of the control. * @log: log the value. * @validate: validate the value for ctrl->new_elems array elements. * Return 0 on success and a negative value otherwise. @@ -142,6 +144,10 @@ struct v4l2_ctrl_type_ops { union v4l2_ctrl_ptr ptr1, union v4l2_ctrl_ptr ptr2); void (*init)(const struct v4l2_ctrl *ctrl, u32 from_idx, union v4l2_ctrl_ptr ptr); + void (*minimum)(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr); + void (*maximum)(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr); void (*log)(const struct v4l2_ctrl *ctrl); int (*validate)(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr ptr); }; @@ -247,6 +253,12 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl = *ctrl, void *priv); * @p_def: The control's default value represented via a union which * provides a standard way of accessing control types * through a pointer (for compound controls only). + * @p_min: The control's minimum value represented via a union which + * provides a standard way of accessing control types + * through a pointer (for compound controls only). + * @p_max: The control's maximum value represented via a union which + * provides a standard way of accessing control types + * through a pointer (for compound controls only). * @p_cur: The control's current value represented via a union which * provides a standard way of accessing control types * through a pointer. @@ -306,6 +318,8 @@ struct v4l2_ctrl { } cur; =20 union v4l2_ctrl_ptr p_def; + union v4l2_ctrl_ptr p_min; + union v4l2_ctrl_ptr p_max; union v4l2_ctrl_ptr p_new; union v4l2_ctrl_ptr p_cur; }; @@ -425,6 +439,8 @@ struct v4l2_ctrl_handler { * @step: The control's step value for non-menu controls. * @def: The control's default value. * @p_def: The control's default value for compound controls. + * @p_min: The control's minimum value for compound controls. + * @p_max: The control's maximum value for compound controls. * @dims: The size of each dimension. * @elem_size: The size in bytes of the control. * @flags: The control's flags. @@ -454,6 +470,8 @@ struct v4l2_ctrl_config { u64 step; s64 def; union v4l2_ctrl_ptr p_def; + union v4l2_ctrl_ptr p_min; + union v4l2_ctrl_ptr p_max; u32 dims[V4L2_CTRL_MAX_DIMS]; u32 elem_size; u32 flags; @@ -723,17 +741,25 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct= v4l2_ctrl_handler *hdl, * @ops: The control ops. * @id: The control ID. * @p_def: The control's default value. + * @p_min: The control's minimum value. + * @p_max: The control's maximum value. * - * Sames as v4l2_ctrl_new_std(), but with support to compound controls, th= anks - * to the @p_def field. Use v4l2_ctrl_ptr_create() to create @p_def from a - * pointer. Use v4l2_ctrl_ptr_create(NULL) if the default value of the - * compound control should be all zeroes. + * Same as v4l2_ctrl_new_std(), but with support for compound controls. + * To fill in the @p_def, @p_min and @p_max fields, use v4l2_ctrl_ptr_crea= te() + * to convert a pointer to a const union v4l2_ctrl_ptr. + * Use v4l2_ctrl_ptr_create(NULL) if you want the default, minimum or maxi= mum + * value of the compound control to be all zeroes. + * If the compound control does not set the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN= _MAX`` + * flag, then it does not has minimum and maximum values. In that case jus= t use + * v4l2_ctrl_ptr_create(NULL) for the @p_min and @p_max arguments. * */ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, - const union v4l2_ctrl_ptr p_def); + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max); =20 /** * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu cont= rol. @@ -1571,6 +1597,30 @@ bool v4l2_ctrl_type_op_equal(const struct v4l2_ctrl = *ctrl, void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, union v4l2_ctrl_ptr ptr); =20 +/** + * v4l2_ctrl_type_op_init - Default v4l2_ctrl_type_ops minimum callback. + * + * @ctrl: The v4l2_ctrl pointer. + * @from_idx: Starting element index. + * @ptr: The v4l2 control value. + * + * Return: void + */ +void v4l2_ctrl_type_op_minimum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr); + +/** + * v4l2_ctrl_type_op_init - Default v4l2_ctrl_type_ops maximum callback. + * + * @ctrl: The v4l2_ctrl pointer. + * @from_idx: Starting element index. + * @ptr: The v4l2 control value. + * + * Return: void + */ +void v4l2_ctrl_type_op_maximum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr); + /** * v4l2_ctrl_type_op_log - Default v4l2_ctrl_type_ops log callback. * diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 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 =20 enum v4l2_ctrl_type { V4L2_CTRL_TYPE_INTEGER =3D 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 =20 /* Query flags, to be ORed with the control ID */ #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 --=20 2.43.0-rc1 From nobody Tue Nov 26 10:43:58 2024 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2055.outbound.protection.outlook.com [40.107.22.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0664917C9F1; Fri, 18 Oct 2024 05:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230346; cv=fail; b=M6mfYa+HcM1CQ6/nlKcU0fV9Bu4pylXldWBnmaSGhE5I1mGbVbYVcnAJ8VNJBD0Kdmm1oKCJmBoHelKRMYQXY5SM1cfmI0iblAsw+y14/TGq5QbQUr+doNe0Sucwgxi3xch/+INty82kKdgvQOJS4g5yVACqlQplKdaM9uvxqxs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230346; c=relaxed/simple; bh=qlMctEd7HhmPLSLQ4UfA6kmjyFU0zrsFsFbe82VEEa0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=KoG/5zflgJ0df/YxojeEIYnZVRePyIZ6w5q0nDC56GxJWmKGcTlnK63Ae5BQ+r8vnYKDLRkgPuz/tz7pZOYwi9MRoKEU8MAasxUS2FRbZPud7QTFw9H4eGFXlDtBnSZIXHuBa5F9RgKZwkp/xz/UJlIvUCyu/U87riaYCHl7hCU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=hGSBRlco; arc=fail smtp.client-ip=40.107.22.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="hGSBRlco" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ua2rSwGCbewIaL6lSsKK7JhzQ7kIwRl2bgalStgO+hoMhOPLzaqROWU927yBA20nq0ai6lRAzRkDbys5Bto7sGa4ZKMvo21KclTCucKuC1eV2dv827Pr0y31JoqitHpINaEdopWGG/ymv4h8+ibyllVuO/Fx/XVErSXjAf056wOmBtJyCdzdsVpTEoZTSVj3zHqc+2IEhSyNLYwDZat+AEwr2pAkCYmKZw9d6i8p17BnW177Ft978rDJhw6OikxjK2RslSPEGqeG5AZEoly/N/xZvs6BuiglhYivMUZpZ5J4sZT5KW8X/gcWTPk/hIGFpai6L+UjAwRuWTc1KMVusA== 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=8jzw5eWedJmMj6hhrqj55ALXVWPHESKXlNDMgQg+VhU=; b=df0uIzyMGFjO08/lpMmIx+HvWkp93823eAAOMSCB2N5DDPCEOWGCUAwKPlFjTfOTDgZ9gn/8u++WXXpGoN4eQjL4Vr8sGMrkq5FKtWPLMAJORE62ukJtLuPa5ZgqVSkjRQbHM+Hn8Xctxxnc0UfSfHhDTemSZRwO2M62hkcrSX2Edkvc5gsRZyMrcNJva0XQzbfEZ1LmK9se5em4tPHixLitTAf8P7r4QHz6xp05m0NDqpIAMKSo/BEjiKqFBb+bSkTi/KDkvntQK5nUdYnnKDQXrtk08yaEEnHMpX/B926AajPaBvN7wZMYQNeAtYaz4ijNmoHCR52iMrmkfmCUxg== 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=8jzw5eWedJmMj6hhrqj55ALXVWPHESKXlNDMgQg+VhU=; b=hGSBRlcoerhLDRtgDZicCDyI07ai3VBdAEKVwbHaI4B0+KknDbFqCw0zm5Si5yBvFWqq1Hf629jcbCYYK+9JH5JZEv3nxNIeUXC+xX3BqRPGJU9072ZyXd/1Hv5FraVYHumdda1fnk/zg2YZFYQJKxE0RdOHmcq7QHTaUb1+DJdcZ+gj9bik7OSg7KdGiHNsmQnBpSagvHhjcCTbzky3Gxsd0H1irea3CDllfMfgClktb5qclBuEcVL/1hbsqzIRUlFglYsYBsYxjGagxnSPy6KI5yXV+YUiuw6K0sWUpdHJeyPCAzwJ9esF1xG5qPWEnkbLc+9VO+BlnK45NzhzSw== 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 VE1PR04MB7312.eurprd04.prod.outlook.com (2603:10a6:800:1a5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Fri, 18 Oct 2024 05:45:42 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%6]) with mapi id 15.20.8069.020; Fri, 18 Oct 2024 05:45:42 +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, ming.zhou@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 v2 4/6] media: v4l2-ctrls: Add V4L2_CTRL_TYPE_REGION Date: Fri, 18 Oct 2024 14:44:46 +0900 Message-ID: <20241018054448.3190423-5-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241018054448.3190423-1-ming.qian@nxp.com> References: <20241018054448.3190423-1-ming.qian@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::15) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|VE1PR04MB7312:EE_ X-MS-Office365-Filtering-Correlation-Id: fc30868e-1e3b-4a8f-3736-08dcef381a3b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XZmCUXNElnq2KcGEzWTSuaYX74kZKS3IqYfGomtTqSHQozgF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P4BYdjB4J9uN3L2kNc6PFqQDRJcqrCycsf3aT4MJnPbN22EB0?= =?us-ascii?Q?p79sTZ35m/NlTrcaWNQlLoF9rPrk6HXJmKB8ig1i98/RWEeCbkZHQ2QxW8aJ?= =?us-ascii?Q?2CU6b0/Uug0UeMwcWWFCQ7l/oRtziR44FgRmxsvrCarhA1wb4XQ/LwKPuwIk?= =?us-ascii?Q?MGdJCOGEdYzL5/yPmzfAj3al2bbaX/r8/11O7VPWnCmls8UBH+01tTIJPII5?= =?us-ascii?Q?JTz5Z7rmAaS69dHyhRTDJecSNK49d/k4KmjnoXApDqSsKfwbv986y/yVe+F5?= =?us-ascii?Q?bw2HwDQWBMxr26khp2gBZTtVOFLUs7Lqgco/CHenCEVlTUY+Ac8BlzjTibi2?= =?us-ascii?Q?sHxKOm4sU9S4QI8ZHfAhANIzZ+deBCgxKH648U2YLI8VfDywX+CNeOGt5Efm?= =?us-ascii?Q?YARfkJJFaQsaX/Dr6iu+zmSMMyW5LX0bgum966H2ZL9E67mSd0UmGSoVGuUH?= =?us-ascii?Q?kAANwj4=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?O8lAHFBhqCNKmOrJCkxLJSdWLZfNVh72/Lpz9Kk5C8DjMHUaeTzK2Wcx1U6K?= =?us-ascii?Q?DXZucYhWgisYArEN4fBJRlJtOk1FQX+uGP+lWpZoPMglB2HHwNbyZ4e1Gb+r?= =?us-ascii?Q?UkpkoMebT7KmgHHkWqzTpwd7s2D06rD798/LKd9rEOQYP68zYkBRXK7yBjcv?= =?us-ascii?Q?SeY4ZBg5aPN3K/zMRR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WFc6Pwhn6j16KVQpx24OOZvO4v7TNdXVwsF1VAJfJU2C0IicunONSw1s1f?= =?us-ascii?Q?XGupGmDVvK6A3vX7QWmOGFonqmtnWYNcfoxT02hbgm6DPGuXxNYw5x5AREAt?= =?us-ascii?Q?YQD+nA/HzcGHZFJ9Wqg4ctoXGyblkkFTWx9DhTJ/aKsKfJHaCU9JbO9k7O1r?= =?us-ascii?Q?IMmTj/AAJGICJACx5YBaXKIniLRxG8TUmCI93dVgkR5AKSVO6XOu8jFVCw9R?= =?us-ascii?Q?P0OLWrv/uuVySdCeU24boePI0+Q5q5VRp8m46XW8GgobutBoqUnuadzUIEjI?= =?us-ascii?Q?g0QzKk3wOPvsACjxCXduKR6q3YbH/ObbynK8G8kqyTpDBFGLkvTPCjPbcBcm?= =?us-ascii?Q?9NxKTwnhBFwGJuZlJE+pv2B3Aj782BvrVa+fNHjjKroVJIcqw4P0GD8do4n6?= =?us-ascii?Q?pHw37iAvFcsRK3EoN1oOsMDz7CbcM433pnw5mWDMilDNgXbttsMVAAk4+tlX?= =?us-ascii?Q?TB1p8VXn9irsp0ZnVshSQgldy75cTBX64FdabNFR?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc30868e-1e3b-4a8f-3736-08dcef381a3b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 05:45:41.8983 (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: 1PuyoK3+pag38VryqPEaP3qM5RhvTFz4kPX6VLjTO+rr0f2TsCyt18FOjO1d/QuOVJP4RoCr9xdzvw/3gitIJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7312 Content-Type: text/plain; charset="utf-8" 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`. Vali= d 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/D= ocumentation/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 rect= angle + described by the position of its top-left corner, the width and the heigh= t. + And a parameter for detailed purpose, for example, it's QP offset for vid= eo + encoder ROI. Units depend on the use case. Support for + ``V4L2_CTRL_WHICH_MIN_VAL`` and ``V4L2_CTRL_WHICH_MAX_VAL`` is optional a= nd + 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_ct= rl_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 a3abbde5379b..8dabc6a87126 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 *ctr= l) 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 =3D ptr.p + idx * ctrl->elem_size; unsigned int i; =20 @@ -1248,7 +1254,10 @@ static int std_validate_compound(const struct v4l2_c= trl *ctrl, u32 idx, if (!rect->width || !rect->height) return -EINVAL; break; - + case V4L2_CTRL_TYPE_REGION: + p_region =3D p; + zero_reserved(*p_region); + break; default: return -EINVAL; } @@ -1957,6 +1966,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ct= rl_handler *hdl, case V4L2_CTRL_TYPE_RECT: elem_size =3D sizeof(struct v4l2_rect); break; + case V4L2_CTRL_TYPE_REGION: + elem_size =3D sizeof(struct v4l2_ctrl_video_region_param); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size =3D sizeof(s32); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 5c38d6d5ae5b..8b271a7485f4 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; }; =20 +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 =3D 0x0102, V4L2_CTRL_TYPE_AREA =3D 0x0106, V4L2_CTRL_TYPE_RECT =3D 0x0107, + V4L2_CTRL_TYPE_REGION =3D 0x0108, =20 V4L2_CTRL_TYPE_HDR10_CLL_INFO =3D 0x0110, V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY =3D 0x0111, --=20 2.43.0-rc1 From nobody Tue Nov 26 10:43:58 2024 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2056.outbound.protection.outlook.com [40.107.20.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70538186E4A; Fri, 18 Oct 2024 05:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230351; cv=fail; b=NCUijY2k2DTVULJHTc1pV1U1g/IJv3p6hZ4WcY4hx+3rqU5/XqW2gpFc+WBnY61ouYdYswmg0C6kCQlUw3KZQdu99L+VI7u0piQX2TZjkp57+vaQbRjiq/Yjf4I4eEvEI2SHXko0dJfW3IwO08ZlJIBGvImDoqKg3oqNfM/ThA0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230351; c=relaxed/simple; bh=lklxAnXDrYHpoSq0emddoKYRrbLBif5sXKUDM3gX1DQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=mNppY0Zb+6CoNKka/umSug+AsmAAHXYr1SqI0UHMorwmFddW+gXqRB4UsOkXHst+lobwwWw2HcBlMgTR85P55y/TbAQcjlkogKzTveoIoutMxJf1efcYmFIg6LYWBe3NO7wySxVuQjy2S3yePuAl1NlHoPDYGIT+Z8MXZcCQK0g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ebvUIEWd; arc=fail smtp.client-ip=40.107.20.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ebvUIEWd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wsOmkVyVWVloDVeF62C6xmlDPUL9oimW9hHZfk9jkUSVko+3GgMdC4Sd0MSeu8cf4p9MXXqiQIFbjcUb9cXN2f355juZhRWXVgOINROSyjxj9L55bPwqZxEmZmx6/s6KQo9GW0uUFg3XdvYw5jHl+3AhBIFKHgywAWjrtYzVp+/wz+0w90QooxWetnAUeRKekKAZzYnd3kA2zOLY4hWf49DBJpm3vaU7MZ9XBd1vSP9V05m/CYU2ZPiSuwcw0+mQ9znAtav1Lf842OYUe06srp1vhkitR/auRldBTu+rpo0OV0vyFNzxb5ViztH5efxbIdU9pNNUf2NEu4hCX7xMxQ== 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=Z9PzfpCy8VITzYYkrLd2PN0k6Gc/8tbXXgoVtrDYriY=; b=gUNqd/lvL4HdLOZEZ/k+B4GqDbtlRVFHxteDaAMhfJ7VZIgOP2RG5X0vB6Cx1FERfWMDramz2zq3sqVfgFSM9LkYQ5ArXk5dqx85BzlhQ14lsTvJpe8JGpBCIBl3eynkQJOiIzP1AdUZMIHVcvNhInkGlgYm9REi0ULCoQ5qnyRfomigA0aA10fKsxYM/kYOwOr6o6ywySRrdcB/pD+H9KTHBzEwIF5Y/GPhstzCBAQWozGBiAvDfNXYFLTXMid5g69JE+JjwP50OY1Q/eWljhioUEykTCfHjcmRzL/IcAxF0q6YU71ev043meQ9GaUoV0ViLBTuTuj/LLRGvIyULw== 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=Z9PzfpCy8VITzYYkrLd2PN0k6Gc/8tbXXgoVtrDYriY=; b=ebvUIEWd5eRzzJSBGQTX8+MqCRdrJ8Eu+4MU76n0Mmpp465d36H/1Qx3M5nKwMQWS4IQqmUCwsjkcjY6XqpBzThM9fupRjaLMsWe69HMb8U2i0a6MpUQ5AMu4tPDgdB35d5Q67RjWiZhZQa7BQ5K3BdMBYXRoebjPkZHUmptBVmVd64Todrdcfgcwd3syWZydxat64IthHl33owEhngdVLHEtdfMD0tV2xXFpWoXVJ+DuD9+83FU4FKsEPIHmoqts7rFklK78cDXBb4xlcttcRmC6pSs0Kggp0oRWcG++cyRI3yRnF5hBdPEVqp9oDZrCTi4XGQyXQZhr91KrGf8LQ== 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 VE1PR04MB7312.eurprd04.prod.outlook.com (2603:10a6:800:1a5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Fri, 18 Oct 2024 05:45:46 +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.020; Fri, 18 Oct 2024 05:45:46 +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, ming.zhou@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 v2 5/6] media: v4l2-ctrls: Add video roi ctrls Date: Fri, 18 Oct 2024 14:44:47 +0900 Message-ID: <20241018054448.3190423-6-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241018054448.3190423-1-ming.qian@nxp.com> References: <20241018054448.3190423-1-ming.qian@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::15) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|VE1PR04MB7312:EE_ X-MS-Office365-Filtering-Correlation-Id: 189c8452-548c-42d6-e3c2-08dcef381d02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yd+j6T8AgtU4unf1knDDwUiH3JLGXoaGS33UiLIzGGRUmYaMAZk46KqOKvTp?= =?us-ascii?Q?enLRl2qvEW+6lC9zJDltJ1aXl+yYu86NeLQK8jMdNG0t0Mf613rHGk1CMFQO?= =?us-ascii?Q?S99J4IvTp1bG2VACQdaSyXX8Zydbr1BCfoA6oVJeFKTdVZOx0tpyT7DKkLMx?= =?us-ascii?Q?8lwdgxw7zwPpKtjgX836qWtty9FuackE8/b5QtW706oaJWecg0yL1YAL7Tr6?= =?us-ascii?Q?U/XZruPtLFK6Xq41boXsYb78sIwyBFaesFzxoA9bw0KBoz5/HG7g72CcPtYq?= =?us-ascii?Q?IIoHHQA40dVIfsGMgJPS3XJrAbgMR+ngY9tc2uIXnoViKlTz2UOCdD2NmqE1?= =?us-ascii?Q?Hjunk8x3iyVEqlTocgR7J5ZB3m0dN6av7PJdkyct+Mu+iDHxN6M1Ij8c5/aW?= =?us-ascii?Q?2LHczsZ9oH4rUUlTHaK6DWJ7MjidFKOkjD5czZX1WF5Xd/06Rs1bRdGqARyj?= =?us-ascii?Q?Vx6yvWuxx0EeShu/OgTwUOo+tmr3HHX2qFihBaNW08X5HA6G1qECnI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: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?MuuB43tEzOYh+2Y8LE9zDBiotfwcVICfZMXFJzG6PFNjKvFXO6vqemxcxbAj?= =?us-ascii?Q?mcX183j5mL7GvNHH9cLuhnnYlQvUyb+3AwG6Pym7uBac2l0ASperOzeRNGr+?= =?us-ascii?Q?lGngX5K5pJA0EZXf1CPi2vDUjTyr7DzGJqS1YYVQ22RzEVyKuQcLgYgyx63f?= =?us-ascii?Q?jA96T4P1VJB8uqjNk3zGl6YwutYh3a2sFKiWrH1wpNG3ot4kFbFYi4mvjVdE?= =?us-ascii?Q?Q+q5Fr9w+mZDWh3I+W9kt1EFK1eyNHDTgd6Hj3UN9eAJ+4nAgRQGed0PFaAx?= =?us-ascii?Q?5KaNOwyN/Aa5VbYjZ0pmZWxMkiWXIUiRoGtb4ghWLwpAMFTKopNBnPQ2p8ub?= =?us-ascii?Q?xNQHxNi1HOb1uJ8g8etNZ2b4/asymDbpjZfdpx7pyrcPIj1sVB1FqXGA9u6i?= =?us-ascii?Q?AooapVSICZfOrjJlf1gjVUFh8LTC090UmK9QEb1Fw0uni32b/QzzaIKRE1nP?= =?us-ascii?Q?DPakTCE+cNC74oSnG+43dXe31WnAe9IDmAEIt+T/FrX+a9kaw8oetygD+Qv/?= =?us-ascii?Q?N19GTF2Hsjop67XdR89EZNkvyN2lmyUWweJAtppCpWch7C150eGL58DUvXWb?= =?us-ascii?Q?iKuBVg3ZWLqeoAPQKNdAsR+V3k3gmJOkrqaqaufQ/wVi2O9jvXAT3hAvQGN6?= =?us-ascii?Q?ZJ+oskrEu//6dv3akwrPRVh/ChEPnkCiSQ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GPfheNQTvbTAixinBAPrfEd?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 189c8452-548c-42d6-e3c2-08dcef381d02 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 05:45:46.5461 (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: nX+3LYDHQ/N/bnRGjiiykedGTwGRPVTvOc/APOjbiQ1w+K8PWrvMBezOp0oPEGB+5ZEfzGGRibYDNoDlqARAFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7312 Content-Type: text/plain; charset="utf-8" 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 | 11 +++ 3 files changed, 113 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Do= cumentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 4a379bd9e3fb..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 =20 +``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 =20 \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, }; =20 + static const char * const mpeg_video_roi_mode[] =3D { + "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"; =20 @@ -1512,6 +1525,22 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum = v4l2_ctrl_type *type, *type =3D V4L2_CTRL_TYPE_INTEGER; *flags |=3D V4L2_CTRL_FLAG_READ_ONLY; break; + case V4L2_CID_MPEG_VIDEO_ROI_MODE: + *type =3D V4L2_CTRL_TYPE_MENU; + *flags |=3D V4L2_CTRL_FLAG_UPDATE; + break; + case V4L2_CID_MPEG_VIDEO_ROI_RECT: + *type =3D V4L2_CTRL_TYPE_REGION; + *flags |=3D V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_= MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_MAP: + *type =3D V4L2_CTRL_TYPE_INTEGER; + *flags |=3D V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_= MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE: + *type =3D V4L2_CTRL_TYPE_AREA; + *flags |=3D V4L2_CTRL_FLAG_READ_ONLY; + break; case V4L2_CID_PIXEL_RATE: *type =3D V4L2_CTRL_TYPE_INTEGER64; *flags |=3D V4L2_CTRL_FLAG_READ_ONLY; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-c= ontrols.h index 974fd254e573..169a676fd64c 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -900,6 +900,17 @@ enum v4l2_mpeg_video_av1_level { =20 #define V4L2_CID_MPEG_VIDEO_AVERAGE_QP (V4L2_CID_CODEC_BASE + 657) =20 +enum v4l2_mpeg_video_roi_mode { + V4L2_MPEG_VIDEO_ROI_MODE_NONE, + V4L2_MPEG_VIDEO_ROI_MODE_RECT, + 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 V4= L2 */ #define V4L2_CID_CODEC_CX2341X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000) #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_CODEC_C= X2341X_BASE+0) --=20 2.43.0-rc1 From nobody Tue Nov 26 10:43:58 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2084.outbound.protection.outlook.com [40.107.21.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56B83188008; Fri, 18 Oct 2024 05:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230356; cv=fail; b=IdiuB0reyE9b3AQsyKo4S4MgQebWF0aEoFxr6KNMJQZZuRiBz4HYottIYbQ/4dYbSQO5H1fdO4pkzUkgHb+3u2syw0UKCwINOBloxsag+PH2PWJvAU0wlexvYl0buhEpY+onM5ySFFo6z4fRouthHV+uQVx4XSAqnomn+3iBDJY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230356; c=relaxed/simple; bh=uOwMQIkZ9RIxIpbFlViNiVIbaql1bLSvdFZewvkcJzk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=r0T/4SAM6qT+7VMi+NXE++8Jd2agFXmDp+L+y2+BgR4bOY4nOtUQ0mrX6EewG+hwq7WLq3fmBgqVuTDirrVzm15o9lgpLCGmjWDw7HJ/eXAFhui6aAySC649WsqkQkzp3FUjqEblDhtiSOEwQh6vkFcmwTfxcaIt/py3yw7+t60= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=l6MgY4KH; arc=fail smtp.client-ip=40.107.21.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="l6MgY4KH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h/YSOx+9mjeabYNuluM64oohnVQF7SJxUfwV2O07Q80/WEeD60QbdTuOdWdZIojf6Q6D22I+I0YER/mSlcP0tdSM1woM2CKjRKkyJ2gS0YZxb49ByZ8mhtskHM61o+9u0+XuIIhJkDIpJ2OVVg0ynoJ2Mo9uFkGwvCYXhWNuj8ORlpEC5LTt6Ld9wbpUeWpHoUmfGPZRtASji4TURBk7wXfdPATlgQ/1PgMUepuQWpueZeEco8bdEznQ6vOqCNWOUush+CzJc8E8i7V5hqgqIK/mer6qCQQ6SxRiRKWXyo6tJ7iMUBLGcUD5KbCURJa+xZ9zv4eLvPjTUl3x9rGVNw== 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=K3+zhNI5VS6IKWb6QOdCtjpVCycJVK3rFo5kROJWK80HB9VKaxcf1k0HYRQGDcxQMJNjPWHGZZhCriS8q/tXZ8qKKouDzEYW6l53mPc2BGdRGZr2QJnvlUCh28Nq+QPk0lCD34hhtePobCfjNuUqMF+kPOxn1YnhI1/EHhJ58X0T5J0hXRtyfaiVCVk/kkYRr0wxnCcwjVAZUuxbLEFfUsUNUZPF0koIW4np0lhKcGgNWo8CGz/+L14eSA/iZJ6GoEqGbe/E+G0854mCUIQlEDRrZRDjHpfTGCpq/e40fTx0/Q0l8uDyRLVoZRtgKcdn/KalbuiJ+G8M/UH124phRA== 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=l6MgY4KHgdS8yON9Q8CXD2YDYJVHhOk3hcQuz9yHXDpl4s2a7YMrdRrZVqkQViVUrvkuok53pM4CZR2eEWns9PSq762BYA6O/JfF36tl/DPGKR0RyFxM2croMlfed5JbvqkwuxWGs0tN49Ge++JOcmSXZI8EyFRC9pHZHqBD1ZmWbELbBeHcC0rKpoMQLwbC47Wg0xcvKLqVqDTVEE0Xb758GXUI2fXgord8zAq2Bls6gtXgR3Ba6bMGIEcGRNy1dvAslOR2/NTGFM6gKZ6/lLUsikrTtxvfO+93uj2aTwIUILIhVhRJAj4ERglNirJqXcZTSyOXcsMPxHQHtVZ/sA== 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 AM9PR04MB8537.eurprd04.prod.outlook.com (2603:10a6:20b:434::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Fri, 18 Oct 2024 05:45:51 +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.020; Fri, 18 Oct 2024 05:45:51 +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, ming.zhou@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 v2 6/6] media: vivid: Add a video region ctrl Date: Fri, 18 Oct 2024 14:44:48 +0900 Message-ID: <20241018054448.3190423-7-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20241018054448.3190423-1-ming.qian@nxp.com> References: <20241018054448.3190423-1-ming.qian@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::15) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AM9PR04MB8537:EE_ X-MS-Office365-Filtering-Correlation-Id: 04d5cf1c-7e08-4454-e7f0-08dcef381fc1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|7416014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WvfrIRCagXW6lgJodzE7r8+87vi5sXwmT8XO/FYX2Cf2Di7UTyd7Dgx/pF1X?= =?us-ascii?Q?I4nlnL3WsODVAG8E7VU4lSHlkyNE4XE77X3Mqck35WVjJFyh9zRzJLOKNzcK?= =?us-ascii?Q?iRSS/wP0lTpu9p8O0PC3sQDn8tE0p9azg1Q/U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9TWntn/L6jDNv4omYS56thVNa6OzOkmSLRNpCe9FF+8e+7hAopOVBQ?= =?us-ascii?Q?4pG4J5mlbt8jHTnW3pjkzvsWXc3JntE/RKWsZcZoGZd1iQVsW2LIxGClT4Vw?= =?us-ascii?Q?t/38ORfXkwjjGjC1jvsq/5UygqzlzWaOLU6LmamWmeTQOWLvgy7GUJMINO8M?= =?us-ascii?Q?aCASxgMlemJuOJYPGmU978ly0NqjPOwPV+9rzvHFLRqEq3eazZhM9EQn9T/6?= =?us-ascii?Q?aff8w3WTdYCk2aiXWpk5x6YSlQ7kotz++cykMxwc1uFdrtWfv5+DncndviLa?= =?us-ascii?Q?voAGBKD6sWk5sruimLKmSNTlmOdMLsExE2KLOHX+VyHlx4suyx+2TniJt9s+?= =?us-ascii?Q?kIFGDuI=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(7416014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?kh3FGxBie9ilP2sqY89/KKJF03yfbnGjatde1c98iw7FRsDOQZLhrfxPOrIk?= =?us-ascii?Q?wLapakohB1rBlmiLVM77T+cFJugtc50JT5M68jhQbch57g4PxDiqyK2gokXr?= =?us-ascii?Q?ru5nBbWk9Fg9G5QP/M+kGbUAB0/DwI61FQdYrNfxazbbFtjZ6kelVhkkhL8l?= =?us-ascii?Q?myajekf7A5+DAipSccSA8G+lCCN0FWPian97znnrQ0S4J/QIHUxByA/Wu0O0?= =?us-ascii?Q?LAHCD4OEqx0NFbA8RXoZc61N0JaW+Z0Htd0Fzx4ijqmObbpVXv1XbjL3wqnH?= =?us-ascii?Q?jo5FrORIJpq3wHbyg/jn6SCMnBIe3moJvTM0TIH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EqQlTKxg+4D0hIocs/p6hW+QpaQdcADWCNR596H2HCArZ?= =?us-ascii?Q?SsgSBmW86iUBEUMpYKYfNtfgGs1LhwUA2a8NPNsfy5oqmSwkBMZL80lFJwsx?= =?us-ascii?Q?KrYWCjbiZ0BAz9kkY5xVk6lI4hh8JG4J+l/8agdoOa/V2PuMXUm6rSNEPIxQ?= =?us-ascii?Q?u7sfvmQjsZ2i9689awxUi4t7p6Mtv1jpbVIdvx3FjDoaO26iQUPydtePHkhH?= =?us-ascii?Q?yzGyisp7YA9h5NwBwFX/Nnp6I5DNt0VUJ3TXw5VXoi3TR0W63qYNPfFNRVbj?= =?us-ascii?Q?0sqRX68wF0ft59e0HUodmcHV2o38dMinb+w3Hw1fcdfXZlPCebu8HCr9+kQD?= =?us-ascii?Q?7she2CW1ARA14+FvPqvrpS3EDxnf0hda8WLaHf6T?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04d5cf1c-7e08-4454-e7f0-08dcef381fc1 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 05:45:51.1571 (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: wO+OUdwEYc8HR+W5VTIl/VMc4mwdEyXPlsRWJvsNr2Ekkz0xEy480E2Zerx+eCqtdbOBUtiqc2hMPqaea/2N3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8537 Content-Type: text/plain; charset="utf-8" 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) =20 #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 = =3D { .p_max.p_const =3D &rect_max, }; =20 +static const struct v4l2_ctrl_video_region_param region_def =3D { + .rect =3D { 0, 0, 0, 0 }, + .parameter =3D 0, +}; + +static const struct v4l2_ctrl_video_region_param region_min =3D { + .rect =3D { 0, 0, 0, 0 }, + .parameter =3D -51, +}; + +static const struct v4l2_ctrl_video_region_param region_max =3D { + .rect =3D { 0, 0, 1920, 1080 }, + .parameter =3D 51, +}; + +static const struct v4l2_ctrl_config vivid_ctrl_region =3D { + .ops =3D &vivid_user_gen_ctrl_ops, + .id =3D VIVID_CID_REGION, + .name =3D "Region", + .type =3D V4L2_CTRL_TYPE_REGION, + .flags =3D V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX, + .p_def.p_const =3D ®ion_def, + .p_min.p_const =3D ®ion_min, + .p_max.p_const =3D ®ion_max, +}; + /* Framebuffer Controls */ =20 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 =3D v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_ro_int32= , NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_area, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_rect, NULL); + v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_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); --=20 2.43.0-rc1