From patchwork Tue Apr 1 09:06:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ming Qian(OSS)" X-Patchwork-Id: 14034528 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013050.outbound.protection.outlook.com [52.101.67.50]) (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 6A0B01E1A16; Tue, 1 Apr 2025 09:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743498483; cv=fail; b=mcH6OzPS+8uT+Zv2ToEqqppNo6OD04OfjxSOT9KVGN+SwNrikOC2XoeVzUkNS0YW9Hc1AZ7JBpXY4e8F3jrqjAB/X/g8b3OrO2G+XG1qERoYPyJcguLVfxdcLf3E7YDCne8h/OejeHUWc/UbtB2sO2YDi48FE8y/LUaCjlyp4zc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743498483; c=relaxed/simple; bh=Qb5irVb/Kz5XA+aHPUEOdtPFJyyP6AL7zllEv/252gY=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=S7okw7Skmel5tFpRwGn0beNOw4gYUHwl/MjOLg4sm9juMOCV9NOZg5d2fk55NphuCDHdujxqDYsSJloqPH+rbRgg4favwryV5IoqPDt5WPEq3Tj6lbwPBZj2tzPkoN0JHxTh9kWKz8vesavqZWO93v2amfUVGQNNhymIyl70VgA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=aen0pOH+; arc=fail smtp.client-ip=52.101.67.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="aen0pOH+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uUUMFeHJdYt90Ir+DED0ZQYebN8UARZnkcLhfRwyJqfgYtGI2lWWoc/V3Cm6OvmUFMacqEKYjG5dy21lF4u0M4R7eFPB574ehI2KHsX7Z2Gm2pVTakgll09OKWUEXC2+4gJ8x2/wXOH6+UOFrYMpavoYmNHX30gSdvP30n9Bl+c0cTuXNUIRm4tuDXwPapf5EM6zmTJizyTxzwY7PjEKOu/Mcr8i+V0h4dxuZbRP/uPUDDoZZj163LBPZcAjUwWP5yirhXlj/f95J+r1TFpPGJwRLPgKtJxxmvgkRaR0m0l8p0AZ3e7ZYN0ZRl+K0dyZuf1enE3gWlz1z51dj9zPWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=tjpFCeE8U/vA4Im1GvKDEDAWyr0Faam67XP/kLqCcXc=; b=sVx8FunAm4frbCObWYTHDnVgxK5GQ+KNdBL2KegT8zA4q+0qhneUVB+TZqa205nddmtUYyeqRxvqmd2nosJevvXSeX6n68vQ+p8ILUvBR+HKRMJg7uFHyIwWRqDMNAZ9PvZ9xdQh4QVIeDiImAH+/B+5eD7pV8PBdgwCX6+AjhIsMawSL5rThKkbHGO2mUThOAMckS+B9xmuomqSWoyy+QzvbIK3FGAbgdgkoPpvmofzMr11kLg9eAnxAQkcCRA8tyaZ5k4qEjkFmF8gG7HBbXQdot/OMpgF4wK75xOiaKVaz5WSsjUfB8ES2ZoX2Fnx4aM3V+GLdW1cacJ0TTq48A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tjpFCeE8U/vA4Im1GvKDEDAWyr0Faam67XP/kLqCcXc=; b=aen0pOH+gGri5uT0Et5U1KcTGRjPh3XrW5kopC/9daxgWL0Aau3Pv4A9SbpOgXxKc800tJ7RBr7G0UYg8B16cnnCvvLI5lNltEKDbaQaLvBRr7JdkryFyXnQ+mnbaJkdQCXUNj3r59zOiR5M+0nw6EdkcUkWp5EygsPOII7W+n0ajS062QBzbBdHpUIxShiL8xZvKwYtyP13nQaHHmOBRiatrGkhFNeDO0fgL0G1Wf1sI9LYpws8YWYQmIJ5UFyxZa5EKmvi0eA86hCQ9RqR8LAxc+OjozMQ/CNG1YVQ1Wm9fnDdmY+vtUHOqoWncXtDDzVcJOJaH3baw5jiMvRkAg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AM9PR04MB7491.eurprd04.prod.outlook.com (2603:10a6:20b:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 09:07:57 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%4]) with mapi id 15.20.8534.052; Tue, 1 Apr 2025 09:07:57 +0000 From: ming.qian@oss.nxp.com To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: nicolas@ndufresne.ca, sebastian.fricke@collabora.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, eagle.zhou@nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 1/2] media: amphion: Reduce decoding latency for HEVC decoder Date: Tue, 1 Apr 2025 17:06:56 +0800 Message-ID: <20250401090659.1702-1-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.48.1.windows.1 X-ClientProxiedBy: SG2PR04CA0153.apcprd04.prod.outlook.com (2603:1096:4::15) 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-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AM9PR04MB7491:EE_ X-MS-Office365-Filtering-Correlation-Id: 781b24b3-7cd5-43a0-dcad-08dd70fcb1af X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: +MfDk65ardQHGtBdaKKWLDtssQ55eKXUSAlYDpSfV03xTe17KdihSA8LE7E/DSOCb416zXo9QKFSZ20CdosSmNKvOqnWdgI8TTIhficjxiG/ykkDhriDQpO0swKJErGV8ZdrNUKGt4BG+uYk0bFRA9ZIdS/GbYVLNb+dSl0MYp963FoF46xiKUVB0N8+Fzqa8LVX7VW9Ul9LHysOHx7Fz4a407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FJjIc2S22JKbFHLI7DcY+DWaXXI91KsANLGs15ntoJvUbOyH+VTqQvO5msW8z664ZQwDFrs/DJKYtUhjd4B3EamOG3ZSOZEz34Yb/0qP79XjvP0HkRMhjvcmE8CtWxiNCxHtWTEVLh+PtOGcd8V9OWhLbPCD6peckDBtAnKJPe/v5VargzYvJV 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:(13230040)(7416014)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h5WhZxh74TV7U9TzdA/vFHHwgSseayP1CrgoZ0hoJfhVjn/w3gTwwHEn7JBFwTIgJMdNupxJMgpEw5rIQZsr1vhsDoP21bGWCvtbkFRXbJuiOUeItrvofGJXHGQFxpx39Uv1rQC1yOI7VEtgAC3L45MGvOyqZBXrPNN/YedaQL9yHgBCoswCaJcHfYePidxymHIfIc2vIz7Tfdr4yE6JHkXBdKOMH1d5Nrqm9akISnZpQkjDm0cGkzlDgBUbUzyfc3yKvmgwGG87dFMc1aSjLPbbma1kzcjpMX+ILus3P27xDuQHRYJZ7M7gRtK4jSbakqGA9HvW103fAUKnrh4KPSw+ZToe7JXcJ/CLE4NCe5x7ayZ5d3XnOWscEPZp1IzXjDJKPl7ktmJZfmdrWA3IDsC6yhA+AnpWoHWUt5JQwu7ZFFLPHwvpA2uTwEMDjlHAULJ2UPo7Dag8/BYNWASZAHt8WXfzYWlhOpv8Z0ZnxUxc+jNdkcxpTHAaI/sS+5jljLAS7AcTrGgPuxt2ehU906MCvgs96AkQlp38jR53DsdIxCKOix0uNeIa2t7Cw/RJ3VyXGvN+8ZyAVtiuoxs/59/DFoi5N+wNoVY1ThjZQG3fkMMducKDMJ4T+FRBN68BbKoalZaxTk9uCXn49OIupc1DW7KpEq0Bbx/ljog8IZf5ihOxRONwfjqryZ4BmXEwH2WB+ZUyfyenAoux2GSLtKxiLPkSx2RRWtaMJzCl0zpaS6D9kX5wGgmXxjl6ypK0R8wzMi6cxlU6D/ONVMiXJsEP7o7hogWxRgTAjmDW2mOA7PKHBXCFYB5SG3eWKfd1MT+ya/n0VRI5aekQo/f5ScrcxAHCHX6oJ7Cj5ApNfLJM8oPwLHcAnLNylCUOZj9xasyLUSYsu8Z7rCV1trBbQ19xzyj3SRGrr25w6naylNFI7CFmmmQDva9k4vrJb9BodOWEIPypOSL5HLEZ1aeE+QryohjkR9APTEEAfqsgfrH1d6slOSTIWiFd6afL7HwQxe68WO93YVU7HDfSvENv1i4HwrkjT0VgB8fQf0ml6dlGldS51xOxReFkG11muY0qC1289uLLtr9DbobVrDSZeB6nJK8dgbhl5/FuPaSE8PcLS53hobvRUmLwoLQwpArq+RAR+aFOpjBXxwNFnHeVw1YNpk34yHH2Ya3X9D1uYmSsceUMZv0Rbio2kClFfPckPL8KRUj9A16O/Qfd1PgQdfatpD6mrXZMWlRDvhrEQLjV9AbM43dHw9qpeJESZ37gW53GuBoxPLsyUp3MbKx4CsbIsjlJG2dQ3ZU9RQTI2fD7+9Sy3xxvRvKZTf872MPevRHNrIzFbRDTFuVqsXF2Nav3QWcQ49+eXpIo1+15Hzrbvd84+vHZf3D0ReBSYvXkRzietVoF8kpIDjmXNv1NtETf4Ku/C2aq6qQdggrfw6wnh9jB3VM/7CjzMMbuZvNJGeidazQgoZ2hauI4LZDknd2yyZhu4h/JO+zMCQaREOdawxGpdQhCn4tiSMlDpOnz72oEWFQ7xNm9mNtD3SMOf1WpVGeHzLDvRusQ2ci8SAhx94sX2thOpfGzqW+FkNSa X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 781b24b3-7cd5-43a0-dcad-08dd70fcb1af X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 09:07:57.4592 (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: pNBPU/nd4GxN6xG+Nh2C6/DP6ROp1rEgOp9sw22gFm3Gbp6sKqG8cTGtqMLi/x5Ljur92akXEym07wbsNmeDdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7491 From: Ming Qian The amphion decoder firmware supports a low latency flush mode for the HEVC format since v1.9.0. This feature, which is enabled when the display delay is set to 0, can help to reduce the decoding latency by appending some padding data to every frame. Signed-off-by: Ming Qian Reviewed-by: Nicolas Dufresne --- v6 - include bitfield.h v5 - Apply FIELD_PREP() and FIELD_GET() in CHECK_VERSION v4 - Add CHECK_VERSION macro v3 - Improve commit message as recommended v2 - Improve commit message - Add firmware version check drivers/media/platform/amphion/vpu_malone.c | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/amphion/vpu_malone.c b/drivers/media/platform/amphion/vpu_malone.c index 5c6b2a841b6f..112645b30e15 100644 --- a/drivers/media/platform/amphion/vpu_malone.c +++ b/drivers/media/platform/amphion/vpu_malone.c @@ -3,6 +3,7 @@ * Copyright 2020-2021 NXP */ +#include #include #include #include @@ -68,6 +69,12 @@ #define MALONE_DEC_FMT_RV_MASK BIT(21) +#define MALONE_VERSION_MASK 0xFFFFF +#define MALONE_VERSION(maj, min, inc) \ + (FIELD_PREP(0xF0000, maj) | FIELD_PREP(0xFF00, min) | FIELD_PREP(0xFF, inc)) +#define CHECK_VERSION(iface, maj, min) \ + (FIELD_GET(MALONE_VERSION_MASK, (iface)->fw_version) >= MALONE_VERSION(maj, min, 0)) + enum vpu_malone_stream_input_mode { INVALID_MODE = 0, FRAME_LVL, @@ -332,6 +339,8 @@ struct vpu_dec_ctrl { u32 buf_addr[VID_API_NUM_STREAMS]; }; +static const struct malone_padding_scode *get_padding_scode(u32 type, u32 fmt); + u32 vpu_malone_get_data_size(void) { return sizeof(struct vpu_dec_ctrl); @@ -654,9 +663,15 @@ static int vpu_malone_set_params(struct vpu_shared_addr *shared, hc->jpg[instance].jpg_mjpeg_interlaced = 0; } - hc->codec_param[instance].disp_imm = params->display_delay_enable ? 1 : 0; - if (malone_format != MALONE_FMT_AVC) + if (params->display_delay_enable && + get_padding_scode(SCODE_PADDING_BUFFLUSH, params->codec_format)) + hc->codec_param[instance].disp_imm = 1; + else hc->codec_param[instance].disp_imm = 0; + + if (params->codec_format == V4L2_PIX_FMT_HEVC && !CHECK_VERSION(iface, 1, 9)) + hc->codec_param[instance].disp_imm = 0; + hc->codec_param[instance].dbglog_enable = 0; iface->dbglog_desc.level = 0; @@ -1024,6 +1039,7 @@ static const struct malone_padding_scode padding_scodes[] = { {SCODE_PADDING_EOS, V4L2_PIX_FMT_JPEG, {0x0, 0x0}}, {SCODE_PADDING_BUFFLUSH, V4L2_PIX_FMT_H264, {0x15010000, 0x0}}, {SCODE_PADDING_BUFFLUSH, V4L2_PIX_FMT_H264_MVC, {0x15010000, 0x0}}, + {SCODE_PADDING_BUFFLUSH, V4L2_PIX_FMT_HEVC, {0x3e010000, 0x20}}, }; static const struct malone_padding_scode padding_scode_dft = {0x0, 0x0}; @@ -1058,8 +1074,11 @@ static int vpu_malone_add_padding_scode(struct vpu_buffer *stream_buffer, int ret; ps = get_padding_scode(scode_type, pixelformat); - if (!ps) + if (!ps) { + if (scode_type == SCODE_PADDING_BUFFLUSH) + return 0; return -EINVAL; + } wptr = readl(&str_buf->wptr); if (wptr < stream_buffer->phys || wptr > stream_buffer->phys + stream_buffer->length) From patchwork Tue Apr 1 09:06:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ming Qian(OSS)" X-Patchwork-Id: 14034529 Received: from AM0PR02CU008.outbound.protection.outlook.com (mail-westeuropeazon11013019.outbound.protection.outlook.com [52.101.72.19]) (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 2CC151EC01E; Tue, 1 Apr 2025 09:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.72.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743498488; cv=fail; b=sqPLrhlKOq8XJUhY64QS++LKWagiHboTYdEkQ/K9jLlL7FXiVGVjb8/l4enMlOceZxK/+jxfOK1kGTKcEDOBuRJXya1tCww3zWHdpzb5lJWNErauVXhPI5UpyXtgCvX4CnamE9MOrzNx2Q0HPZrfUN1yRpSfXz2CrmX3p+KwWwE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743498488; c=relaxed/simple; bh=S8NF5PzALu49HJAQL2yxzSlcVPD0fCNqN8akg2REEk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=N6x7gq1hpmL6W+hed5JvP8zgjyEb5q48BCXc5M2SjmXZkya638lhr5MBK8aqUvLZ0sTUDpiOzO3Dssds8Ui+or+IRjSq/lum9wI7PXf8jKrNjAcyi1+vRa553QKSf2Nj3BI44Z64cn0euOiDOih51Abag2WHLy5+dC5RAkwca8M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=NJsRO3Qm; arc=fail smtp.client-ip=52.101.72.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="NJsRO3Qm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mBnMLTw9wAPMzbRH1Xmyufa9lCRNRwb0XRKB1xs7hcMQJZyVszkFDEPOt0QIcYi6YZHpAwc+d7YZeXqhPp3w8Ntn3B2XmLiNfWOtkyrgNFpevTZR9HdjI/MhDGu8RcsVLvE/cLcaxwUIJOfNqA6TuV4Jx8xzJve3eRo9hVFpBValb4voZV26fFSl+DbdYcptOjBpLjO1AlNi0hs1ZtZaxyCHOSIIKNgoOM48mTQclVb9Pw0iKCFo4TwEUO9LQn4gw3r7tMXDrehaULAj5zIybUuzW/LVFFIeOsll9Jbz+8gfaKPHurTcR7Oho8ls/vB6zHc48Bdly83AMpLwEGxMhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JChxjhOJDpk/L7xMKEA8swf7OFz4nQt6GYKlE0r1AbI=; b=BwR3KQ2xcjd65ncJ7nDG+qaLSHfXsTgFUT7k45LQfODVMaFFVj6ap2trFY2/fz0CFV6DPbmYnvZpEUPRGipFB0L8T2Rpw0sgGHJhEiv+Ew+TyJT5M/L+T4mFucm3Xj/NgNqEPQjIpK976BF9Bb1y7jN19718iFyYWe4g752J63dMSIEyXpSo480oMzZk+TCGff5wzkVBs1N2TUP4b4rAbrGYrNsdRGssO044Fy5bbYUg2i6WjhrtV4z4Frsr49ElRK7RZyQ8FJa/LzFeXl59oN3EAC5lEInQIlzsKyH6RjoQCzdZx5ai77ea5uzMfUlT9WeGqWNrTALzUc2s1w5uzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JChxjhOJDpk/L7xMKEA8swf7OFz4nQt6GYKlE0r1AbI=; b=NJsRO3QmarEe+yVwhOxXrMxwhZ3Ldau7yNtTKLEcP2Z/z+ZHdTrwcZoH9wAzwY78ZiSEoVusQqNwBBNb0mYhqSkYeZlc+EtK7BtzZu1W3wPkYYhQFVH7QnKsJRPCeyQ0AihVLZlJ97u3OwYx8AjpK6ckdCi/wWj0158vOa1b7Up4mdlKRxQapBkB2OvASyClMFidzCZbQkVYeJlPUe5/ZafsiATKmq8Knljtouhbrv+MuxDX9O05uJR8QehaVIlrZc6HerEF1SyYE4Pyg427F0Rl2FdlSruZQYag/YXfhrBLOPFm1jLEkJtK6XbRk66SUJO4dN9v/QCxJYlgRo+MRw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by AM9PR04MB7491.eurprd04.prod.outlook.com (2603:10a6:20b:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 09:08:03 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%4]) with mapi id 15.20.8534.052; Tue, 1 Apr 2025 09:08:03 +0000 From: ming.qian@oss.nxp.com To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: nicolas@ndufresne.ca, sebastian.fricke@collabora.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, eagle.zhou@nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 2/2] media: amphion: Add a frame flush mode for decoder Date: Tue, 1 Apr 2025 17:06:57 +0800 Message-ID: <20250401090659.1702-2-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.48.1.windows.1 In-Reply-To: <20250401090659.1702-1-ming.qian@oss.nxp.com> References: <20250401090659.1702-1-ming.qian@oss.nxp.com> X-ClientProxiedBy: SG2PR04CA0153.apcprd04.prod.outlook.com (2603:1096:4::15) 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-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|AM9PR04MB7491:EE_ X-MS-Office365-Filtering-Correlation-Id: 12a5a69e-ddb2-4a16-baa4-08dd70fcb4ea X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: 8nfDEs+m5dhc3PUC8NM6H3LIxXZgM/rbriYe38DEfLkekhgUHc8J24uoBK90R70QWggd1OdtJuKiuV5O2w/yfVyPk52iLgWnZ84McYPiKn/mzWFVjMZHwlRVZAKelpgZ149NfM4ErvYZ/dl+8IGVMrSWXarvnhEdcVK0b7Ed2UD8fP4/XKskblXPZ8suDcT52wEkeRgK2oh41kZJka1rpWdbRgYSBruWKeeRXpa+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soViF8e+3rTS9jIs9CemJc51nfAecy8MY4ZUgc2fDvm6P75C5jtem0h7regQ4IZzYT0imuPF6GaOUR9vVR3ZQ7EidByOOAftMNJc6dActX7ov6jgFzgaOfIgVZhukwNikzmMc9gJjA5YztQQsh61DMwD2 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:(13230040)(7416014)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bwa8MpPgDEE++xO1fO1KpChdRNBe7/juUG+TjPkpOWlLvxhuztqhtc7dL14YMtJDtXzl4zM4As1tc9GfWB98xp4LQV7e2fmvjRfd4nwGTUZxoxueO19EOBeRRlIcgZ6+xxeryCLIzxQVFxc2JKjJEArWvv1J2skwkFX4OFGiYM954A83LTl+IGek+CnthmioMAo7d96QAWxpK6QA2LZRzgdmIRUIoUKBAE+L4G7pjefqQM2QxqtR2iJcpfmUOm/UTLokTKLTEYo/WgAhuf29aJe5/u15TOnjxmJdM2PHNWkcdJrP7fy7dcEPHFoEiIZV0ONLQY0U06/CBvjJXvQbGfNYkx6F9chcaJfE2FfEQDspUS74HIRfFKrM8ZMgwJEICxW76SIB0PIjMPpGhzMQbWUoPFGZvTRHsDw+CIQL5NKdwfCXZdAdZAWB1pPR0oq1ZjJvlFFJMa8z9SHxshLIGsV1TDeam+xaVvLDgPj0bCICYNAYrat/3BEugC8MKLXy6FwmRB4dAc79lN6nk1ZuSAuN+3xM8R51prVwH1SVW1Xa1UOejjZWaapkELKBTDZOK80Oa837AaQC6aZgI8WMNTsFQquB4jiWZy71R2aEKW+dDu0GQ8x70kgzOYHsqrmtnw9nGRDJZPsrtrXImXfdC/AlUufKLQL3kTc9iLUk8v7zlGYZ/oq003594PmgmYPUihMF35QxRMGqv15YCJdX3QuMwpGqfQoEar41/KboXW94SD0+8v++ycnMaaUe7HhnC3Ij1D23Y2gnxEJQYr9WdR5NIxT6ZkQGXrchoMcJanBwXowBqbKNM6uDobNO9TC75hlIAxiORXXUKf7z2ae8KUqSf3Gcznjb20Tb0Q1uICDovZWjvA+oDiDTH3HNfcJ5LgKypY4nxPeGf9WEB3xUDhSGNLFFF2OmBMyZ9E8cXGw3BCqocLZznGLiVu3Y2Qq5NPNWwT9O85vj8ksJ3PAjU5rybQJS41IpTbtDutJJKiQtlo2+QNbjkxSxLZpYSV6qRfsFnNUeYSSGQu1dWqhuo90k6CB6066ZBHpX+GOhASWzX3z9zG0QYkeoz1oQ5l+qVGMuCKpJrlnzHaP3rs/kU27dOLyYgDryyCO/DDt0gskVMkTFuq1KM8FINKmaaTdw8IUsOmsFGhnYmhps8rKVEa3xZplnMknGM1wy0DT0r3uuDfUN03VBaEvXw4cGuvJ1sLxK1qhZRLnksClkoyRHvJELvEjMuie2Bt7Q3670ump9DuKnmSAguOr8iMZKdU4sJvxZo5dcc3tgn30oz4sJcbzznq9TkhlGAP8/YOLczWVFURR7CCKq5nwChaLgjxO2hZfqxmuyXnouAen+ZxWyXELdbtA5OIV30S1q0pb7I6BVaYIF/K44nYBLEZdZQA2EGBbbprAY4lzTbcjC+tP5L22w6lwlK5c0wK+vMM5BhORX15VpIAtPJc0isEBvPOBZMbKJ8Jrk6llBhFRJ8snsLpcBYkrDY0EvMYIe8uoEl2tPahFlsiMpNSvyn3MrzVwe3lemqGUs6OjcpnUoaOgWjeDDQXmZc5xlGHLf9grKM6RfBapo3E0nJg0BZHTIo0UA X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12a5a69e-ddb2-4a16-baa4-08dd70fcb4ea X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 09:08:03.0067 (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: welGMze4BvCXZdtPy2BmBiHc7rJEhU2RvFttqmMpp2Mq+PhdFQ3T84JDZDfpT8rpjnfitinRvGDJAxNO46bkeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7491 From: Ming Qian By default the amphion decoder will pre-parse 3 frames before starting to decode the first frame. Alternatively, a block of flush padding data can be appended to the frame, which will ensure that the decoder can start decoding immediately after parsing the flush padding data, thus potentially reducing decoding latency. This mode was previously only enabled, when the display delay was set to 0. Allow the user to manually toggle the use of that mode via a module parameter called low_latency, which enables the mode without changing the display order. Signed-off-by: Ming Qian Reviewed-by: Nicolas Dufresne --- v4 - Improve the comment expressing v3 - Improve commit message as recommended - Add some comments to avoid code looks cryptic drivers/media/platform/amphion/vpu_malone.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/amphion/vpu_malone.c b/drivers/media/platform/amphion/vpu_malone.c index 112645b30e15..1b59c77a84db 100644 --- a/drivers/media/platform/amphion/vpu_malone.c +++ b/drivers/media/platform/amphion/vpu_malone.c @@ -26,6 +26,10 @@ #include "vpu_imx8q.h" #include "vpu_malone.h" +static bool low_latency; +module_param(low_latency, bool, 0644); +MODULE_PARM_DESC(low_latency, "Set low latency frame flush mode: 0 (disable) or 1 (enable)"); + #define CMD_SIZE 25600 #define MSG_SIZE 25600 #define CODEC_SIZE 0x1000 @@ -1582,7 +1586,15 @@ static int vpu_malone_input_frame_data(struct vpu_malone_str_buffer __iomem *str vpu_malone_update_wptr(str_buf, wptr); - if (disp_imm && !vpu_vb_is_codecconfig(vbuf)) { + /* + * Enable the low latency flush mode if display delay is set to 0 + * or the low latency frame flush mode if it is set to 1. + * The low latency flush mode requires some padding data to be appended to each frame, + * but there must not be any padding data between the sequence header and the frame. + * This module is currently only supported for the H264 and HEVC formats, + * for other formats, vpu_malone_add_scode() will return 0. + */ + if ((disp_imm || low_latency) && !vpu_vb_is_codecconfig(vbuf)) { ret = vpu_malone_add_scode(inst->core->iface, inst->id, &inst->stream_buffer,