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) From patchwork Mon May 6 08:49:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13655166 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 A27BAC25B5C for ; Mon, 6 May 2024 08:50:13 +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=3ay5rMwbCg8zMlJBqnC6sNC6DVIO029lmzuDEsvGESA=; b=yd4z2kVHdHNXm5 hPasmycbC3AbOzQYYR7wJvc2UzF6PaViPWyf4pQrsE5zGvbHqtWPtt4D5FZ3lXDfEajQiJ+/7xdoT 5jQQev2ZsQQ4hG5ySZP7Dp1OUKYTnRHbgHKTurImVxz2/9NgPhQ5xVwIPWZ3UIQonpzs3LE4Wtadu d/Vq1xwZrcOjxzE1UIal6hEBeKOhrH0mny3oIKCkAlzNnTulsXVInsuXNfbHIHPhfkj187HauuYNz cZctVFNu6d6jT1PTs4woeU1tSRKKo7RjyDyZsfPCTcZ50RWeBesZZIc6DEsVR0c0qqNbnOT5xJmzU eKvC+Dfr+UxNZWPIC31g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s3u2q-00000006hLF-3v5j; Mon, 06 May 2024 08:50:00 +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 1s3u2o-00000006hIJ-015A for linux-arm-kernel@lists.infradead.org; Mon, 06 May 2024 08:49:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iezDbPtP8WNYJKsa6tJzEzGbWNZ9RQjFJTBsN2pOgzGKxo94wCaQKVhobqeyfhKb4Mys/1fx0mvTvpZvgekePFwsHJfnZc3YpgY7cjIIHqp3+zqXiLXnWwdXXEUnQBb2I3OZ6USzi6/KZy6nUVUifld/ktTF8LGK5Z3/Zp5c6IcSBrNdM47vzyJTPseyiDGm0TdroI4hkCNVy6evbzeeJ5BNjyuvXNv9YHx20CRlNmRj1J8V7zZDIAKKSlXqPkzDaZL5bcohwUxiOt07kyJEmQUaBgCaWp+fg8B52tZix5OuL44e5wt5x+QdwdpFfs3Y+pycM/e5vqtrWgWuWNfuBQ== 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=b9YfFe3rFeY2EoSGpF23QQWQydVBAsyfl7fdO+m0dyU=; b=b8KuG8n59+loPrpQ4UuPbAqqWhiXPDuLgiWSUX7q8MLj0lSaYJmRi6Nad/ztg+IxkpIqO30qJXCy5fo2z1ykAsKxZ9b7jxCeO6ER9R5S9KEs9Q833TWawgLlaIayTColnNZWHIQJ57pUjtp8Jg+vXVunmIqpExgCYp4e+px1CqBAv092oMj/kCnmHH+7/SLFuM01nLXUfpbJlVDKMqHAWiJsIluAb40jWDrZvvevWd2Q2mMdgRQxkZpucYLtfoPlfIuhFiWSyfRC1wjMB0MDnG9BIEg5Jj9B4Q3QdXnJzTZWtC7WWWeHa1lAy0LpwTy5neWGJzSnAvJCmX8Jk6ezEg== 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=b9YfFe3rFeY2EoSGpF23QQWQydVBAsyfl7fdO+m0dyU=; b=aXVQ41h1+IOgo1nOy/UNJHRbhHABSL5z0eOMMG+3t6sxd3r9VDNI4NiMnzYCORIXxXryTjVib2GLbk36DO8IOa/z6towtHfCMp3YruiFdr+XwduCXISUiS7h3C7HFzRE2spQQJtIVK3rTwJJRQaKSHF+tZnJqySfkUJyZUg9gOc= 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:54 +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:54 +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 2/3] media: amphion: Remove lock in s_ctrl callback Date: Mon, 6 May 2024 17:49:17 +0900 Message-ID: <20240506084918.799544-2-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20240506084918.799544-1-ming.qian@nxp.com> References: <20240506084918.799544-1-ming.qian@nxp.com> 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: 690063c6-884d-463c-a301-08dc6da97f9e 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: Ksdd0OiTYRSmozho9ZndmnEQ62evfmTT09hsuSlRlNZzjh3UcVjuhN+IhftvvaGZDB63bLCH6wDYqWQ5ff0sAThd1d/b0ZWuRZJajGNLkcB/onjH7X3M/J78K3R2xIbA/Shg3tXgkdO57SkvRVfHClay3M7/0FzAJd2T/UVXgpibU5J0wRuv6ouXhRECh/hpvyBVd+D+rYp33EJSK1+oJ9MbNHRJ8x0HebHJakcAlFmwTQqN+guAfhU55m79gvViYCT+jvBOXUoGu/KY/45xKUTSxPBuQoFPrq7ETDM+uu9LK1UndtLBRE5xSYqsxZLqbfpiAh8mO0gNXuHkgytGheNinDHGXEWir26JHRNqZOcpbqIEAGzWTMazn1YqhPXu9rzRZLjtJ5ut/00GgCtnZO3bi4c6247CWCmp82VxXrvIc9XmQxTjJ/j4h2/PqA9EJiUQhyWu2+A56tsEoWfSBhOrgMzc8O/uE8qkp0aZg78B+v6Hon1Vw7fI7kb+w2dldjCdfKDr8wOazSCIJTDickDNU0Hiet+IuQP+CWl3nS5fnH2CPOIA2mQfPcrkWEdY2xLMjC+IKJ9jnuEaij6QntoFn4V31JhnJAb7e1Tj/EoGKtKNoyhl43xc6ibVaZb9bdz6Q0LtLgYDBSbBlObff/0RQbJifqonoi7JOShksuwlkp4lUtl1rutik7W+Y1d0HTId3iFkxHwZl1FRZifiY6/dclegrGMU4JS33CLnu9fvrDg1Q99OFkIMQLh5c+ICYhsj3F5+rG4bHNjRB2PvV3L25QDwOBFT5F0qBTaBj0KIdecs2tiwbBJS01apmtVD0Mrk3fz/XE79DqjOd2/+fnlylB8CXGY8nDKe4k46ERoPj1xR5B1pnf3AVYTpcFChglicjuC3vXtgRMngx9DDlu4D7AT8Oj5pXJWLgi+PwUSL5PVtHepeZ8SHA+WzRa8xg1emxRoWl/tVREqI5R02FWQiryHTgg+ESDNsu1B0tV8WWBAOjevjPJ4uDpYiI6RAawlkE5TvE4INYyyce+idzqiXwssjE8686lZl9eFeQ13tlX2pDcB6QtiiApmm2+1bJcfrR9Yp2nIUmeJhN+2is3PjU7+YBodj3DJixh2ztAmF65HaPmcOtsPIdsOYNv9RmPvWPUeAVtuV9Rpa0xtlqSBdLWS4W8wDjVXDAOxqUuZBcGg58hUvQKFERkq8iWrGJlHB2BqDTjyVX5eP/nZna5MziZeXEUt2i4kIH2OaEl5mFoeS/zIqlXZeSVq3nf1am0GRbj8JhLVxDDrMaWifLg4h99OSBabNe0Qkxv3l1GG8vx8RQ1aQROEkwIHycIx0ULeSBcpz4qlv2NqZydTDKg== 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: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AujXROrE08zco085Y3r+tkGO7lKGPyraFpDQxciq6DqWUAKGaMqdhTBz0/rDEhv1kF4AlqWv/TTmhI/30l40CN/3oj/+RLuxKm5yAm32gbEtbnoanF3MFyGHLh9Fn/BCU6L4TAdw2nBwtVbVoZuMg6E7kE6g+gPCs7EHF4qtTVnXuqC2V3VbZ6FilTr2xhBX+8Jy7fCmJiRR1B8yF8zA+NO/kT3focdc+9pW15zNppLTnCMFG1rwzvr5oENFdF+LnD+MFOIEoW8YIYCmNajUFbSH2GcyIdRULc0j7BLf/Qy76GIgyntbZDIygR4kIlBaENQUQE58jV5DSpv2ZkLpXXijjuDElYWwvTR3WG05t3w7Nr2AArUcmNg047yXoft5xmcGIjVjNKIAnlMLiWBZfFC0YmSUMbsf1pQER6ELX2kI38Oc+G4NWy6sxaFyeVhV0SdP8Cp/vez4zyhIFdQp1qDk6vQ2/G/S7+aPGZ6nhDkY00j14QrUfYK1WZFBiXtn4SEq5VAKcryxkcBSh65EfW9shxN8fOysg7unvx3qoCdFeusBaUeLA5Pkh1jzmbiUiUQ9X4+qS1IJT42LunAYRHSk2ViR X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 690063c6-884d-463c-a301-08dc6da97f9e 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:54.0846 (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: Jflz+0+tGm1mbSDv12wxwrzU/afIrD4V0+eOAtZzwCpi+DvvF0aUpoci2jsNGh9mH3bza1fnY6AXQCy5+4LdoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7812 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240506_014958_067837_7786C0D9 X-CRM114-Status: GOOD ( 11.42 ) 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 There is no need to add lock in s_ctrl callback, it has been synchronized by the ctrl_handler's lock, otherwise it may led to deadlock if driver call v4l2_ctrl_s_ctrl(). Signed-off-by: Ming Qian --- v3 - move this patch from 3/3 to 2/3 to avoid confusion drivers/media/platform/amphion/vdec.c | 2 -- drivers/media/platform/amphion/venc.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c index a57f9f4f3b87..6a38a0fa0e2d 100644 --- a/drivers/media/platform/amphion/vdec.c +++ b/drivers/media/platform/amphion/vdec.c @@ -195,7 +195,6 @@ static int vdec_op_s_ctrl(struct v4l2_ctrl *ctrl) struct vdec_t *vdec = inst->priv; int ret = 0; - vpu_inst_lock(inst); switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE: vdec->params.display_delay_enable = ctrl->val; @@ -207,7 +206,6 @@ static int vdec_op_s_ctrl(struct v4l2_ctrl *ctrl) ret = -EINVAL; break; } - vpu_inst_unlock(inst); return ret; } diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c index 4eb57d793a9c..16ed4d21519c 100644 --- a/drivers/media/platform/amphion/venc.c +++ b/drivers/media/platform/amphion/venc.c @@ -518,7 +518,6 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) struct venc_t *venc = inst->priv; int ret = 0; - vpu_inst_lock(inst); switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_H264_PROFILE: venc->params.profile = ctrl->val; @@ -579,7 +578,6 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) ret = -EINVAL; break; } - vpu_inst_unlock(inst); return ret; } From patchwork Mon May 6 08:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13655167 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 40542C4345F for ; Mon, 6 May 2024 08:50:21 +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=BeqDwbXTgiDy+aghzcer3P/cn6RiFo49lMlzYwB1jNI=; b=B9+r6gpg4hsGG7 doIVk5MtVmXh9HpXfubZ1xk1bxyV2BirrNordvV4t1u3ElqqKQMVG30XmB6hJyvM4K7VKh4DCRHe/ u249YukqEuDTeXmC073+o/Ru7j+ZrAk/QVr5YhkX4+zWnY7KSgNNeJECDXL8VLkX9roz/dWCJ2TYR RPFzJT8bBh2TyY01IjeTRJAoN3Ei/UfMPFpEr5UrzgJVfdAgjA47g4U5zDcljZ7+9w9jKCEjOy+X7 ejMHVb5tFHp0WHKXTHp1rw3zhA4xZbnpAl8CttGXmjUesJ6SJO6cwWlJh5MxfZGb3qqwnxDhq27DF s3tj5O8vu8OnO9hbtE8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s3u2x-00000006hOm-2T4t; Mon, 06 May 2024 08:50:07 +0000 Received: from mail-db3eur04on0613.outbound.protection.outlook.com ([2a01:111:f400:fe0c::613] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s3u2u-00000006hLk-3Bis for linux-arm-kernel@lists.infradead.org; Mon, 06 May 2024 08:50:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jPH/uXmkbjw4Wf5Nj9qR53zEbTsm/awhPEONI0lvECsRQlxGY9OLJI68sFfe2tTvP/shwWDI9bsNG19s71phf7+Jb1a+bdHouJWkHzTMG0mrG69SynmC/gjaaCnH1k7tu6EA8ZBhry8f1uPvbSpzDB0U8h/K7HOBuKIZJc+lHa9uj0qNekWdvg18HAwffqA5VenMv1d2qAYzjEdhiQmYO1/MJpwjMetyK5jxsDcNE0Iz23zN+r6wuCAeLl9EBjWQCJRssN/e5/097ABJGNAoNdn2LRMmXLDTGqBlVqjgrmPFK7WRNJqfyDBzrNnGm7LJTMtdTQBUP6MoVVwFR8xBSA== 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=a1IykQN+7zxh/rSx1K34XsiQKrkUGKubvULsgDaJIm4=; b=hTHKQIcz5u+kJgabhFwIEeBELOCE2MPt6uTvA3rKuQqAx6iH2fH8BxHaEibpgWgSQiy6VrzaWmLF9bA5MSm8sYQNp6FlprQyPjYwz9zSWtD/P7aF+gyJGceWihIyUFyR8UkMgZbnRlGhY/v4i4y2aAaOlx8IMSkKzazGDxny5Q903Q/5rbvNiMcFNAvMkXmLvzijmG08vPxrcR/AxWELGCqyeYIzZsR+kVItbp185xYcuU5hbXahSzkffSEq20fboI+fRMg2DE+H36XuKoEWP9BLvV+VsJcDAd37H9+77mTvfyeL1oM9GF15KduSxru85377oQ835a8fuGAGpt332g== 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=a1IykQN+7zxh/rSx1K34XsiQKrkUGKubvULsgDaJIm4=; b=WkgTHzhh3+2N8xFYvbnOpFbcj8RQtD7BsATsObRgWq2UFpJvAosX2sFDLU4pRN3+W20+D0BrCwvuLDQ9QfielwEGCT50ju1Ijl8qEj2xuSRu/LdHXZ0U0UNcYbpc6wWV4NxqlUpA70oX/GcVmk66DH/FjeqcPv99G24CGb1Fcn4= 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:59 +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:59 +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 3/3] media: amphion: Report the average QP of current encoded frame Date: Mon, 6 May 2024 17:49:18 +0900 Message-ID: <20240506084918.799544-3-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20240506084918.799544-1-ming.qian@nxp.com> References: <20240506084918.799544-1-ming.qian@nxp.com> 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: 126284e8-b5e9-446f-a527-08dc6da98300 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: MtJafDPqbJrzqdbGElyheUgrDQ0Mn03bKBXFtwIkeXbvC3hkZTRIiNl82dfaxoDQbKOP3/sor8w3Ie7Tfjji8tId1eHq6Hr2egi02z02xUhiULCzdGODyLwKCrnfcQi9rhALC1cistNxfBIQt68RcXW4PcRnMmTtJqctMehs+1qOdPdBIIuOp9eJ1qGJoG11bVL/gW3q9pQe9t+5f5bm5U9l+Xx0fho01goHnh51kHI0FKVKjvToCzFiQBjcEdvrr58itJwJVgWnyoHR/w2Lq98c6OFHIto6AAHfcjCuf3sPyDgavfqDBbGEsTDzqwRqxUI4CtBGbrwjs6KrBdu+XusU4kfVc7Ycddc10tH7BFLVCVErzZFhJ4p7HH2mTuVjocwapojrem4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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: Ta4tvBo71BF9YEGLLNz4ZOrzX54dYQ1tSQBPR1pv1UWR4m1ZfIgBqLaB8H1lh3/4dEwO6SBiZglum+iWALCM/m4iOPcVunZdgtLSvivDoEHgDLiC5+yK/n5Y+imufShDat+h7noBk7vWJEfQtjqxYaY7ksIv4dWwX10qawjIk1OHNAuMvZKS+Hvyt45eIIL8c4AEUlAwk0REvzdSplsmK/hZm8gYeMxOHZLJOl7BQs1mwf2kGhDYg8to0qbRmj99sSuzpUIOYTQT0+XJ1caw+yuB4DWXyto09kHNsSXOs2dUaKkPo24jHyNk36fvYv26BtD/OTi5wj3q7+iUZzVP/LUZVASxqn94mlZ66OY75GFlQCD5ZaKxFAOZgc5OjE19q8Ekx5cc04MAtOMZlc7rh+a+Ohqsa95Y1AnJ2LVXDIYdQwt0w/WsInQX7M0eW8tgicVsk1S1zaYQoy/FoX8EvUipgMWLgGqL63FlHl2PDn+QAEgJXuEsk6TwvQUrIxoMtNPwB4aeWTdzRRT8GoNcc1QSSCHNLuoJEfSNhnUqU3fIXZeMooKq3A9Af53Qp92tF3cK8lyQptrUm1PJOMFVjZaSr+CKbI4dZqiIEXVdTyuDoqk7sHHhLdXPFg5LBK5EEm/2vTADFDmIz5QMidxIQWgpX/lzzdx9jNY8KiOP0YKQCSVpd5b1hzIjlpQWWGDnfk7GNbZtXZ3MMscvBsbh0FV+t+UrZ4pmaATRxEPa0lUdazfeiJTB0iJgMLQB8TWPHnh4O1MKOUg+sW5SheF66qaAwlOb5Sv0HVUpKJEA5MOEoU91Zk8vAWEwNTibuY8+vgBPdkAp3zZC/kpdKUGkMc7qK/rs0uKtPlz0WcyKU357cKR2DJmiX9gNWeU/VUsqJwWMYLIHPx+b9zHnAJxpSSNHwIVFIS9pDh5Ld4X11BggS+UyLAdUM+LPqJz2d9s+bNBVo7akebssyAE5Y/GKpAnCDjAI5sL8LwXvKE8in62srFva3p/ChNRRpBE8DENqlaZpPNNOirUC9nPB4meHm0rQtXh7QD4QzUU7HS1d8C5ZH6vU6LhvqjEdfAeFAssVB2sBbwRu/xWDCwnQDfuD71KBwfjuV39sTorq/CqAGUL9axJs510fB/6mUpEYHpN6Rf5uyujwhkP1SvPQ+FbzZ+9evJWkadcmL8zU0JR2Lo5Yf189Tgu8zvJUr0AGy/SDNU194CIxIhvdqdHP+Pd5XDlskwPm4gOD75KWGOfsGz3NJRz+K05bsPYWZLJFpJCkXpOIofiziuy465jxA5QqaS/yuONp6jvxHQPGvn8JmlNmCQW3BYslkoctyorOYpZL3U9dPmEMGgdR1i/3znZ56s/3cPw7W4ga/5ZeZQ5iHJ4oEFd2gBvIs3XJskQrKJ65SsSE/xiYT8uxfH/nGrOl9cVu0YpN9m30n8EZYiPJ9C5G5BAEoTbAxnTdiec7J1k0lNrvMcQvOR44H9FXqMuINp8F7idnSQSgYcD105feHbI49cmV7udoRcbUZyUBCRwHc0KJQi1v5awRCpp7er9xoLG0EDnc66MEm0o8gd5Ut9t0BBAANN27bCQ/IW2dLpJ1 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 126284e8-b5e9-446f-a527-08dc6da98300 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:59.6660 (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: X8TgrOg8eo8Jg76T5v0UgtSeyDyB7F6OSxQkypLcBDCXYA/j6uUb6GdpxzEOsqVIqhFSQbQa72W0M/qNVMQGRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7812 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240506_015004_847146_1A1A804B X-CRM114-Status: GOOD ( 14.29 ) 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, the value applies to the last dequeued capture buffer. Signed-off-by: Ming Qian --- v3 - adjust patch order v2 - drop the volatile flag drivers/media/platform/amphion/venc.c | 4 ++++ drivers/media/platform/amphion/vpu.h | 1 + drivers/media/platform/amphion/vpu_defs.h | 1 + drivers/media/platform/amphion/vpu_v4l2.c | 16 ++++++++++++++++ drivers/media/platform/amphion/vpu_v4l2.h | 1 + drivers/media/platform/amphion/vpu_windsor.c | 2 ++ 6 files changed, 25 insertions(+) diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c index 16ed4d21519c..351b4edc8742 100644 --- a/drivers/media/platform/amphion/venc.c +++ b/drivers/media/platform/amphion/venc.c @@ -678,6 +678,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, NULL, + 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); @@ -817,6 +820,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..22f0da26ccec 100644 --- a/drivers/media/platform/amphion/vpu.h +++ b/drivers/media/platform/amphion/vpu.h @@ -306,6 +306,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_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c index c88738e8fff7..83db57bc80b7 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); @@ -539,6 +546,15 @@ static void vpu_vb2_buf_finish(struct vb2_buffer *vb) struct vpu_inst *inst = vb2_get_drv_priv(vb->vb2_queue); struct vb2_queue *q = vb->vb2_queue; + if (V4L2_TYPE_IS_CAPTURE(vb->type)) { + struct vpu_vb2_buffer *vpu_buf = to_vpu_vb2_buffer(vbuf); + struct v4l2_ctrl *ctrl = v4l2_ctrl_find(&inst->ctrl_handler, + V4L2_CID_MPEG_VIDEO_AVERAGE_QP); + + if (ctrl) + v4l2_ctrl_s_ctrl(ctrl, 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)