From patchwork Fri Mar 29 09:23:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13610440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCE1DCD11DD for ; Fri, 29 Mar 2024 09:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=D5viafeFxBjIbrfe3Aie9hmkI1mS6I90uJbWkAMHQS4=; b=h99Q3c6mdSl22t S6cbzosgSQxbuLICHyc+FiBIF9FHtUw0oyWVEqGjCbb0qX6LypFGdQXgab7Va67P9A40Qbaz2aZpB +6r6pKWDBxiQO0eU6lDwhNz7pQb08J4U3IsFtgRIEr9QmrReb69AV831FF1BTem+QvTjN/8OauDlT jr/gni0NjtKOZppUAikGO8EsQiQegYGuW+wq/mwNnp3uakSsI3TwHUkM5xOoZ5QNQ3gjaN9n+awdG t78x6z2WFhK8a0QKvoWWw6WKIUYi8sVxcBH08ET9IjfI+1VirOTs6yGcTKddiAg52qm4HuEN+g94X 7YTQuXIH4xMJkzgcwb6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq8Ta-0000000HTMy-1BTd; Fri, 29 Mar 2024 09:24:42 +0000 Received: from mail-vi1eur04on20700.outbound.protection.outlook.com ([2a01:111:f403:2611::700] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq8TW-0000000HTKA-1hdx for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 09:24:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U1bJtM2jVYSc5m3H0aYXE3sY2PIG2bL2z9VVLFRi3RpmejVnFeWOFIdZTGQ8XPliTbglQ5WtMHUw/XTL7I21cxiOJb7Rp+TIvFQitheQUdrm60g1aBHati7CCQumUS/NsfH+2QuHuVVyqqjG94jvRYJ0mxicdKEbCCJ/Tc1b5GgLtt3xJ5TLULGZRzerkBCXTdWpwmtKg5gtvRwjWvd0W1CqGcPTbuh88nvltf7HVGUTeS4CZw2rbd0TVnzc2EhMthP432/EWit0DU/Wi08z6/09dk/AMezQw0P5S8H9QVJxSsYmO1HCJBYixtR2UoDCIApQCW4pYsZaD6CR1vgrRw== 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=4JDnT5nTIUgOckyy9oY4LIf24tUGpA9APVeXCVtyg+g=; b=BCtd1MdDUZBwRdLyVzCw8C22fewJ2feUlzr2JDvxRGDWxOCMNAjNBdWdGvvg2rfivkaHjtDs8+OSMWk4DKE0bHKQYekpeKeK7qtT3PXszvN/e2u+dZOm0d1k0s7QIvQRgtFaNAA6UBvhE2tmpfDA7IVIau1wQAttlH1dSjj/2NkOO5OljErOOn7XAQcZeXkgOFyl2p0YXjngnTOQd342fCmhK/1Zam7+Qzcn+kWXh8tAJka7ezx8Sgjqew0OpDHXIXNW+T3poqAuKivSCFCkSP+SZezhIdocCdGHZWGCQRXM93OncwTqvSmGatDgLgaEwQ4DH2ZEyUiu8bvoPVAPLw== 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=4JDnT5nTIUgOckyy9oY4LIf24tUGpA9APVeXCVtyg+g=; b=Xq3Iy/Mpw0EB4+LAhSQrex+oaqNvlY1EhfuJnIddg1htdd+HzoEd/aVUh3SzKmf7t04LUuisuOlnxpEIVFhQ2tgpWhXMmoKc5wlznqrq+SjqCWJQJDpGC/t0OXIqtxO2xtjWDVKJScyGT7WMb5LroHuHmOMnA4VoQ2jiYFipbm0= Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by GVXPR04MB10475.eurprd04.prod.outlook.com (2603:10a6:150:1ea::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.38; Fri, 29 Mar 2024 09:24:22 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::da55:641a:a6f2:6e4e]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::da55:641a:a6f2:6e4e%6]) with mapi id 15.20.7409.039; Fri, 29 Mar 2024 09:24:21 +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 1/2] media: v4l2-ctrls: Add average qp control Date: Fri, 29 Mar 2024 18:23:51 +0900 Message-ID: <20240329092352.2648837-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 X-ClientProxiedBy: SG2P153CA0029.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::16) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|GVXPR04MB10475:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s5y9iJJgmJjZnBGt8As8zlicRSan3/AskYTJSHOcH7/Fd1eHut0BvUvaD3aDadrz8RhMJEDRLOoRY4ryxILUPJA+lKIb86HGhq6pvvzExnWThJuLqTvH9qUP1ji34hOlTcYLKsRspYPrJE/FmSh6xCsxuOnjEUQlQPy1wjIP8DqUox/Ja5ycPPji+jjkNRf1Ji8PHZcpIg3e39bskDCyI0WIOdUbG6p9bhu082RSoN+sXUt3rpZWYa+OlqmNUxQd9WqlRxbuB/FOXfRzLo+Pntoffa7rWxtgXWteMbFTmROAZGCWzfBQF2JfiZiNv4BvgyVRmuTDHtYMjvEDVRCPB0/S0qWRNMXvOGIx52ttaKkRw0pk0lr8vR5qmE27Odw7c1/eft8eKTvGwvhJIZC5hqTK49sUGw5lreWKGDBWbidiH82R5atcmPe/fnF5o9LEKiMS9UJbadKRTiUTO4tR7jr+FLVMS/yzq/QXVYtbok6kxZOJk+TY6ahuv1fYkobXca9IxdcWvQ60Rh3K0a/tdCCbSy5hDEpKMjY+ucPRU7tYIOIetdXIYxbZ05jl10in8WcFeBxUOi4fyeFRfJP9eSLGGQ96xSQY2NHeUJlwqZHmY6XV2ujj9Tb3wBmuRNZGaLkXqplrrq3tUiBS5ODSwgqwBkCpQG6/UwjGeMAOWtJinuYFMDTixOSYW2cQKkotkZ9NSwEfZdLIoNEjv4LhIPOD1YheXI3WD8zLD5Z2fhE= 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)(366007)(1800799015)(52116005)(7416005)(376005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n3/Q/GL5QNgo5crE1i4catwdy5AwPe7CbJsRKF7FhthrP9ix9K9NKo/0XrMyJzMcr68gvarUosFJ1JRGU1urkkKeJrgnILUq1zyue0OX9R2nH8341kG0iQzSOZS12S5cGhAeFAYOdp2JI0IWdPWVEktSJ8TutxUkkuhOqXBrqIGVSWTcphcLm8orihJvp+xMipxMNVRBbmr27imZK3X3GeTEDmpSrSiWQ4/pN6yjMrgmxxClVdHGWznS+kYo4qynah6Iy+x30tmpuqPrOjGTXm5iOnD33Wf1lIum6thLulJlKfRB70spf7us66VeA3M/qPdNrBCdNukfiobhXxK9WCUrLSsCKHOsNvwxzRPeVLKmflT9DFs6zP+KtAuNzqTO8tXkrS/s/I2Aj1hpheB0Yr++EnSl3yQpup8S5mSeM+mL7bFHXGgjHXt8l2xcrDcnsS1AZe3DnMmukr6tli/XSnBify+WZ6D1e5ik/+zi6Ba5yR8RvapPbq89ZNUCpogRFzKQEb2QxH1uK3XO5ZivsyGNHn2nwyLBaks8pNVxr3otG7fdNIODIn/9EHXnWlOYUdYDkAkwUHFI/jdg8LfRInQUHVc255IBjZulg2HJ4r9miNLGzqZmcAiP4QvXkhfqOeuAjlSa6VXXI6Y49RiqesLgP9JDMCS03BvwzMlWVfejFN+k5ENUacT4FUdGs0AkyOGdYFW56wnLeuMLDCUD+Kq9alxYJmxhU+hCjYw2u4ge0n15YPrFQ9tnATZhAQ12i8IYYOdRfE9qaaYtL/1ytvV1D6DrvYP6gzlLbc1ZCJWi/qnU1tSV+j7gn0YIMw63dj2DB+YhiRjp6S1eDbSWOBZFHFZpeGk9BlRd0Z7X7lqNxR6buGIV8TUR0IV7OayY5OfvZJCBvQVWGbSLqhvpdkfBnc8SRqv6Yb2NmD3yqmKHi6HK8pSmpbMaFkrPDlBapBmtFcrDKeokpmLHVG6ZyWS63ITcPPEkM3pjWa2SRF3ZNfZ1AVoWDEV6o7+haa5HRRnZCPuvfsQiWBUp3VNPeAq/3CXoC6V6hZvDigTnzUgkt9PhIt1n/HWfd1qxWMU5hvvOPftC6MB2/Udbwr0Hfvpby5lYNVfzX9xj6Q1c6HLJxr0qtZMhvuMhKCw63RAGtI4tiXVNWh9hP0XcUYywqnk5Aa+xJhH8OqvzxgTRjSKaRj51N3791JBgFY6+S3T2pSEdpXfyHWnCYy8lkArTEekocW4K54lFmiuFvt3eigb46kIhPRmq9DIys3Oa19UwImMUMwg1lNgWM8LESMfkNeABI2m3AfU6IBX4dhbEJCJ8G6dStOxLpri1q3xEylK4AS/pVg6KQQZPa0wPHNQEyRAxm/W3Fud8Dc+o3GkvP5o4SzJ6O187FHmXwMbvvd6BCQ783kO7nmBdpNvRGHWI/JepB0MxKoXN9ablzxfhCuz4l1L2/v4Fw2vPNdIUsNh4ZhxljTrHDS9r8ujZ8mzAwUZAEkQvUz0KFkT7mCtwcgA2cdE1OhqxBnZYKK/2cGuziQfSE0feWIKnM/XjPd/9R+4L/NI+0T3swqRc4wFGU20cj3Q9ZlVUGus/rBxxTA73 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38b86d86-89c3-4983-ce3a-08dc4fd20482 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2024 09:24:21.9041 (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: YDxB4tHz9u8RkYToCrNERj05kPABMuZnK7Z9pjGi7cfaMvzZfBhsAh9o/QIAjXrM9eWEUNgHUCZm2yQIvLdKEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10475 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_022438_452801_BC37FE1E X-CRM114-Status: GOOD ( 11.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a control V4L2_CID_MPEG_VIDEO_AVERAGE_QP to report the average qp value of current encoded frame. Signed-off-by: Ming Qian --- Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 4 ++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 +++++ include/uapi/linux/v4l2-controls.h | 2 ++ 3 files changed, 11 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..cef20b3f54ca 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1653,6 +1653,10 @@ 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. Applicable to the H264 and HEVC 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..88e86e4e539d 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -972,6 +972,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES: return "Use LTR Frames"; 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"; + case V4L2_CID_MPEG_VIDEO_AVERAGE_QP: return "Average QP value"; /* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS: return "VPX Number of Partitions"; @@ -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_VOLATILE | 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) From patchwork Fri Mar 29 09:23:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13610441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2211ECD11DD for ; Fri, 29 Mar 2024 09:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V53bp3VEzowQi9t+G7fzbPexLiiBRrCZEv3rqBH+jkk=; b=KKBIwDlENmREm7 OdPOPKgghSIi/saDPVRk/HtbqERD6+TApfkWc07qITqOeACWVWh04WusAqOrW34bcfTFIr2OCcKtv /UxkDGrsuWktzz4/dJgHu37HU3+qDLz3J+dDs5w2cKV3CiutmNYeSPdnYqXxC+sgBaPZTXNydsCEy oEOL4Bmn51cF734BmqWAefToEVsGAzSu8CAmS2KIwxEYRXfjyLbqQxCQQrJiaU+MTJuZqPdLfFP0e zlrpjH7o62MIVRggaJ2oSrlAXI0l4S6wM+2FI9hNIou8oxlvorWo3BJlAz3MhBEMYlNt2bTWTG56x N2oL3z4cgG7FDwAzwoRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq8Ti-0000000HTQQ-2Gno; Fri, 29 Mar 2024 09:24:50 +0000 Received: from mail-vi1eur04on20700.outbound.protection.outlook.com ([2a01:111:f403:2611::700] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq8TY-0000000HTKA-3tcE for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 09:24:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jcfXqcFwYgY0doAcQxjboTbqXgFV8K/XlpGfAMB7iNL/KTtu/tF/yMjRrMQK6BQ44jZkYYbF7tfSWUrkOAI97GISixtNcB+MMwHF9Wq/ENZ3SakYCZlfjmdaQyYFTckhJ6fMUF1NGpb1JRW8W9EFov3uQBIIRP08zg85FVr6ouIaYPebo+PGN6ClKQuMwZ/hy7xcVCO989rLqbQ3lqaTealt5bLSmDVuZp2BxpTfr+PhIheBmJIFiSC+nb65Fxdift6KXJu7ANRw3W2l9Q7ueoTMpomb2BXbUvD++gJfr2LLIpEee9o5QhJv4rRPDxnyUFPB/mfb2FdgUF1nD/qJHA== 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=iMFaKvUuHX+1VHJEEM6NLZqnsucukjMHPwV+vSOhDmE=; b=F4wiK4jYLBRXKZ+2us+t0oex4jpc7vYurMAUAqo1w258W7CYP5hYBREqTOhrX/0UB52fBsBnX7NeTqWLN4Ri/0/X2eR/a8ElOEWEuDZpQox6KF7sJ5i7JY/VkqXCQLtYtmurVLIgHRlUK9/5oiZzLLWo00OssOgkiqrCexF4aiLQZJPSua0ZY7WPgIHQetoT8ZeASPrYaSBuUZVFmRNLvbQoVKsLJYaxx7RuzBlcNsXlcw47tPcEzeDiemRjYPCoef40NDbVquyctUd6DI5+/8zjTRsX9dfdR3EkelRIFyUkwNm58bQjkWPeOHxVqQtTNHUSKB/yVtdXkSENPp8GSg== 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=iMFaKvUuHX+1VHJEEM6NLZqnsucukjMHPwV+vSOhDmE=; b=i1dilrejmTpbroqAHtkmrEElJz3U7VRng703jVVxplkDHWow2nHLBOnk95cvOb/N/PK2KeEkdrnRx5mKsYVBPtWRMWl2yHoF9CJPakV22M2fRxuixPLTcXYaOGB7K8CK26Gswq06QSQSVWwIJyPEjAlXaFhML2JC26vH7jUqa60= Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by GVXPR04MB10475.eurprd04.prod.outlook.com (2603:10a6:150:1ea::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.38; Fri, 29 Mar 2024 09:24:26 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::da55:641a:a6f2:6e4e]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::da55:641a:a6f2:6e4e%6]) with mapi id 15.20.7409.039; Fri, 29 Mar 2024 09:24:26 +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 2/2] media: amphion: Report the average qp of current encoded frame Date: Fri, 29 Mar 2024 18:23:52 +0900 Message-ID: <20240329092352.2648837-2-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20240329092352.2648837-1-ming.qian@nxp.com> References: <20240329092352.2648837-1-ming.qian@nxp.com> X-ClientProxiedBy: SG2P153CA0029.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::16) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|GVXPR04MB10475:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wYY2dAIIrcvbQRDZ0D2z+Hj/BUAt/yx1AKXD+Fw0+MiX9Em4adm+vhrHrIq6PMw2Ssfb4ojC0qUggCLCUKfQHPbFTgu/Xzbu2iQftxWuLwdrGYZ23mQTdQqo7rFDZbbvwkweES+OHDyTGPILpW6kpxA2K2ubKEjGPwXOcSDn7VWX7bOSre8BSAFBbLKnrr9YuT9NykqxdcnRTRcjmXCHpQJUwhry1jAQvoJj/WOfTtnnXm6OXortZNE6kMBPv8p64xONKkKKuH7S3GI+BhKjYqhJnRDqc+WN0aTNK1pVzNn7JsJZSn9Thbpgck+LMq3mF7ZTbS18JRqzIVkBQrcmGqxvNS9FRod1NFcFzkaXwxZFIVT2Pp1oZz8KM2xhvx4YZQh3AIa7KIp/OSOdblzayHDS7El/NjO/SfgXoxJwkUVX1S759UDv3KRuwrrIlF8ALpbA+exeZqp/j4m5R9J6vX05MONyX8sQzHvp9xvuasPbJsk/hEQtjylICQhfNmfzJYQs2SGZTkTH7BR+3DDEMSXIIuLxlQ+oy9LAO4eZn4IwZbCFASmM/Gq43XKr6nVcGz7CxKK+K+y2zD77b/SvUqhnwQyanvSLH1hW+DQOuxvZFrp2rxztnYzVKOSXqz3nXOPeZKdivcVFfz2AkKeRPV7ikTCfqrS3d/WbSwfMJeoIX8R8d4hrDJMr/HmQvK6yS86esK3n12aN7MaECUStqe9Ma3uHVizSXwyexd8MnVI= 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)(366007)(1800799015)(52116005)(7416005)(376005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UKRv2fp0qmv6HnHzti7+GhX/xxx5t920aT8WMO/Garnm0dPNRYrkCtykNlfJM+YEPsppsUae5GzyPSXTjzH5dCLWb9VMzmbuM6mYP3O93qPqvb5yqSlJh9qZR9YmSP2+25GPz7xDzZd92S/+35JUR/9tgUYqmCGnsFLhuHRh3e/+M6dK8GK+1V3R7UGehYT2asHobE3ef45ucnxI6ZNmX5BFl5AsQr0rqz2fh5LnLS8kN4w4FefoGZ2DAl4rG00MYrOMP0uSkP1kliYCi9qWA0HGi3/Q3+n+v0QtthaTnyJYlRe16nMX+ejKVLk3JCqg4/simGr0weO5//6CPjr6u2ArEBB6mtNICdBRxTgFZxHMYdWi8bZiWiqykuqV8ASDyfJ4tTcHQW4xLMtcCQCpi4CkXx3eYBivoCGdIsnTULXuST4SzS1EiV21jisdivqWR7ktlsLkVvlyNlhTIAksVYSO1l8LPmLqdrVz3gmos+av4WkhCU97ar+9i5a5QUAhYNDosNBwndU/DReJ9QhztjUiusNoUHMrElea+wXa8ouonOmEzABvKW601Y0gg24mtFDVmRqJ0HZHBRCHp9veYIdOKPSSD2JSwbfpoCyV2xPr+eOIonDhlFsg90fmSSraNJ3bbaw5uvCFiACWsWBtE5FykTZVKy04qcL1p8g1cQs+vzKYr6P1phjEq8u3HR7RC8JwqYoWHKr0woB9u3C98KLMaeOFJ2bKm6gsx7Hx64ai7RFr6VpV5hQkNMVHD8eXz7DDmKjq/ODQv2RIADrpr9V4ApGhvxlriA5XnmE2CIYJPY+xFWBYIw460zLtK50bovvbnqRWwIqt8nK17AicUuHJMNpm4rhR7g2WYTaPFuhBdmKrYgF2a8SeggTGD/LgSKXykgD6f3hcDNCuQ4KjpgUOSYJiytq4bvAFMerIOt8R5w2Gb9Mps33e/rSgUr+XP2td0jmjq7SpLMx3LyLAAu8/Z2/qDXrZEs8QFN7ZLOJzRod4lPKn49oMbilRdJZI8VOGerKmCYy7zmQmukvA225jxGqDVSZvsjBNyN0QWv42Hovq5T8Cgi5C/TDR6Zb7fYOYcgQ2doOi9jQCjMCDFSranY12aAVx1HzQkt1TOgZKHsWeolF17Lof7IZPqBglj+28AM9270r0omQFM7kB4+/+GOykFzpmNKz/ChHx148SgisplSNsvSXNc6hrSOJwaCTah26FXQi4/OrG772oGSJs7XGTXq5EftEl25qeK2mnckFs56lTEjOsbT3DIyomEdGdfwOSF7c73pa6BPSmyFjiDFbsKV6JxoHglBVYzQGD80dgkq2ZvBdhCXROsRVUwL8ufMY5MsadpOjPigqhjxW06aL2JpHlg1VDYFZo6w1Fvu/BOeuZGlJOER2HBlVJFFEEL3M/5XnK4BEIjAtcil+qqURtEmK5BKISsrc9OzvUdvUVrGtEyrUljl5Gflrywn5HIov3UeBSO8EAzMS3/fLjehVLq1oMJrPe1AIWGZWvMk62lv+MMg8mWVVk0EapYWQT8DPaw8zS2dWL0te7gdH1EeupikromafSGytKAfjjQ9UwsttggflW/u9NTTjV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb6a1c81-7b9d-4492-9bed-08dc4fd20767 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2024 09:24:26.8534 (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: P0hzS9gnAHO/Cb8oTI6a6G9Xm7UmgKr7FqfFZMvANtBLZL3RamDkjLUezozyjGN+CSo2JXHPxvMhcVt7Hdjuhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10475 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_022440_981988_B4C8689F X-CRM114-Status: GOOD ( 13.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Report the average qp value of current encoded frame via the control V4L2_CID_MPEG_VIDEO_AVERAGE_QP Signed-off-by: Ming Qian --- drivers/media/platform/amphion/venc.c | 4 ++++ drivers/media/platform/amphion/vpu.h | 2 ++ drivers/media/platform/amphion/vpu_defs.h | 1 + drivers/media/platform/amphion/vpu_helpers.c | 3 +++ drivers/media/platform/amphion/vpu_v4l2.c | 9 +++++++++ drivers/media/platform/amphion/vpu_v4l2.h | 1 + drivers/media/platform/amphion/vpu_windsor.c | 2 ++ 7 files changed, 22 insertions(+) diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c index 4eb57d793a9c..12cebafeaf3b 100644 --- a/drivers/media/platform/amphion/venc.c +++ b/drivers/media/platform/amphion/venc.c @@ -680,6 +680,9 @@ static int venc_ctrl_init(struct vpu_inst *inst) ~(1 << V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME), V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME); + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_AVERAGE_QP, 0, 51, 1, 0); + if (inst->ctrl_handler.error) { ret = inst->ctrl_handler.error; v4l2_ctrl_handler_free(&inst->ctrl_handler); @@ -819,6 +822,7 @@ static int venc_get_one_encoded_frame(struct vpu_inst *inst, vbuf->field = inst->cap_format.field; vbuf->flags |= frame->info.pic_type; vpu_set_buffer_state(vbuf, VPU_BUF_STATE_IDLE); + vpu_set_buffer_average_qp(vbuf, frame->info.average_qp); dev_dbg(inst->dev, "[%d][OUTPUT TS]%32lld\n", inst->id, vbuf->vb2_buf.timestamp); v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); venc->ready_count++; diff --git a/drivers/media/platform/amphion/vpu.h b/drivers/media/platform/amphion/vpu.h index 0246cf0ac3a8..d21ca6bf2459 100644 --- a/drivers/media/platform/amphion/vpu.h +++ b/drivers/media/platform/amphion/vpu.h @@ -270,6 +270,7 @@ struct vpu_inst { u8 xfer_func; u32 sequence; u32 extra_size; + u32 current_average_qp; u32 flows[16]; u32 flow_idx; @@ -306,6 +307,7 @@ struct vpu_vb2_buffer { dma_addr_t chroma_v; unsigned int state; u32 tag; + u32 average_qp; }; void vpu_writel(struct vpu_dev *vpu, u32 reg, u32 val); diff --git a/drivers/media/platform/amphion/vpu_defs.h b/drivers/media/platform/amphion/vpu_defs.h index 7320852668d6..428d988cf2f7 100644 --- a/drivers/media/platform/amphion/vpu_defs.h +++ b/drivers/media/platform/amphion/vpu_defs.h @@ -114,6 +114,7 @@ struct vpu_enc_pic_info { u32 wptr; u32 crc; s64 timestamp; + u32 average_qp; }; struct vpu_dec_codec_info { diff --git a/drivers/media/platform/amphion/vpu_helpers.c b/drivers/media/platform/amphion/vpu_helpers.c index d12310af9ebc..59139302cb1d 100644 --- a/drivers/media/platform/amphion/vpu_helpers.c +++ b/drivers/media/platform/amphion/vpu_helpers.c @@ -378,6 +378,9 @@ int vpu_helper_g_volatile_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: ctrl->val = inst->min_buffer_out; break; + case V4L2_CID_MPEG_VIDEO_AVERAGE_QP: + ctrl->val = inst->current_average_qp; + break; default: return -EINVAL; } diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c index c88738e8fff7..893f494ffb0b 100644 --- a/drivers/media/platform/amphion/vpu_v4l2.c +++ b/drivers/media/platform/amphion/vpu_v4l2.c @@ -63,6 +63,13 @@ unsigned int vpu_get_buffer_state(struct vb2_v4l2_buffer *vbuf) return vpu_buf->state; } +void vpu_set_buffer_average_qp(struct vb2_v4l2_buffer *vbuf, u32 qp) +{ + struct vpu_vb2_buffer *vpu_buf = to_vpu_vb2_buffer(vbuf); + + vpu_buf->average_qp = qp; +} + void vpu_v4l2_set_error(struct vpu_inst *inst) { vpu_inst_lock(inst); @@ -536,9 +543,11 @@ static int vpu_vb2_buf_prepare(struct vb2_buffer *vb) static void vpu_vb2_buf_finish(struct vb2_buffer *vb) { struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct vpu_vb2_buffer *vpu_buf = to_vpu_vb2_buffer(vbuf); struct vpu_inst *inst = vb2_get_drv_priv(vb->vb2_queue); struct vb2_queue *q = vb->vb2_queue; + inst->current_average_qp = vpu_buf->average_qp; if (vbuf->flags & V4L2_BUF_FLAG_LAST) vpu_notify_eos(inst); diff --git a/drivers/media/platform/amphion/vpu_v4l2.h b/drivers/media/platform/amphion/vpu_v4l2.h index 60f43056a7a2..56f2939fa84d 100644 --- a/drivers/media/platform/amphion/vpu_v4l2.h +++ b/drivers/media/platform/amphion/vpu_v4l2.h @@ -12,6 +12,7 @@ void vpu_inst_lock(struct vpu_inst *inst); void vpu_inst_unlock(struct vpu_inst *inst); void vpu_set_buffer_state(struct vb2_v4l2_buffer *vbuf, unsigned int state); unsigned int vpu_get_buffer_state(struct vb2_v4l2_buffer *vbuf); +void vpu_set_buffer_average_qp(struct vb2_v4l2_buffer *vbuf, u32 qp); int vpu_v4l2_open(struct file *file, struct vpu_inst *inst); int vpu_v4l2_close(struct file *file); diff --git a/drivers/media/platform/amphion/vpu_windsor.c b/drivers/media/platform/amphion/vpu_windsor.c index 5f1101d7cf9e..e7d37aa4b826 100644 --- a/drivers/media/platform/amphion/vpu_windsor.c +++ b/drivers/media/platform/amphion/vpu_windsor.c @@ -499,6 +499,7 @@ struct windsor_pic_info { u32 proc_dacc_rng_wr_cnt; s32 tv_s; u32 tv_ns; + u32 average_qp; }; u32 vpu_windsor_get_data_size(void) @@ -734,6 +735,7 @@ static void vpu_windsor_unpack_pic_info(struct vpu_rpc_event *pkt, void *data) info->wptr = get_ptr(windsor->str_buff_wptr); info->crc = windsor->frame_crc; info->timestamp = timespec64_to_ns(&ts); + info->average_qp = windsor->average_qp; } static void vpu_windsor_unpack_mem_req(struct vpu_rpc_event *pkt, void *data)