From patchwork Tue Apr 1 07:35:24 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: 14034424 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 8E18CC36008 for ; Tue, 1 Apr 2025 07:38:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=B2BbTQIwrMUtrZ4MqH1dH97kHKOn4PoBBw6vrlLL7nY=; b=HSezQ5Tge9FTr7WUXZIQQYJ9jZ oewnnHVl8BPQwi8NA0gOSbPwMvDOj5ieJ8ijfS83Giru+ocaFBlB1+wqlJCwKLHFQMw4yObjn65wa KHuCsqJDp+XJ532Cd3XLTQ+jItlLPLmPdVzrWYYXEqxEkpD5+pe0oquxJYOyrPz68e2w5e3rdngaP MT47NKX6WJlSwtbVcHAYS72bieUiO6OTFid4LsIt0yjAogNusx6k7yGGFgB3TupnC40xDkl2822lZ SbeCC/mxVYSfYcgpevOBp8wnwZU7IkMKBQgZwOTtzf0tAQfYGDH6/sw+GfIbe7WiEVkqbqfVmsD17 ntu9f7sQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzWC4-00000002Cxn-3q8E; Tue, 01 Apr 2025 07:37:57 +0000 Received: from mail-vi1eur03on20622.outbound.protection.outlook.com ([2a01:111:f403:260c::622] helo=EUR03-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzWAG-00000002Cpe-1oCh for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2025 07:36:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y1qxr76rf0Z+Vep5QCRCZMoheZCAr9mP+ZZfsCZZZJydGhh4M1W5FIZ9xwbs3Iz03t+1Iw+PU9brHV3XTELfGk12cZ8jmo+Gc+Ysh243oi35nu2+J7A8XfcUO2Krki/NCIS9N+qyqmLHK41xJXyFiZPYQw4m1bqmb72GhUwUyIn9vwKhQ50gm4auoksG00AVioJ/bz8Pm7ZHRv4OsfQNc+EMM7IUyu6s8b7E+Tn4haNaVK7KUMVqZSbiDOPyWgcSlgBzIEeft3LWiH7xH/qeuZtufq2xtw6zD1THC0ijXwVrbFYeyBgSnguOlHB9vBkuWDlNCxt2WnpevxGWTkjW1Q== 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=B2BbTQIwrMUtrZ4MqH1dH97kHKOn4PoBBw6vrlLL7nY=; b=KLhphCB/Uo/msplNREdVGOs/61yUJGyL0GAF/Gr6azpQZOmtXKlGLDWvmgGR+GrStWB0hffspycms2Ho/mbf2FhD56F3gBCCAay45yG16F3puB7hHU/AHVzo8XNVlShu42gl+dnOZ/7wwXehhy09Ox5ghcP00CVUqn/+68QTH1AuuexBQMn/wmp4322xH02jxGmySCaK1U+aNHKmgrvd6vBB4DkzlYikzbsS8Q7jcRH3A3nrwuMXHDttq9yWNCI4ZGiHyERUhkXVATY5Noa2dqZTa4fkFuFgen11QUdrkNUi4o2iqfLd3AjlBAfzbN0P9119tUXNSASDcTvLZVjv5Q== 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=B2BbTQIwrMUtrZ4MqH1dH97kHKOn4PoBBw6vrlLL7nY=; b=kQqG3MzMN6jcTOzc56bfFS2HwpIyKgmLPDGA2gs7U2B8pPiUPlE2Cze6TP1T9EkKEUZdrXrhPZ4H38Poo+EuUi/YA5DzCuNrlg7ej9qcMaMML86mwuXLTLtw+ZF45wn3SYpLFJEAQKwPmAYsHYBdADo5+Id4i1t7yaKbkao5UY7lZlXQgjzgsQM4t3IiSOh0i6jfmep/NtgC1bzW84WnTls5+TmYAZwwa7v5M4UhtsClcCT+jPn4ZLO9FIfl60l5fwzGEsYJmtjWax+xlUMHr37bnNmAuYqyl12nr3drwvHSRZeBItbXgiYZ2iPVEhO+7KV+zt3bb7WsB4LEgshXSw== 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 PAXPR04MB8893.eurprd04.prod.outlook.com (2603:10a6:102:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.52; Tue, 1 Apr 2025 07:35:58 +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 07:35:58 +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 v5 1/2] media: amphion: Reduce decoding latency for HEVC decoder Date: Tue, 1 Apr 2025 15:35:24 +0800 Message-ID: <20250401073527.1626-1-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.48.1.windows.1 X-ClientProxiedBy: SG2PR01CA0143.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::23) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|PAXPR04MB8893:EE_ X-MS-Office365-Filtering-Correlation-Id: cba32e3c-aca8-4842-d37b-08dd70efd81b 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|366016|7416014|52116014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: X25uh0WlUxTw5/TsBl3wWv4K8cCBC8g+KNiIS0lBZ8QTVQs9B77KTfKptd94LkErM2KCbmmrPsLCFHuY1wLLt0DqK4zo2xE9XNzWWnDLSgKoDSw9lmfuK2gIRTWhmuTV/whdcm7PPHxENjtKgjCCsnDiXcfQc8nkrUwHMUNqr6bbUE+XiQyllbqUVYkfIDGkr4wSc1X2yyeAVARlxAcfirLwSC3PCHwW3xECTekNkeUqzp3D6Oi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VLwKpAWUgt5ZdI8rPrMMwIcruQeNQ5YMISh9G0ZD/e+jilB7SFhF7afHpc0wZhDDWKDDIXvU6lVCMuhx2DFN683OHPNVad7hpDChmvVAg+uT38WGLy37805hYNBujZWYd8MEHLTFaufmvL02zN6/85thk 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)(366016)(7416014)(52116014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e5xGpdc4aDVdZV93uQPMBCxgLHYRoPZV3KE1iQwWWPEgs6183wsNU/NwJ1FwUvsdhAgprPeGGKJw7uTBcJBwoETaN87iPUGaF1dYNWdgQ+q1eowbSaOCgBqS7OihPuZb0rBNP3Fs6U3MnWv8cZY0TdCEAA7ZDWDJBON1b2PgUPXM/KwK+bd/JwJdw6d+ZZ3D9lMGhPTisg+wghDaRUdRUR0d+Ij5vtTm2ny3Xtm7UZphkkMjPUccx/0zqEGWj8eTX+7/TsSERrfr/MJNbsJifsv6/juLYxj3+6DwZ99ogTfM8tN26kaISwtHMUUP5wQ+AQtGegA/HRA6i1b/EuV8yy84trAfwDs6iEH+3gVvj+ei3DqYbgtHD4rEe/jvbLtOxh9cbxdQmBGcfs3oCA//wTGjaOz1Amm/vselrHROAtBgRz9Nlz454KwrpFyvEKlh12bSu9xOpCFzSnyHTwelb/bogED+z485Q7gAcGZz5XtRwmqKVrW9zbj4rZQi6F6XUpadN0aKHqqzrH32LlHd1EWIOGdLV0En9Vw9Z8MwkDeQIyfBMikgbYx0CNXkRotof60iRUDCM+bIfMhi09gOWITKwX0hpEYf0Ulqc2s9mV15uoQT+DQMhhIElCsRPFmOTSuF8F1urUqtomKXj/vGohdCfKXv7EDpOtk7kX0MFzDbEJsjgnK+tZWo8HTKlvxhXQmVDG0stuLUiAubQTt3xUanDDoGzlhSn2R6aPv/yqgqs98B2Xyq+Kp1z5193qaRdRszCuD/NRGl/Gs4/aqhcnxwzVLOLi/5ELNjtTvoYY2LQLNqF7iVol7jUO/x89EVFz7y/phpbk09W9HbqOo9fG62lttGpd/s31ryJ7ZsS3anZyy9Vs+efDND8UcmGJYMJ6KQSy2t1nW0Atkqq2rQMEzQgWfS0xFs+Moq1dwVt1hkeQfQ503JULk3w1vgItGcDmPfnFuqgOFhu4ofX3m56O9Xq8LS3LoN/w6gxBgtHSdOmjYS4t1iYeDGc6SoKuIZS9sHMo0yDX4X/oOihRLQM4G+0Bswg5Uu/7rlrM/yVFoYZvZd6dBPPigKq/0vVN8nKxwGg4d4nbxK6HHkI/RFzGmGkvrU2ggDrqXOqRKHaXfW7H8618Zo33CL1mkkIr9opeL+EfDrjGMC6DL+NuoRTmloE8YXndHG5ffVN2dWkiQw77Jmjp8ywKt8/LdLOrWrNKEcn+4r/J/MGeAUCxqkpjCrgDEFySCpIRJWcHPzZEHaI6AsGK5BEWE/TfkGF2t3Buc2ZAqFvnx9FlSJnhAy7hZgciMg6rtS3Aytzj0UnKbcuQQGcYF74KM7S2rA8fX8lVIW6PeB9dwBAcx/GZH7MxR5vUexuPDgvklcKsABr+eD75VhAaxUy6ty+vLiI/6lyqgheUav0hxtqUxpQgPBw7oXwg1I/rh1CzVhA2A/t3XXKtKSdw+EnbPB1kwrJybroLEZcemnXzgq8QU8ti0TRZCkfJP425hxH9GVHDgzJX/6Kyh7cdg30k4pV6heb+f4uBSGt5TrcCHar94ZmhZMMHh+2b1P/yr1N5SoJ3QtYGBKpF7Yxqb64UCAJUxqjP/q X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cba32e3c-aca8-4842-d37b-08dd70efd81b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 07:35:58.4149 (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: Ox0uIplFf0P8pmXSSZj51CsbV3YD9JuptlUgHJ7/xzfvwdlu9opcKvjiFeDdI+0dsPAjqIVWl3C36OyUF1Qxlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8893 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250401_003604_481772_1B79AC03 X-CRM114-Status: GOOD ( 15.94 ) 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 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 --- 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 | 24 ++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/amphion/vpu_malone.c b/drivers/media/platform/amphion/vpu_malone.c index 5c6b2a841b6f..b6e4996c2d91 100644 --- a/drivers/media/platform/amphion/vpu_malone.c +++ b/drivers/media/platform/amphion/vpu_malone.c @@ -68,6 +68,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 +338,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 +662,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 +1038,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 +1073,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)