From patchwork Mon May 6 08:49:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13655165 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 03126C4345F for ; Mon, 6 May 2024 08:50:12 +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=bPqG9XjYYGF9IZYXCSD+9SbhEaBBTy9AY5G1jG4lk4M=; b=QGvXAtjGZ+Ahfc 3gxOQ1gkYUaurZFtMyPVe6f9EWsEksNeEsT4kTGPbFhbCHH2iwmxjOUKFVam+PIn7l+ixmFR/5Eir z3m65OCUa8pNeii3PsbUdgfcf7m7Aw7reg2F1hnBYJkyJGw2jqHW+6IkvzhzYIvyXGR8XOZP7jNvS SMMz60FSdLsK8X9NgkhLQ/1rq9v+npXRkX91ZFCBOQ3XprpAvDvSwuuJ73ge9xPb+BzWM7fNjRFGf k5ag+bzGwe484w1X1fOD68y6Z8JDVr7rihN1NqaPly2G91Qd6yEWg93AW59GHmiQ7mOHbEY42v0f2 AJFc0QOYHmxMV26rV/RA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s3u2p-00000006hKT-0RbP; Mon, 06 May 2024 08:49:59 +0000 Received: from mail-db3eur04on060a.outbound.protection.outlook.com ([2a01:111:f400:fe0c::60a] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s3u2l-00000006hIJ-2MUn for linux-arm-kernel@lists.infradead.org; Mon, 06 May 2024 08:49:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QP/X4QoiDA63cO6m1KGENhWyLtd8cVVJWIFEovfdbGrHd3tOfa1uZn/wObdnaSOI+D6VtevV9ptEpqHk6WuUMVU1XA9JMIaC2bJSYduyZDiEy/SmsE7+L2dyWhoeGRnbp7amLXCC3yo8fkLVWF34ZbmQ+/JCEDs2gI7LYqi9yROVaBRl3q7EsXaaG4zRRSt/a9ub4nQ40Zlreb1is22Ses8l2rS5x41XV/fgr1ehFIEC7Ikk3AvigVU5ihklNcOhIpph0uVh44f9jFjsk7n+M4DOWG5UthNmLdF/zIYQ0tsK3E2RqnQ/UVPnrJLFFYOc/J+SYvvJzlCmPOS5rCOX4A== 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=gTo0bKjrWDb9F8Hec8Bi5UndAfsSQb0e++NEeYY+48M=; b=SxqzRATLZ5cLaAPrQXt1mmz+WiuctydlfsGYZNBKif90bZ2NUEWNIMWYrHtMD8m3jKEt74NyhS+iZvL/xLl8V2mHkHh9VFa9oBuReMpavEAT3sWJ0YygAssW0M/xQ0U/xKo75ZJFeTYziKHD5Kf9bZYVaEh22jU1LJrnFi5H4VD83V5fRtUVWySZrPDQnoT9jARWPLDS2UHQiHeFO4d1pVmpbmCLDas/IG+mZypv9AAu2GHw/Cq1xTQ5cfUVn/NYvoj3KjUHODd4vjI7pX+gV05nsXpA53EQ1k2ii+SHNOXlQQ1r+1LaqUURVHC6GNCShXGFSn9SzHIRYfnfACXmxw== 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=gTo0bKjrWDb9F8Hec8Bi5UndAfsSQb0e++NEeYY+48M=; b=Ev9WGC7jZTatwSo0Y9lniHQkltOeU7x2EzCyXIPy12kAo32xNE15XbKKxyDa0UFQXAxAA7I+ACfSTYz7OeA7u6XjeJrON20QAWQ4o3NErjy4VKfIl9y0ddjRQwg1ko8w6y2MfedpLMDdNE8rDtqYeIym2RZVDRxCyHgMuDGep1M= 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 AM8PR04MB7812.eurprd04.prod.outlook.com (2603:10a6:20b:245::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 08:49:48 +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.7544.041; Mon, 6 May 2024 08:49:48 +0000 From: Ming Qian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: nicolas@ndufresne.ca, 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 v3 1/3] media: v4l2-ctrls: Add average qp control Date: Mon, 6 May 2024 17:49:16 +0900 Message-ID: <20240506084918.799544-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 X-ClientProxiedBy: SG2PR01CA0178.apcprd01.prod.exchangelabs.com (2603:1096:4:28::34) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AM8PR04MB7812:EE_ X-MS-Office365-Filtering-Correlation-Id: b8f87b94-73a4-4318-f5bc-08dc6da97c3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|7416005|376005|52116005|38350700005; X-Microsoft-Antispam-Message-Info: iHeIsPfUiSvkcabBogVdVfHGsYBfTxRA3n30ZoK9NpFD9eprLsFZ3qoyh9FBWs0B0VrLxjVvkBQES9XKs89Q3ViRomQwtO06MssKQOrI9943bOWZC6/LIAAIsjPRmojiWBePWNh6d7Qf2Qj+j3mdAOCguCxYP1A8siCF8TmIAc2U0Fds3uwIeh5dPcxRREE8YzkocGxTjuKiI6348eju/8/Yvv0xeA4g2uohwm97pGM7AmL+9b1GjAlQ8li4qovZZc3fe1h/fXT5g2wtZ7tgIpyO5oZ8KOPkgwc93tBr+raPnb4rsMV4MWDr01stWvW2nIOkoNpKkl17EPmX3zQjrponW6oR5DrAvY7xvejv4wcCFJnvN/jB6rv6kc9jJBbfpT8ETnAS/Cm0IOFcohnVieG2ETWjqWjBt+MUb7xgPohXxGN9KuCI37CuGpOGrOh9TO6S/0LQDBrZ33CfojGKBG+Ivd9bZ3k5Gn13FLupKYYCWvGhrJaRLsONLeVaYs79ArmCtqCsfrL9NZ1wJw69dGk8MDnCpF8NY5C7Hz+9escg5xkqvO66WkV6RdAz7kq5WW0QbpQpWuqbM3z7sYOIolyO4YnOK8+aRSuSPasI7igh+78yVxu8KUrsN1ufjl1WxG9jHmU5KFSudJSBMCdBX4PiRpTaF8D1CRWwJ4lny+Uute9eyJB8nq6iZM4S8nFa4xffwxuhsxKiWvxsHiPCKV1ePxtn8Se3mmhblKC8hXViyRKqkQCf8eNQJ2AStEWw81Q3gOL/hyrUknopjvdCW9bsixOU13B59XuLDkL9xjPJDo2NerpqmG655R/yPzHlsxa/JBws27FF7ll25j999L0Km8wzBpPYfiBX3/CXKdRsVHccWJ/PBXbh/UpuyPpayT2UcG+d6xSuxha8KxdoEiFpRtPgtTcXDbFg6BbBmB7HIW/t6zjZmdPo3LXih0gftx8C8TDjdTiaLKlRmtGu2Ea8ie7YgcRr7jIsW+rVKewOlncVvMdGITBDgCWS0BGZ8syFyF7N8BBY/HHCsCMASDr/kPX5ckBB70VkLO7NGl7bEdeN7XslSViRL0xZYYNyrbP0gGVh/jM6+WsWZRGzg6lZ+i8XwFL4UuyjZvsubqucsuOETiQow68LTPywsXhak95IhgJUdbOE0+7GSXQqSWKfoD06sHVM0oOShp2Q2ttd4c3Oif0kByJWg1Lsgvou7k5WS4DcX9dSntnlIqVQ/+oNsM5Qrmf5Iesun/c7wUVAxVkspnGLVFIlBrmDXjQA3e/HqBp2tOhp5rbGz6iQRK5O6wn1Uy6k13um1YMcOTU2sxz+RaqC8U7qElqGA8u6WUhRAqBDbqzhgv9srqjZIg== 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)(7416005)(376005)(52116005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: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WouDKq2MBZZOg1sdyRYIWT8whNR62MedcvMn7fS0F/HuFVyReNrOaBqQ/23Zgq2nY3bcyHqJDI9xntixnOX6RBIJ9gQ3Bw6joZn0k2JZZv5jJ9nKhCkfG9QxgaZLxrK7IawEUsLUTF8qiDWJH3gN6EpPtjP7xpmwA6APKDwfmd/WodZtVLDasbuqS+QfaU1TMozPhaH0ZVBSDZbqkt0hd9IvTeqBLSagKT6v8xkpcSKyCLRNjC/Ag5Ov3MYLjjHqninEnhGpHQ4A8cCuMz0006ec3s2a6bKkUrgmqggGvaJJyV6yF6e7/KAFwgdVImp4wD9AVvz4w0DCBStKJWqAGTUaqnNiIQ0d7VdiuRzirZihFSVwmXcc+RR8/QyzTAm2PsXNvPBFKkhU4CVLFxGax0jP9aOuEPh0kNbJBqNzTbzGDbn+WNdZM6dSY67WKV+K6EPujYlZ57LNWbgvcaCaWunSRTj71G/nXfnv0ch0NcfZN9p0YPUMOSo+a7KBZc97S5CMlThdPMrHhakdI50 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8f87b94-73a4-4318-f5bc-08dc6da97c3e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 08:49:48.3436 (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: XluSTc9C9ye0fSGyDHZ/3nsLYTFcH0lOLltJ06VUkwPQW5vIxpJdilnaTFwZT5tdY37CLc9Pzyijk3gWMtukpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7812 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240506_014956_151488_22B1FBAB X-CRM114-Status: GOOD ( 14.12 ) 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. the value applies to the last dequeued capture buffer. Signed-off-by: Ming Qian Reviewed-by: Hans Verkuil --- v3 - document the valid range of the new ctrl v2 - improve document description according Hans's comments - drop volatile flag .../userspace-api/media/v4l/ext-ctrls-codec.rst | 14 ++++++++++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 +++++ include/uapi/linux/v4l2-controls.h | 2 ++ 3 files changed, 21 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..4a379bd9e3fb 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1653,6 +1653,20 @@ 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). Its valid range depends on the encoding format and parameters. + For H264, its valid range is from 0 to 51. + For HEVC, its valid range is from 0 to 51 for 8 bit and + from 0 to 63 for 10 bit. + For H263 and MPEG4, its valid range is from 1 to 31. + For VP8, its valid range is from 0 to 127. + For VP9, its valid range is from 0 to 255. + If the codec's MIN_QP and MAX_QP are set, then the QP will meet both requirements. + Codecs need to always use the specified range, rather then a HW custom range. + 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)