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: 13642891 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2053.outbound.protection.outlook.com [40.107.8.53]) (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 6D2895A0FE; Thu, 25 Apr 2024 06:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714027844; cv=fail; b=TQ9WfVkHi8mdhuMNJ7kF7GTpfV77LgfR/1JmFeVI8VkuACKx6B9cKbo1eQ67SH4O9is1cn4sNebBAeu56D5OPndbCDeX91ZEYqy4cUjlxOo7ao5yxJnUMi2z7QfRybBDm0HztkmU4dxrdsr512Hvv/pEEfwKHHxbruugf6lFZ0U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714027844; c=relaxed/simple; bh=PCh2y4lk9VdXFUYXgfFqT0jif/eN/c7URkk9y9K1NGE=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=Q7gIjhXPunuG1ioa5Xm2O14YlaeVC/oD9uYERtdZJeKivvxo0/f0OYFQmNk8ZwLihn7X37HYmxTgNHgeiygYBYxzdlqRrPBD+Wp4IJ9Y0O/Y8qQdfPztF/dcoGvZ+MWqPAwYTxLJ79kv8Noj3GvjuqUdSl9gTc9k5aWoLVRIB0c= 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.8.53 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: linux-media@vger.kernel.org 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-M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sgqgZQ/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) From patchwork Thu Apr 25 06:50:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13642892 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2053.outbound.protection.outlook.com [40.107.8.53]) (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 A77C45A11D; Thu, 25 Apr 2024 06:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714027846; cv=fail; b=p7BCRkvbx+Gm4M21WUTbG9CLKzBXh5gJ4evcv0Yg5PgYtW3hLzJIXGg9O6Fes3UEUh1VZHUL/yis9bS2JIaoE1Ud/eWCGvUPd5cN4gb5hkHCvxs2sH57ms+m9iym0MVLckbAv/cx/ovnqwYkvYTZErkeUrltIZjRyJvXB2tssfM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714027846; c=relaxed/simple; bh=mmU+zePcFxn/lN3MmcMQNqBG4EyBouGvTCjErT7lQyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=fb4WHqyXfaoMGYM+lv+dm63mvSFUIEaV3wj+YR0lTBTLUSzMXAQMZ3K1vwEfxl9DlG2Cw2/0ZvzTf5khZHA2D+lCHpS89EBEUO553+5BRJZhbgYmEIJ8zG/3oMZXrHTKICo8SeK2z5Q5jEAXR/UGROiR9fFfa4HfOS1us7H0miY= 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=r02bg8/2; arc=fail smtp.client-ip=40.107.8.53 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="r02bg8/2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kdHi1qMrrDbKZP1sDKeuKiSyJfTK+HeOJ9ncFPCgnKZI76NbPNjJfOciVHMbkEW+YFl8RLGVDHRuhx6G/WZ2M20TEaUnLG9+2ZRfAgVbPIqD4dwSXWlIYjLeY4dawNqPqNbh5fZU6pxWPYpOQa2ioL2wWVM/2rVcWSwit4LQTFNN3fV0XN5udIRJIqx3xXWopZrUuBR7E0mumsMFm1xEG/te6nBVwk1a8j0I08ssL0R1Af+yeBoZYrz5rqd5dlhiiNCt9NkT+1Vxcm2Lw5hu2QI+7nSnl7Xud4nuUsHMbdMoFisemHQVoeqpJwYWHbgDP7Etfn/XbKyXqC5oqbIcsA== 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=i0noLQq/4KoXdHGux6YiTKEv0yPUugR/8h3uespzAVc=; b=BRvJdfSbmKk2dGmF3lPgTxTh45uo72adDOgsK6VI0+tmOmuzo3yM5lP6Q5Ec+8iH12pwh2Yzge/dk1/82VlOFWnQoblIOR1YjFyCdkDQv8wxmAsKJZUUHfCdYq4ugaOMcjHUsEoj0jfvKNlB/GpqemJkyGAk5EEOD0gXYbDXFF9BFXvTVt1FM0BwJd4be/KoiX+ipF/k/YKeGgDa5LjB7hYFJH9Mp+F6a1g8WLFDOtwFSL+zd/GVvwSXbBLQGWQgB6K3bgFN0EOnHkxSMFjbOvogbdhekkNyW23713QLmErDPTv7h7F5xi7F16B+58J6xbifcoKww5cdw/2oabvQlw== 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=i0noLQq/4KoXdHGux6YiTKEv0yPUugR/8h3uespzAVc=; b=r02bg8/2C883uGMYEQSqX+/fzU1dBfISaa/O79ES2VDM8UB2YSxCyhrxXSM8u1cn5a9ZaWRpzbRbCGqxAXF749Rv7AMnpeVzPaCWDAiEns+1k9TjLOO3Im3JRAoY7t99sU4lAVr46paK8imBbOTr0y5Ll6DtwgXK9jI312z5BJ8= 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:40 +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:40 +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 2/3] media: amphion: Report the average QP of current encoded frame Date: Thu, 25 Apr 2024 15:50:10 +0900 Message-ID: <20240425065011.105915-2-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20240425065011.105915-1-ming.qian@nxp.com> References: <20240425065011.105915-1-ming.qian@nxp.com> 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: linux-media@vger.kernel.org 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: aba0c73d-e875-4e67-0f5e-08dc64f404fb 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: Ofq/ajAIPpYBZg/4Hv4+V+v2Cpowy85Z0siiqHoQaFcue4ZSrwmI7ZAx6UtNtW3i2NbIBTG3aOxXf1t2LFmr5Oyc4maEIE+vbRQpbvvVyiKbHcGCXEFNnc7cDsNvnxw4wtI6feJAgEadU4QsrVAdwU92rjHk2liOY4HcrA7s87kuf3aDQU9RNqqpmmxl4ASIzYmreVy6dwJC5hUGQAPTKKFBW5zEP9DHjlJ5H7rI6JVHVJHHWkxkkLOtFB4b/5Zq6FH8ZjSXhr7JyioOhTQJZTTdISvFhb3qSZ14nHUwxNWBhR6BoTh+ZrraNWlUvxnJfQ2cLmeQKcRxP0LlRjgHR1aSgTsPBZ7bIzZPqv6RwZvNtKhXiFzqlYqVb3+9oa0ukVvdBKnsetTKs1E2TGHrD30t8zFLxap212ntdoUoHBQqo3ohBkRHgBXaD1a2H9tKcCjjLGtoM7xl8ECCkbpiY+11xxs2r2II4eGSj0cDNnpf14mPmXqjt0bWyNAK15xz6qgUDPqbJheBCg7LBu0NoZZLU40EjoGjSlSToXwuOkq0gUlCswxyRiMAF8ZqnJurjg5aVS/7uzmbsVZaGcfj18Gx+P0PNDHFOJTvwEfZYEAeP0KkWw5R+WFqVWF3gr4LDFJWXseAok/Pk1A1XpDQvTIXWDPW3CAByUdFX8Dyvmr7GBKqk2JmqGk4FTeGV9vo4g+Sm8zOxE3OEg8MMfarWl1xABLWXOoEHnHLI/Ko1Oagdtpngt85/v03KawjEiYSOwHw8zE25Ghu60f44vJNk+B3WlGytmPfbqigobyMm+dS4a8tPbfZYAfzF2WzCTHjLW8mtXi/GWFp+gNZTeJQSJ1KEBmv9JDKrUgXOMwjvNj0cjFppr4xHBzvOLGxxSD7IiU0jmyA2uy0AnkALgCXgm96tsFKOKJ+vob/yd8iNavS8lKN4gs+b9bgCBZpY13iyhwzHIvh6BFlYm2pV27syv+jDF8JmEo0bi4MRg0ThCCrDdeTfqzg7TeE1Sh817KtAEyNhSnEDLJv/jjAnAKNn0HNdon/rk6yspbXE0rT/r25O4hLRlV8EH7Tq8taRy/neDMXwdSFRuQuIwLFRgB/zmuqYrEIxgw+wU48sdktGdsmG6hlp6v+HyV2rGZYnhaRVr/NC/5J/CjSsYSx00EMi1/xzbX5qGB+OP5m0E5qDsysxaIa+urWqLzHk9ttfyA2UATGnKnRVf1YbuDJxIan2iH033NAUyZhN/8YFrS+JNOjssZ5wWH5t9iwKeoBaU2gr+bUTpnmbsp2ZDeg5W+20SCIfyaJUh1MJK9ahFafieWR6TORsv2hu3ZU9tSElSOasyUxw0rhhDvawhWjfIeJ2Q== 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: +aI73CGegqJ08xGflU/eQJ14I2H9/Z2rd1ThRoYSaBnbYregdOnJdjRc/a9pD8miyVnoaY6suKXt+RXjyyrx44jR6U9cYGXYoBUNrA6XQujXQm/DsNHeYPUTTU2mHAPOoFMPXtqDqeeJ6Rnt0inDg1Bl7dH1gVexON7pjR6ZhaBp/DMSl0v10lmCCJrw6QO0jsT/aEnLehJ2ziLlQ7YBCxuoBubyGiy1PVLfvGvF0F5ZEGbZz7YG5ApgkX5T7LL6vQTJZesTEVbdAY9f8KShoieYghBoJz6HuEsJ6xO5OCDw7o+DVeVL3iqOj2/CVU2Ic2N6+oz2y65na8TLrLkbsJLhUBQnAexO8cf37Qwftsp7qxZlmZ1VIQPXZuVFpCNlePe7extfsrbv4EtiEUSqBb8o6wm7MX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V48YwgQbLl+9fWNXZjCkf3x4QRTbohXXgZDv/rGyPHTpjJ29DaWuMWVsYYDW6VicAo7OqaXscyrzxtcUvzHUkugN6XapDEEu/sbQcspfvBUY X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aba0c73d-e875-4e67-0f5e-08dc64f404fb 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:39.9927 (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: EPuDYc4seZGbU98uf9sPSYxZABeA3rzT7jt5m+mLcBKMOIOiTBFtqnTvBGv4RYXZavDECCmaYSBYWPAg372l/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9200 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 --- 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 4eb57d793a9c..cdfaba9d107b 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, 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); @@ -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..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) From patchwork Thu Apr 25 06:50:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13642893 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2054.outbound.protection.outlook.com [40.107.8.54]) (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 650DC6BFD4; Thu, 25 Apr 2024 06:50:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714027850; cv=fail; b=cPcFCr/dmXdCfCWw9A3VXo/J82Su5hwuih0j+/H9oOnBJMEepa8h7+QBS2R2ovEnkIiiMpnuHDWBs7py3dNpnX2H6A8/GEJr5oVl170bzu32R4oRhrMowx2XOHfpFF0b+5QncyLPJWBCIKaDYYKNLjZH8h+iHSt9JSKk7BUQZLg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714027850; c=relaxed/simple; bh=D30yGpPmVgCnnlBDsy0nJXeTSgQ6INrC94CaUA36n0o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ag/cjIqZwmRKg4sKdhoXWqVdZtvdbH61RqbA5CqimQP7YzL9trSWcRN1k8RsRQd8aj/dBwp6ZpG9o3oqgAvz3eZP5PfkipfH2+fOeECmVXWxWz8T7QsidRWVX64lWfdRLa3fSNfneucNLAiNKstzq4wJKusD3qvCffatz60qO9s= 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=gWwwiK0x; arc=fail smtp.client-ip=40.107.8.54 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="gWwwiK0x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cTik1O3MCohT2OM5ecup19PJnKIrM/CinijtilC+9pjE6jBloAWwZgTJou028ej9ffsl99rXmSc9TpnM8NmxUS++Hb+k705N25Tp5j6VSzTBCnzXhbU7ZBxgCJeuWGP7wMw10gguVi1Y8qkTwPDe7otA/j73RDfTvVyoQkV5Y+/uI+SytnN2qW4Frg+BVsZEzb7uAXaDx3pXZUr7AaSizbvKfiayYh5GGFnJQL71aVa3HHnnzhhLV9hy1WMh+zrvlv2MMcOOfEGu4LQRD918FUjF8b+FHL1SdyP1+cJheN3CV0og2ZBuD5P15FXuSzoGKt8X+x80evkq/6qi/W15zQ== 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=vKO7USvgcRpf8ZtjOwhMKho+dhIGOBV2S4yWRg0mIdQ=; b=B7kGdkmuU1ytlAQsy6KTM3Iegy0Rx/fVkrXDym6eeJpWyiecHWSDy5mu7fcL6bU+AXgVDDSu5r5PCarIOmn5KLIvnsRFqSq/C3cOekGPvUYIlqwQcRztEP6YKW3fHx80ScVRpUPL44SaCcvBcKgKbkACi/OSI/1+8WC1Hjnt0H4wE3t0EVqk0zRDysn1jwQbuoE4azOQeuEipbbS5fwPYvTeU/ZyS0coG1IsRydwRsxO34nnk+KyHu1XfBDkweP8ujDCPg+dtoZTQ/BGtHkyFTy9LEgCckI/3pWq1lhDS82ZnAzKYlsV8PEaOIaMKTNUSS2kjBgX8IQt214vgwtI2g== 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=vKO7USvgcRpf8ZtjOwhMKho+dhIGOBV2S4yWRg0mIdQ=; b=gWwwiK0xv3q1OpYzfviqeIQxRFMG52BEqZDOBlfKGr/BNiuqQ59pxDedBhwdeQBA12es+8sABiUGCp/96bIYK0IvzYiLOkjOC4ItTN3ZIg+38TAl4luVFMSe5YE0CRSD1gC1FkCtvG4CTAZbSxb88Nf096f4xNb5h5ruRDSwVjg= 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 DBBPR04MB7564.eurprd04.prod.outlook.com (2603:10a6:10:1f7::5) 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:45 +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:44 +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 3/3] media: amphion: Remove lock in s_ctrl callback Date: Thu, 25 Apr 2024 15:50:11 +0900 Message-ID: <20240425065011.105915-3-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20240425065011.105915-1-ming.qian@nxp.com> References: <20240425065011.105915-1-ming.qian@nxp.com> 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: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|DBBPR04MB7564:EE_ X-MS-Office365-Filtering-Correlation-Id: 69330978-63b0-474d-919b-08dc64f407e9 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: HhqIhHaTA3hhTyr0Jkf++OuXmaBB9c+cbiBk8XC0pxgSEVIwVJotDb9DWYOMeZeWyaQPqnSi/7zrhc86c1iJFJB39M0J9z5BHCBMzqS+pHTGlz4BuAavKSB0FA6kaSvEIjsj2fg1B38kxSVldkt0vv75VkDyP17XudMwqual8rIdN8AGV8ZqGAFkr9vFwUdKI7srx71VMF8BCy90xwicU6r3yMyTHNgM5twDIQRTguiaX7wB+r9sZ96MHw5c5BVc4Q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3pMdGsTbBVUSJ3BYnSzpI4YSE6c5o+t1vg== 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: doSxjQKkZGZq18Y98sAjyxEuonUECT7u19kWVzzl3cvRYto/6oUi2uT5tkRc3ntS7mjhZvgZjtSt5E/U0GiKnjMGnH5Kwy8V/FmRXFkEPc8kS0f5q/mZwAFpXsygYCW1IdfgwrWhrf2U6R2tlj9pm1C+LlqGPhFs7qLauT/oyr+Do3GijHCwELljnRFOB3OV0mtYCc7mMpsJSulE2s8+yU3CoeCNXZQ24TlBk9XAWoK+WKXaHzO8UNsQFcWBtioQGXqdcN6s33Z6awgT+Dvzrom8HSe6nnnjDoXTd4hLe4ncs0tRWSGBrrNs92phYZwDUgYWli2LgUvh6MJfmCE2fE3+CY+aVKPER3zUkRJvXn/8OMhi8IzanC5fR5dOSgPtdcwr8/xKsGaXPCzR2hwbP4xiwWY5tqZE2/B/cbpO1wBllu7AmA2fs9U4DaoccJONX1tS/BSuabv7uVKlmDEa0uYEK0nXDSRLAjue8tZdTCk3iSE7Jj/JIr1SFFDbR//l4ndrnkF/laJf5qigk5zCoTbAIq2dq8p3cIBjEoxi3EefVXtzCi9uSNQMfky8zQwafQeAsKPQYtBM3UQzQWqOY8LMFWxrDEDveop9Ht0Xp4YS3LbkV8Nbl2vr1tVD8AJAE1vk/xOYv02nbVlrDPMBVVfQrmXyHhbiCrmSsAvxQvzvcVZr75sOSJRURoKtcFJ9Kt478ORsuITeBlrCA+4Mok+snMBgy/OYPj9jp/FsN/FwfEi6iBtg/xw/wkfpHVkzhFRtwj0rjkxQVw8pS0SiuKmlap5gcGEwbnREPEJW8ij+V0j1dJl33HSRAj857fU65woA8o3rNdSTxUTdBi2S4lRUbyzbwm1c1ghOpdgnArWfa5Pire49gUvhCtbaJUnxU6kBSDcd3BamkhY1a2nbq0+wrdD0vjWTr5n0Rdrjf/qcJev49+H/HvBKonkRoToqpZKu6hhy+u7mgpO9LD/BJg5KC9/JWWSgiJ5CWrh5uTJT5bKXqvK1h6KSSvycaWnGoeGUanqwpyhwGDq8YijM91VPKJLIH2H8eGblRUMHleystIzhaTvxhSZHhthNAniT42bTKausvBAAMe82cewTAxD5ecM4urtdmQ7TLaiW73POWuT0ZktdvgcCbwYc81tpu9fFBZAhOhNzv1n9KOyJ/ahd1xa3ZvihJXE55eXbj6KIiYHRHlnE9+RitJOLozTHgWmefdleFEwjd3S7W05VZxzDQGmFUdDkNW3uZVC1dFfEpKg6IblNdIJVMUylS8ObqqLwWZKbv8F+bHG/p53LVg37++xWt/LF4UbOM7vY6UHdifXYYmPcJ9QIc28sNXBvHJv0gzCIF4kAmJC4vUuRHZTUzB7MqKUOS7HY3YMx/Wxk4ICxiqARHNSdkoVA3CuPMKQyANY+SpoLmGwkYVvtYYG4l0x/s38oboKpwIa+LNFiWBYWDon369swaOqu2zMbXJ9AVaznB8BwnBFc+7qXn7bQfohzRepY+IrPdEUBKwMrhLn1Di7ILQCtS965EjblmpUzPQukFGkUN+ulsR2IWSmmVy9KIP+0Yn24dlHrZTtriY9qUUmANniAcEfDqJep X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69330978-63b0-474d-919b-08dc64f407e9 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:44.8871 (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: KNDMdHRUTm4vGvbJ0xhqrfmaoNUVXyYGK0KH3HjvBotEulBCsWyAC2aZS2uK179lbb/RBHnSHzsiXW4UmNLuCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7564 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 --- 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 cdfaba9d107b..351b4edc8742 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; }