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: 14034420 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) (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 E0129126BFA; Tue, 1 Apr 2025 07:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743492965; cv=fail; b=jqLl50EGWxN+qvGbhCBuggzuEKnNbRNu5/zoKtqh2sKdbSEswgmyIgxkGZPQqqy/rGiXoqDauqR+0ebdldhmNL9WdH+b1YzCvP2xww9JJx0x6ZdXzVkB5BVsss4FsRxbWghv7HEwGu/3/ponOlKyWqJJEN2cR0gLv+MVWpqRuJg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743492965; c=relaxed/simple; bh=hjKKtIhqYb3Y8y5pFTXnopWSwy6bL8meaqNryuG/axs=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=BBni/aD4jLuMl9KAtjL1Exn9/39f5PmFQ8DUBn7YpJ6uMtoNvZXgV+1bqyMhWS+dGTSgxgByX1v0pLcFnO7pdKwlP3yeNqAIqil1nNVcg1BVFdBOPZqsJKBwithOz62+xKM/RTqY4w/p5FUno8Um/jX+7kHiq1fd2oLG9C7rglo= 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=kQqG3MzM; arc=fail smtp.client-ip=40.107.22.58 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="kQqG3MzM" 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) 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_|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+XiQyllbqUVYkfIDGkr4wSc1X2yyeAVARlxAcf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mlemuLJ23AZchr0RiBKg2u9nHjlR34tVLwKpAWUgt5ZdI8rPrMMwIcruQeNQ5YMISh9G0ZD/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 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) From patchwork Tue Apr 1 07:35:25 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: 14034421 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) (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 1390F1E7C18; Tue, 1 Apr 2025 07:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743492967; cv=fail; b=WtjbXBauk8L/JIbC0rECQS0Imjcx4mNsUoqNZKn4+fV+f1rsm0F+NZc3FS2GbSCnQbEfCF7/2u49m80EQVlAzBu4j9P8ypj/uY3QPBht/lv/cgyZlUO96uXdB7qlg2m3x83uQEqZmc+4/dYD3ivHharSq99UBJdOCMkB7/qIluI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743492967; c=relaxed/simple; bh=u8NMi6lbAkYZKULoliP71fMpfO8urN0lNsMEIqUhbwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=EOx1FkmieliGZjkSYKqsoIyj6xYvMbAqfN1NEPygGn72t9Y/74yKhx1j6vV7029hQRyvBK3XjqyoYJkqrjg9S6a8a5E4n32xAaE2HepR9ci0z2erZVnEq/ruwiF5Esh131PLEQk1Pzc/fDzr/Qm5WxO69dkDtn+q0Trt6a6qMfY= 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=YC30kJDm; arc=fail smtp.client-ip=40.107.22.58 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="YC30kJDm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RxTvaNZhTvfSPhcBJf9dbXxaH1paZUCEVz+/sV1ZE+uTPUFdwiF+dn4Y6v+0Ckk29m+2LgmfYOlK0bUHrVXPjwucRXgAqMyCiaTtNSanW8SSk665PqdCC/B/FTGdOkEVy/dasN5ejcjIm6Q/onLU7ftMYBUhBq+uedM6XXG6BVd/Esndhd0kJZ4xCZgxZXYvMI5FUwJV8vLABjPAztjckLGqzdj0UawSoHmw1pSyhlAt/8LOlt3Ou5n6qTXUn8wusIg1CvLLG3claktbfct5c4wFUAjBGenXDqW23tVnj4vwu4+e1T/7zXzmJl7+wRsqMeNBCahmKMGfBUHFdhxq7g== 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=/zUFhkjN07lKFNy4wSSfsWq7x4iV6wJvKuoBP4MGc58=; b=vHIo7uNS8LapY1NOCAM0XqXWi7pA2UPSO+aG7RhVFmLw2k0CXHeYBCmnyrXaVqWNBRGv6LuIIlg4hS4+WhiBHfmGGOh3xI5ytgktB7LZHdgRJwH7UMxdyukI3j+7gP3+Phxw7xZ5+z1rb8iKmH+ZJocijWL8bvve+KuBdDNltV7/QuLqF0kFxhjHaFyPbJH32VCa/w3opuLD2x7vvHC6/oBYhhCgfrsnHjJ5NLHX6D7A/mNK5D0DCJegGdzTCaUXzv7mDnbthMraTjn34mTxIECFczyjcO8EvRrV2vN4lwsklvYeY9t3RAM/Gs1Sk5FarGSgwv91Fceiy8CD5UqamQ== 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=/zUFhkjN07lKFNy4wSSfsWq7x4iV6wJvKuoBP4MGc58=; b=YC30kJDmCbQSt06WhlJ1L9slZDrudsuJB5vi0oKdctdCVzo5tZ6R9412QfXbHl8ww7lEqO4aSvCU4ZpnSfvbwc0BAwybD3/7shJvWZ/1WywW15Lk0qE6LcWmLglDDimUqSVCvhuVb/0NYdz7f3v7o4yYcP4Y60f1raOAYoiM17kQOro1GZZF8WTOuSZH4w5pIU+mru1VUCb/IMH6agLjDsw73HfGWIBph5pi993R3y1LH4E/DiCFD/ey8E66YjO5/2I0TkzTp2Z7Dm/IyEC9PIHuDNcJeGDXJlu2+C091zOxAX9/inMuA4NM29lfHsfnvWUZvyIOpiBt15abcKfo/g== 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:36:04 +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:36:04 +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 2/2] media: amphion: Add a frame flush mode for decoder Date: Tue, 1 Apr 2025 15:35:25 +0800 Message-ID: <20250401073527.1626-2-ming.qian@oss.nxp.com> X-Mailer: git-send-email 2.48.1.windows.1 In-Reply-To: <20250401073527.1626-1-ming.qian@oss.nxp.com> References: <20250401073527.1626-1-ming.qian@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0143.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::23) 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_|PAXPR04MB8893:EE_ X-MS-Office365-Filtering-Correlation-Id: d4111d9a-db13-43f9-a380-08dd70efdb88 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: RGRWc35WjRckGxvrqIkVQQo+FRpECqSyOEYpBqYlQQ+7T6hQdE/ItLEIcfSAxJa8h4HnDCWA8gnwIYbxyRZ9sxOYvUvlM+J0phtwiNSQ48zYg6p2+pgDPF3NA0KQRvlRpOArd97Y82FAyXpgbC9Ht7lin716sxN6pVffIwdPiR7ecsOcX/tH1X2T6Ky26S7QOYjyOLGHaEACfvy6u6mWS19dH9qNDMQ24O1Z46ilt6+jRwjqvLvCtJ8g4NVlDqWnQ68afJlB33l07hnl8pXSkLu5jXl2bvsSj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kPrldL3G9Twm96FaMaqtKB8hfODj06SCka2cZmCTacjIznrtu/2BqcTuK+sq0viL3XTEBag6CR1jZPz4erCkEjBSuTbaWSNpVBTK4i+zSZHIxP 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: OyiEqJWdg7XDwobuDJ6iI03xl4Zwg70lbv/lBlcnJlzrcqLbBRS0fUEjnDwiHaYJWshuW8NJPrCHBLYDEUAjkXqglVGGovmD1pcPNGUQUv/O25lKyuSZGo+POyjwnXRZ12tT3FtWGuw67diqBgEjYGMREHzJm7BqtFzCBD4OZp/jYSGnL15VTf2pG8eHHOiCPseNTZbMMAylt9ZvOOs/a7s9zqYv/2U/3kco9iBiSj3E3YeZzlfEFxrZFLK7e8JVJEycwMF5gQNGqmUrRFtgPA5vi7LVl0R49P9p7DjC1WnCdKsEna9DkWCPFdB1KR+27MCm4P7P4HfGhT2TeMgmJKUv9Xn7yxJ+BPFPnRRWnIdLTh5aGmWxXEIovC7h2mKTXzVyyBfEjd6Whkpv/Fj67zkiGUUCD6lAwgfXAHcXvTggywXWaoTo3l/9J3lopWsAoyo7V5cC7LIWpXAJAEIDqHA0Zr6UsNHXSYiWpNQcPGxONhTcnMbymedsfbSeyOeamQPN2c+qkQhIvatXgNDYa+Qxjt5WLFXj0m+flp0LEG56Grw0AuLTkNiNJZzoUrsWu//RydjpsEcqkVmefyAC75UTI52CqRhC/pLNn84Y95aEzB3hXvP4pe3D8wMxrEtRTPTBJTRwF5Fidg+Ih0eOU58Aiyez/uCa3NsGeaT142gwTdODr5lO1t6wXeaxRrIwSH8ZAGDyESn8wdeXcI0XbXPHNfCKoRgCVaBMaGrv2EG5IiQuSLPIG2VU/WWtQPlwo2sQ/LnvqCtFOSM5k5DuzI839EKjpDAVOhhGDcQ5WH0vLLvk9wi8kHT5ILA5Km4OPfQAmV4WNUwtTuB29YwspkaeZk7gffLCaLv7ouacZog98qmkEM9Aj6HEs06Ipyd4ZaIJvfTruIl+A8Rn6IxFo6llerHCRUHzP1dfJ2i+kIDv1m6duWHppq3T4udWle95rKobiR3fHxQ143/nChOAZo/Onum1bl1X1Mki5Fz0DN+b18hdTYTCGMzajSa1/zHPkbz+BBvHdXoryZV7CpieWqcIvsdlvl7mKfWDzt1ZLun2nYM8S+pakSYlOFS3EHY6/ExzWK+rKqFqmZJ5HIcX2zMgfETRaRE20OxfnsZOQAf/cIEYdVfCUQVfurAHe50gyggbddNGEdBh3cLs8Dx1B+aIftiIi+4g/yRW1GaHaLhzqrLL/aHoKRnm8KxjwwsH7z/m2Lx1UJ+zFnSMnplCQhtPhnKv5l33zIB/zJGnUAqhr/d7ygv4x3P3duZy6Hbn1MQgehfNkqkhL7R7Qb5sgPqoGHy6kxURVGP0ObNBP5rHAGfC+EuDJVDaYkJi+5zQiL5mEnxDpN8BbHPgFSJ5a130zly0eQFjoezUx9itlkzcnPXzBNQ5be5wWiIkinqA6mxpoXS12b5CJj4zNIt3FYealzrfbhp8Ouj5jgzW1VlCpAhvboBEBkOiQ5VkrlrsoF3gBUHZA12ZN5uCjQjnqzCkbcBgpsHgn2/CXB2xbndAu/8YuMqDQAAVA01PGgwqV9LycWP7WCjWmAetuvq1A6a4T2pvNlrqUV9LGqG5N4kCoJH5T2tjc9CicxpbmwHR X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4111d9a-db13-43f9-a380-08dd70efdb88 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:36:04.1878 (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: mV7Di2xPxyDIzncScAH+nz5G+WufDw6BOSlgSkCY2mmXiunZ3xplkIGqgtzboTVVCwatFr+CSTegKwbCXEiT7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8893 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 b6e4996c2d91..89af89087e2b 100644 --- a/drivers/media/platform/amphion/vpu_malone.c +++ b/drivers/media/platform/amphion/vpu_malone.c @@ -25,6 +25,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 @@ -1581,7 +1585,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,