From patchwork Fri Oct 18 05:44:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13841122 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> 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-media@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: 9K8X8m80kXHxG9u74PuBW91Dy8J7lJcdY+TDixzCi/QX3KAOO+zRKFpDezVc7q7DgbHtxyvRc+eKrmyff1JC09Sq8sH7UDxTFDyray+yCXTAo7ixQvWOAvSnHCWJDmHmTMGq6BaQPLGuNpJu2JQFF+PsfsLhuMZXBh81rhP2G+gARdN3B+CzNErLg2omHdsXLhV2S9b3TIUbk01cwTLabOb7AtipgDNr5d1X9FH3mRKZ7KJTkTSGi6e0O0NjYPdk0AmH04j4Pn1367Xbb50PxcG7yZttsMIdizWLk7bo0nAsFP+sCVjL6w4vXl52xXcCa+/T4qnR/QQ/RFlzAR4UEQDJhheJ5/I2eZhn2Ud0sbx/fRIdvCgrTL1yctQNsglwaAIT5kqHLmTtTYG6uwfsSfR6OoQhaFB5Ff10ohuqwQEniMl02w67ssUVB5VHJuX7nE2b4amFuQv7LgvckTRUbbE/ZkBk6x/HHBovZbTTzRzkcsnoCOZKwdDUxqYdxJA9vfOfytipgXJ5WTijKR3Ub5vbmAuN2HEmPHmmKJjDMZaoNSgrJdPQhqSt05cGydcxkpECEsZ+p948/8bPMTg7KRz43PLe+tCuZ2eNarzgDV/PZIoAOuzwDK1zuCsnFJh6wzWLCW4P4tmiIP+jvTAALvLAZ6ztDwZn7e1mc342CcpJycktgKm3g1YGNnC8kHb19tjQ6yNqkpXWjlZsPszqp99RPOL7aB0sfX/4eUCyBkmQ7VOocWRKd938xtXeQqj8a2B6j9PDlGsyshepk6NVa+oMRkt+s+Fxtbmkjx1PdCEgwBsJuj02XhDazKFReCmBx4VnC3RIwdbd0yX3NvvrAaiJKcgx3HN2Nk0JAKCDuCwWAaVDhYJNt+Jtbfs/xjG0ZaTVnT4ra2OpnMdcd5rP8XgtgKJMMD6rIiNE6+utYFl6ETrnfa9lOisaqhcGr9HyS/yFU2Y6QWET3o/mCpZOVNdHtAMeI6o2qQfyr4v3xFz3TkxZBlbZQmNF2YM8n6r2z8cGcWdTb/XKJAnDimC0ejRIuKYq1jtb2PoMq69ehXnN+BDL+aBXdBMsTu0t16XdHXMV1bPYWsyCgOFWC38s+O+RQpF6U0Hjmq1t128YWOj25TDvnSsczIebt7LUD30fCJVDb6kLq3rlUv+D7s6N0l+h3+vEc/nwz4SOuYxd6IVoxPTDDs8f4UssKAbL9aj4oGxtnrElM7jkOK9udg4XlhRdIakLZfsfWNUH+twGS5/YKpXmy5QzjPjUx+jq5wHDlTkgS7AGfmOt0GJ2pB1wHSbeORnv8pTSBl517MqhH3FWyqqzPdR/Zm4uQSmUq3/2Ql+Yi3HHY1GH856aUnFkOETq4Mv/tYAmM08sr5bq7zQ= 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: +DRhV38qRprBFsyh8MlXCvwGoBmvv/3sSRBYYzbD+hwyUX5syp2hn9H27bfByFL3cZDYUO0Cxitb1YyjycmdxOMO5xhKbrp0hatrsLeixCtAVPGK/DQPB9r9xPkA6RnqfcLlK1XPphtahWs7VY33BYaGda0rSDx3MGej1c71gIf2ZF06Pk7TFX7d67YbU+AXCY7QKANPyt4yXbR4DH0j4ZZlnd1R5744mFwcHN+k7VhzVJROlPnQikbTc/k2Icc0CpP14LhZXgaxPJGQd46VAWtuRv4Vy7n9WaqUH/Uj0uE7rkdVhzA97Zh3yY6Qf2Y7vWRe/qwcHPDwO4DKX+5SXVd2BxlDP0WEfQlMl7MqxbBE8QANnncYLBL5riwnQD1/AwAH8T+9WRXqBNLLiSZ1S4Z0EOGgJ/XbyddbKubOl4A5OBOBSaxQl/ZjjyOibHp3NsQ3+JY8uEZqfaUxRr2QQ+qLTniNwu/+K7BxeL2ShFhZfGU1BIfEolmM4UEZsRsKM0Uvs2Q7GjSGRlLGqZj6j6An8GgukBmpt5Ga/zHYTYH05ODSBmV3kZm8OApcMG6KvKWlYfJfqAS36o4fdDnFZjyDmlNPlNO1cpUTdvjP5K98B9haU21nMHzL0MTomf7SQ+0Ysnd4gL3V+zqiSLM9jiOaebHmH2f9G+WeqyNSbHJ/co9PdvFakZmFUauiwf+FlDhbcnZJfRQn8IjFJMmzJftbfKM+Mxkx7HSeBKR2ss6UvrH9S1gJ4wUlTExSyUG8MCdLZ2lZezaHJMse/Cu5JMPFsCR8xrRKJhHmGF9CI4zhM42R3sIZfFhwz1pGqyA5F0Zsvv9zb2XjrA9wlDYJo3GN//9md97Fbb9ZrTpTc08Q0YjhAanYQ74vxEueZXTS4RT//Vl8HNTUqyhPTBkqW2sATVKbgTHv6Bgd6h6oSr5zhHamlf6zWLCb9hvsKXVVe52lqKyraLWOwEDV3OaJtxzwVuoRfRdUmgOQiJZLdqMJSsdCCBsguei/1UqzcTjDQoOtmqDcIvmUrJPJkB4McJEIlqn7dsVsvRCH+Esw4E4kSgoqdPU1SDSl0dJKCtckg3oE5CLQ9D58FSazxdj1hozlYiMjTMkl+cHF4izSddWjxGJFTkn0r5SosLtcYPSuMRhpRUOnQnYqAmyC44Dt1TRXaJETBYpb+LBnx5ozyo446CojwnwY9w2mMyrR3qxopK+Mo45+l8jQXlZE7h0rRQv0ByQm+v7MpTBqx2nhDJZocp28QMfEzXmUjCji8n1wDp8fd/H4jwpPdG+NS5CatbA/HzM8aQrf8y+CIv44NvX/xTqa7cFrRj1yYvqJgZpbVThEnNO1fLGoDR0d2Yn5y+1mss8vhzBrJvccOSSz1znNj/l3kj1PpDwTiLx+IGRzQ1l7SfRWziZOBG7cbU61GeSAWCQUED5WyIwbTk6U0T3+GH3Cle0E/BmRvqQqOYH5FPIPngcbjhm5cnsqVnwG/TzmWx8S3EhOA41EN6+nr3qA00N5awaxmUpzbRaddX5tEuEJxz5HcSNe/XpHLJ91GwGfe96o7RLrSxtW3D3dPjgAJsz7LHwwuLCHcFmSkNlx 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 From: Yunke Cao Add p_rect to struct v4l2_ext_control with basic support in v4l2-ctrls. Reviewed-by: Laurent Pinchart Reviewed-by: Ricardo Ribalda Reviewed-by: Sergey Senozhatsky Reviewed-by: Daniel Scally Signed-off-by: Yunke Cao Reviewed-by: Hans Verkuil --- .../media/v4l/vidioc-g-ext-ctrls.rst | 4 ++++ .../userspace-api/media/v4l/vidioc-queryctrl.rst | 7 +++++++ .../media/videodev2.h.rst.exceptions | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 16 +++++++++++++++- include/media/v4l2-ctrls.h | 2 ++ include/uapi/linux/videodev2.h | 2 ++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst index 4d56c0528ad7..b74a74ac06fc 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst @@ -199,6 +199,10 @@ still cause this situation. - ``p_area`` - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is of type ``V4L2_CTRL_TYPE_AREA``. + * - struct :c:type:`v4l2_rect` * + - ``p_rect`` + - A pointer to a struct :c:type:`v4l2_rect`. Valid if this control is + of type ``V4L2_CTRL_TYPE_RECT``. * - struct :c:type:`v4l2_ctrl_h264_sps` * - ``p_h264_sps`` - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this control is diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 4d38acafe8e1..56d5c8b0b88b 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -441,6 +441,13 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_area`, containing the width and the height of a rectangular area. Units depend on the use case. + * - ``V4L2_CTRL_TYPE_RECT`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_rect`, containing a rectangle described by + the position of its top-left corner, the width and the height. Units + depend on the use case. * - ``V4L2_CTRL_TYPE_H264_SPS`` - n/a - n/a diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions index 429b5cdf05c3..3cf1380b52b0 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -150,6 +150,7 @@ replace symbol V4L2_CTRL_TYPE_HEVC_SPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_RECT :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR :c:type:`v4l2_ctrl_type` diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index eeab6a5eb7ba..4c8744c8cd96 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -370,7 +370,11 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl) case V4L2_CTRL_TYPE_AV1_FILM_GRAIN: pr_cont("AV1_FILM_GRAIN"); break; - + case V4L2_CTRL_TYPE_RECT: + pr_cont("%ux%u@%dx%d", + ptr.p_rect->width, ptr.p_rect->height, + ptr.p_rect->left, ptr.p_rect->top); + break; default: pr_cont("unknown type %d", ctrl->type); break; @@ -815,6 +819,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; struct v4l2_area *area; + struct v4l2_rect *rect; void *p = ptr.p + idx * ctrl->elem_size; unsigned int i; @@ -1172,6 +1177,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, return -EINVAL; break; + case V4L2_CTRL_TYPE_RECT: + rect = p; + if (!rect->width || !rect->height) + return -EINVAL; + break; + default: return -EINVAL; } @@ -1872,6 +1883,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_AREA: elem_size = sizeof(struct v4l2_area); break; + case V4L2_CTRL_TYPE_RECT: + elem_size = sizeof(struct v4l2_rect); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size = sizeof(s32); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 59679a42b3e7..b0db167a3ac4 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -56,6 +56,7 @@ struct video_device; * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure. * @p_av1_frame: Pointer to an AV1 frame structure. * @p_av1_film_grain: Pointer to an AV1 film grain structure. + * @p_rect: Pointer to a rectangle. * @p: Pointer to a compound value. * @p_const: Pointer to a constant compound value. */ @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry; struct v4l2_ctrl_av1_frame *p_av1_frame; struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; + struct v4l2_rect *p_rect; void *p; const void *p_const; }; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index ded023edac70..4b12322be592 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1857,6 +1857,7 @@ struct v4l2_ext_control { __s32 __user *p_s32; __s64 __user *p_s64; struct v4l2_area __user *p_area; + struct v4l2_rect __user *p_rect; struct v4l2_ctrl_h264_sps __user *p_h264_sps; struct v4l2_ctrl_h264_pps __user *p_h264_pps; struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix; @@ -1927,6 +1928,7 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_U16 = 0x0101, V4L2_CTRL_TYPE_U32 = 0x0102, V4L2_CTRL_TYPE_AREA = 0x0106, + V4L2_CTRL_TYPE_RECT = 0x0107, V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110, V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111, From patchwork Fri Oct 18 05:44:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13841123 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> 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-media@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: O0+7Qypc+lwmS8+k82ForojsUIcBf10cCOexPnQeeypps3tyNm3W3BYLg9Hm1f/ggHDu4qgY8xoSRYEvbl8IAkacKZ0QsZbIBusJg/GTpn0sCxSIKcmRnd215gzbp0dlo9ZNJ39IH140FZeczUu+ldMBjXRycsIqRpZIy++QPtOXRpdxn+rh9M0j79ZBfOQDfM4z77BIQFYTS/bCsoDCAxHONOuLGBe3ONgFa6LSY3NtlrijWEyVFqw5P6wHBjh9cA/PHi2AAui8jcJHGhSYi/YmnSZQorzdu6Uf4PO+tfjIiR5O1oTef+jRE/PlaONVSKR82vEy8Ejc2TvVxJpS9DQpS3XtAvN/xxlkG0pLZYae/x+hHjmD0V1uOBqo+w1ctFpu71CnlwVTKUSDsoAF1V8ufhNMeC8x1b79JrWHD6JnqXZfW2mdI33IZ1m2QOHKNopuNnW+R2z54rYmPmM/ryiAcKJkdM2yBx72NvBaIJEwJ+tFqab2cUXZzi6qDy+z5j1jp/4zKdNRn7MXQhdnV9bu5GwA4fJrQgdPEFn/5qf5BrmsrngaB5akFeaEsuZvb7xFuJxAWnZ2c30BT3H2+jpTfoFOZzcfHOQHIjND21JRVH1igWN/PZQZEjeujl/VjwesmuKRqj1HL+MxWimuiOeiigunPV3MZbdAaoW8PTa/8PlU8RIFaatOLglDUZnPO0v2CfWG37+FhVHVCJk1o9oxQSxFuDriV5GXVFUsH9dNJOvllIBpcxWIZGNzh7ITIOiB3oJn8TJANXl1Jz/kjcBEpQ9i147NM0u5MJSnsqivV+DOdOal3Mmv4MCZrYxUh17vQu9YTyr4iy6wY8AV2VN+YHATI27xY0X0sVkGCU5KtK2IyIs7lGOlwFNit90C+UOrfVTGxkxeMTfKC2zY2CnoiC7pysrX8IW73nT4Xcy5+XsEC+kY8pjRhn9n4AU3ExXPyRqHq+T1x6ciwm4mOCUf9TQi3KvMXJ5hRbIaTHqXtkcFJWA8fDswr69h2SitdtsS18hijR3FUc1CT6LI7aqk98+4vmJ4h/JtJNCGtPQDr4IR/2d3xy40rOYltMJrxR+41ygmLlRHDXXk5eK3cMQFi1ChCWwJBF3hO62UahbyYbtRkOGLInAP9NGCnPWF0hPoaUdXu3W/TLmvL3PcwBABM3E+7L6nAn4k6+DwjndT/wO1v76ovAnrIyw7lcfPK/gtQOJIxrT3xEmPYdEJFcD+5D/VKdaxFfG8U5rHPDKYNBvaPyJIKTe+ATGQJhNpYXeIE+XsmXM4dHmaYOMq9IBO3d1FVL+ooCZm6yYR1nMiyma1ohkr/hIuElfxkWoBMuwW3B9mF4oP/8hIA5mEEDyixDDawsAZHe248WCZ0Fk= 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: 1ORZruj46Q/jr+6qrW6nP5npdTU4poY3kbZ5wvyPSIr10oKMyyEMsvmsi1bE3L1Y1HFvntLP4wXwr5udCOQb3JG9/o2V0tp14zzsF35ZIFe5fbWR5xj0o0qXSy6mAQztmn5C0IYz4jUp/wK5hn0/jBe2plRIQsDVDZ2Da/QZ7sMuY87bEi4i223gw40XD+L0Z+LyQfghr5VNAg8+VGLrupwk4ijdDTk1gQqysvUJmg+8Mpn2q9Cp0G9bw4DTIRVN7kNTsGL6IQi63bUjYhsdFZoz39VcsowSxUkKsv7WWFBfbOLF4WmdRjQW1Lf7qHsHRuoXalw0TpytQ9kJZevdBa8jJw5xT2wvzVebP59xb3aTlF2Pd944MtIs9rYYPS59WNx92FJfNlwSpCJJPi5vGs2kaCk44TDH3krjRrn0LMlnncN62KiU0bvTeZXgfEMY4LNC+MR2Yg3WMv0iBeoNwg4StEs+oKayim+UPCrOm7rfxZf5CPGo9wWmvWonvlnuNLnSpeQhT4A7x0WeOp2ePjZMnJbF4RCkiuFVioJa8WJWwvRgFAopYiLfxVp9Q3LaVAKtvOgQIFJSITnE85AP7Yx/nHnbrKKWBJjtXI1l968pzsVv5bLCD8DF8rUaPICtcclpabtaQEukpPaui1ni+aMeL9U6pTudx4kTbUkRUWULTgL+G9Y5zGPviwFhpF8LwPzrgxDj/rnfaelJU05FAOeXX+eGb7Ieo/Zn7UzGmO/nWCp7CgzVOadLH8aWBO+IjVzmPT8spxo/7p3D1SfOF99dTAVO3qp1guawXS3YeWztveulQXpuFnhB6mYqpsqwtauQgbvM6JbR67rN3hRCAExiwQ3dMQyjfqy0dw+NLm60RTfwLd+vvND3lx5EYFBPHb++ECd45OvES63VWy/wwyeusxxnxx37COUGCJw4I21dQ2sadE37iEie+ku96+n4BM4fFEKSYUIxUop0kYZ7r7fYsi+OPnszcsh9M5+jJGU0Gk4cacRHYfG/sRZSecq5wXIyKFR6t0ksqsbSjjoQOhY/PQworci93wu0y4jvPsXQ2T2qEq5k1kQErBgdqrFgrHHrHql+R9Sh33+omjykzidCnb6W6cdCOvEeuxiJMXS+YS0pjag7wqoIWVvPIE/UKVKT88A97yJKYTXQNjHyZJIsx8MZohAXojU+DJndYPaZC1eKRK8CMAxh50s0XAEWCTr0omvJ/VOb9Gb1PFzts9PUR6gMaFSBPwmQZgUkHMP32P7nNkTaUV45tCe0T1HRuAVgDGSRXQP4D1S/eRxadkm7USi2NBPSeA7LSfuVOs8PvpC2CfkFg8/hPFCBwXv304SHkgI5Bs3Av5c+TzOlHygVtTUbRc6WzthcxZe4/dG6HU5G+ATBv/unxklg+nZ6Uq3epArWrCXNLBFHQkVhJoH+MBbiF1q+yK0UDT6gZXjviq6QDCgW61rKkjRQ7UzmzIaunuwl6wfBUg1O/Lgj+E4lXI9We0fvJQ22MHSCE/xFknbALNUB0n4zvQg5tJnYh2tdOEk1V3XnceIidkDOVoJa9zp5tmaSwRuGE9hwQCT80+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 From: Yunke Cao This control represents a generic read/write rectangle. It supports V4L2_CTRL_WHICH_MIN/MAX_VAL. Signed-off-by: Yunke Cao Reviewed-by: Hans Verkuil --- .../media/test-drivers/vivid/vivid-ctrls.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/media/test-drivers/vivid/vivid-ctrls.c b/drivers/media/test-drivers/vivid/vivid-ctrls.c index 8bb38bc7b8cc..bed5f4fb0c69 100644 --- a/drivers/media/test-drivers/vivid/vivid-ctrls.c +++ b/drivers/media/test-drivers/vivid/vivid-ctrls.c @@ -37,6 +37,7 @@ #define VIVID_CID_U8_PIXEL_ARRAY (VIVID_CID_CUSTOM_BASE + 14) #define VIVID_CID_S32_ARRAY (VIVID_CID_CUSTOM_BASE + 15) #define VIVID_CID_S64_ARRAY (VIVID_CID_CUSTOM_BASE + 16) +#define VIVID_CID_RECT (VIVID_CID_CUSTOM_BASE + 17) #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000) #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1) @@ -360,6 +361,38 @@ static const struct v4l2_ctrl_config vivid_ctrl_ro_int32 = { .step = 1, }; +static const struct v4l2_rect rect_def = { + .top = 100, + .left = 200, + .width = 300, + .height = 400, +}; + +static const struct v4l2_rect rect_min = { + .top = 0, + .left = 0, + .width = 1, + .height = 1, +}; + +static const struct v4l2_rect rect_max = { + .top = 0, + .left = 0, + .width = 1000, + .height = 2000, +}; + +static const struct v4l2_ctrl_config vivid_ctrl_rect = { + .ops = &vivid_user_gen_ctrl_ops, + .id = VIVID_CID_RECT, + .name = "Rect", + .type = V4L2_CTRL_TYPE_RECT, + .flags = V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX, + .p_def.p_const = &rect_def, + .p_min.p_const = &rect_min, + .p_max.p_const = &rect_max, +}; + /* Framebuffer Controls */ static int vivid_fb_s_ctrl(struct v4l2_ctrl *ctrl) @@ -1685,6 +1718,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap, dev->int_menu = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int_menu, NULL); dev->ro_int32 = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_ro_int32, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_area, NULL); + v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_rect, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_dyn_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u16_matrix, NULL); From patchwork Fri Oct 18 05:44:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13841124 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> 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-media@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: TDMmkpsVgtbHcCMcIylpmilDho8QDl+dM5ldEfXniELPM0kipGCay8bCy6KsXpKjiHc3ZyKo1BMSnlDXboB4n60cL9Y130wO5SoyVIDb66GMBvk3XGBdIUAXNMgFDmL4bi3EQi+zHAmj9HFizQlrSufQIN+5S2I8xQx4IN46bfrr8CNV2iFurUmjC6GZaBvQ03GYTR+pDNj435GgCK7LzgZYcGxHtojQ9OuJfKaNpeSXLiPnvwAXWKocTftyK6HDEQVoyZG/al/wXJdIjo09y24zrFyXZKV2iCHx0QyVoqrQRAFPNJJsKZTCvBPXu5BmjUgAToz/cRVQzTS7Gc2k+kKoLft3+IXppcEM8aRX80iuKY9FzS17GaxNRiydo3pNPQbhyC2fx5g3lGd2DCadt3aPUIyzW2x+awNaWFCil8d74ce4IM2ZcU7Nya+yfvySqhXLHEJ+2teuPB9D7obozvymm2DpwiG1ocmBJ/Z1IWVKcWpRoKn2ktfu4JCPj/xbEtz+qSO9QSOqyaLxOZkxo9O6xknZLas4Q9zCaxXwzq3VQNkxSIZo6KgeuFAzAGgpalMRUbzOW7jbQTNOLt9mMJScaKYevMZsS9U+tl14AIw+IYhgR5rZLOSMxbGTiZ5tdmJCgV7pZxJ7nAaw6QbJ/dQA4x7+tZiuUavRgEC1vkRXWn380fOTibFNvdQBxKe4zHmi9f6sp9+6RcY2rAbOcSoWR86srcjKGIkgrq1HEV1G6z7+zk5Z1qTw9w44myqQE2xH8VDm1eBXNKIpG1ZO2MxYgKm4qOZyMof/2CgYCP1uyDRlj7mkjmuz1CMSpDocWeMy+RcDYgFLN+WRnx4gZ4qv/eLBBeVtJ86rTW9L7RB3KGoRPEEr+nTcScaVD0HspZmdbDDiGHSfVCSOP28YszHTGQ9OnfP8e3HLE1gkpUBubCkYtakpmVWqTIj76kCVmLfgCBG/o5NzIxQo2zKoouZ4CX+39/dc/sgEOGqPIN0vltIA7PVbAt3ixbX9u8eRTnkMYQn7hwuQtya5TLKHk4GsuBd1fkP58RWop/hImfxPjF37/EsRpt7D4YD53zt53VJSTcRWmwxR2BboI0ogf7wGWe7qtVs4b7uYDYB/6THioS2YOg5+3D0lULP2vf6RoOs8i7+Gwwypv8SqEWk7B9inTWVz2UaSDaWo7CM0kUyaQYJqbJCGyIbKWecwNVt+FX+MxPSLSGAQJ/AAFGmtXu3rXXd0gJDn5Us0Aeuy61KIedhRlgrFwovoU1LANhCnRoqjjArLZ87Ia3YthxNelWoDN3pc7IRQF+yQHZQZje/dvO+586vmOCn1wM/1HEHVauzb4ILTvdEXfmrrTim5ET/VT/Ien4thJjNF1x72qMY= 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: 0+/THK0xsFlTQcX1U5yR+Vpl1qHSRjCTePUoXic/a3fplQRKNtkht+3kYcubck9peQstRTu4FMjf1O2UeXlgPaSphnzXgbzZDZwCRZExOgdjr7IUr57eHnoyiKi5TEMJFEYuNRTHA0/n7xKbHFlAvJefJruN6F4UUvN/7I1ZQMH/pN3C9o0EsPSXuzAaIyYoL1CILVhiWxhe1EMxGbgsS5aUBxoWIYuWYARvYa1aFN2ttrV5zy6DdxE5oErKgNlpxO5GRrUsxZybnO2Harm8Qp99mRuW8PZYRB5uv0XO5sAfwObmtpyCWc+QRO0wq121hWNIfQYln46hcpinA/j5zuzWFkYrsrkMtEH32HSZcBWOC9eqEtATXuL7DVo7JXePs1TRSOdQLyz93cTz5uqqkjEMyE3ru45IbKGDZRPa6fDqRh9+EqPaBh+XtPJ4wQocZPp+I05XiuENJJOzAG6mK5u6La4cDCew59cFMJRffyFg9637FExwSYI8LGfNAkvv5epXbrAu5WLexueF+/g0ybN2X6jsa5rUnbfi6OhmAOkO5q+HBpyNI2xDI9azhM1gZ9UZG+Y8lN9PPU8kcQt3JyRc5N3D++/GAZr33ZNqP6cYJN4dXiO5xLNPuFYcmdbwLtNSOei7DY2yRwQtrCHpFxHW2HqJv8DaV3OXHVAy64Oy6ctDt/j5pi/CjKvIbZZvKBtMzWh9Ar4112WTteJKyfEZauFyqNJS0rTwa/Ib6oBbiwEIQuI9EeJlZwrFdrzLumW6m+kP0a7VKs72Mm7pB9IPtLFLfL1Lag5XIzkaJPWEXIevBpwEscZciMttLOVzxin1ABOKpAg4dUvjKZ9TFbBtB+ELmoLfIZTm6cqHVWFpZsNm6KHnKo5kAqZDliSwimAHNPBGLt73EsoKjS68PDYqJERdbo+8aPD0JCsz09gpJ/v2ZxIw/frowmuTemyH992/yeBQPhSt9I+r3iVVYXT30Hz8Yp7MFSEYGdLdgTRxajE+6glMtpEVRD2mCGhDQcNT+PwQIlNEYoy5QfgEAr63uolMUsIOBxoy4YBVik1ZN506eOMWmH8/Oxaxm327nqN9ZcjR4fiBIVImIwVNhC8MyFArqq8lRewcamBNGF+oMv1b2ICywjIAJYsV4uK9m113TA/bcEm+mqSiTtG/ttrVsc0mIqvuGm7WvrtTsVwjaweZmaVOwdB7HsMNONIpedvD8naA5Ari/VukCoACpLvwcCqKnSuDeakMLqv568LjcQ+P7X7j3mlNLJtaacya/71TBDD6G9Pwh1Ih7B/mbNofx7U+Awr8gq++dUnAziYMAE/g2bIsrO0zr7ZViL7PWTnVbysPJthbA1laIdDtFCVACFThafz6++v9stdarWqL4VQOkVvh05qZSr0zk6l4qeR5BgcjGWwK61gKs2ZgMxA/sC55naR3kr7X5Rr6q7uYH6O3uh8KijNu4qdG9EKL3A7oTX1I154yvaGc0T8BcOI0lAwHOkWr1nQkmYO/TubHr8mQkyVElWjJcWAEcVZKtF+tOtVXTWBu+VIRVLaOfAROaHj4vB+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 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 value of the control, ``V4L2_CTRL_WHICH_DEF_VAL`` will return the default - value of the control and ``V4L2_CTRL_WHICH_REQUEST_VAL`` indicates that - these controls have to be retrieved from a request or tried/set for - a request. In the latter case the ``request_fd`` field contains the + value of the control, ``V4L2_CTRL_WHICH_MIN_VAL`` will return the minimum + value of the control, and ``V4L2_CTRL_WHICH_MAX_VAL`` will return the maximum + value of the control. ``V4L2_CTRL_WHICH_REQUEST_VAL`` indicates that + the control value has to be retrieved from a request or tried/set for + a request. In that case the ``request_fd`` field contains the file descriptor of the request that should be used. If the device does not support requests, then ``EACCES`` will be returned. - When using ``V4L2_CTRL_WHICH_DEF_VAL`` be aware that you can only - get the default value of the control, you cannot set or try it. + When using ``V4L2_CTRL_WHICH_DEF_VAL``, ``V4L2_CTRL_WHICH_MIN_VAL`` + or ``V4L2_CTRL_WHICH_MAX_VAL`` be aware that you can only get the + default/minimum/maximum value of the control, you cannot set or try it. + + Whether a control supports querying the minimum and maximum values using + ``V4L2_CTRL_WHICH_MIN_VAL`` and ``V4L2_CTRL_WHICH_MAX_VAL`` is indicated + by the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. Most non-compound + control types support this. For controls with compound types, the + definition of minimum/maximum values are provided by + the control documentation. If a compound control does not document the + meaning of minimum/maximum value, then querying the minimum or maximum + value will result in the error code -EINVAL. For backwards compatibility you can also use a control class here (see :ref:`ctrl-class`). In that case all controls have to diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 56d5c8b0b88b..3815732f6a9b 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -447,7 +447,10 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_rect`, containing a rectangle described by the position of its top-left corner, the width and the height. Units - depend on the use case. + depend on the use case. Support for ``V4L2_CTRL_WHICH_MIN_VAL`` and + ``V4L2_CTRL_WHICH_MAX_VAL`` is optional and depends on the + ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. See the documentation of + the specific control on how to interpret the minimum and maximum values. * - ``V4L2_CTRL_TYPE_H264_SPS`` - n/a - n/a @@ -664,6 +667,10 @@ See also the examples in :ref:`control`. ``dims[0]``. So setting the control with a differently sized array will change the ``elems`` field when the control is queried afterwards. + * - ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` + - 0x1000 + - This control supports getting minimum and maximum values using + vidioc_g_ext_ctrls with V4L2_CTRL_WHICH_MIN/MAX_VAL. Return Value ============ diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions index 3cf1380b52b0..35d3456cc812 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -396,6 +396,7 @@ replace define V4L2_CTRL_FLAG_HAS_PAYLOAD control-flags replace define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE control-flags replace define V4L2_CTRL_FLAG_MODIFY_LAYOUT control-flags replace define V4L2_CTRL_FLAG_DYNAMIC_ARRAY control-flags +replace define V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX control-flags replace define V4L2_CTRL_FLAG_NEXT_CTRL control replace define V4L2_CTRL_FLAG_NEXT_COMPOUND control @@ -570,6 +571,8 @@ ignore define V4L2_CTRL_DRIVER_PRIV ignore define V4L2_CTRL_MAX_DIMS ignore define V4L2_CTRL_WHICH_CUR_VAL ignore define V4L2_CTRL_WHICH_DEF_VAL +ignore define V4L2_CTRL_WHICH_MIN_VAL +ignore define V4L2_CTRL_WHICH_MAX_VAL ignore define V4L2_CTRL_WHICH_REQUEST_VAL ignore define V4L2_OUT_CAP_CUSTOM_TIMINGS ignore define V4L2_CID_MAX_CTRLS diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 4962cfe7c83d..b0439005ec71 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -774,7 +774,9 @@ static int imx214_ctrls_init(struct imx214 *imx214) imx214->unit_size = v4l2_ctrl_new_std_compound(ctrl_hdlr, NULL, V4L2_CID_UNIT_CELL_SIZE, - v4l2_ctrl_ptr_create((void *)&unit_size)); + v4l2_ctrl_ptr_create((void *)&unit_size), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &imx214_ctrl_ops, &props); diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index d9d2a293f3ef..7f370438d655 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -607,11 +607,16 @@ int venc_ctrl_init(struct venus_inst *inst) v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_COLORIMETRY_HDR10_CLL_INFO, - v4l2_ctrl_ptr_create(&p_hdr10_cll)); + v4l2_ctrl_ptr_create(&p_hdr10_cll), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY, - v4l2_ctrl_ptr_create((void *)&p_hdr10_mastering)); + v4l2_ctrl_ptr_create((void *)&p_hdr10_mastering), + v4l2_ctrl_ptr_create(NULL), + v4l2_ctrl_ptr_create(NULL)); + v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE, diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-core/v4l2-ctrls-api.c index e5a364efd5e6..d44fbad95c11 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-api.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c @@ -94,6 +94,22 @@ static int def_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) return ptr_to_user(c, ctrl, ctrl->p_new); } +/* Helper function: copy the minimum control value back to the caller */ +static int min_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) +{ + ctrl->type_ops->minimum(ctrl, 0, ctrl->p_new); + + return ptr_to_user(c, ctrl, ctrl->p_new); +} + +/* Helper function: copy the maximum control value back to the caller */ +static int max_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) +{ + ctrl->type_ops->maximum(ctrl, 0, ctrl->p_new); + + return ptr_to_user(c, ctrl, ctrl->p_new); +} + /* Helper function: copy the caller-provider value as the new control value */ static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) { @@ -229,8 +245,8 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, cs->error_idx = i; if (cs->which && - cs->which != V4L2_CTRL_WHICH_DEF_VAL && - cs->which != V4L2_CTRL_WHICH_REQUEST_VAL && + (cs->which < V4L2_CTRL_WHICH_DEF_VAL || + cs->which > V4L2_CTRL_WHICH_MAX_VAL) && V4L2_CTRL_ID2WHICH(id) != cs->which) { dprintk(vdev, "invalid which 0x%x or control id 0x%x\n", @@ -259,6 +275,15 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, return -EINVAL; } + if (!(ctrl->flags & V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX) && + (cs->which == V4L2_CTRL_WHICH_MIN_VAL || + cs->which == V4L2_CTRL_WHICH_MAX_VAL)) { + dprintk(vdev, + "invalid which 0x%x or control id 0x%x\n", + cs->which, id); + return -EINVAL; + } + if (ctrl->cluster[0]->ncontrols > 1) have_clusters = true; if (ctrl->cluster[0] != ctrl) @@ -368,8 +393,8 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, */ static int class_check(struct v4l2_ctrl_handler *hdl, u32 which) { - if (which == 0 || which == V4L2_CTRL_WHICH_DEF_VAL || - which == V4L2_CTRL_WHICH_REQUEST_VAL) + if (which == 0 || (which >= V4L2_CTRL_WHICH_DEF_VAL && + which <= V4L2_CTRL_WHICH_MAX_VAL)) return 0; return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL; } @@ -389,10 +414,12 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl, struct v4l2_ctrl_helper *helpers = helper; int ret; int i, j; - bool is_default, is_request; + bool is_default, is_request, is_min, is_max; is_default = (cs->which == V4L2_CTRL_WHICH_DEF_VAL); is_request = (cs->which == V4L2_CTRL_WHICH_REQUEST_VAL); + is_min = (cs->which == V4L2_CTRL_WHICH_MIN_VAL); + is_max = (cs->which == V4L2_CTRL_WHICH_MAX_VAL); cs->error_idx = cs->count; cs->which = V4L2_CTRL_ID2WHICH(cs->which); @@ -432,13 +459,14 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl, /* * g_volatile_ctrl will update the new control values. - * This makes no sense for V4L2_CTRL_WHICH_DEF_VAL and + * This makes no sense for V4L2_CTRL_WHICH_DEF_VAL, + * V4L2_CTRL_WHICH_MIN_VAL, V4L2_CTRL_WHICH_MAX_VAL and * V4L2_CTRL_WHICH_REQUEST_VAL. In the case of requests * it is v4l2_ctrl_request_complete() that copies the * volatile controls at the time of request completion * to the request, so you don't want to do that again. */ - if (!is_default && !is_request && + if (!is_default && !is_request && !is_min && !is_max && ((master->flags & V4L2_CTRL_FLAG_VOLATILE) || (master->has_volatiles && !is_cur_manual(master)))) { for (j = 0; j < master->ncontrols; j++) @@ -467,6 +495,10 @@ int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl, ret = -ENOMEM; else if (is_request && ref->p_req_valid) ret = req_to_user(cs->controls + idx, ref); + else if (is_min) + ret = min_to_user(cs->controls + idx, ref->ctrl); + else if (is_max) + ret = max_to_user(cs->controls + idx, ref->ctrl); else if (is_volatile) ret = new_to_user(cs->controls + idx, ref->ctrl); else @@ -564,9 +596,11 @@ int try_set_ext_ctrls_common(struct v4l2_fh *fh, cs->error_idx = cs->count; - /* Default value cannot be changed */ - if (cs->which == V4L2_CTRL_WHICH_DEF_VAL) { - dprintk(vdev, "%s: cannot change default value\n", + /* Default/minimum/maximum values cannot be changed */ + if (cs->which == V4L2_CTRL_WHICH_DEF_VAL || + cs->which == V4L2_CTRL_WHICH_MIN_VAL || + cs->which == V4L2_CTRL_WHICH_MAX_VAL) { + dprintk(vdev, "%s: cannot change default/min/max value\n", video_device_node_name(vdev)); return -EINVAL; } diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index 4c8744c8cd96..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, } } -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 = ptr.p + idx * ctrl->elem_size; + + if (ctrl->p_min.p_const) + memcpy(p, ctrl->p_min.p_const, ctrl->elem_size); + else + memset(p, 0, ctrl->elem_size); +} + +static void std_max_compound(const struct v4l2_ctrl *ctrl, u32 idx, union v4l2_ctrl_ptr ptr) +{ + void *p = ptr.p + idx * ctrl->elem_size; + + if (ctrl->p_max.p_const) + memcpy(p, ctrl->p_max.p_const, ctrl->elem_size); + else + memset(p, 0, ctrl->elem_size); +} + +static void __v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, + u32 which, union v4l2_ctrl_ptr ptr) { unsigned int i; u32 tot_elems = ctrl->elems; u32 elems = tot_elems - from_idx; + s64 value; - if (from_idx >= tot_elems) + switch (which) { + case V4L2_CTRL_WHICH_DEF_VAL: + value = ctrl->default_value; + break; + case V4L2_CTRL_WHICH_MAX_VAL: + value = ctrl->maximum; + break; + case V4L2_CTRL_WHICH_MIN_VAL: + value = ctrl->minimum; + break; + default: return; + } switch (ctrl->type) { case V4L2_CTRL_TYPE_STRING: + if (which == V4L2_CTRL_WHICH_DEF_VAL) + value = ctrl->minimum; + for (i = from_idx; i < tot_elems; i++) { unsigned int offset = i * ctrl->elem_size; - memset(ptr.p_char + offset, ' ', ctrl->minimum); - ptr.p_char[offset + ctrl->minimum] = '\0'; + memset(ptr.p_char + offset, ' ', value); + ptr.p_char[offset + value] = '\0'; } break; case V4L2_CTRL_TYPE_INTEGER64: - if (ctrl->default_value) { + if (value) { for (i = from_idx; i < tot_elems; i++) - ptr.p_s64[i] = ctrl->default_value; + ptr.p_s64[i] = value; } else { memset(ptr.p_s64 + from_idx, 0, elems * sizeof(s64)); } @@ -214,9 +249,9 @@ void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, case V4L2_CTRL_TYPE_MENU: case V4L2_CTRL_TYPE_BITMASK: case V4L2_CTRL_TYPE_BOOLEAN: - if (ctrl->default_value) { + if (value) { for (i = from_idx; i < tot_elems; i++) - ptr.p_s32[i] = ctrl->default_value; + ptr.p_s32[i] = value; } else { memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); } @@ -226,32 +261,63 @@ void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32)); break; case V4L2_CTRL_TYPE_U8: - memset(ptr.p_u8 + from_idx, ctrl->default_value, elems); + memset(ptr.p_u8 + from_idx, value, elems); break; case V4L2_CTRL_TYPE_U16: - if (ctrl->default_value) { + if (value) { for (i = from_idx; i < tot_elems; i++) - ptr.p_u16[i] = ctrl->default_value; + ptr.p_u16[i] = value; } else { memset(ptr.p_u16 + from_idx, 0, elems * sizeof(u16)); } break; case V4L2_CTRL_TYPE_U32: - if (ctrl->default_value) { + if (value) { for (i = from_idx; i < tot_elems; i++) - ptr.p_u32[i] = ctrl->default_value; + ptr.p_u32[i] = value; } else { memset(ptr.p_u32 + from_idx, 0, elems * sizeof(u32)); } break; default: - for (i = from_idx; i < tot_elems; i++) - std_init_compound(ctrl, i, ptr); + for (i = from_idx; i < tot_elems; i++) { + switch (which) { + case V4L2_CTRL_WHICH_DEF_VAL: + std_init_compound(ctrl, i, ptr); + break; + case V4L2_CTRL_WHICH_MAX_VAL: + std_max_compound(ctrl, i, ptr); + break; + case V4L2_CTRL_WHICH_MIN_VAL: + std_min_compound(ctrl, i, ptr); + break; + } + } break; } } + +void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr) +{ + __v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_DEF_VAL, ptr); +} EXPORT_SYMBOL(v4l2_ctrl_type_op_init); +void v4l2_ctrl_type_op_minimum(const struct v4l2_ctrl *ctrl, u32 from_idx, + union v4l2_ctrl_ptr ptr) +{ + __v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MIN_VAL, ptr); +} +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 = ctrl->p_cur; @@ -1296,6 +1362,8 @@ EXPORT_SYMBOL(v4l2_ctrl_type_op_validate); static const struct v4l2_ctrl_type_ops std_type_ops = { .equal = v4l2_ctrl_type_op_equal, .init = v4l2_ctrl_type_op_init, + .minimum = v4l2_ctrl_type_op_minimum, + .maximum = v4l2_ctrl_type_op_maximum, .log = v4l2_ctrl_type_op_log, .validate = v4l2_ctrl_type_op_validate, }; @@ -1768,7 +1836,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, s64 min, s64 max, u64 step, s64 def, const u32 dims[V4L2_CTRL_MAX_DIMS], u32 elem_size, u32 flags, const char * const *qmenu, - const s64 *qmenu_int, const union v4l2_ctrl_ptr p_def, + const s64 *qmenu_int, + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max, void *priv) { struct v4l2_ctrl *ctrl; @@ -1892,6 +1963,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, break; } + if (type < V4L2_CTRL_COMPOUND_TYPES && + type != V4L2_CTRL_TYPE_BUTTON && + type != V4L2_CTRL_TYPE_CTRL_CLASS && + type != V4L2_CTRL_TYPE_STRING) + flags |= V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX; + /* Sanity checks */ if (id == 0 || name == NULL || !elem_size || id >= V4L2_CID_PRIVATE_BASE || @@ -1900,6 +1977,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, handler_set_err(hdl, -ERANGE); return NULL; } + err = check_range(type, min, max, step, def); if (err) { handler_set_err(hdl, err); @@ -1941,6 +2019,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p_const) sz_extra += elem_size; + if (type >= V4L2_CTRL_COMPOUND_TYPES && p_min.p_const) + sz_extra += elem_size; + if (type >= V4L2_CTRL_COMPOUND_TYPES && p_max.p_const) + sz_extra += elem_size; ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); if (ctrl == NULL) { @@ -2006,6 +2088,22 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, memcpy(ctrl->p_def.p, p_def.p_const, elem_size); } + if (flags & V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX) { + void *ptr = ctrl->p_def.p; + + if (p_min.p_const) { + ptr += elem_size; + ctrl->p_min.p = ptr; + memcpy(ctrl->p_min.p, p_min.p_const, elem_size); + } + + if (p_max.p_const) { + ptr += elem_size; + ctrl->p_max.p = ptr; + memcpy(ctrl->p_max.p, p_max.p_const, elem_size); + } + } + ctrl->type_ops->init(ctrl, 0, ctrl->p_cur); cur_to_new(ctrl); @@ -2056,7 +2154,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, type, min, max, is_menu ? cfg->menu_skip_mask : step, def, cfg->dims, cfg->elem_size, - flags, qmenu, qmenu_int, cfg->p_def, priv); + flags, qmenu, qmenu_int, cfg->p_def, cfg->p_min, + cfg->p_max, priv); if (ctrl) ctrl->is_private = cfg->is_private; return ctrl; @@ -2081,7 +2180,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, min, max, step, def, NULL, 0, - flags, NULL, NULL, ptr_null, NULL); + flags, NULL, NULL, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std); @@ -2114,7 +2214,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, mask, def, NULL, 0, - flags, qmenu, qmenu_int, ptr_null, NULL); + flags, qmenu, qmenu_int, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); @@ -2146,7 +2247,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, mask, def, NULL, 0, - flags, qmenu, NULL, ptr_null, NULL); + flags, qmenu, NULL, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); @@ -2154,7 +2256,9 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); /* Helper function for standard compound controls */ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, - const union v4l2_ctrl_ptr p_def) + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max) { const char *name; enum v4l2_ctrl_type type; @@ -2168,7 +2272,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, min, max, step, def, NULL, 0, - flags, NULL, NULL, p_def, NULL); + flags, NULL, NULL, p_def, p_min, p_max, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_std_compound); @@ -2192,7 +2296,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, } return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, 0, max, 0, def, NULL, 0, - flags, NULL, qmenu_int, ptr_null, NULL); + flags, NULL, qmenu_int, ptr_null, ptr_null, + ptr_null, NULL); } EXPORT_SYMBOL(v4l2_ctrl_new_int_menu); diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index b9a3c6b20282..77d999380c2d 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -893,7 +893,9 @@ static bool check_ext_ctrls(struct v4l2_ext_controls *c, unsigned long ioctl) return false; break; case V4L2_CTRL_WHICH_DEF_VAL: - /* Default value cannot be changed */ + case V4L2_CTRL_WHICH_MIN_VAL: + case V4L2_CTRL_WHICH_MAX_VAL: + /* Default, minimum or maximum value cannot be changed */ if (ioctl == VIDIOC_S_EXT_CTRLS || ioctl == VIDIOC_TRY_EXT_CTRLS) { c->error_idx = c->count; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index b0db167a3ac4..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->elems. + * @minimum: set the value to the minimum value of the control. + * @maximum: set the value to the maximum value of the control. * @log: log the value. * @validate: validate the value for ctrl->new_elems array elements. * Return 0 on success and a negative value otherwise. @@ -142,6 +144,10 @@ struct v4l2_ctrl_type_ops { union v4l2_ctrl_ptr ptr1, union v4l2_ctrl_ptr ptr2); void (*init)(const struct v4l2_ctrl *ctrl, u32 from_idx, union v4l2_ctrl_ptr ptr); + void (*minimum)(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr); + void (*maximum)(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr); void (*log)(const struct v4l2_ctrl *ctrl); int (*validate)(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr ptr); }; @@ -247,6 +253,12 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); * @p_def: The control's default value represented via a union which * provides a standard way of accessing control types * through a pointer (for compound controls only). + * @p_min: The control's minimum value represented via a union which + * provides a standard way of accessing control types + * through a pointer (for compound controls only). + * @p_max: The control's maximum value represented via a union which + * provides a standard way of accessing control types + * through a pointer (for compound controls only). * @p_cur: The control's current value represented via a union which * provides a standard way of accessing control types * through a pointer. @@ -306,6 +318,8 @@ struct v4l2_ctrl { } cur; union v4l2_ctrl_ptr p_def; + union v4l2_ctrl_ptr p_min; + union v4l2_ctrl_ptr p_max; union v4l2_ctrl_ptr p_new; union v4l2_ctrl_ptr p_cur; }; @@ -425,6 +439,8 @@ struct v4l2_ctrl_handler { * @step: The control's step value for non-menu controls. * @def: The control's default value. * @p_def: The control's default value for compound controls. + * @p_min: The control's minimum value for compound controls. + * @p_max: The control's maximum value for compound controls. * @dims: The size of each dimension. * @elem_size: The size in bytes of the control. * @flags: The control's flags. @@ -454,6 +470,8 @@ struct v4l2_ctrl_config { u64 step; s64 def; union v4l2_ctrl_ptr p_def; + union v4l2_ctrl_ptr p_min; + union v4l2_ctrl_ptr p_max; u32 dims[V4L2_CTRL_MAX_DIMS]; u32 elem_size; u32 flags; @@ -723,17 +741,25 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, * @ops: The control ops. * @id: The control ID. * @p_def: The control's default value. + * @p_min: The control's minimum value. + * @p_max: The control's maximum value. * - * Sames as v4l2_ctrl_new_std(), but with support to compound controls, thanks - * to the @p_def field. Use v4l2_ctrl_ptr_create() to create @p_def from a - * pointer. Use v4l2_ctrl_ptr_create(NULL) if the default value of the - * compound control should be all zeroes. + * Same as v4l2_ctrl_new_std(), but with support for compound controls. + * To fill in the @p_def, @p_min and @p_max fields, use v4l2_ctrl_ptr_create() + * to convert a pointer to a const union v4l2_ctrl_ptr. + * Use v4l2_ctrl_ptr_create(NULL) if you want the default, minimum or maximum + * value of the compound control to be all zeroes. + * If the compound control does not set the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` + * flag, then it does not has minimum and maximum values. In that case just use + * v4l2_ctrl_ptr_create(NULL) for the @p_min and @p_max arguments. * */ struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops, u32 id, - const union v4l2_ctrl_ptr p_def); + const union v4l2_ctrl_ptr p_def, + const union v4l2_ctrl_ptr p_min, + const union v4l2_ctrl_ptr p_max); /** * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. @@ -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); +/** + * 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 enum v4l2_ctrl_type { V4L2_CTRL_TYPE_INTEGER = 1, @@ -2017,6 +2019,7 @@ struct v4l2_querymenu { #define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200 #define V4L2_CTRL_FLAG_MODIFY_LAYOUT 0x0400 #define V4L2_CTRL_FLAG_DYNAMIC_ARRAY 0x0800 +#define V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX 0x1000 /* Query flags, to be ORed with the control ID */ #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 From patchwork Fri Oct 18 05:44:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13841125 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> 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-media@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: XZmCUXNElnq2KcGEzWTSuaYX74kZKS3IqYfGomtTqSHQozgFhZJR4BDrIf578xOmtYBNWHW0MMud3sNDBzpFnHqoY6OTMlmKDnCxMZvWmXTUU6q3AjM86LL9KxHpfjFKAfWRy+8jti/0ZDxxiuT5FwsPuql+Yr/vVuwBCDsdv8dy8J1drkl6I1mUloXNywMkGj1fR9NFxpMMJvxkAEj+J1jHJ2NWMvJeeiuq231qmr+2sLeETvLRNJcO3aNlVn8GBXoyORe52rnulLcKR7bmqjhzQ8MO4HZfCRQ4g9HVEybEt5l8sKO9DUolmXUHcaDdTNu9/2V1RD/BvyGEV3x+bTXNZIU9cpjMhyz/R1AnFjDKPaO6gc+kYNkd4Xdtc4+6dN44ApIwfbNTPenhkEw3r94o1s+b6q7lZgEWUkQAIpCurMa2J4oDvMW6UoSergbl3Q/iLKDG10eb6XOmMeTf6h+CzWr/YJQWWgKB4fZUFZasgyebLdgkwUvYXBA9zDeylyWYMzl9Z085zK7jkXmYC/xUcBNjXmSDvZHIfR3oe8mfcYxYdyUXP4KQqTypMgPX3z9SbLuBZo2wU8mMmgyYjTvMs2NdZ1WXhBVgHQl7JT0PvLAMnnCtrasHfp3XDO5eu8QhaDk0SSI4Z1veLj/UmAL6qHnf6Bv1e1r8pgjVdKFzr589TZ0ZvrZLRd/5gopK6dvDcH2kfVOfBQYLOloCZT3JOLphJGwEGAbFbBqDGmNQb1QCENjaqM/upYJQcum5VbXbjh0UDkPoDa0fZsH3cn6dGz6uVwe4F9bEMouPoNgUts9J/LGxblFtAowuSID3hUSpGIzZm3qbmxA7ZwtYqV/nqmyoMsorrIap3OVGxQD4w3PDrLM/FIC2jDjiamApFb9jwm+cCjmD//BP4BYdjB4J9uN3L2kNc6PFqQDRJcqrCycsf3aT4MJnPbN22EB0p79sTZ35m/NlTrcaWNQlLoF9rPrk6HXJmKB8ig1i98/RWEeCbkZHQ2QxW8aJ2CU6b0/Uug0UeMwcWWFCQ7l/oRtziR44FgRmxsvrCarhA1wb4XQ/LwKPuwIkMGdJCOGEdYzL5/yPmzfAj3al2bbaX/r8/11O7VPWnCmls8UBH+01tTIJPII5JTz5Z7rmAaS69dHyhRTDJecSNK49d/k4KmjnoXApDqSsKfwbv986y/yVe+F5bw2HwDQWBMxr26khp2gBZTtVOFLUs7Lqgco/CHenCEVlTUY+Ac8BlzjTibi2sHxKOm4sU9S4QI8ZHfAhANIzZ+deBCgxKH648U2YLI8VfDywX+CNeOGt5EfmYARfkJJFaQsaX/Dr6iu+zmSMMyW5LX0bgum966H2ZL9E67mSd0UmGSoVGuUHkAANwj4= 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: O8lAHFBhqCNKmOrJCkxLJSdWLZfNVh72/Lpz9Kk5C8DjMHUaeTzK2Wcx1U6KDXZucYhWgisYArEN4fBJRlJtOk1FQX+uGP+lWpZoPMglB2HHwNbyZ4e1Gb+rUkpkoMebT7KmgHHkWqzTpwd7s2D06rD798/LKd9rEOQYP68zYkBRXK7yBjcvSeY4ZBg5aPN3K/zMRRlUkigXQqAtA24p2/RUo9bGpJd8FZmKuA1VFVixX0dqGciuA40eIKl86YcCiVHs4ET8iykaWoa/f8r61vcTU8weRuONhAGJ1roiFRBHqL0i/yJT7WlgINxMhc3n2GNIHOGbDZPDzk3UH70NoGw2aPk2Y/VXssZaibQlf2lFnRHfe5RE9xQjA6nf4zVPooVsQxPBN7ld5C3uSQnt+eoVgAnZfhK7JDmrasEz96F1uYNAOgJVPiofjjD5JeBEXj1ogXiwxANav4qw3XjxouKyvwub6M75fA4LnYf1nWnLNyv6z3nOqoHsZ517Ap9rW00U1iTok2Qz6W0GYp2qKks07uhsEuVHSpT6lrKE4uSSI9ppn1Vs2x0/Zdi05AxrXJ08Ybheo5HlvKJXoD1/GqMmFPJ12yQweWTsUZDn6tin+GEQgVOjQnXwNyLc3pDEhmpiCrHfJNJRKtI2er5Rbjjgq5+3To8nbwd3zpHkGNAcDhW0fxE48hWIEL/XnqJn6m1fkYjdiGxNlrIQUE0hhZPVAR3gvFZq0L02jEHWrerevlrgltO0YUqp1AjXyxr4++tk5R+cS4A9KYS4HEa3usNbMvd9fEGjyNBR3A5AiGk8mo2RMFszzCIe1zlFXZahu13xYn7Xyd6dRHmPj6dRWJffUiqVC5eWQ2V6m87qbEWBUUX4tnbV6+XZ345xhZyU/A435SOd4J33akJkzWLlMIc8JJ29IqtB9h8KyESTRZgjeApozg4vHi7weRWBNdaXC72rFbxBvzorArQoO5LatiUUd1Q8fhPVdQjqh5xlBwau7L5zcrBcXdNrDHCbNjKChJnyo2t2onXL1oedloT+6BQ2BXmzxQtoXHShmER+vLKuX9YnvKYv3iHvoOWFc6Pwhn6j16KVQpx24OOZvO4v7TNdXVwsF1VAJfJU2C0IicunONSw1s1fXGupGmDVvK6A3vX7QWmOGFonqmtnWYNcfoxT02hbgm6DPGuXxNYw5x5AREAtYQD+nA/HzcGHZFJ9Wqg4ctoXGyblkkFTWx9DhTJ/aKsKfJHaCU9JbO9k7O1rIMmTj/AAJGICJACx5YBaXKIniLRxG8TUmCI93dVgkR5AKSVO6XOu8jFVCw9RP0OLWrv/uuVySdCeU24boePI0+Q5q5VRp8m46XW8GgobutBoqUnuadzUIEjIg0QzKk3wOPvsACjxCXduKR6q3YbH/ObbynK8G8kqyTpDBFGLkvTPCjPbcBcm9NxKTwnhBFwGJuZlJE+pv2B3Aj782BvrVa+fNHjjKroVJIcqw4P0GD8do4n6pHw37iAvFcsRK3EoN1oOsMDz7CbcM433pnw5mWDMilDNgXbttsMVAAk4+tlXTB1p8VXn9irsp0ZnVshSQgldy75cTBX64FdabNFR 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 Add p_region to struct v4l2_ext_control with basic support in v4l2-ctrls. Signed-off-by: Ming Qian Signed-off-by: TaoJiang --- .../userspace-api/media/v4l/vidioc-g-ext-ctrls.rst | 4 ++++ .../userspace-api/media/v4l/vidioc-queryctrl.rst | 12 ++++++++++++ .../userspace-api/media/videodev2.h.rst.exceptions | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 14 +++++++++++++- include/media/v4l2-ctrls.h | 2 ++ include/uapi/linux/videodev2.h | 8 ++++++++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst index b8698b85bd80..f00c6d1f7784 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst @@ -203,6 +203,10 @@ still cause this situation. - ``p_rect`` - A pointer to a struct :c:type:`v4l2_rect`. Valid if this control is of type ``V4L2_CTRL_TYPE_RECT``. + * - struct :c:type:`v4l2_ctrl_video_region_param` * + - ``p_region`` + - A pointer to a struct :c:type:`v4l2_ctrl_video_region_param`. Valid if + this control is of type ``V4L2_CTRL_TYPE_REGION``. * - struct :c:type:`v4l2_ctrl_h264_sps` * - ``p_h264_sps`` - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this control is diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst index 3815732f6a9b..df3cd36b67ab 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst @@ -451,6 +451,18 @@ See also the examples in :ref:`control`. ``V4L2_CTRL_WHICH_MAX_VAL`` is optional and depends on the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. See the documentation of the specific control on how to interpret the minimum and maximum values. + * - ``V4L2_CTRL_TYPE_REGION`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_video_region_param`, containing a rectangle + described by the position of its top-left corner, the width and the height. + And a parameter for detailed purpose, for example, it's QP offset for video + encoder ROI. Units depend on the use case. Support for + ``V4L2_CTRL_WHICH_MIN_VAL`` and ``V4L2_CTRL_WHICH_MAX_VAL`` is optional and + depends on the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. See the + documentation of the specific control on how to interpret the minimum and + maximum values. * - ``V4L2_CTRL_TYPE_H264_SPS`` - n/a - n/a diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions index 35d3456cc812..22307e029883 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -151,6 +151,7 @@ replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_RECT :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_REGION :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR :c:type:`v4l2_ctrl_type` diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index 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 *ctrl) ptr.p_rect->width, ptr.p_rect->height, ptr.p_rect->left, ptr.p_rect->top); break; + case V4L2_CTRL_TYPE_REGION: + pr_cont("%ux%u@%dx%d, %d", + ptr.p_rect->width, ptr.p_rect->height, + ptr.p_rect->left, ptr.p_rect->top, ptr.p_region->parameter); + break; default: pr_cont("unknown type %d", ctrl->type); break; @@ -886,6 +891,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params; struct v4l2_area *area; struct v4l2_rect *rect; + struct v4l2_ctrl_video_region_param *p_region; void *p = ptr.p + idx * ctrl->elem_size; unsigned int i; @@ -1248,7 +1254,10 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, if (!rect->width || !rect->height) return -EINVAL; break; - + case V4L2_CTRL_TYPE_REGION: + p_region = p; + zero_reserved(*p_region); + break; default: return -EINVAL; } @@ -1957,6 +1966,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_RECT: elem_size = sizeof(struct v4l2_rect); break; + case V4L2_CTRL_TYPE_REGION: + elem_size = sizeof(struct v4l2_ctrl_video_region_param); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size = sizeof(s32); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 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; }; +struct v4l2_ctrl_video_region_param { + struct v4l2_rect rect; + __s32 parameter; + __u32 reserved[2]; +}; + /** * struct v4l2_capability - Describes V4L2 device caps returned by VIDIOC_QUERYCAP * @@ -1858,6 +1864,7 @@ struct v4l2_ext_control { __s64 __user *p_s64; struct v4l2_area __user *p_area; struct v4l2_rect __user *p_rect; + struct v4l2_ctrl_video_region_param __user *p_region; struct v4l2_ctrl_h264_sps __user *p_h264_sps; struct v4l2_ctrl_h264_pps __user *p_h264_pps; struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix; @@ -1931,6 +1938,7 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_U32 = 0x0102, V4L2_CTRL_TYPE_AREA = 0x0106, V4L2_CTRL_TYPE_RECT = 0x0107, + V4L2_CTRL_TYPE_REGION = 0x0108, V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110, V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111, From patchwork Fri Oct 18 05:44:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13841126 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> 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-media@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: yd+j6T8AgtU4unf1knDDwUiH3JLGXoaGS33UiLIzGGRUmYaMAZk46KqOKvTpenLRl2qvEW+6lC9zJDltJ1aXl+yYu86NeLQK8jMdNG0t0Mf613rHGk1CMFQOS99J4IvTp1bG2VACQdaSyXX8Zydbr1BCfoA6oVJeFKTdVZOx0tpyT7DKkLMx8lwdgxw7zwPpKtjgX836qWtty9FuackE8/b5QtW706oaJWecg0yL1YAL7Tr6U/XZruPtLFK6Xq41boXsYb78sIwyBFaesFzxoA9bw0KBoz5/HG7g72CcPtYqIIoHHQA40dVIfsGMgJPS3XJrAbgMR+ngY9tc2uIXnoViKlTz2UOCdD2NmqE1Hjunk8x3iyVEqlTocgR7J5ZB3m0dN6av7PJdkyct+Mu+iDHxN6M1Ij8c5/aW2LHczsZ9oH4rUUlTHaK6DWJ7MjidFKOkjD5czZX1WF5Xd/06Rs1bRdGqARyjVx6yvWuxx0EeShu/OgTwUOo+tmr3HHX2qFihBaNW08X5HA6G1qECnIAJd8kWERhN0XT0F12X4pLZUIIiy4PV9i94hG+Bgdlme0a37kCckPcgGH4mu9jwhcALdN7tHxDVGRto30/XTywfv2mxiTLlLe09MAfuv9ug9ypjZa6n0HoRTT64OWJDLVyAGARxLe4PZpY656oL2DJjFIaBA/Ms0gsCXSrdRLNoDfTzF+c/ygpylhFoDeOxqtRhOXX7lHkNfji52mnH1UusHlgnL/ZdD61eUjlfazZuMCSFuCxH+jrrXPyaU/H8Y3T5r2nmyYXybQlVVZ1DwnWkuHd+hGHXYfT9iupcbaOlmGCOK2NBU5HN8HTRGV4xfkbAj8KmOc4AJZHP1kWz7OaNOWGZb7ojWwIJP8nfuvxlxGOjw42zsre/eEwAKQppSZDycQNxyVHakruXkJFscyUz9zB02oreGkPfRyb/i8qleqXBthT5t3OmRwFWhvCRvdu7Zd8sIG9AZenhBuGxqOZqmmNyZ2v7FR0++DwP15rlJn1G7Ghjc0CORFlWfUNmQETUCzhWiVeda0AYpidBtF8/gZbyXbQY9LmmSxllD/+MsCDzRuUqDdo22xY14t9p8WXdsdkur+Oxd8j9qnbdlnYXvxmLoi0EVnsQTFBqZJEJ+IR3YieV1xkPtqw8FstPEP1FnHUe5HI0j+gcBxAQ42/6ng1gelR6kDaww25vt5fZBO87kZI7KGox64iFJmnu5Kx1g+1/gQ755CfwlgBfHncdT5YiNXS5C/rAYWl55hiB61F/OU+/CFISsAS+AF4zGKbw3Z06t4GKNQQTxI5O/TOkNJrqpvdjo8E6VJQwvZtnKSlQJcYXm+PFnZpv3bRJxlhrvRMGRe/q1BAr6sjAeEo= 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: MuuB43tEzOYh+2Y8LE9zDBiotfwcVICfZMXFJzG6PFNjKvFXO6vqemxcxbAjmcX183j5mL7GvNHH9cLuhnnYlQvUyb+3AwG6Pym7uBac2l0ASperOzeRNGr+lGngX5K5pJA0EZXf1CPi2vDUjTyr7DzGJqS1YYVQ22RzEVyKuQcLgYgyx63fjA96T4P1VJB8uqjNk3zGl6YwutYh3a2sFKiWrH1wpNG3ot4kFbFYi4mvjVdEQ+q5Fr9w+mZDWh3I+W9kt1EFK1eyNHDTgd6Hj3UN9eAJ+4nAgRQGed0PFaAx5KaNOwyN/Aa5VbYjZ0pmZWxMkiWXIUiRoGtb4ghWLwpAMFTKopNBnPQ2p8ubxNQHxNi1HOb1uJ8g8etNZ2b4/asymDbpjZfdpx7pyrcPIj1sVB1FqXGA9u6iAooapVSICZfOrjJlf1gjVUFh8LTC090UmK9QEb1Fw0uni32b/QzzaIKRE1nPDPakTCE+cNC74oSnG+43dXe31WnAe9IDmAEIt+T/FrX+a9kaw8oetygD+Qv/N19GTF2Hsjop67XdR89EZNkvyN2lmyUWweJAtppCpWch7C150eGL58DUvXWbiKuBVg3ZWLqeoAPQKNdAsR+V3k3gmJOkrqaqaufQ/wVi2O9jvXAT3hAvQGN6ZJ+oskrEu//6dv3akwrPRVh/ChEPnkCiSQCeuqpIpADThGxzc0tPgJgTuciNKyeIzZBOWS4B+5xLlkE7L6l03wBMynrgzYFzCdjl1NFPvGz0qcBBX96idMNRCc8fPJ50W4kzM8aMLTWDCx/shtKyklqCopmn57ANmNAtAN3Pck3DGm4YeAu1wTteIZthJXL8ZZCZDas66keJx91GN3ysIwrc2MCyjj1ysZlojstDCSJUPhhgmxaPG4l2f8bk0Gu0v3su94yixFekSqk/Zq+u+t60S6rVFP0sk8EsMwn7yvXO14yk5cd1QTful4lN1sk82LbFgg4AvWe5rWoo5sO/+o7wBmP6i8ixIzn9Pon6Q+HyDEFd4o9mCbEZAoCrF+wubl65R31tpB7gLUnNof4CHxFTTZWVSLdXBnh8oT7Vw2pjELJhmxFEzpdgdgryuYGl7YOIXambOtvlzmwp1u+F3O5bN74S9j1iCqhjaxacMZU/eHpRo/PG4jNcaor5CuqltIzeRbx7b2RjRw7sohAipfauAvWyITgY+nNKO3r04SjQ5oruz3FqNdOrumR/lGzCE2YwgzzuuuNrAY8XtwZ02BjJRGJuJRiVTZJDunFwAevhbOdEdUAS6ztqxRO35ClBYqCFzcEX1wJOi6CG3jILNPhZiqXGAV/tDC2axH1fhyc3MTCxLeyE/itNtBWehrjrFRVRtzKFeqrJFnteveMSF70PSh5o9/O1PsgqjlBr2BmLqLQDa92v1dnKIjvYwd/wMj5/SEU9TNF++v1AN4j0iQIkSYQsYHIJAOpA51UYoqH9ul1kdPbp+CPf3ujH4Aaqbrh59U2ZdJQLzf3C+MudnVw4cU6/I5l0NOYjHPOb/enpxrVHCnp//2JHf8y4PBs6a3EZDaapqedkKYypvtV00GPfheNQTvbTAixinBAPrfEd 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 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/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 4a379bd9e3fb..6b972247778c 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1667,6 +1667,79 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - Codecs need to always use the specified range, rather then a HW custom range. Applicable to encoders +``V4L2_CID_MPEG_VIDEO_ROI_MODE`` + (enum) + +enum v4l2_mpeg_video_roi_mode - + Video roi mode. Possible values are: + + + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - ``V4L2_MPEG_VIDEO_ROI_MODE_NONE`` + - No ROI in the MPEG stream + * - ``V4L2_MPEG_VIDEO_ROI_MODE_RECT`` + - Rectangle ROI mode + * - ``V4L2_MPEG_VIDEO_ROI_MODE_MAP`` + - Map ROI mode + +``V4L2_CID_MPEG_VIDEO_ROI_RECT (struct)`` + Select rectangular regions and specify the QP offset. The + struct :c:type:`v4l2_ctrl_video_region_param` provides the + rectangular region and the parameter to describe QP offset. + The maximum number of rectangular regions depends on the + hardware. This control is a dynamically sized array. This + control is applicable when ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` + value is ``V4L2_MPEG_VIDEO_ROI_MODE_RECT``. Applicable to + encoders. + +.. c:type:: v4l2_ctrl_video_region_param + +.. raw:: latex + + \small + +.. tabularcolumns:: |p{4.0cm}|p{4.0cm}|p{4.0cm}| + +.. flat-table:: struct v4l2_ctrl_video_region_param + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 1 + + * - struct :c:type:`v4l2_rect` + - ``rect`` + - The rectangular region + * - __s32 + - ``parameter`` + - + * - __u32 + - ``reserved[2]`` + - + +.. raw:: latex + + \normalsize + +``V4L2_CID_MPEG_VIDEO_ROI_MAP (integer)`` + Specifies the QP offset for each block. This control is a + dynamically sized array. The array size can be calculated + from video resolution and the roi map block size which can + be got from ``V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE``. This + control is applicable when ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` + value is ``V4L2_MPEG_VIDEO_ROI_MODE_MAP``. Applicable to + encoders. + +``V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE (struct)`` + This control returns the roi block size in pixels. The struct + :c:type:`v4l2_area` provides the width and height in separate + fields. This control is applicable when + ``V4L2_CID_MPEG_VIDEO_ROI_MODE`` value is + ``V4L2_MPEG_VIDEO_ROI_MODE_MAP``. This control depends on the + encoding format. Applicable to encoders. + .. raw:: latex \normalsize diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 1ea52011247a..54219a3b215a 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -612,6 +612,13 @@ const char * const *v4l2_ctrl_get_menu(u32 id) NULL, }; + static const char * const mpeg_video_roi_mode[] = { + "None", + "Rectangle", + "Map", + NULL, + }; + switch (id) { case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: return mpeg_audio_sampling_freq; @@ -750,6 +757,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id) return camera_orientation; case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE: return intra_refresh_period_type; + case V4L2_CID_MPEG_VIDEO_ROI_MODE: + return mpeg_video_roi_mode; default: return NULL; } @@ -971,6 +980,10 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX: return "Frame LTR Index"; case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES: return "Use LTR Frames"; case V4L2_CID_MPEG_VIDEO_AVERAGE_QP: return "Average QP Value"; + case V4L2_CID_MPEG_VIDEO_ROI_MODE: return "Video ROI Mode"; + case V4L2_CID_MPEG_VIDEO_ROI_RECT: return "Video ROI Rectangle"; + case V4L2_CID_MPEG_VIDEO_ROI_MAP: return "Video ROI Map"; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE: return "Video ROI Map Block Size"; case V4L2_CID_FWHT_I_FRAME_QP: return "FWHT I-Frame QP Value"; case V4L2_CID_FWHT_P_FRAME_QP: return "FWHT P-Frame QP Value"; @@ -1512,6 +1525,22 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *type = V4L2_CTRL_TYPE_INTEGER; *flags |= V4L2_CTRL_FLAG_READ_ONLY; break; + case V4L2_CID_MPEG_VIDEO_ROI_MODE: + *type = V4L2_CTRL_TYPE_MENU; + *flags |= V4L2_CTRL_FLAG_UPDATE; + break; + case V4L2_CID_MPEG_VIDEO_ROI_RECT: + *type = V4L2_CTRL_TYPE_REGION; + *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_MAP: + *type = V4L2_CTRL_TYPE_INTEGER; + *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY | V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX; + break; + case V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE: + *type = V4L2_CTRL_TYPE_AREA; + *flags |= V4L2_CTRL_FLAG_READ_ONLY; + break; case V4L2_CID_PIXEL_RATE: *type = V4L2_CTRL_TYPE_INTEGER64; *flags |= V4L2_CTRL_FLAG_READ_ONLY; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 974fd254e573..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 { #define V4L2_CID_MPEG_VIDEO_AVERAGE_QP (V4L2_CID_CODEC_BASE + 657) +enum v4l2_mpeg_video_roi_mode { + V4L2_MPEG_VIDEO_ROI_MODE_NONE, + V4L2_MPEG_VIDEO_ROI_MODE_RECT, + V4L2_MPEG_VIDEO_ROI_MODE_MAP +}; + +#define V4L2_CID_MPEG_VIDEO_ROI_MODE (V4L2_CID_CODEC_BASE + 658) +#define V4L2_CID_MPEG_VIDEO_ROI_RECT (V4L2_CID_CODEC_BASE + 659) +#define V4L2_CID_MPEG_VIDEO_ROI_MAP (V4L2_CID_CODEC_BASE + 660) +#define V4L2_CID_MPEG_VIDEO_ROI_MAP_BLOCK_SIZE (V4L2_CID_CODEC_BASE + 661) + /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ #define V4L2_CID_CODEC_CX2341X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000) #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_CODEC_CX2341X_BASE+0) From patchwork Fri Oct 18 05:44:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13841127 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> 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-media@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: WvfrIRCagXW6lgJodzE7r8+87vi5sXwmT8XO/FYX2Cf2Di7UTyd7Dgx/pF1XI4nlnL3WsODVAG8E7VU4lSHlkyNE4XE77X3Mqck35WVjJFyh9zRzJLOKNzcKiRSS/wP0lTpu9p8O0PC3sQDn8tE0p9azg1Q/UHWUmfebYLvmKB/x3dPxa+G3AvhJSGgFpzJa3OqHzzb/28ZOlCKLaPR2ppxLEkWdjMbpNkrvBfqs2PbuGStjLyg+7WQ/bJbKBlYYHEKn4k79+koRsOCkjEL2Q0jLdDYcTJ2dstJ7aWcyg8Mo9JwKQdNkM/rU8UqRUReK4pPvBy+k3AuvaNOo1S4PCShb0GWh3Vqr1NadIc2UDYNzNhdMqarApYPWHlAFYauICPVW+AigPC8o1Yrt8Dg2Mzos7bC77vTRefNzHqWtwcQd4vXvyzNoxgLEL22sufiOtFstA0g/yO+mjnJ4J06nVhOgWhA5zgh64x9B0p5yOYzT+LOOiUb4Cwc/amcnZcWaHgky07qGwLoK6WwUBgHLvoKRd3M1yn6hBfNer7k3CIHU0WqozOST7ez7AgFbiFjIjehLl6qgkte8Z9Y5TvAaqhqAa1y88EHgd3sbHRANwq84uD/WfnPabWzvONvfgbAf5cKCjG4onMBu4FVEMNzWBTWCpLsIvPigJmSksAvm/azVsEICofbRkBBCWjTF5y/xs6ZLZIgJzhYdc2exxNpbgZIdLdkstRY28WEqzLVVWAVilMVOCT7LsBeAPWsrVOZ/Sw4WqSzCwhosLZzrtqI4t3cTIKAhrPLpubYLwVCvkPQxQTL8KLhf1MaGPLHoI5cVKDVNAAZGAM6e8r2vLV/+pyIHH++SEsfMavHnfeqBaH4j+UMEfSQ/eCrCum1XAfyC0bPXZLU4TIa4abqVrlSWINEeehvY15e1bUrnIBy3bdFJh0xO+/HHh8G0GAEJRGzGjB19gNNX3LI9PJUzkLHieGr3DhQ8fydia4jpwynv8P/efE7tv2N+G13yggS924Yygi9TWntn/L6jDNv4omYS56thVNa6OzOkmSLRNpCe9FF+8e+7hAopOVBQ4pG4J5mlbt8jHTnW3pjkzvsWXc3JntE/RKWsZcZoGZd1iQVsW2LIxGClT4Vwt/38ORfXkwjjGjC1jvsq/5UygqzlzWaOLU6LmamWmeTQOWLvgy7GUJMINO8MaCASxgMlemJuOJYPGmU978ly0NqjPOwPV+9rzvHFLRqEq3eazZhM9EQn9T/6aff8w3WTdYCk2aiXWpk5x6YSlQ7kotz++cykMxwc1uFdrtWfv5+DncndviLavoAGBKD6sWk5sruimLKmSNTlmOdMLsExE2KLOHX+VyHlx4suyx+2TniJt9s+kIFGDuI= 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: kh3FGxBie9ilP2sqY89/KKJF03yfbnGjatde1c98iw7FRsDOQZLhrfxPOrIkwLapakohB1rBlmiLVM77T+cFJugtc50JT5M68jhQbch57g4PxDiqyK2gokXrru5nBbWk9Fg9G5QP/M+kGbUAB0/DwI61FQdYrNfxazbbFtjZ6kelVhkkhL8lmyajekf7A5+DAipSccSA8G+lCCN0FWPian97znnrQ0S4J/QIHUxByA/Wu0O0LAHCD4OEqx0NFbA8RXoZc61N0JaW+Z0Htd0Fzx4ijqmObbpVXv1XbjL3wqnHjo5FrORIJpq3wHbyg/jn6SCMnBIe3moJvTM0TIH5buECPp/T62geIXt5TuJ5GBdZp7fz5usFFSOrB+kTL9z8RJVCZaMXzCotjx60T9GVOCZujeoFWFJZi8IMHxOf8wEtr/EqoSm11czDqAuUB0ec5QhCZxuGCt9LHxb9pjyyaKFTBYY/69Upp8GHZekPrlcVWro4uYolcfrzCNgc45UBsLOG3W2o/1tMdvA7IgjPqOdFfvcIjFooyRVvaMSjDXCx6hsb9ML1waKDHhZi/ca4d2WEkgXbuEvxNK2IVpt2paA0o6vObA8VGID2tubCpW6KjKnHv/RpHvP4HYrfSdFFeE1Re/ifwwhCFMd8H8HazVWYyUbmnaR575Gcs2iTto1pO/43fruWtE0C42cGHNYQIkYVTdvTqvrXqJUNzKK9Fg4KU93Q15yJpnfeek4RzFyCKUv67ZQOx4a7AxdHOmJ+Kk1t1fuX2a0O/q1IARGTqK/flyTrDgNZ8G+koOety/5sEOdH4YZYfqC3Rnv+we6jRBVuoOWUWbnP1nQiu5ltMHi6yNnb/4WgE6uKSPncGCdF26jKMTXYEg+dmqA3FQ1Fl64uGDSVj4IYGL1HqMBoksZ/JSBwGhwUdOi2dgtOIIR+PEt1mPPRmebvItXzgc0NHM3Lt33uCk3lMKH1qlxzo+70fH3poYK7DlRV9D9yeOtuYzpFhcTswBLX75Laj9RUW0DWmMmaGIyepgkom7WftSd3JXo0qQs86+e63KY0LXHI3wLtHqpEOYuArMP5mrt32YSkbmj0cwWuksCvMRDRzJ+z29j8qDMXxNBPvh8Vh5VpgvlnJHinbXFw1MidF3jifiSP4YHhXfU7ZRLXoP6PERPSvdneCfKyiAjTHZCIrrwXvAFCJvso8ISrONexfaYEqQlTKxg+4D0hIocs/p6hW+QpaQdcADWCNR596H2HCArZSsgSBmW86iUBEUMpYKYfNtfgGs1LhwUA2a8NPNsfy5oqmSwkBMZL80lFJwsxKrYWCjbiZ0BAz9kkY5xVk6lI4hh8JG4J+l/8agdoOa/V2PuMXUm6rSNEPIxQu7sfvmQjsZ2i9689awxUi4t7p6Mtv1jpbVIdvx3FjDoaO26iQUPydtePHkhHyzGyisp7YA9h5NwBwFX/Nnp6I5DNt0VUJ3TXw5VXoi3TR0W63qYNPfFNRVbj0sqRX68wF0ft59e0HUodmcHV2o38dMinb+w3Hw1fcdfXZlPCebu8HCr9+kQD7she2CW1ARA14+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 This control represents a generic read/write region. It supports V4L2_CTRL_WHICH_MIN/MAX_VAL. Signed-off-by: Ming Qian Signed-off-by: TaoJiang --- .../media/test-drivers/vivid/vivid-ctrls.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/media/test-drivers/vivid/vivid-ctrls.c b/drivers/media/test-drivers/vivid/vivid-ctrls.c index bed5f4fb0c69..6ea64bea13de 100644 --- a/drivers/media/test-drivers/vivid/vivid-ctrls.c +++ b/drivers/media/test-drivers/vivid/vivid-ctrls.c @@ -38,6 +38,7 @@ #define VIVID_CID_S32_ARRAY (VIVID_CID_CUSTOM_BASE + 15) #define VIVID_CID_S64_ARRAY (VIVID_CID_CUSTOM_BASE + 16) #define VIVID_CID_RECT (VIVID_CID_CUSTOM_BASE + 17) +#define VIVID_CID_REGION (VIVID_CID_CUSTOM_BASE + 18) #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000) #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1) @@ -393,6 +394,32 @@ static const struct v4l2_ctrl_config vivid_ctrl_rect = { .p_max.p_const = &rect_max, }; +static const struct v4l2_ctrl_video_region_param region_def = { + .rect = { 0, 0, 0, 0 }, + .parameter = 0, +}; + +static const struct v4l2_ctrl_video_region_param region_min = { + .rect = { 0, 0, 0, 0 }, + .parameter = -51, +}; + +static const struct v4l2_ctrl_video_region_param region_max = { + .rect = { 0, 0, 1920, 1080 }, + .parameter = 51, +}; + +static const struct v4l2_ctrl_config vivid_ctrl_region = { + .ops = &vivid_user_gen_ctrl_ops, + .id = VIVID_CID_REGION, + .name = "Region", + .type = V4L2_CTRL_TYPE_REGION, + .flags = V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX, + .p_def.p_const = ®ion_def, + .p_min.p_const = ®ion_min, + .p_max.p_const = ®ion_max, +}; + /* Framebuffer Controls */ static int vivid_fb_s_ctrl(struct v4l2_ctrl *ctrl) @@ -1719,6 +1746,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap, dev->ro_int32 = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_ro_int32, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_area, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_rect, NULL); + v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_region, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_dyn_array, NULL); v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u16_matrix, NULL);