From patchwork Thu Apr 25 06:50:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13642894 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2067.outbound.protection.outlook.com [40.107.20.67]) (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 D73225A0F6 for ; Thu, 25 Apr 2024 06:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714027843; cv=fail; b=jrn6sAm4NXsy0rzGvXe2SqAIl/fkkIiatWOGqhustFgSpj5yzOTrH5r0MIK30pekJu43QiWaJFim30vKt6Dn8LcA0M35bGmPBNFneBPxc/uJHOz2zVFo6vX6u1+DBNp9rJU6YEsM2GBRVo7Lv0mnbUJMjCMmsPeao/AGI7HmfRQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714027843; c=relaxed/simple; bh=PCh2y4lk9VdXFUYXgfFqT0jif/eN/c7URkk9y9K1NGE=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=nF5m1GyvHc/UIUxUHm+b9WNKd8G1qcGhKPCrGw7ejPtj0JH4hiegloGcYlZXenkUGnvdqIaeJRHwl3N2jlX7SZNCU3kWb2rf7ZWIHsqoLkVjOFfXJqx/DFuPx4A5zRC5L/pYF1v8OT4gV55ZRgqSzU66kFbsavqhGe42CDvUDhA= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=bCbP1y7E; arc=fail smtp.client-ip=40.107.20.67 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="bCbP1y7E" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rjp1jK8UUO00q0sqTmxn/CYbu/MJczMdyYyURm01JYWtIc28z1NIe/vJy1w1xxtba2WDsVXrZcWnE5J6y4+LbYzSElkua/pYUG62Ie0v8K+TzFXe+YrUEE5pCDRVejL5x0S2ckl2OC6b4Qoe/xz5NHLSYN8+aMdZq+6iMJnhLscHaaeiFeAlAYuYRzlS+cHVKI5WhQmKKg+7vyqrvxvXzZR4Orq4JxMb8FQ5cMUXD399ENIYFtPcGlFb93WKIGXfhmuAhZ1f+QYRqbEf5kzaJ0J/0+ULuY+pHQFiafhcDZoSz3xgoDQiU4IZbc3uLWZxbYdHidqtpDIklWOm2EDvsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=rvGgJHNKtsZsUR4Sb2tsoJuO8jlu/mfjnKWRw3saWmY=; b=IUy8c1hPl1brxO12Yc583Y/FlRIZ/rag4D51df1C2OD/cj9U0XRITMLNqvjT48w/Jp5FPawu9qOe9XUGfeGJmay3j3Hc0gy7J3PsXRlTDdbrhv42nG62UkdxoRP6u4HxVuDaQqlLScpfnGAdCbOgudR+fRTtuj4WIjvp1hu4eYZv3WibkZyf/Nsnp+UaURpY6gBL318Rp7uxhGpSNrnz0Qfo6HjhZVEKgvRTW9RQe7W7XSZDJjyuyGYbye2iMRKbwzZK34cNhUjUuKDTWCJSQdH0YHMzmSHmRJHtEzv8hQuQJJKovPaNQa01+fVdbdlyGSZVFGD+P2xdmXMoeKTXQQ== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rvGgJHNKtsZsUR4Sb2tsoJuO8jlu/mfjnKWRw3saWmY=; b=bCbP1y7E5ORyzSnFRrnpGfYqsn9fbU0HHGJeYmPxKZ6zjkM4dFwOXyVrcUV7m6UQZxNjsNdRyDBM8HMtOinBVhWQmgXDYUuNv/1k4V9Eo+CHZ4Bi7thMSLHMCsxypezz5dOtSybAzxohM7/R07JhHfhnpwtEZv/63akJrmeDPp0= 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 GV1PR04MB9200.eurprd04.prod.outlook.com (2603:10a6:150:2b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Thu, 25 Apr 2024 06:50:36 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::8589:eb00:ecf3:b4ca]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::8589:eb00:ecf3:b4ca%6]) with mapi id 15.20.7519.021; Thu, 25 Apr 2024 06:50:35 +0000 From: Ming Qian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/3] media: v4l2-ctrls: Add average qp control Date: Thu, 25 Apr 2024 15:50:09 +0900 Message-ID: <20240425065011.105915-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 X-ClientProxiedBy: SI1PR02CA0057.apcprd02.prod.outlook.com (2603:1096:4:1f5::10) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|GV1PR04MB9200:EE_ X-MS-Office365-Filtering-Correlation-Id: 51a33c27-e91a-4e1b-4b10-08dc64f4021b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015|7416005|52116005|38350700005; X-Microsoft-Antispam-Message-Info: moqUoB6AnNibxhvxHAmL94Xv+8r0kifS2/S00FGFL/19XaYOFJ/qNaOkiI+AYo+3mqAiPYEo2y8iGekt4OBIOqP3pd/4b5QOxWxHrjp5WaCCvAMFY4Ca3nNOYdVOrN/RG1WbQY4zJDi/GUk08Bj8i+r5WNtT33AaDh6L/WCHRGqdNMHH7DhyU/X4r3SyaW5HRSdGynH7nWoxOb8fGa62sHsJSiQlFiTDnGPU9PgfZsHDFql+YmXJ7d4QCLVtBaCIL/RL6iat4Q5XUCpHiOrJrIZ+Ptq03cKKbsh9M41cK6cmLLq6pngU0eji9wcySRTSUV/y5saaTB8MCR4wvxE4//OL/9K/T9r6OAPTrSnmkMJyOPlYefYLbO1FG5CXs/pVfd2NnlCWsuQmaUBuNABCrPxJbXIC7kqFWi77kLiL/3UR9WHeIZt7k/cHXzR+Ss4pskJsyYBvae0hyancjFsVtWSwIt2A1kbjwwc4jtceQQk4KZB479dTXMdLzHJhiS2Ihc3v8oAartKfK9pWMl0PoYEb2IZbEWbCNbDOWDxmxSjBR1CClY6pDKd4K5vAMI6sN6K7WfJyDRAMQWEXNNQmKLg9BQPPm46cU8Vhf7o03wVaBuCs+HnKcre/FiGIkTEvWW5/YYTwIVdZTKcuKfGSQUAmUNXvak2yRm9pSclYOPpuHzNUNSCoUmR+GiJ3lrD09SNkn4Tqx0n3s047jsXlIynL4JIntTNzWFU19URl4Sz6zymo1bNNjkGpNzNHlcAQWeThPd3h2JMpdXnE7kpUnCcbISAw9uVrz31WDrXrFMLkxrq58QDf8R2Zuuye9tTrgECkSab++uhSPLf0rbZoZYguBWkRa02MnVxCGBwr3wEVvJl+KRrOvNK8ZvlX3Gk13UBR/fIwlh+B/8Dlb3uR6zOfaOkO9U3pa0pLoZissjXtrYKB/PfLuBw0zr/hh78Uu43iDFpOjEJ2cUsrzCjANl7GQgEHH7y6EfEkk948sjBg51J//ynwJsZc7qnbG5rSyD8YOJ4qzhuSGyz2YVBgeW2gl3CdXeFukjEn/t1x9/ctDRfIkcWW7WAqfOF5KWQt1472Hz1Yjz+V5bpM3V6BjYIVxWcuDofzrlPOmuRxGOvbWojmgM56qnOyAdCTr98p+zqHYE+K12KuSIvYIs5kRlPexbvU/eotfGyUgTEiJj4q99ATaSzzTjNcWRT4SvaMlrZ4wBRBzOv8X6wLMeOjDw39ta9I+ZtY+T/WwXopV6csBj42mMQYGkDV/DKLE30v222yDKNEi1VTPSkNj9ZSvyTAr4uYLtnMXfgytyaISz4uC9VQLn1pwEZT4W747z/NeG7whc+iatwfFKgxY+iZ6w== 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:(13230031)(376005)(366007)(1800799015)(7416005)(52116005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A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/H4TsYyIfgJ3DqTf4pUTjLc9VvFGBHbdypQsK9exDiU8GqLbKXHvJHR5pwAn02i3YfKjZ7FwsU8CYqhWkaYmDpzcLE6np4lmQ4GZRocvBAV4lMSLEOjnILojoRv6HW6Zl6CrMeHQhZRqJPem0t8j4olGtO/xvoJgXhGz871qsTwCfpK+nheopfP7ZrR9yY3PNW9uS5TW8BVsiXdpjUt8zfJ2cpxibuYkaEcUzuRDKF9EC8Z0d8j7mTEuzlISAt2RccArYzREYrDvM8HeRxWZbaloGKM/7ZjYy9fLIMWKEf7HjNgupSHXVw80zfyFofe3aQnTH8+7sI0Z4YgeUA7vyriCz3yUD5h7leFhC6LMzLx0LduAF/yHBS1S2IZKhQ0REFG9DSaxvLvhfALwCL9+xg7ChXp9WZw810QoPDAFh+lSRooufjVVFXisx7e/sYZ9QN3pAtdvdXKE0ulnf74gSsc6ghsh47/Wj2twrv3FBVgJ0xPe5v/p2tadAhQ7BPzvwVxLhByWxix00cGmZhQj X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51a33c27-e91a-4e1b-4b10-08dc64f4021b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2024 06:50:35.1522 (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: 2TsM83956d+JVOaUYbe5Ohq2Ca58CuZdUTRJhoM6pXimwqG9xXOYJrQZX7CiasOvvszs8IBePfcCa/dqsSPp0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9200 Add a control V4L2_CID_MPEG_VIDEO_AVERAGE_QP to report the average qp value of current encoded frame. the value applies to the last dequeued capture buffer. Signed-off-by: Ming Qian --- v2 - improve document description according Hans's comments - drop volatile flag Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 5 +++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 +++++ include/uapi/linux/v4l2-controls.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 2a165ae063fb..7d82ab14b8ba 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1653,6 +1653,11 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - Quantization parameter for a P frame for FWHT. Valid range: from 1 to 31. +``V4L2_CID_MPEG_VIDEO_AVERAGE_QP (integer)`` + This read-only control returns the average QP value of the currently + encoded frame. The value applies to the last dequeued capture buffer + (VIDIOC_DQBUF). 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 8696eb1cdd61..1ea52011247a 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -970,6 +970,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_LTR_COUNT: return "LTR Count"; 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_FWHT_I_FRAME_QP: return "FWHT I-Frame QP Value"; case V4L2_CID_FWHT_P_FRAME_QP: return "FWHT P-Frame QP Value"; @@ -1507,6 +1508,10 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *max = 0xffffffffffffLL; *step = 1; break; + case V4L2_CID_MPEG_VIDEO_AVERAGE_QP: + *type = V4L2_CTRL_TYPE_INTEGER; + *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 99c3f5e99da7..974fd254e573 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -898,6 +898,8 @@ enum v4l2_mpeg_video_av1_level { V4L2_MPEG_VIDEO_AV1_LEVEL_7_3 = 23 }; +#define V4L2_CID_MPEG_VIDEO_AVERAGE_QP (V4L2_CID_CODEC_BASE + 657) + /* 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)