From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 2B19C34DB61; Wed, 11 Feb 2026 05:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788556; cv=none; b=Wn+p1YXxQuYvU+zAjFdDNN9kya+XpLffLh1nN/kcCK/17Kijc/oq9zZgGhEzOGy9PGaqWhLwq7c6jEYlXjJWvO47d5285ehplB8T4GVEIPPHlJtlq3wlB1qop6y5oD3/mOOS8FtTyd5pu5VNkTnlKDhGOr/qmFOnWkqQsHRJknY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788556; c=relaxed/simple; bh=3ik4H+i8eDJp1sH9StVyHQRXGSE7vwTMq44bPWUWxPI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pfvuoyDJP23gMCaaqRmTVSA5tcYgN1t8+i3J6UMdjhDqitu1GPKxovIr85HtY9Z0GX8wr6vyYxzKAVU4EQ/qYEWjwjxX612Uwwj+QwyqL/mvapQtu6K/VskehTAw32JSTStX7ElHpUmfCfsLt1SnMzKmXvOLek8qnAdVa6V23lo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=rb6Y3++H; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="rb6Y3++H" X-UUID: 7154d946070c11f1b7fc4fdb8733b2bc-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=WOsm93dC1ZdTq3wpgyLk0vcjKRPu4R7eUMfAYzPQW8A=; b=rb6Y3++HOo0J/vsm3OgK3DX1Uggn6xsYFW2xFdWaC5yRunjvQaCUl4S1YFTorcPnS0cLg+UMOVwPWa2I/vzypZbVei8x+VOIV1bBdzOj7cKkr0LVUD0EsdGF/V1jjmNY/CVIOnlLWyJv66tdriC4qeEosq15yKbF2FtGcOFSNWU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:bd874f0b-46dc-428d-bcbc-88b44998e589,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:89c9d04,CLOUDID:6450d47a-8c8a-4fc4-88c0-3556e7711556,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 7154d946070c11f1b7fc4fdb8733b2bc-20260211 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 671420633; Wed, 11 Feb 2026 13:42:24 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:41:53 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:41:52 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 01/14] dt-bindings: media: mediatek: vcodec: add decoder dt-bindings for mt8196 Date: Wed, 11 Feb 2026 13:41:28 +0800 Message-ID: <20260211054149.27249-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" Add decoder document in dt-bindings yaml file for mt8196 platform. Signed-off-by: Yunfei Dong Acked-by: Nicolas Dufresne Acked-by: Krzysztof Kozlowski --- .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev= -decoder.yaml b/Documentation/devicetree/bindings/media/mediatek,vcodec-sub= dev-decoder.yaml index bf8082d87ac0..74e1d88d3056 100644 --- a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decode= r.yaml +++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decode= r.yaml @@ -76,6 +76,7 @@ properties: - mediatek,mt8186-vcodec-dec - mediatek,mt8188-vcodec-dec - mediatek,mt8195-vcodec-dec + - mediatek,mt8196-vcodec-dec =20 reg: minItems: 1 --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 2419C3446AF; Wed, 11 Feb 2026 05:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788551; cv=none; b=pu2HAFltz57VAYjh5calYdihgo16US2Dv5R4xyALCbFiuGuOf9YRyaxg+LCvM30Sdu4ybqBm0jTDPG9tsCPMPp0IUWR4PzwWjGU2B+APEjXGkEE+kLW4+KNG+Z1bJv3k+rq7+OBzyX3UOwwv69rVj9xqwsSrCjgMELYvSAt3Rcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788551; c=relaxed/simple; bh=KqQohbKfTdOqIyVgN3FAMIj+hBqZyqOX0Esf7bkPNiA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lFNH9pC14el0KhbPd5xJsm7ZiZFP38EWLpprAD4biBweLfylGk2fVM8hU+TnmE2go/+t4YsLLZShPMFGLwmKSLvv/t+pr9jddEr00sqLwZbN9eVFkJPmipvAqtmgc8gYEniWCaHJfqBTb/NyvxqfyK04s4t01TGqI7gpmwB+VaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=XXgDI2Hh; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="XXgDI2Hh" X-UUID: 7111d18c070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=MCL4hqxaTQo/RIAjUcHg0QLG8ihGCe0KxhTgmFf/7/g=; b=XXgDI2Hh0kLhl1U3RvlCDmTL0wwPcE3QS3RpbK3KRgC2phQalScoKLBJbbGkuFuny6ll9MNlAgsogCcqVYjyUtDQCk9Mn9HQLxbB9rEeBIGpTr7hZKZMqtSyP8T5uZUHkvNpYmO/JETQJShotvWgPZ9I5UBWiEW5ee3qjfhJJzU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:25bbd944-a2c7-4a47-898d-cce2b20fa339,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:89c9d04,CLOUDID:4850d47a-8c8a-4fc4-88c0-3556e7711556,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 7111d18c070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1068123530; Wed, 11 Feb 2026 13:42:24 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:22 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:21 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 02/14] media: mediatek: vcodec: add decoder compatible to support mt8196 Date: Wed, 11 Feb 2026 13:41:29 +0800 Message-ID: <20260211054149.27249-3-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" MT8196 is lat single core architecture. Support its compatible and use `mtk_lat_sig_core_pdata` to initialize platform data. Signed-off-by: Yunfei Dong --- .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 6 ++++++ .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_= drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c index 3b81fae9f913..d9f722698198 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c @@ -347,6 +347,8 @@ static void mtk_vcodec_dec_get_chip_name(struct mtk_vco= dec_dec_dev *vdec_dev) vdec_dev->chip_name =3D MTK_VDEC_MT8186; else if (of_device_is_compatible(dev->of_node, "mediatek,mt8188-vcodec-de= c")) vdec_dev->chip_name =3D MTK_VDEC_MT8188; + else if (of_device_is_compatible(dev->of_node, "mediatek,mt8196-vcodec-de= c")) + vdec_dev->chip_name =3D MTK_VDEC_MT8196; else vdec_dev->chip_name =3D MTK_VDEC_INVAL; } @@ -560,6 +562,10 @@ static const struct of_device_id mtk_vcodec_match[] = =3D { .compatible =3D "mediatek,mt8188-vcodec-dec", .data =3D &mtk_lat_sig_core_pdata, }, + { + .compatible =3D "mediatek,mt8196-vcodec-dec", + .data =3D &mtk_lat_sig_core_pdata, + }, {}, }; =20 diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_= drv.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h index c9d27534c63e..f06dfc1a3455 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h @@ -29,6 +29,7 @@ enum mtk_vcodec_dec_chip_name { MTK_VDEC_MT8188 =3D 8188, MTK_VDEC_MT8192 =3D 8192, MTK_VDEC_MT8195 =3D 8195, + MTK_VDEC_MT8196 =3D 8196, }; =20 /* --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 ECECB34EF04; Wed, 11 Feb 2026 05:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788555; cv=none; b=G2khlPe5y1rghC7+z8pxCAUusyriLzYdB1B73YA3s603/W0PtdQA72boFVlH9BpXh7fThBPkMUlK8dTCyAEAo0SLdedYRX0ANzysVOLMuAO/JdUIdiRtVRhJ5fZMMOVk6DkJwopvUP92s6ykiX8xiDCLll+pWy56LTAGx3VNnI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788555; c=relaxed/simple; bh=T9VQZTzZwxECrhsM+qTx5Pknye7eE4eA2JvbevlbXlQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PTqnYWhb5Nvb3d4yRJ+MEBk+Fh3w4gzQSC4VRTQRnNfXtJhdgHAH/Qi7sf8F1T1afs8+ldAkjOACnMEMOQKitndStFc2gQlYLBPqq+/DLkBulYK6iGWcmbpeuKcTsMkLP3OtxeW5A9cCDz3D1K4Aut+tVtoYoj/6HMsaxl/kdTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=j9IAxAcE; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="j9IAxAcE" X-UUID: 71684b0c070c11f1b7fc4fdb8733b2bc-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=hKbEc71K5rETiWTJkwFDafHXQpiNT0NtRytpfBFCfpE=; b=j9IAxAcEbUqsZ3w8Sn4pC0E+oRKN1SUwVjxsNqfzvK9Kh04rgRUxoKMmo9eL8orJ1g6FaQIhRVBz1H7myIhX+rvyWdF2YgfFK9XQjafn3n7a6AvvNt1iVEOIr12IERw1SY4duombeNhDuLlkyszgMZ3WkiVz2lWT8rlZVbu5cFs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:60e5218c-d46f-4c27-8884-148c77f4c564,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:89c9d04,CLOUDID:d1682b5b-a957-4259-bcca-d3af718d7034,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 71684b0c070c11f1b7fc4fdb8733b2bc-20260211 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2105904845; Wed, 11 Feb 2026 13:42:24 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:23 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:23 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 03/14] media: mediatek: vcodec: add driver to support vcp Date: Wed, 11 Feb 2026 13:41:30 +0800 Message-ID: <20260211054149.27249-4-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" The processor is changed from scp to vcp in mt8196 platform. Adding new firmware interface to communicate kernel with vcp for the communication method is changed. Signed-off-by: Yunfei Dong --- .../media/platform/mediatek/vcodec/Kconfig | 4 + .../platform/mediatek/vcodec/common/Makefile | 4 + .../mediatek/vcodec/common/mtk_vcodec_fw.c | 3 + .../mediatek/vcodec/common/mtk_vcodec_fw.h | 1 + .../vcodec/common/mtk_vcodec_fw_priv.h | 12 + .../vcodec/common/mtk_vcodec_fw_vcp.c | 505 ++++++++++++++++++ .../vcodec/common/mtk_vcodec_fw_vcp.h | 139 +++++ 7 files changed, 668 insertions(+) create mode 100644 drivers/media/platform/mediatek/vcodec/common/mtk_vcode= c_fw_vcp.c create mode 100644 drivers/media/platform/mediatek/vcodec/common/mtk_vcode= c_fw_vcp.h diff --git a/drivers/media/platform/mediatek/vcodec/Kconfig b/drivers/media= /platform/mediatek/vcodec/Kconfig index bc8292232530..d23dad5c78ce 100644 --- a/drivers/media/platform/mediatek/vcodec/Kconfig +++ b/drivers/media/platform/mediatek/vcodec/Kconfig @@ -1,4 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only +config VIDEO_MEDIATEK_VCODEC_VCP + bool + config VIDEO_MEDIATEK_VCODEC_SCP bool =20 @@ -21,6 +24,7 @@ config VIDEO_MEDIATEK_VCODEC select V4L2_MEM2MEM_DEV select VIDEO_MEDIATEK_VCODEC_VPU if VIDEO_MEDIATEK_VPU select VIDEO_MEDIATEK_VCODEC_SCP if MTK_SCP + select VIDEO_MEDIATEK_VCODEC_VCP if MTK_VCP_RPROC select V4L2_H264 select V4L2_VP9 select MEDIA_CONTROLLER diff --git a/drivers/media/platform/mediatek/vcodec/common/Makefile b/drive= rs/media/platform/mediatek/vcodec/common/Makefile index d0479914dfb3..2f68692e8c98 100644 --- a/drivers/media/platform/mediatek/vcodec/common/Makefile +++ b/drivers/media/platform/mediatek/vcodec/common/Makefile @@ -14,6 +14,10 @@ ifneq ($(CONFIG_VIDEO_MEDIATEK_VCODEC_SCP),) mtk-vcodec-common-y +=3D mtk_vcodec_fw_scp.o endif =20 +ifneq ($(CONFIG_VIDEO_MEDIATEK_VCODEC_VCP),) +mtk-vcodec-common-y +=3D mtk_vcodec_fw_vcp.o +endif + ifneq ($(CONFIG_DEBUG_FS),) obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) +=3D mtk-vcodec-dbgfs.o =20 diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.c = b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.c index 08949b08fbc6..fc547afa4ebf 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.c @@ -3,6 +3,7 @@ #include "../decoder/mtk_vcodec_dec_drv.h" #include "../encoder/mtk_vcodec_enc_drv.h" #include "mtk_vcodec_fw_priv.h" +#include "mtk_vcodec_fw_vcp.h" =20 struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_= type type, enum mtk_vcodec_fw_use fw_use) @@ -19,6 +20,8 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, en= um mtk_vcodec_fw_type t return mtk_vcodec_fw_vpu_init(priv, fw_use); case SCP: return mtk_vcodec_fw_scp_init(priv, fw_use); + case VCP: + return mtk_vcodec_fw_vcp_init(priv, fw_use); default: dev_err(&plat_dev->dev, "Invalid vcodec fw type"); return ERR_PTR(-EINVAL); diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h = b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h index 300363a40158..c1642fb09b42 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h @@ -14,6 +14,7 @@ struct mtk_vcodec_enc_dev; enum mtk_vcodec_fw_type { VPU, SCP, + VCP, }; =20 enum mtk_vcodec_fw_use { diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_pr= iv.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_priv.h index 99603accd82e..0a2a9b010244 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_priv.h +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_priv.h @@ -4,6 +4,7 @@ #define _MTK_VCODEC_FW_PRIV_H_ =20 #include "mtk_vcodec_fw.h" +#include "mtk_vcodec_fw_vcp.h" =20 struct mtk_vcodec_dec_dev; struct mtk_vcodec_enc_dev; @@ -13,6 +14,7 @@ struct mtk_vcodec_fw { const struct mtk_vcodec_fw_ops *ops; struct platform_device *pdev; struct mtk_scp *scp; + struct mtk_vcp *vcp; enum mtk_vcodec_fw_use fw_use; }; =20 @@ -49,4 +51,14 @@ mtk_vcodec_fw_scp_init(void *priv, enum mtk_vcodec_fw_us= e fw_use) } #endif /* CONFIG_VIDEO_MEDIATEK_VCODEC_SCP */ =20 +#if IS_ENABLED(CONFIG_VIDEO_MEDIATEK_VCODEC_VCP) +struct mtk_vcodec_fw *mtk_vcodec_fw_vcp_init(void *priv, enum mtk_vcodec_f= w_use fw_use); +#else +static inline struct mtk_vcodec_fw * +mtk_vcodec_fw_vcp_init(void *priv, enum mtk_vcodec_fw_use fw_use) +{ + return ERR_PTR(-ENODEV); +} +#endif /* CONFIG_VIDEO_MEDIATEK_VCODEC_VCP */ + #endif /* _MTK_VCODEC_FW_PRIV_H_ */ diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vc= p.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c new file mode 100644 index 000000000000..9fee52fed181 --- /dev/null +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c @@ -0,0 +1,505 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2025 MediaTek Inc. + * Author: Yunfei Dong + */ + +#include +#include +#include +#include +#include +#include + +#include "../decoder/mtk_vcodec_dec_drv.h" +#include "../decoder/vdec_ipi_msg.h" +#include "mtk_vcodec_fw_priv.h" + +#define IPI_SEND_TIMEOUT_MS 100U +#define IPI_TIMEOUT_MS 100U + +#define VCP_IPI_HEADER_SIZE (sizeof(u32) * 2) +#define VCP_IPI_ALIGN (4) + +static struct mutex *mtk_vcodec_vcp_get_ipi_lock(struct mtk_vcp *vcp, u32 = ipi_id) +{ + return &vcp->ipi_desc[ipi_id].lock; +} + +static void mtk_vcodec_vcp_ipi_lock(struct mtk_vcp *vcp, u32 ipi_id) +{ + struct mutex *lock =3D mtk_vcodec_vcp_get_ipi_lock(vcp, ipi_id); + + if (!lock) + return; + + mutex_lock(lock); +} + +static void mtk_vcodec_vcp_ipi_unlock(struct mtk_vcp *vcp, u32 ipi_id) +{ + struct mutex *lock =3D mtk_vcodec_vcp_get_ipi_lock(vcp, ipi_id); + + if (!lock) + return; + + lockdep_assert_held(lock); + mutex_unlock(lock); +} + +static spinlock_t *mtk_vcodec_vcp_get_msg_queue_lock(struct mtk_vcodec_fw = *fw) +{ + return &fw->vcp->msg_queue.lock; +} + +static void mtk_vcodec_vcp_msq_queue_lock(struct mtk_vcodec_fw *fw, unsign= ed long *flags) +{ + spinlock_t *lock =3D mtk_vcodec_vcp_get_msg_queue_lock(fw); + + if (!lock) + return; + + spin_lock_irqsave(lock, *flags); +} + +static void mtk_vcodec_vcp_msq_queue_unlock(struct mtk_vcodec_fw *fw, unsi= gned long *flags) +{ + spinlock_t *lock =3D mtk_vcodec_vcp_get_msg_queue_lock(fw); + + if (!lock) + return; + + spin_unlock_irqrestore(lock, *flags); +} + +static int mtk_vcodec_vcp_notifier(struct notifier_block *nb, unsigned lon= g event, void *ptr) +{ + struct mtk_vcp *vcp =3D container_of(nb, struct mtk_vcp, vcp_notify); + + switch (event) { + case VCP_EVENT_SUSPEND: + case VCP_EVENT_STOP: + dev_dbg(&vcp->pdev->dev, "vcp notifier suspend"); + break; + case VCP_EVENT_READY: + case VCP_EVENT_RESUME: + dev_dbg(&vcp->pdev->dev, "vcp notifier ready"); + break; + } + + return NOTIFY_DONE; +} + +static void mtk_vcodec_vcp_free_msg_node(struct mtk_vcodec_fw *fw, + struct mtk_vcp_msg_node *msg_node) +{ + unsigned long flags; + + mtk_vcodec_vcp_msq_queue_lock(fw, &flags); + list_add(&msg_node->list, &fw->vcp->msg_queue.node_list); + mtk_vcodec_vcp_msq_queue_unlock(fw, &flags); +} + +static int mtk_vcodec_vcp_ipi_register(struct mtk_vcp *vcp, u32 ipi_id, vc= p_ipi_handler_t handler, + void *priv) +{ + if (!vcp) + return -EPROBE_DEFER; + + if (WARN_ON(ipi_id >=3D VCP_IPI_MAX) || WARN_ON(!handler)) + return -EINVAL; + + mtk_vcodec_vcp_ipi_lock(vcp, ipi_id); + vcp->ipi_desc[ipi_id].handler =3D handler; + vcp->ipi_desc[ipi_id].priv =3D priv; + mtk_vcodec_vcp_ipi_unlock(vcp, ipi_id); + + return 0; +} + +static int mtk_vcodec_vcp_msg_process_thread(void *arg) +{ + struct mtk_vcodec_fw *fw =3D arg; + struct vdec_vpu_ipi_ack *msg =3D NULL; + struct mtk_vcp_share_obj *obj; + struct mtk_vcp_msg_node *msg_node; + vcp_ipi_handler_t handler; + unsigned long flags; + int ret =3D 0; + + do { + ret =3D wait_event_interruptible(fw->vcp->msg_queue.wq, + atomic_read(&fw->vcp->msg_queue.cnt) > 0); + if (ret < 0) { + dev_err(&fw->pdev->dev, "wait msg queue ack timeout %d %d\n", + ret, atomic_read(&fw->vcp->msg_queue.cnt)); + continue; + } + + mtk_vcodec_vcp_msq_queue_lock(fw, &flags); + msg_node =3D list_entry(fw->vcp->msg_queue.msg_list.next, + struct mtk_vcp_msg_node, list); + list_del(&msg_node->list); + atomic_dec(&fw->vcp->msg_queue.cnt); + mtk_vcodec_vcp_msq_queue_unlock(fw, &flags); + + obj =3D &msg_node->ipi_data; + msg =3D (struct vdec_vpu_ipi_ack *)obj->share_buf; + + if (!msg->ap_inst_addr) { + dev_err(&fw->pdev->dev, "invalid message address\n"); + mtk_vcodec_vcp_free_msg_node(fw, msg_node); + continue; + } + + dev_dbg(&fw->pdev->dev, "msg ack id %d len %d msg_id 0x%x\n", obj->id, o= bj->len, + msg->msg_id); + + mtk_vcodec_vcp_ipi_lock(fw->vcp, obj->id); + handler =3D fw->vcp->ipi_desc[obj->id].handler; + if (!handler) { + dev_err(&fw->pdev->dev, "invalid ack ipi handler id =3D %d\n", obj->id); + mtk_vcodec_vcp_ipi_unlock(fw->vcp, obj->id); + mtk_vcodec_vcp_free_msg_node(fw, msg_node); + return -EINVAL; + } + + handler(msg, obj->len, fw->vcp->ipi_desc[obj->id].priv); + mtk_vcodec_vcp_ipi_unlock(fw->vcp, obj->id); + + fw->vcp->msg_signaled[obj->id] =3D true; + wake_up(&fw->vcp->msg_wq[obj->id]); + + mtk_vcodec_vcp_free_msg_node(fw, msg_node); + } while (!kthread_should_stop()); + + return ret; +} + +static int mtk_vcodec_vcp_msg_ack_isr(unsigned int id, void *prdata, void = *data, unsigned int len) +{ + struct mtk_vcodec_fw *fw =3D prdata; + struct mtk_vcp_msg_queue *msg_queue =3D &fw->vcp->msg_queue; + struct mtk_vcp_msg_node *msg_node; + struct vdec_vpu_ipi_ack *msg =3D NULL; + struct mtk_vcp_share_obj *obj =3D data; + unsigned long flags; + + msg =3D (struct vdec_vpu_ipi_ack *)obj->share_buf; + + mtk_vcodec_vcp_msq_queue_lock(fw, &flags); + if (!list_empty(&msg_queue->node_list)) { + msg_node =3D list_entry(msg_queue->node_list.next, struct mtk_vcp_msg_no= de, list); + + memcpy(&msg_node->ipi_data, obj, sizeof(*obj)); + list_move_tail(&msg_node->list, &msg_queue->msg_list); + atomic_inc(&msg_queue->cnt); + mtk_vcodec_vcp_msq_queue_unlock(fw, &flags); + + dev_dbg(&fw->pdev->dev, "push ipi_id %x msg_id %x, msg cnt %d\n", + obj->id, msg->msg_id, atomic_read(&msg_queue->cnt)); + + wake_up(&msg_queue->wq); + } else { + mtk_vcodec_vcp_msq_queue_unlock(fw, &flags); + dev_err(&fw->pdev->dev, "no free nodes in msg queue\n"); + } + + return 0; +} + +static int mtk_vcodec_vcp_msg_ipi_send(struct mtk_vcodec_fw *fw, int id, v= oid *buf, + unsigned int len, unsigned int wait) +{ + struct mtk_vcp *vcp =3D fw->vcp; + struct mtk_vcp_device *vcp_device =3D vcp->vcp_device; + bool *msg_signaled =3D &vcp->msg_signaled[id]; + wait_queue_head_t *msg_wq =3D &vcp->msg_wq[id]; + int ret, ipi_size, feature_id, mailbox_id, retry_cnt =3D 0; + unsigned long timeout_jiffies =3D 0; + struct mtk_vcp_share_obj obj =3D {0}; + unsigned int *data; + + if (!vcp_device) { + dev_dbg(&fw->pdev->dev, "vcp device is null\n"); + return -EINVAL; + } + + mutex_lock(&vcp->ipi_mutex); + feature_id =3D VDEC_FEATURE_ID; + mailbox_id =3D IPI_OUT_VDEC_1; + + timeout_jiffies =3D jiffies + msecs_to_jiffies(VCP_SYNC_TIMEOUT_MS); + while (!vcp_device->ops->vcp_is_ready(feature_id)) { + if (time_after(jiffies, timeout_jiffies)) { + vcp->ipi_id_ack[id] =3D -EINVAL; + ret =3D -EINVAL; + goto error; + } + mdelay(1); + } + + if (len > VCP_SHARE_BUF_SIZE) { + vcp->ipi_id_ack[id] =3D -EINVAL; + ret =3D -EINVAL; + goto error; + } + + obj.id =3D id; + obj.len =3D len; + memcpy(obj.share_buf, buf, len); + + ipi_size =3D round_up(VCP_IPI_HEADER_SIZE + len, VCP_IPI_ALIGN); + data =3D (unsigned int *)obj.share_buf; + dev_dbg(&fw->pdev->dev, "vcp send message: id %d len %d data 0x%x\n", + obj.id, obj.len, data[0]); + + ret =3D mtk_vcp_ipc_send(vcp_get_ipidev(vcp_device), mailbox_id, &obj, ip= i_size); + if (ret !=3D IPI_ACTION_DONE) { + vcp->ipi_id_ack[id] =3D -EIO; + ret =3D -EIO; + goto error; + } + +wait_ack: + /* wait for VCP's ACK */ + ret =3D wait_event_timeout(*msg_wq, *msg_signaled, msecs_to_jiffies(IPI_T= IMEOUT_MS)); + if (!ret || retry_cnt > 5) { + vcp->ipi_id_ack[id] =3D VCODEC_IPI_MSG_STATUS_FAIL; + dev_err(&fw->pdev->dev, "wait ipi ack timeout! %d %d\n", ret, vcp->ipi_i= d_ack[id]); + } else if (ret =3D=3D -ERESTARTSYS) { + dev_err(&fw->pdev->dev, "wait ipi ack err (%d)\n", vcp->ipi_id_ack[id]); + retry_cnt++; + goto wait_ack; + } else if (ret < 0) { + dev_err(&fw->pdev->dev, "wait ipi ack fail ret %d %d\n", ret, vcp->ipi_i= d_ack[id]); + vcp->ipi_id_ack[id] =3D VCODEC_IPI_MSG_STATUS_FAIL; + } + + dev_dbg(&fw->pdev->dev, "receive message: id %d len %d data 0x%x\n", + obj.id, obj.len, data[0]); + + *msg_signaled =3D false; + mutex_unlock(&vcp->ipi_mutex); + + return vcp->ipi_id_ack[id]; + +error: + mutex_unlock(&vcp->ipi_mutex); + dev_err(&fw->pdev->dev, "send msg error type:%d msg:%d > %d ret:%d\n", fw= ->type, len, + VCP_SHARE_BUF_SIZE, ret); + + return ret; +} + +static int check_vcp_loaded(struct mtk_vcodec_fw *fw) +{ + struct device *dev =3D &fw->pdev->dev; + struct device_driver *drv; + + drv =3D driver_find("mtk-vcp", &platform_bus_type); + if (!drv) { + dev_err(dev, "find mtk-vcp driver failed, need to reload."); + return -EINVAL; + } + + return 0; +} + +static int mtk_vcodec_vcp_get_vcp_device(struct mtk_vcodec_fw *fw) +{ + struct device *dev =3D &fw->pdev->dev; + int retry =3D 0, retry_cnt =3D 10000; + phandle vcp_phandle; + + while (try_then_request_module(check_vcp_loaded(fw), "mtk-vcp")) { + if (++retry > retry_cnt) { + dev_err(dev, "failed to load mtk-vcp module"); + return -EPROBE_DEFER; + } + msleep(1); + } + + if (of_property_read_u32(dev->of_node, "mediatek,vcp", &vcp_phandle)) { + dev_err(dev, "can't get vcp handle.\n"); + return -ENODEV; + } + + fw->vcp->vcp_device =3D mtk_vcp_get_by_phandle(vcp_phandle); + if (!fw->vcp->vcp_device) { + dev_err(dev, "get vcp device failed\n"); + return -ENODEV; + } + + return 0; +} + +static int mtk_vcodec_vcp_load_firmware(struct mtk_vcodec_fw *fw) +{ + struct mtk_vcp_device *vcp_device; + int ret, feature_id, mem_id, mailbox_id, ipi_id; + + if (fw->vcp->is_init_done) { + dev_dbg(&fw->pdev->dev, "vcp has already been initialized done.\n"); + return 0; + } + + if (mtk_vcodec_vcp_get_vcp_device(fw) < 0) { + dev_err(&fw->pdev->dev, "vcp device is null.\n"); + return -EINVAL; + } + + vcp_device =3D fw->vcp->vcp_device; + + feature_id =3D VDEC_FEATURE_ID; + mem_id =3D VDEC_MEM_ID; + mailbox_id =3D IPI_IN_VDEC_1; + ipi_id =3D VCP_IPI_LAT_DECODER; + + ret =3D mtk_vcp_mbox_ipc_register(vcp_get_ipidev(vcp_device), mailbox_id, + mtk_vcodec_vcp_msg_ack_isr, fw, &fw->vcp->share_data); + if (ret) { + dev_dbg(&fw->pdev->dev, "ipi register fail %d %d %d %d\n", ret, feature_= id, + mem_id, mailbox_id); + return -EINVAL; + } + + fw->vcp->vcp_notify.notifier_call =3D mtk_vcodec_vcp_notifier; + fw->vcp->vcp_notify.priority =3D 1; + vcp_device->ops->vcp_register_notify(feature_id, &fw->vcp->vcp_notify); + + if (!fw->vcp->is_register_done) { + ret =3D vcp_device->ops->vcp_register_feature(vcp_device, feature_id); + if (ret < 0) { + dev_err(&fw->pdev->dev, "%d register to vcp fail(%d)\n", feature_id, re= t); + return -EINVAL; + } + + fw->vcp->is_register_done =3D true; + } + + fw->vcp->is_init_done =3D true; + + mutex_init(&fw->vcp->ipi_desc[ipi_id].lock); + mutex_init(&fw->vcp->ipi_mutex); + + kthread_run(mtk_vcodec_vcp_msg_process_thread, fw, "vcp_vdec_msq_thread"); + + fw->vcp->vsi_addr =3D vcp_device->ops->vcp_get_mem_virt(mem_id); + fw->vcp->vsi_core_addr =3D fw->vcp->vsi_addr + VCODEC_VSI_LEN; + fw->vcp->vsi_size =3D vcp_device->ops->vcp_get_mem_size(mem_id); + fw->vcp->iova_addr =3D vcp_device->ops->vcp_get_mem_iova(mem_id); + + init_waitqueue_head(&fw->vcp->msg_wq[VCP_IPI_LAT_DECODER]); + init_waitqueue_head(&fw->vcp->msg_wq[VCP_IPI_CORE_DECODER]); + + dev_dbg(&fw->pdev->dev, "vdec vcp init done =3D> va: %p size:0x%x iova:%p= .\n", + fw->vcp->vsi_addr, fw->vcp->vsi_size, &fw->vcp->iova_addr); + + return 0; +} + +static unsigned int mtk_vcodec_vcp_get_vdec_capa(struct mtk_vcodec_fw *fw) +{ + return MTK_VDEC_FORMAT_MM21 | MTK_VDEC_FORMAT_H264_SLICE | MTK_VDEC_FORMA= T_VP9_FRAME | + MTK_VDEC_FORMAT_AV1_FRAME | MTK_VDEC_FORMAT_HEVC_FRAME | + MTK_VDEC_IS_SUPPORT_10BIT | MTK_VDEC_IS_SUPPORT_EXT; +} + +static void *mtk_vcodec_vcp_dm_addr(struct mtk_vcodec_fw *fw, u32 dtcm_dme= m_addr) +{ + return NULL; +} + +static int mtk_vcodec_vcp_set_ipi_register(struct mtk_vcodec_fw *fw, int i= d, + mtk_vcodec_ipi_handler handler, + const char *name, void *priv) +{ + return mtk_vcodec_vcp_ipi_register(fw->vcp, id, handler, priv); +} + +static int mtk_vcodec_vcp_ipi_send(struct mtk_vcodec_fw *fw, int id, void = *buf, + unsigned int len, unsigned int wait) +{ + return mtk_vcodec_vcp_msg_ipi_send(fw, id, buf, len, wait); +} + +static void mtk_vcodec_vcp_release(struct mtk_vcodec_fw *fw) +{ + struct mtk_vcp_device *vcp_device =3D fw->vcp->vcp_device; + struct device *dev =3D &fw->pdev->dev; + int ret, feature_id; + + if (!fw->vcp->vcp_device) { + dev_err(dev, "vcp device is null\n"); + return; + } + + if (!fw->vcp->is_register_done) + return; + + feature_id =3D VDEC_FEATURE_ID; + ret =3D vcp_device->ops->vcp_deregister_feature(vcp_device, VDEC_FEATURE_= ID); + if (ret < 0) { + dev_err(dev, "deregister feature_id(%d) fail(%d)\n", feature_id, ret); + return; + } + + fw->vcp->is_register_done =3D false; + +} + +static const struct mtk_vcodec_fw_ops mtk_vcodec_vcp_msg =3D { + .load_firmware =3D mtk_vcodec_vcp_load_firmware, + .get_vdec_capa =3D mtk_vcodec_vcp_get_vdec_capa, + .map_dm_addr =3D mtk_vcodec_vcp_dm_addr, + .ipi_register =3D mtk_vcodec_vcp_set_ipi_register, + .ipi_send =3D mtk_vcodec_vcp_ipi_send, + .release =3D mtk_vcodec_vcp_release, +}; + +struct mtk_vcodec_fw *mtk_vcodec_fw_vcp_init(void *priv, enum mtk_vcodec_f= w_use fw_use) +{ + struct mtk_vcp_msg_node *msg_node; + struct platform_device *plat_dev; + struct mtk_vcodec_fw *fw; + int i; + + if (fw_use =3D=3D DECODER) { + struct mtk_vcodec_dec_dev *dec_dev =3D priv; + + plat_dev =3D dec_dev->plat_dev; + } else { + pr_err("Invalid fw_use %d (use a reasonable fw id here)\n", fw_use); + return ERR_PTR(-EINVAL); + } + + fw =3D devm_kzalloc(&plat_dev->dev, sizeof(*fw), GFP_KERNEL); + if (!fw) + return ERR_PTR(-ENOMEM); + + fw->type =3D VCP; + fw->pdev =3D plat_dev; + fw->fw_use =3D fw_use; + fw->ops =3D &mtk_vcodec_vcp_msg; + fw->vcp =3D devm_kzalloc(&plat_dev->dev, sizeof(*fw->vcp), GFP_KERNEL); + if (!fw->vcp) + return ERR_PTR(-ENOMEM); + + INIT_LIST_HEAD(&fw->vcp->msg_queue.msg_list); + INIT_LIST_HEAD(&fw->vcp->msg_queue.node_list); + spin_lock_init(&fw->vcp->msg_queue.lock); + init_waitqueue_head(&fw->vcp->msg_queue.wq); + atomic_set(&fw->vcp->msg_queue.cnt, 0); + fw->vcp->pdev =3D plat_dev; + + for (i =3D 0; i < VCP_MAX_MQ_NODE_CNT; i++) { + msg_node =3D devm_kzalloc(&plat_dev->dev, sizeof(*msg_node), GFP_KERNEL); + if (!msg_node) + return ERR_PTR(-ENOMEM); + + list_add(&msg_node->list, &fw->vcp->msg_queue.node_list); + } + + return fw; +} diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vc= p.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h new file mode 100644 index 000000000000..fada786124d5 --- /dev/null +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h @@ -0,0 +1,139 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2025 MediaTek Inc. + * Author: Yunfei Dong + */ + +#ifndef _MTK_VCODEC_FW_VCP_H_ +#define _MTK_VCODEC_FW_VCP_H_ + +typedef void (*vcp_ipi_handler_t) (void *data, unsigned int len, void *pri= v); + +#define VCP_MAX_MQ_NODE_CNT 6 +#define VCP_SHARE_BUF_SIZE 64 + +#define VCODEC_VSI_LEN (0x2000) + +/* enum mtk_vcp_ipi_index - index used to separate different hardware */ +enum mtk_vcp_ipi_index { + VCP_IPI_LAT_DECODER, + VCP_IPI_CORE_DECODER, + VCP_IPI_MAX, +}; + +/** + * struct mtk_vcp_msg_queue - process the vcp message between kernel with = vcp + * + * @msg_list: store share buffer list which from vcp to kernel + * @wq: waitqueue that can be used to wait for vcp message + * @lock: protect msg list + * @cnt: the count of share obj in msg list + * @node_list: share obj list + */ +struct mtk_vcp_msg_queue { + struct list_head msg_list; + wait_queue_head_t wq; + spinlock_t lock; + atomic_t cnt; + struct list_head node_list; +}; + +/** + * struct mtk_vcp_ipi_desc - store the ack handler + * + * @lock: protect ack handler data + * @handler: calling this handler when kernel receive ack + * @priv: private data when calling handler to process + */ +struct mtk_vcp_ipi_desc { + struct mutex lock; + vcp_ipi_handler_t handler; + void *priv; +}; + +/** + * struct mtk_vcp_share_obj - share buffer used to send data to vcp + * + * @id: message index + * @len: message size + * @share_buf: message data + */ +struct mtk_vcp_share_obj { + unsigned int id; + unsigned int len; + unsigned char share_buf[VCP_SHARE_BUF_SIZE]; +}; + +/* enum mtk_vcp_ipi_msg_status - the status when send message to vcp */ +enum mtk_vcp_ipi_msg_status { + VCODEC_IPI_MSG_STATUS_OK =3D 0, + VCODEC_IPI_MSG_STATUS_FAIL =3D -1, + VCODEC_IPI_MSG_STATUS_MAX_INST =3D -2, + VCODEC_IPI_MSG_STATUS_ILSEQ =3D -3, + VCODEC_IPI_MSG_STATUS_INVALID_ID =3D -4, + VCODEC_IPI_MSG_STATUS_DMA_FAIL =3D -5, +}; + +/** + * struct mtk_vcp_msg_node - share buffer used to send data to vcp + * + * @ipi_data: share obj data + * @list: list to store msg node + */ +struct mtk_vcp_msg_node { + struct mtk_vcp_share_obj ipi_data; + struct list_head list; +}; + +/** + * struct mtk_vcp - vcp firmware private data + * + * @is_init_done: vcp is ready to use + * + * @ipi_mutex: used to protect ipi data + * @msg_signaled: whether receive ack from vcp + * @msg_wq: wake message queue + * + * @ipi_desc: store ack handler + * @ipi_id_ack: the ack handler status + * + * @msg_queue: process vcp message + * @share_data: temp share obj data + * + * @vcp_notify: register notifier to vcp + * + * @vsi_addr: vsi virtual data address + * @vsi_core_addr: vsi core virtual data address + * @iova_addr: vsi iova address + * @vsi_size: vsi size + * + * @pdev: platform device + * @vcp_device: vcp private data + * @is_register_done: register vcodec to vcp + */ +struct mtk_vcp { + bool is_init_done; + + struct mutex ipi_mutex; + bool msg_signaled[VCP_IPI_MAX]; + wait_queue_head_t msg_wq[VCP_IPI_MAX]; + + struct mtk_vcp_ipi_desc ipi_desc[VCP_IPI_MAX]; + bool ipi_id_ack[VCP_IPI_MAX]; + + struct mtk_vcp_msg_queue msg_queue; + struct mtk_vcp_share_obj share_data; + + struct notifier_block vcp_notify; + + void *vsi_addr; + void *vsi_core_addr; + dma_addr_t iova_addr; + int vsi_size; + + struct platform_device *pdev; + struct mtk_vcp_device *vcp_device; + bool is_register_done; +}; + +#endif --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 A829134DB7E; Wed, 11 Feb 2026 05:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788555; cv=none; b=UBF2vsqmAdJy7FC+YFlPk5ABYy+IBTuNT4IAbEDhm2wufUTLL0dUivu2kXbaziEYtRMCG5TKb9V1r/J/HYllGE3DjXa8FCMjddp8YEUQJplq2f6cbiMii7TDWrX9k1Mv0XI8CC6lxINxJL1sHF8fmhDQuqqeHAKkfAJPrw87Utk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788555; c=relaxed/simple; bh=QZsJ6NW3LSh0b//+23a7cpbYB7McomY+p1w8G0zfGJo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A4t6/qerK3qboKL8YgBALqMRuI3SbA9Cb8WfXzXxyn8eT3wsZag0NZcSYvl68eE/VWhQBHpXowgRmlWlBf7P8jqdUKAE5EQvtzYAGlZucSR/ISzj7oiud3gTyZulxokIn9uYnFSa1lzdSyhfDsNOfUnPy6PGXO5hyHVBySOaSuU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=U7SWp/HE; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="U7SWp/HE" X-UUID: 725c4a18070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=sP83mE/V22wNUz2FwAiwzp1tjQcAYyESfEE5KEPt/HY=; b=U7SWp/HECQH4l+CEHa5wrZ+frQFXYHK+LCGucypkvAu1/WKJ9VxDiKnT1kdF7sILdg4EIDFrWC8Nv7ec94pQUHj253BvOnmxtlV4sdLyc9Bi/HeY9SGu2J3KzlrVd96rOxdzMngZy/kGRkJuoy0IRas95RePagHaqrBZqi7MraA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:62d6fe8b-32c7-4205-aa6e-c3e52fc4462f,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:89c9d04,CLOUDID:8750d47a-8c8a-4fc4-88c0-3556e7711556,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 725c4a18070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1396336693; Wed, 11 Feb 2026 13:42:26 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:25 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:24 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 04/14] media: mediatek: vcodec: add driver to support vcp encoder Date: Wed, 11 Feb 2026 13:41:31 +0800 Message-ID: <20260211054149.27249-5-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" Encoder also need to call vcp interface to communicate with vcp, add driver to support encoder. Signed-off-by: Yunfei Dong --- .../vcodec/common/mtk_vcodec_fw_vcp.c | 56 ++++++++++++++++--- .../vcodec/common/mtk_vcodec_fw_vcp.h | 1 + .../mediatek/vcodec/encoder/mtk_vcodec_enc.c | 1 - .../mediatek/vcodec/encoder/mtk_vcodec_enc.h | 2 + 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vc= p.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c index 9fee52fed181..32d4e566f357 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c @@ -13,6 +13,8 @@ =20 #include "../decoder/mtk_vcodec_dec_drv.h" #include "../decoder/vdec_ipi_msg.h" +#include "../encoder/mtk_vcodec_enc.h" +#include "../encoder/mtk_vcodec_enc_drv.h" #include "mtk_vcodec_fw_priv.h" =20 #define IPI_SEND_TIMEOUT_MS 100U @@ -226,8 +228,13 @@ static int mtk_vcodec_vcp_msg_ipi_send(struct mtk_vcod= ec_fw *fw, int id, void *b } =20 mutex_lock(&vcp->ipi_mutex); - feature_id =3D VDEC_FEATURE_ID; - mailbox_id =3D IPI_OUT_VDEC_1; + if (fw->fw_use =3D=3D ENCODER) { + feature_id =3D VENC_FEATURE_ID; + mailbox_id =3D IPI_OUT_VENC_0; + } else { + feature_id =3D VDEC_FEATURE_ID; + mailbox_id =3D IPI_OUT_VDEC_1; + } =20 timeout_jiffies =3D jiffies + msecs_to_jiffies(VCP_SYNC_TIMEOUT_MS); while (!vcp_device->ops->vcp_is_ready(feature_id)) { @@ -351,10 +358,17 @@ static int mtk_vcodec_vcp_load_firmware(struct mtk_vc= odec_fw *fw) =20 vcp_device =3D fw->vcp->vcp_device; =20 - feature_id =3D VDEC_FEATURE_ID; - mem_id =3D VDEC_MEM_ID; - mailbox_id =3D IPI_IN_VDEC_1; - ipi_id =3D VCP_IPI_LAT_DECODER; + if (fw->fw_use =3D=3D ENCODER) { + feature_id =3D VENC_FEATURE_ID; + mem_id =3D VENC_MEM_ID; + mailbox_id =3D IPI_IN_VENC_0; + ipi_id =3D VCP_IPI_ENCODER; + } else { + feature_id =3D VDEC_FEATURE_ID; + mem_id =3D VDEC_MEM_ID; + mailbox_id =3D IPI_IN_VDEC_1; + ipi_id =3D VCP_IPI_LAT_DECODER; + } =20 ret =3D mtk_vcp_mbox_ipc_register(vcp_get_ipidev(vcp_device), mailbox_id, mtk_vcodec_vcp_msg_ack_isr, fw, &fw->vcp->share_data); @@ -383,6 +397,20 @@ static int mtk_vcodec_vcp_load_firmware(struct mtk_vco= dec_fw *fw) mutex_init(&fw->vcp->ipi_desc[ipi_id].lock); mutex_init(&fw->vcp->ipi_mutex); =20 + if (fw->fw_use =3D=3D ENCODER) { + kthread_run(mtk_vcodec_vcp_msg_process_thread, fw, "vcp_enc_msq_thread"); + + fw->vcp->vsi_addr =3D vcp_device->ops->vcp_get_mem_virt(mem_id); + fw->vcp->vsi_size =3D vcp_device->ops->vcp_get_mem_size(mem_id); + fw->vcp->iova_addr =3D vcp_device->ops->vcp_get_mem_iova(mem_id); + + dev_dbg(&fw->pdev->dev, "enc vcp init done =3D> va: %p size:0x%x iova:%p= ad.\n", + fw->vcp->vsi_addr, fw->vcp->vsi_size, &fw->vcp->iova_addr); + + init_waitqueue_head(&fw->vcp->msg_wq[VCP_IPI_ENCODER]); + return 0; + } + kthread_run(mtk_vcodec_vcp_msg_process_thread, fw, "vcp_vdec_msq_thread"); =20 fw->vcp->vsi_addr =3D vcp_device->ops->vcp_get_mem_virt(mem_id); @@ -406,6 +434,11 @@ static unsigned int mtk_vcodec_vcp_get_vdec_capa(struc= t mtk_vcodec_fw *fw) MTK_VDEC_IS_SUPPORT_10BIT | MTK_VDEC_IS_SUPPORT_EXT; } =20 +static unsigned int mtk_vcodec_vcp_get_venc_capa(struct mtk_vcodec_fw *fw) +{ + return MTK_VENC_4K_CAPABILITY_ENABLE; +} + static void *mtk_vcodec_vcp_dm_addr(struct mtk_vcodec_fw *fw, u32 dtcm_dme= m_addr) { return NULL; @@ -438,8 +471,8 @@ static void mtk_vcodec_vcp_release(struct mtk_vcodec_fw= *fw) if (!fw->vcp->is_register_done) return; =20 - feature_id =3D VDEC_FEATURE_ID; - ret =3D vcp_device->ops->vcp_deregister_feature(vcp_device, VDEC_FEATURE_= ID); + feature_id =3D fw->fw_use =3D=3D ENCODER ? VENC_FEATURE_ID : VDEC_FEATURE= _ID; + ret =3D vcp_device->ops->vcp_deregister_feature(vcp_device, feature_id); if (ret < 0) { dev_err(dev, "deregister feature_id(%d) fail(%d)\n", feature_id, ret); return; @@ -452,6 +485,7 @@ static void mtk_vcodec_vcp_release(struct mtk_vcodec_fw= *fw) static const struct mtk_vcodec_fw_ops mtk_vcodec_vcp_msg =3D { .load_firmware =3D mtk_vcodec_vcp_load_firmware, .get_vdec_capa =3D mtk_vcodec_vcp_get_vdec_capa, + .get_venc_capa =3D mtk_vcodec_vcp_get_venc_capa, .map_dm_addr =3D mtk_vcodec_vcp_dm_addr, .ipi_register =3D mtk_vcodec_vcp_set_ipi_register, .ipi_send =3D mtk_vcodec_vcp_ipi_send, @@ -465,7 +499,11 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_vcp_init(void *pri= v, enum mtk_vcodec_fw_use struct mtk_vcodec_fw *fw; int i; =20 - if (fw_use =3D=3D DECODER) { + if (fw_use =3D=3D ENCODER) { + struct mtk_vcodec_enc_dev *enc_dev =3D priv; + + plat_dev =3D enc_dev->plat_dev; + } else if (fw_use =3D=3D DECODER) { struct mtk_vcodec_dec_dev *dec_dev =3D priv; =20 plat_dev =3D dec_dev->plat_dev; diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vc= p.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h index fada786124d5..c0632a872892 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h @@ -16,6 +16,7 @@ typedef void (*vcp_ipi_handler_t) (void *data, unsigned i= nt len, void *priv); =20 /* enum mtk_vcp_ipi_index - index used to separate different hardware */ enum mtk_vcp_ipi_index { + VCP_IPI_ENCODER, VCP_IPI_LAT_DECODER, VCP_IPI_CORE_DECODER, VCP_IPI_MAX, diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.= c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c index 0d4e94463685..48cb5dded70a 100644 --- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c +++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c @@ -26,7 +26,6 @@ =20 #define MTK_DEFAULT_FRAMERATE_NUM 1001 #define MTK_DEFAULT_FRAMERATE_DENOM 30000 -#define MTK_VENC_4K_CAPABILITY_ENABLE BIT(0) =20 static void mtk_venc_worker(struct work_struct *work); =20 diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.= h b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.h index 908d8179b2d2..84156c102d8d 100644 --- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.h +++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.h @@ -23,6 +23,8 @@ #define MTK_VENC_IRQ_STATUS_OFFSET 0x05C #define MTK_VENC_IRQ_ACK_OFFSET 0x060 =20 +#define MTK_VENC_4K_CAPABILITY_ENABLE BIT(0) + /** * struct mtk_video_enc_buf - Private data related to each VB2 buffer. * @m2m_buf: M2M buffer --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 2845534DCCA; Wed, 11 Feb 2026 05:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788554; cv=none; b=P4yATKzHGYiekHfRlYGW8a/fo95PWF/Mfwf/BSG+RBQknYLrAAQAvNJw9t+2LtykiIl6WP5i97PM1TcOn9YdZXLn7IX0BpxzELWcJqAjL+EUK9VHGlUTRW4oRfyFFnhXyF7G4ZO7RCSzhdwfANUnXYXG/5GZKKArsIYNQmH+fYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788554; c=relaxed/simple; bh=CBnbEcsfW9rG8jpm+xy+HApI4E0OOSlKcBsJrOCyn8Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W92+n9OjMKCvrrbDd02OXgyeEOIyAqdf/lGpn2nSC0ToqDlQQpbARCNB3gLjvJTEFAz5oitGhzMD389+P/++sNX3WG+Uh373gGrJD0JCqTkai41NjbNJLQg0DinHn6ni87KSE06DWrX2g7gjPwQH/UQerPfGQxYiqOYa0b4LiCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=pMKVR2wa; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="pMKVR2wa" X-UUID: 7265c4ee070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=I8JOeYlQ4PIMz2gRUrc87JnjNhfOyg4gIeV6N6y6Lvc=; b=pMKVR2waMuvE+Zu00GnnQny8xHvQ06WazA3uzIfehwhi0Ji9vltwn5oTVCrtBGDhE73Mn7fQXtPrDfufGTO235vM+GybtFYV+qnWISlueotsx9Oy11x22H9Ar3bS/1Wl2YqnMWSsxMBvHjtycE6ly7kdGQBW5Gz+HOf1mYBWNmA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:0c992375-f131-47a7-be83-faa222e0478a,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:89c9d04,CLOUDID:eb682b5b-a957-4259-bcca-d3af718d7034,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 7265c4ee070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 71550895; Wed, 11 Feb 2026 13:42:26 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:26 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:25 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 05/14] media: mediatek: vcodec: get different firmware ipi id Date: Wed, 11 Feb 2026 13:41:32 +0800 Message-ID: <20260211054149.27249-6-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" Getting ipi(inter-processor interrupt) id according to firmware type and hardware index for different architecture. Signed-off-by: Yunfei Dong --- .../platform/mediatek/vcodec/common/mtk_vcodec_fw.c | 13 +++++++++++++ .../platform/mediatek/vcodec/common/mtk_vcodec_fw.h | 1 + .../vcodec/decoder/vdec/vdec_av1_req_lat_if.c | 5 +++-- .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c | 5 +++-- .../vcodec/decoder/vdec/vdec_hevc_req_multi_if.c | 5 +++-- .../mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c | 5 +++-- .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 5 +++-- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.c = b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.c index fc547afa4ebf..4ed7639dfa30 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.c @@ -5,6 +5,19 @@ #include "mtk_vcodec_fw_priv.h" #include "mtk_vcodec_fw_vcp.h" =20 +int mtk_vcodec_fw_get_ipi(enum mtk_vcodec_fw_type type, int hw_id) +{ + switch (type) { + case SCP: + return hw_id =3D=3D MTK_VDEC_LAT0 ? SCP_IPI_VDEC_LAT : SCP_IPI_VDEC_CORE; + case VCP: + return hw_id =3D=3D MTK_VDEC_LAT0 ? VCP_IPI_LAT_DECODER : VCP_IPI_CORE_D= ECODER; + default: + return -EINVAL; + } +} +EXPORT_SYMBOL_GPL(mtk_vcodec_fw_get_ipi); + struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_= type type, enum mtk_vcodec_fw_use fw_use) { diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h = b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h index c1642fb09b42..142e2e87905c 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h @@ -41,5 +41,6 @@ int mtk_vcodec_fw_ipi_register(struct mtk_vcodec_fw *fw, = int id, int mtk_vcodec_fw_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf, unsigned int len, unsigned int wait); int mtk_vcodec_fw_get_type(struct mtk_vcodec_fw *fw); +int mtk_vcodec_fw_get_ipi(enum mtk_vcodec_fw_type type, int hw_id); =20 #endif /* _MTK_VCODEC_FW_H_ */ diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_r= eq_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_= req_lat_if.c index 7be4b6086920..a22802c9ebea 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_= if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_= if.c @@ -1877,6 +1877,7 @@ static int vdec_av1_slice_init(struct mtk_vcodec_dec_= ctx *ctx) { struct vdec_av1_slice_instance *instance; struct vdec_av1_slice_init_vsi *vsi; + enum mtk_vcodec_fw_type fw_type =3D ctx->dev->fw_handler->type; int ret; =20 instance =3D kzalloc(sizeof(*instance), GFP_KERNEL); @@ -1884,8 +1885,8 @@ static int vdec_av1_slice_init(struct mtk_vcodec_dec_= ctx *ctx) return -ENOMEM; =20 instance->ctx =3D ctx; - instance->vpu.id =3D SCP_IPI_VDEC_LAT; - instance->vpu.core_id =3D SCP_IPI_VDEC_CORE; + instance->vpu.id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_LAT0); + instance->vpu.core_id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_CORE); instance->vpu.ctx =3D ctx; instance->vpu.codec_type =3D ctx->current_codec; =20 diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_= req_multi_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h= 264_req_multi_if.c index 9a9dc2f88d6e..2be1f6096de6 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_mul= ti_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_mul= ti_if.c @@ -1204,6 +1204,7 @@ static int vdec_h264_slice_single_decode(void *h_vdec= , struct mtk_vcodec_mem *bs =20 static int vdec_h264_slice_init(struct mtk_vcodec_dec_ctx *ctx) { + enum mtk_vcodec_fw_type fw_type =3D ctx->dev->fw_handler->type; struct vdec_h264_slice_inst *inst; int err, vsi_size; unsigned char *temp; @@ -1214,8 +1215,8 @@ static int vdec_h264_slice_init(struct mtk_vcodec_dec= _ctx *ctx) =20 inst->ctx =3D ctx; =20 - inst->vpu.id =3D SCP_IPI_VDEC_LAT; - inst->vpu.core_id =3D SCP_IPI_VDEC_CORE; + inst->vpu.id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_LAT0); + inst->vpu.core_id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_CORE); inst->vpu.ctx =3D ctx; inst->vpu.codec_type =3D ctx->current_codec; inst->vpu.capture_type =3D ctx->capture_fourcc; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_hevc_= req_multi_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h= evc_req_multi_if.c index 88eca50c2017..2b0255257384 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_hevc_req_mul= ti_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_hevc_req_mul= ti_if.c @@ -855,6 +855,7 @@ static int vdec_hevc_slice_setup_core_buffer(struct vde= c_hevc_slice_inst *inst, =20 static int vdec_hevc_slice_init(struct mtk_vcodec_dec_ctx *ctx) { + enum mtk_vcodec_fw_type fw_type =3D ctx->dev->fw_handler->type; struct vdec_hevc_slice_inst *inst; int err, vsi_size; =20 @@ -864,8 +865,8 @@ static int vdec_hevc_slice_init(struct mtk_vcodec_dec_c= tx *ctx) =20 inst->ctx =3D ctx; =20 - inst->vpu.id =3D SCP_IPI_VDEC_LAT; - inst->vpu.core_id =3D SCP_IPI_VDEC_CORE; + inst->vpu.id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_LAT0); + inst->vpu.core_id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_CORE); inst->vpu.ctx =3D ctx; inst->vpu.codec_type =3D ctx->current_codec; inst->vpu.capture_type =3D ctx->capture_fourcc; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_r= eq_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_= if.c index e1d4960553f2..36b76a92fdc2 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c @@ -272,6 +272,7 @@ static int vdec_vp8_slice_get_decode_parameters(struct = vdec_vp8_slice_inst *inst =20 static int vdec_vp8_slice_init(struct mtk_vcodec_dec_ctx *ctx) { + enum mtk_vcodec_fw_type fw_type =3D ctx->dev->fw_handler->type; struct vdec_vp8_slice_inst *inst; int err; =20 @@ -281,8 +282,8 @@ static int vdec_vp8_slice_init(struct mtk_vcodec_dec_ct= x *ctx) =20 inst->ctx =3D ctx; =20 - inst->vpu.id =3D SCP_IPI_VDEC_LAT; - inst->vpu.core_id =3D SCP_IPI_VDEC_CORE; + inst->vpu.id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_LAT0); + inst->vpu.core_id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_CORE); inst->vpu.ctx =3D ctx; inst->vpu.codec_type =3D ctx->current_codec; inst->vpu.capture_type =3D ctx->capture_fourcc; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_r= eq_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_= req_lat_if.c index cd1935014d76..a700532ed7f2 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_= if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_= if.c @@ -1844,6 +1844,7 @@ static int vdec_vp9_slice_update_core(struct vdec_vp9= _slice_instance *instance, =20 static int vdec_vp9_slice_init(struct mtk_vcodec_dec_ctx *ctx) { + enum mtk_vcodec_fw_type fw_type =3D ctx->dev->fw_handler->type; struct vdec_vp9_slice_instance *instance; struct vdec_vp9_slice_init_vsi *vsi; int ret; @@ -1853,8 +1854,8 @@ static int vdec_vp9_slice_init(struct mtk_vcodec_dec_= ctx *ctx) return -ENOMEM; =20 instance->ctx =3D ctx; - instance->vpu.id =3D SCP_IPI_VDEC_LAT; - instance->vpu.core_id =3D SCP_IPI_VDEC_CORE; + instance->vpu.id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_LAT0); + instance->vpu.core_id =3D mtk_vcodec_fw_get_ipi(fw_type, MTK_VDEC_CORE); instance->vpu.ctx =3D ctx; instance->vpu.codec_type =3D ctx->current_codec; =20 --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 8C5D334E76E; Wed, 11 Feb 2026 05:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788554; cv=none; b=lNqAYMTASdIE/al+3q+fc18SkSbFGo65mTrCIovxfJ+WqKLtpWjTvkEPlmiEFgxW1N+xpCWUUoKAXi228NUe5eYllORUR8NX+cRvFUY0eghPMIqIRa07knb937EtOcHVqbofnzrbjwc36DYDss9Xe3567x0IXl5k6EJdjN7VqqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788554; c=relaxed/simple; bh=vVImi6FkkAJvsaV57KfeNsGEt28OA47hpuPeyKw6lQg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ksrp2S1+sP5o0j2EwzoFNUlxRMsL/an65D/c+2nSwXdN4pWKJq+6K/o/y/WBYpookEPg8vmOq5jcH4iEJaSw4tjwi2yvoNJ7x2qUC6/wEqlpdK9yTFGbeOjizUMS+TVnwWfTJDeu5PAUESTp7yjEhpjYzrE5tKwxf6t51rP1PsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=lJLoYy8t; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="lJLoYy8t" X-UUID: 739fe3f8070c11f1b7fc4fdb8733b2bc-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=DVN/dqRILVbCUQZ05foM/044JuG1C5cfj/ciUmSswsg=; b=lJLoYy8tqLcBxR8M1BYvSIzmpjdXN+5WQDvH+FI1LxgxcxV2jlO3JPHmHvpVB2OdIT3xQ/M6d1YlHWbPX8+tfDALMQP0IX2HA6SZLWoKofGHA9ZAsAvZU3YzAgA/3ZsvblEEHrs44aF6xGR1jXFk299z4fN2S2R7oJzwTL/+vu4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:d9b68511-5b71-4062-bd6a-444726f40fe1,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:89c9d04,CLOUDID:22ce91f0-16bd-4243-b4ca-b08ca08ab1d8,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 739fe3f8070c11f1b7fc4fdb8733b2bc-20260211 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 139085209; Wed, 11 Feb 2026 13:42:28 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:27 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:26 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 06/14] media: mediatek: vcodec: get share memory address Date: Wed, 11 Feb 2026 13:41:33 +0800 Message-ID: <20260211054149.27249-7-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" There is only one share memory for vcp architecture, need to divide it into many different functions. Signed-off-by: Yunfei Dong --- .../vcodec/common/mtk_vcodec_fw_vcp.c | 20 ++++++++++- .../vcodec/common/mtk_vcodec_fw_vcp.h | 13 +++++++ .../vcodec/decoder/vdec/vdec_av1_req_lat_if.c | 35 ++++++++++++++++--- .../decoder/vdec/vdec_h264_req_multi_if.c | 6 +++- .../decoder/vdec/vdec_hevc_req_multi_if.c | 7 ++-- .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 24 +++++++++++-- .../mediatek/vcodec/decoder/vdec_vpu_if.c | 10 +++++- 7 files changed, 104 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vc= p.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c index 32d4e566f357..6b69ce44d4bb 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c @@ -439,8 +439,26 @@ static unsigned int mtk_vcodec_vcp_get_venc_capa(struc= t mtk_vcodec_fw *fw) return MTK_VENC_4K_CAPABILITY_ENABLE; } =20 -static void *mtk_vcodec_vcp_dm_addr(struct mtk_vcodec_fw *fw, u32 dtcm_dme= m_addr) +static void *mtk_vcodec_vcp_dm_addr(struct mtk_vcodec_fw *fw, u32 mem_type) { + unsigned char *vsi_core =3D fw->vcp->vsi_core_addr; + + switch (mem_type) { + case ENCODER_MEM: + case VCODEC_LAT_MEM: + return fw->vcp->vsi_addr; + case VCODEC_CORE_MEM: + return vsi_core; + case VP9_FRAME_MEM: + return vsi_core + VCODEC_VSI_LEN; + case AV1_CDF_MEM: + return vsi_core + VCODEC_VSI_LEN + VP9_FRAME_SIZE; + case AV1_IQ_MEM: + return vsi_core + VCODEC_VSI_LEN + VP9_FRAME_SIZE + AV1_CDF_SIZE; + default: + break; + } + return NULL; } =20 diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vc= p.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h index c0632a872892..9abc9aaba9a1 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h @@ -13,6 +13,19 @@ typedef void (*vcp_ipi_handler_t) (void *data, unsigned = int len, void *priv); #define VCP_SHARE_BUF_SIZE 64 =20 #define VCODEC_VSI_LEN (0x2000) +#define VP9_FRAME_SIZE (0x1000) +#define AV1_CDF_SIZE (0xFE80) +#define AV1_IQ_TABLE_SIZE (0x12200) + +/* enum mtk_vcp_mem_type - memory type for different hardware */ +enum mtk_vcp_mem_type { + ENCODER_MEM, + VCODEC_LAT_MEM, + VCODEC_CORE_MEM, + VP9_FRAME_MEM, + AV1_CDF_MEM, + AV1_IQ_MEM, +}; =20 /* enum mtk_vcp_ipi_index - index used to separate different hardware */ enum mtk_vcp_ipi_index { diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_r= eq_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_= req_lat_if.c index a22802c9ebea..fd5574ad86ac 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_= if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_= if.c @@ -765,6 +765,15 @@ static void *vdec_av1_get_ctrl_ptr(struct mtk_vcodec_d= ec_ctx *ctx, int id) return ctrl->p_cur.p; } =20 +static u32 vdec_av1_get_cdf_table_addr(struct mtk_vcodec_dec_ctx *ctx, + struct vdec_av1_slice_init_vsi *vsi) +{ + if (mtk_vcodec_fw_get_type(ctx->dev->fw_handler) =3D=3D VCP) + return AV1_CDF_MEM; + else + return (u32)vsi->cdf_table_addr; +} + static int vdec_av1_slice_init_cdf_table(struct vdec_av1_slice_instance *i= nstance) { u8 *remote_cdf_table; @@ -775,7 +784,7 @@ static int vdec_av1_slice_init_cdf_table(struct vdec_av= 1_slice_instance *instanc ctx =3D instance->ctx; vsi =3D instance->vpu.vsi; remote_cdf_table =3D mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, - (u32)vsi->cdf_table_addr); + vdec_av1_get_cdf_table_addr(ctx, vsi)); if (IS_ERR(remote_cdf_table)) { mtk_vdec_err(ctx, "failed to map cdf table\n"); return PTR_ERR(remote_cdf_table); @@ -796,6 +805,15 @@ static int vdec_av1_slice_init_cdf_table(struct vdec_a= v1_slice_instance *instanc return 0; } =20 +static u32 vdec_av1_get_iq_table_addr(struct mtk_vcodec_dec_ctx *ctx, + struct vdec_av1_slice_init_vsi *vsi) +{ + if (mtk_vcodec_fw_get_type(ctx->dev->fw_handler) =3D=3D VCP) + return AV1_IQ_MEM; + else + return (u32)vsi->iq_table_addr; +} + static int vdec_av1_slice_init_iq_table(struct vdec_av1_slice_instance *in= stance) { u8 *remote_iq_table; @@ -806,7 +824,7 @@ static int vdec_av1_slice_init_iq_table(struct vdec_av1= _slice_instance *instance ctx =3D instance->ctx; vsi =3D instance->vpu.vsi; remote_iq_table =3D mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, - (u32)vsi->iq_table_addr); + vdec_av1_get_iq_table_addr(ctx, vsi)); if (IS_ERR(remote_iq_table)) { mtk_vdec_err(ctx, "failed to map iq table\n"); return PTR_ERR(remote_iq_table); @@ -1873,6 +1891,15 @@ static int vdec_av1_slice_update_core(struct vdec_av= 1_slice_instance *instance, return 0; } =20 +static u32 vdec_av1_get_core_vsi_addr(struct mtk_vcodec_dec_ctx *ctx, + struct vdec_av1_slice_init_vsi *vsi) +{ + if (mtk_vcodec_fw_get_type(ctx->dev->fw_handler) =3D=3D VCP) + return VCODEC_CORE_MEM; + else + return (u32)vsi->core_vsi; +} + static int vdec_av1_slice_init(struct mtk_vcodec_dec_ctx *ctx) { struct vdec_av1_slice_instance *instance; @@ -1904,8 +1931,8 @@ static int vdec_av1_slice_init(struct mtk_vcodec_dec_= ctx *ctx) goto error_vsi; } instance->init_vsi =3D vsi; - instance->core_vsi =3D mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, (u= 32)vsi->core_vsi); - + instance->core_vsi =3D mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, + vdec_av1_get_core_vsi_addr(ctx, vsi)); if (!instance->core_vsi) { mtk_vdec_err(ctx, "failed to get AV1 core vsi\n"); ret =3D -EINVAL; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_= req_multi_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h= 264_req_multi_if.c index 2be1f6096de6..b681364d4d46 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_mul= ti_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_mul= ti_if.c @@ -1233,7 +1233,11 @@ static int vdec_h264_slice_init(struct mtk_vcodec_de= c_ctx *ctx) vsi_size =3D round_up(vsi_size, VCODEC_DEC_ALIGNED_64); inst->vsi_ext =3D inst->vpu.vsi; temp =3D (unsigned char *)inst->vsi_ext; - inst->vsi_core_ext =3D (struct vdec_h264_slice_vsi_ext *)(temp + vsi_siz= e); + if (mtk_vcodec_fw_get_type(ctx->dev->fw_handler) =3D=3D VCP) + inst->vsi_core_ext =3D + mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, VCODEC_CORE_MEM); + else + inst->vsi_core_ext =3D (struct vdec_h264_slice_vsi_ext *)(temp + vsi_si= ze); =20 if (inst->ctx->dev->vdec_pdata->hw_arch =3D=3D MTK_VDEC_PURE_SINGLE_CORE) inst->decode =3D vdec_h264_slice_single_decode_ext; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_hevc_= req_multi_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h= evc_req_multi_if.c index 2b0255257384..dd0c0191cd2c 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_hevc_req_mul= ti_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_hevc_req_mul= ti_if.c @@ -879,8 +879,11 @@ static int vdec_hevc_slice_init(struct mtk_vcodec_dec_= ctx *ctx) =20 vsi_size =3D round_up(sizeof(struct vdec_hevc_slice_vsi), VCODEC_DEC_ALIG= NED_64); inst->vsi =3D inst->vpu.vsi; - inst->vsi_core =3D - (struct vdec_hevc_slice_vsi *)(((char *)inst->vpu.vsi) + vsi_size); + if (mtk_vcodec_fw_get_type(ctx->dev->fw_handler) =3D=3D VCP) + inst->vsi_core =3D mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, VCODE= C_CORE_MEM); + else + inst->vsi_core =3D + (struct vdec_hevc_slice_vsi *)(((char *)inst->vpu.vsi) + vsi_size); =20 inst->resolution_changed =3D true; inst->realloc_mv_buf =3D true; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_r= eq_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_= req_lat_if.c index a700532ed7f2..5c2feecb8eec 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_= if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_= if.c @@ -500,6 +500,16 @@ static DEFINE_MUTEX(vdec_vp9_slice_frame_ctx_lock); =20 static int vdec_vp9_slice_core_decode(struct vdec_lat_buf *lat_buf); =20 + +static u32 vdec_vp9_get_frame_ctx_addr(struct mtk_vcodec_dec_ctx *ctx, + struct vdec_vp9_slice_init_vsi *vsi) +{ + if (mtk_vcodec_fw_get_type(ctx->dev->fw_handler) =3D=3D VCP) + return VP9_FRAME_MEM; + else + return (u32)vsi->default_frame_ctx; +} + static int vdec_vp9_slice_init_default_frame_ctx(struct vdec_vp9_slice_ins= tance *instance) { struct vdec_vp9_slice_frame_ctx *remote_frame_ctx; @@ -514,7 +524,7 @@ static int vdec_vp9_slice_init_default_frame_ctx(struct= vdec_vp9_slice_instance return -EINVAL; =20 remote_frame_ctx =3D mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, - (u32)vsi->default_frame_ctx); + vdec_vp9_get_frame_ctx_addr(ctx, vsi)); if (!remote_frame_ctx) { mtk_vdec_err(ctx, "failed to map default frame ctx\n"); return -EINVAL; @@ -1842,6 +1852,16 @@ static int vdec_vp9_slice_update_core(struct vdec_vp= 9_slice_instance *instance, return 0; } =20 +static u32 vdec_vp9_get_core_vsi_addr(struct mtk_vcodec_dec_ctx *ctx, + struct vdec_vp9_slice_init_vsi *vsi) +{ + if (mtk_vcodec_fw_get_type(ctx->dev->fw_handler) =3D=3D VCP) + return VCODEC_CORE_MEM; + else + return (u32)vsi->core_vsi; +} + + static int vdec_vp9_slice_init(struct mtk_vcodec_dec_ctx *ctx) { enum mtk_vcodec_fw_type fw_type =3D ctx->dev->fw_handler->type; @@ -1875,7 +1895,7 @@ static int vdec_vp9_slice_init(struct mtk_vcodec_dec_= ctx *ctx) } instance->init_vsi =3D vsi; instance->core_vsi =3D mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, - (u32)vsi->core_vsi); + vdec_vp9_get_core_vsi_addr(ctx, vsi)); if (!instance->core_vsi) { mtk_vdec_err(ctx, "failed to get VP9 core vsi\n"); ret =3D -EINVAL; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c b= /drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c index b35759a0b353..cdb673e6b477 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c @@ -9,6 +9,14 @@ #include "vdec_ipi_msg.h" #include "vdec_vpu_if.h" =20 +static u32 vpu_dec_get_vsi_addr(struct vdec_vpu_inst *vpu, const struct vd= ec_vpu_ipi_init_ack *msg) +{ + if (mtk_vcodec_fw_get_type(vpu->ctx->dev->fw_handler) =3D=3D VCP) + return VCODEC_LAT_MEM; + else + return msg->vpu_inst_addr; +} + static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg) { struct vdec_vpu_inst *vpu =3D (struct vdec_vpu_inst *) @@ -19,7 +27,7 @@ static void handle_init_ack_msg(const struct vdec_vpu_ipi= _init_ack *msg) /* mapping VPU address to kernel virtual address */ /* the content in vsi is initialized to 0 in VPU */ vpu->vsi =3D mtk_vcodec_fw_map_dm_addr(vpu->ctx->dev->fw_handler, - msg->vpu_inst_addr); + vpu_dec_get_vsi_addr(vpu, msg)); vpu->inst_addr =3D msg->vpu_inst_addr; =20 mtk_vdec_debug(vpu->ctx, "- vpu_inst_addr =3D 0x%x", vpu->inst_addr); --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 EC7F534F257; Wed, 11 Feb 2026 05:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788558; cv=none; b=VoYDwR7uWGvHd6FjGs0NSk2MzLwq6VlpovKL0CVJxaMpirCsUaroLSiK+XkyyNljw3Y+eRYbBbYsCAjJApIlmSh35TacqPnhAkqwYCBEg0yQygKLQ3YdXNEudrjZRBzlg/jQS00pVrtrrMKGV4HuoUwKZzSJlEs8fWB7UilfVmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788558; c=relaxed/simple; bh=Djbv85y2nFoNJ+fYMcftGNwVti7Dt4s+ISvMm6gbhGI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bSYgudGT/5NprUDYhIeCFPCIFWPr9Bl75tcRp/Dq6VYMK6bFPaL37J/Htft2pjWCHthDd0Hom4Zjxvn+La+6r2xNJP+VwHCuAMawxUHYYbb6YO3uZ+OGvqfet7Hf7FUUFd6F/VWRdsb/D03M7uVg+3tuDxsRjjcxUCi/v5ZG+gk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=dPqkBBYW; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="dPqkBBYW" X-UUID: 742cedde070c11f1b7fc4fdb8733b2bc-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=YyOeT9O6aRjml2N9/zjWM91yavUUNRa5MrFVwndBWnI=; b=dPqkBBYW7DZrCOP7BRADq2vJnMjAvv5W7LlrcFkniZoIbg1f5VB1SqYE6DSZ+rnbGaVC1+ItfaYJ5W20z+Oz1NKa0luTaza1xo/4BYIpDQbYVOTek66gytBDRl5BI60NjbNTc0Kq+WRNsHdx0CIzuwE9QtOCGeN5XIPJidYKksM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:c4c7142a-7401-469a-8a3a-10e9f8cbdbd5,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:89c9d04,CLOUDID:47ce91f0-16bd-4243-b4ca-b08ca08ab1d8,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 742cedde070c11f1b7fc4fdb8733b2bc-20260211 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1656069170; Wed, 11 Feb 2026 13:42:29 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS09N2.mediatek.inc (172.21.101.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:28 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:27 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 07/14] media: mediatek: vcodec: define MT8196 vcodec levels. Date: Wed, 11 Feb 2026 13:41:34 +0800 Message-ID: <20260211054149.27249-8-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" The supported level and profile are not the same for different codecs and architecture. Select the correct one. Signed-off-by: Yunfei Dong Reviewed-by: Nicolas Dufresne --- .../mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_= stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec= _stateless.c index 8e1cf16a168a..50f12ff7c100 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_statele= ss.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_statele= ss.c @@ -577,6 +577,7 @@ static void mtk_vcodec_dec_fill_h264_level(struct v4l2_= ctrl_config *cfg, cfg->max =3D V4L2_MPEG_VIDEO_H264_LEVEL_5_2; break; case MTK_VDEC_MT8195: + case MTK_VDEC_MT8196: cfg->max =3D V4L2_MPEG_VIDEO_H264_LEVEL_6_0; break; case MTK_VDEC_MT8183: @@ -595,6 +596,7 @@ static void mtk_vcodec_dec_fill_h264_profile(struct v4l= 2_ctrl_config *cfg, switch (ctx->dev->chip_name) { case MTK_VDEC_MT8188: case MTK_VDEC_MT8195: + case MTK_VDEC_MT8196: cfg->max =3D V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10; break; default: @@ -611,6 +613,7 @@ static void mtk_vcodec_dec_fill_h265_level(struct v4l2_= ctrl_config *cfg, cfg->max =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1; break; case MTK_VDEC_MT8195: + case MTK_VDEC_MT8196: cfg->max =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2; break; default: @@ -625,6 +628,7 @@ static void mtk_vcodec_dec_fill_h265_profile(struct v4l= 2_ctrl_config *cfg, switch (ctx->dev->chip_name) { case MTK_VDEC_MT8188: case MTK_VDEC_MT8195: + case MTK_VDEC_MT8196: cfg->max =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10; break; default: @@ -642,6 +646,7 @@ static void mtk_vcodec_dec_fill_vp9_level(struct v4l2_c= trl_config *cfg, cfg->max =3D V4L2_MPEG_VIDEO_VP9_LEVEL_5_1; break; case MTK_VDEC_MT8195: + case MTK_VDEC_MT8196: cfg->max =3D V4L2_MPEG_VIDEO_VP9_LEVEL_5_2; break; case MTK_VDEC_MT8186: @@ -659,6 +664,7 @@ static void mtk_vcodec_dec_fill_vp9_profile(struct v4l2= _ctrl_config *cfg, switch (ctx->dev->chip_name) { case MTK_VDEC_MT8188: case MTK_VDEC_MT8195: + case MTK_VDEC_MT8196: cfg->max =3D V4L2_MPEG_VIDEO_VP9_PROFILE_2; break; default: --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 B40D73542C3; Wed, 11 Feb 2026 05:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788563; cv=none; b=vGahtv+jrlhHoc0vz/1zhHz8zhyaPzhsJr5iSdJb6u+jyoFfPrf8VYNCqNntwVPOG0Y0tortoimVUkkwIpx6WgK2XORehS+NkoLR0ifW5ZxQs0InkO9cNhqroCXrepktGs4PyBbFyjG2uotK1q0NmS0zf7Lp9e8FYkqMEMKSiiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788563; c=relaxed/simple; bh=3oBnyJNrzN+gy5Rmw7YzX+rdgyHOwTlZSx8Z5EVUmBY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dUqWUENC5E1xR/CyNjwzUx7Tt9ogLTGZfTjZpoF3N6fitMxodL92kGilgn8xKrxelpUHGoJb1p9tLmGPyJktddXcNj0Q5jI118blaqkglei9552Ii5cJlr8nU1U7L5I9jLtmdiirt2ctNdEqgXGOmNBHq/BH0cZa3399q7tEQl4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=X9EHb/lt; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="X9EHb/lt" X-UUID: 74dfe998070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=W50oqbR0eI6igwOGBiAI8u7uiOJbS1jWeDgipBWJQIA=; b=X9EHb/ltG7YjyRYDuHF8UoFWKGrVh8WSg1ZJWZCHslXj1Z/JWUCxNkBgA0h3lyFqQ3Tx42qumaf3/ZDyYrDI6iJTZsF6GfAOxMJNABpZ/qYH3SuK3EBDaE6Hif+yYopNlzBYJSHv2mLBmDy19nP7hV9/eR4Bb6yEw2E+FvKI1Jk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:97bc7eec-be7e-4661-8673-46a64f2b4742,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:89c9d04,CLOUDID:37788de9-ef90-4382-9c6f-55f2a0689a6b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 74dfe998070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1699497260; Wed, 11 Feb 2026 13:42:30 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:29 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:28 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 08/14] media: mediatek: vcodec: support vcp architecture Date: Wed, 11 Feb 2026 13:41:35 +0800 Message-ID: <20260211054149.27249-9-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" Some platforms expose the video codec through the VCP coprocessor. Use the VCP architecture when the VCP coprocessor is found. Signed-off-by: Yunfei Dong Reviewed-by: Nicolas Dufresne --- .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_= drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c index d9f722698198..3db046a1aeac 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c @@ -381,6 +381,9 @@ static int mtk_vcodec_probe(struct platform_device *pde= v) } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp", &rproc_phandle)) { fw_type =3D SCP; + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vcp", + &rproc_phandle)) { + fw_type =3D VCP; } else { dev_dbg(&pdev->dev, "Could not get vdec IPI device"); return -ENODEV; --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 215E834FF55; Wed, 11 Feb 2026 05:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788558; cv=none; b=HiPz1w6FQXh6qAWjWFvqPnWR9a42ZHnoFj18tADFbI0Bnep71c9RGcq4Wqht0dbRgqdmy2fcjdVLpvXPFO4jcJnnJKsdlJ03qhEqf47JneLrJzj5jnT3+vn7IfK0Gd35YYFWz3TuitzXigcUAsc2eVF/u0hY/j6o5wkiSGniH20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788558; c=relaxed/simple; bh=MbCCmzoNxJ6nBvTtEjyO3AYkufSWDgGMXlg2rrVFb8s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TrQsrM/ccLCNKR2Qy+8CbXT8c1mPPKf71VmyufwMBql25rGYpBVPwrsM5kqdJCMMhNvx/o6n6XMMW4771hdGnIb+rYdZipdgjbHqVbM7GHJ6tFYLdVDA+hK2+2OUzQJzs6ZnBV62+TWWqG7EcXGt+wnUJdsX60BJ+UAv3V1oBuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=hz2sIg9+; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="hz2sIg9+" X-UUID: 74e644fa070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=vgySz46TlUlfjH8Hsk+mqZkV9li9/Ry3boCNgFq6I1c=; b=hz2sIg9+r0zxgf1IxN83dDEOK5DggZaGpQX2gAXW9zbTbqWmz/DDfyd1It1i9k+zoM8FOjeLb6BLeUFs9erxW/S6imSYVAWcQ0bzhRPSLlZ30oTLvkL+/Q3JtMplb55Wwk44XiLPhgXfeEZ8NgdsTQV4pLwDSQeqCL+Sl9BBAGk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:ac26a9ef-733c-433c-9fe9-16d52aa7aee2,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:89c9d04,CLOUDID:39788de9-ef90-4382-9c6f-55f2a0689a6b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 74e644fa070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 178863440; Wed, 11 Feb 2026 13:42:30 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:30 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:29 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 09/14] media: mediatek: vcodec: support 36bit iova address Date: Wed, 11 Feb 2026 13:41:36 +0800 Message-ID: <20260211054149.27249-10-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" Need to set dma mask to support 36bit iova address for decoder hardware can use 36bit address to decode for mt8196. Signed-off-by: Yunfei Dong Reviewed-by: Nicolas Dufresne --- .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_= drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c index 3db046a1aeac..7ed40936a0e8 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c @@ -389,6 +389,13 @@ static int mtk_vcodec_probe(struct platform_device *pd= ev) return -ENODEV; } dma_set_max_seg_size(&pdev->dev, UINT_MAX); + if (dev->chip_name =3D=3D MTK_VDEC_MT8196) { + ret =3D dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(36)); + if (ret) { + dev_err(&pdev->dev, "Failed to enable 36-bit DMA: %d\n", ret); + return ret; + } + } =20 dev->fw_handler =3D mtk_vcodec_fw_select(dev, fw_type, DECODER); if (IS_ERR(dev->fw_handler)) --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 8E91332AAD1; Wed, 11 Feb 2026 05:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788570; cv=none; b=u7O5NKDVn2yvr+4sqzGk7naxTMWPIcr5UoKCwmTYh+xCANXp4+WwDoL3KAVlCbwdaUtskXxEKbHCCqEdZbxciz9TNSt0L88geJC5WzKANb6HWho+Ed4xl2lWDQk5DGGVEP+ej3Xwf7Qm9Xl8GD1gjyPytiZ8anD6NO6Xkz5yXrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788570; c=relaxed/simple; bh=QJJ2rE4MNtbgQYa/bE30JePV4kC0smbQDThyHgCYlbI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AOPjUBTJ1Xd8/zfYh1L+75GB+wShZaVl6tXcyPoggR1p/OfW6rlzFu90MbSFPrmyh4x4RW3JpV0vBd7BmhppC8yoAwZWgqI4hYqwpZPuYJWBjuSM55/xlPCQ9LDqWZUa+2MRMTN8HYMEOf07DC4e7BRg1KofgUwiSQ55+4CAh+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=jkvXbUZH; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="jkvXbUZH" X-UUID: 7619b992070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=rth3eEYX1mJeBa3vsqLYmJh6OVUcxBZs54IkCDDT1lw=; b=jkvXbUZHNU8z3T1ALYbe6iyCGnX4os94nJiPIMD+c2YMDG3lZlx3UwcyMUDNDmktvv1e20pY4s7/Fh5XyNhJnCJW6DYkgMk+dvzyoyjmNXmvmE4ZxeVQSJxxAs2aBwTyEkqyrYOS58il3rN9WdIaJBl1TKKd3n6uEB5m9lyWbiA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:b3820028-7ce5-4ed6-97f9-37ca6d6a273a,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:89c9d04,CLOUDID:5c788de9-ef90-4382-9c6f-55f2a0689a6b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 7619b992070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2136975920; Wed, 11 Feb 2026 13:42:32 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:31 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:30 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 10/14] media: mediatek: vcodec: clean xpc status Date: Wed, 11 Feb 2026 13:41:37 +0800 Message-ID: <20260211054149.27249-11-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" The driver need to clean xpc status when receive decoder hardware interrupt for mt8196 platform. Signed-off-by: Yunfei Dong Reviewed-by: Nicolas Dufresne --- .../vcodec/decoder/mtk_vcodec_dec_hw.c | 28 +++++++++++++++++++ .../vcodec/decoder/mtk_vcodec_dec_hw.h | 13 +++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_= hw.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c index 881d5de41e05..e4e527fe54dc 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c @@ -61,6 +61,31 @@ static int mtk_vdec_hw_prob_done(struct mtk_vcodec_dec_d= ev *vdec_dev) return 0; } =20 +static void mtk_vdec_hw_write_reg_mask(void __iomem *reg_base, u32 reg_off= set, u32 val, u32 mask) +{ + void __iomem *reg_addr =3D reg_base + reg_offset; + u32 reg_val; + + reg_val =3D readl(reg_addr); + reg_val &=3D ~mask; + reg_val |=3D (val & mask); + writel(reg_val, reg_addr); +} + +static void mtk_vdec_hw_clean_xpc(struct mtk_vdec_hw_dev *dev) +{ + u32 val, mask, addr =3D VDEC_XPC_CLEAN_ADDR; + + if (dev->main_dev->chip_name !=3D MTK_VDEC_MT8196) + return; + + val =3D dev->hw_idx =3D=3D MTK_VDEC_LAT0 ? VDEC_XPC_LAT_VAL : VDEC_XPC_CO= RE_VAL; + mask =3D dev->hw_idx =3D=3D MTK_VDEC_LAT0 ? VDEC_XPC_LAT_MASK : VDEC_XPC_= CORE_MASK; + + mtk_vdec_hw_write_reg_mask(dev->reg_base[VDEC_HW_XPC], addr, val, mask); + mtk_vdec_hw_write_reg_mask(dev->reg_base[VDEC_HW_XPC], addr, 0, mask); +} + static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void *priv) { struct mtk_vdec_hw_dev *dev =3D priv; @@ -88,6 +113,8 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void= *priv) writel(dec_done_status | VDEC_IRQ_CFG, vdec_misc_addr); writel(dec_done_status & ~VDEC_IRQ_CLR, vdec_misc_addr); =20 + mtk_vdec_hw_clean_xpc(dev); + wake_up_dec_ctx(ctx, MTK_INST_IRQ_RECEIVED, dev->hw_idx); =20 mtk_v4l2_vdec_dbg(3, ctx, "wake up ctx %d, dec_done_status=3D%x", @@ -166,6 +193,7 @@ static int mtk_vdec_hw_probe(struct platform_device *pd= ev) subdev_dev->hw_idx =3D hw_idx; subdev_dev->main_dev =3D main_dev; subdev_dev->reg_base[VDEC_HW_SYS] =3D main_dev->reg_base[VDEC_HW_SYS]; + subdev_dev->reg_base[VDEC_HW_XPC] =3D main_dev->reg_base[VDEC_HW_MISC]; set_bit(subdev_dev->hw_idx, main_dev->subdev_bitmap); =20 if (IS_SUPPORT_VDEC_HW_IRQ(hw_idx)) { diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_= hw.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.h index 83fe8b9428e6..5c906143c9af 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.h +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.h @@ -18,17 +18,26 @@ #define VDEC_IRQ_CLR 0x10 #define VDEC_IRQ_CFG_REG 0xa4 =20 +#define VDEC_XPC_CLEAN_ADDR 0xc +#define VDEC_XPC_LAT_VAL BIT(0) +#define VDEC_XPC_LAT_MASK BIT(0) + +#define VDEC_XPC_CORE_VAL BIT(4) +#define VDEC_XPC_CORE_MASK BIT(4) + #define IS_SUPPORT_VDEC_HW_IRQ(hw_idx) ((hw_idx) !=3D MTK_VDEC_LAT_SOC) =20 /** * enum mtk_vdec_hw_reg_idx - subdev hardware register base index - * @VDEC_HW_SYS : vdec soc register index + * @VDEC_HW_SYS: vdec soc register index * @VDEC_HW_MISC: vdec misc register index - * @VDEC_HW_MAX : vdec supported max register index + * @VDEC_HW_XPC: vdec xpc register index + * @VDEC_HW_MAX: vdec supported max register index */ enum mtk_vdec_hw_reg_idx { VDEC_HW_SYS, VDEC_HW_MISC, + VDEC_HW_XPC, VDEC_HW_MAX }; =20 --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 56F9034F469; Wed, 11 Feb 2026 05:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788563; cv=none; b=tupKbXuXKrTLKy7BAvg9m1GcsmcORz5Yqmo8w7rU7SwZRa83aDbEuQ77ZWvltAe0UP6NejZ8qfv/2J6z+HuIXQB253qWXN29syqMht2DkPPcDtq1pwWjnVWZRmynKOwW5EjhGb71GwDSTvfDkCo6m36ltF+GcPvRF4CJyP3B7Q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788563; c=relaxed/simple; bh=3thw4NfFdeP3JXHype/OBUTqDDI8TNQuLLMvB7ghI98=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MpiDIoIhKivoj870XX20iYlbwFpPIcL+PoRMyUKckZ+WB6e2c0FWyoiSLxIZy7V5v/ELh/ePQMkRLSVBnODbZoTlwjdDfUx5hBLN7isZO7aSoSdfuiITeGxKInE/X/4CX1dXalDaR4rc924C6lRe03/IjC/i0xvf73NhZV3UPqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=A2l48PjW; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="A2l48PjW" X-UUID: 7621f170070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=eGspLHbpygDK2bKTNo5LRmeiQiktsodc8p2NlA9SHpw=; b=A2l48PjWWsB64GOwS8YzZowxWu6Ymj8POaRmCUgQ2pwObgeReUbhFpHXkBYa1amrIxsEGOIMeQTWmwtrmK8tVy0PVFi+jxxji6L0Ko8x7eRSV0T3n/1FfKGlaHOVUnqslDgeu9AGo2h94wdUlasODDcUgY/8eFRN2gD5EIZPiRI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:322d48e9-b20f-4453-ad97-25fa847e4c17,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:89c9d04,CLOUDID:31692b5b-a957-4259-bcca-d3af718d7034,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 7621f170070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 244322738; Wed, 11 Feb 2026 13:42:32 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:32 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:31 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 11/14] media: mediatek: vcodec: add debug information Date: Wed, 11 Feb 2026 13:41:38 +0800 Message-ID: <20260211054149.27249-12-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" Print hevc/av1 output format and 10bit capture format information to debug. Signed-off-by: Yunfei Dong Reviewed-by: Nicolas Dufresne --- .../mediatek/vcodec/common/mtk_vcodec_dbgfs.c | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs= .c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c index 643d6fff088b..5eead4eb6f31 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c @@ -29,6 +29,14 @@ static void mtk_vdec_dbgfs_get_format_type(struct mtk_vc= odec_dec_ctx *ctx, char curr_len =3D snprintf(buf + *used, total - *used, "\toutput format: vp9 slice\n"); break; + case V4L2_PIX_FMT_HEVC_SLICE: + curr_len =3D snprintf(buf + *used, total - *used, + "\toutput format: hevc slice\n"); + break; + case V4L2_PIX_FMT_AV1_FRAME: + curr_len =3D snprintf(buf + *used, total - *used, + "\toutput format: av1 slice\n"); + break; default: curr_len =3D snprintf(buf + *used, total - *used, "\tunsupported output format: 0x%x\n", @@ -45,6 +53,14 @@ static void mtk_vdec_dbgfs_get_format_type(struct mtk_vc= odec_dec_ctx *ctx, char curr_len =3D snprintf(buf + *used, total - *used, "\tcapture format: MT21C\n"); break; + case V4L2_PIX_FMT_MT2110T: + curr_len =3D snprintf(buf + *used, total - *used, + "\tcapture format: MT2110T (10bit tile mode)\n"); + break; + case V4L2_PIX_FMT_MT2110R: + curr_len =3D snprintf(buf + *used, total - *used, + "\tcapture format: MT2110T (10bit raster mode)\n"); + break; default: curr_len =3D snprintf(buf + *used, total - *used, "\tunsupported capture format: 0x%x\n", @@ -122,9 +138,10 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, = char __user *ubuf, =20 if (dbgfs_index[MTK_VDEC_DBGFS_PICINFO]) { curr_len =3D snprintf(buf + used_len, total_len - used_len, - "\treal(%dx%d)=3D>align(%dx%d)\n", + "\treal(%dx%d)=3D>align(%dx%d) 10bit(%d)\n", ctx->picinfo.pic_w, ctx->picinfo.pic_h, - ctx->picinfo.buf_w, ctx->picinfo.buf_h); + ctx->picinfo.buf_w, ctx->picinfo.buf_h, + ctx->is_10bit_bitstream); used_len +=3D curr_len; } =20 --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 9CA0934E75C; Wed, 11 Feb 2026 05:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788565; cv=none; b=IJXAvLxWNNDullc/fdpsJ5hTVrXh8swxKsYXd6K/KSaG3XQ2Brzo3luRoINR0cySzB7+Wlpx9xViNOgvQH8X0ahQl2GxlEwjR7cPCWhfHQkKxNACZ4IUsM/Rv50u2ObnaKwA8HfhYMB6HARolNuHW/MF6peN+P/kHGhe7hr35+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788565; c=relaxed/simple; bh=qj3/SBNT4NTwaP/sKaZGZ2fLwhndnVa55md+IZ0B9LM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iz6riN54PNeGzTcfHzeQ/PNq1OzkNGgM0lArltwjMdyAw9FHpx++Dozlk8HcS+EAxRx/gRvh47hs5QKaAkXksx2ViommE7YLi0/0MK6Jr1SVCbYcg94CrtSLpwXlugOJ0FGiaUvVkATWStmse33kTCATCETrqY9qgSPlzNqWXNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=gAtLgoLo; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="gAtLgoLo" X-UUID: 775195f0070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Y8DpaSc1WPAjTrsmRWTAxjOgRGI49+21nGlzJkD+N60=; b=gAtLgoLoDwz/ZBEtWPBRBYZsKUG9vDoODpBbTQlWXbaxdhaXW7cuAK41wK2gvikK8in5G73eU+BYrMQRlfqjuOxuQJXcQPjsmGJdEIfV+I65T8EXAtAjVbFqgLbD+idvvipL0XqHvBg72E8kkj3G5gJiZTJ8U1d6eUAlgtYHfCQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:e2cafbe7-28dc-4f18-b0c0-76041cdab59f,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:89c9d04,CLOUDID:fb50d47a-8c8a-4fc4-88c0-3556e7711556,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 775195f0070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs09n2.mediatek.inc [(172.21.101.94)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1310561763; Wed, 11 Feb 2026 13:42:34 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:33 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:32 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 12/14] media: mediatek: vcodec: send share memory address to vcp Date: Wed, 11 Feb 2026 13:41:39 +0800 Message-ID: <20260211054149.27249-13-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" The share memory is allocated in kernel for vcp architecture, it's different with vpu which share memors is reserved in vpu micro processor. Need to send share memory address to vcp. Signed-off-by: Yunfei Dong --- drivers/media/platform/mediatek/vcodec/decoder/vdec_ipi_msg.h | 2 ++ drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_ipi_msg.h = b/drivers/media/platform/mediatek/vcodec/decoder/vdec_ipi_msg.h index 47070be2a991..097561a1efdc 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_ipi_msg.h +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_ipi_msg.h @@ -67,11 +67,13 @@ struct vdec_vpu_ipi_ack { * @msg_id : AP_IPIMSG_DEC_INIT * @codec_type : codec fourcc * @ap_inst_addr : AP video decoder instance address + * @shared_iova : reserved share memory address */ struct vdec_ap_ipi_init { uint32_t msg_id; u32 codec_type; uint64_t ap_inst_addr; + u64 shared_iova; }; =20 /** diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c b= /drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c index cdb673e6b477..3a10b32be094 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c @@ -236,6 +236,8 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu) msg.msg_id =3D AP_IPIMSG_DEC_INIT; msg.ap_inst_addr =3D (unsigned long)vpu; msg.codec_type =3D vpu->codec_type; + if (mtk_vcodec_fw_get_type(vpu->ctx->dev->fw_handler) =3D=3D VCP) + msg.shared_iova =3D vpu->ctx->dev->fw_handler->vcp->iova_addr; =20 mtk_vdec_debug(vpu->ctx, "vdec_inst=3D%p", vpu); =20 --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 A9BE43502BA; Wed, 11 Feb 2026 05:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788571; cv=none; b=cOhdNutoBuKybdqgbDxwDLnZ/cwYq3Rsl71S5NOYEtjMXtthHX2Ku3cA7/AFB8w/KWnLu7oxF1tX9P11qzvZs9XBzCiHC3wHLuYT6Co6JvErsB6f5BwxrHH2O4LHYYcVSLD96k4PyS8m6SUxiCIl8R8c2ZmqHPVSvfVu73U2X60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788571; c=relaxed/simple; bh=wPVwI7oPzjnFrvM3kqJWRaFD2aX3ySYtIML7w/wakPY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qHMSjx0A4cM8Sb8CUG4tsudSXEGRQPpcxgV9Bzwj3Go2vK7wQtBqkcgCXfcpzOR40ECdIMGs/mJjn6vMyiedHJqQUfof3xRcfTZnTmmtoq6SCNCR/ayaixv3mHkLyy7jbnlD5Ig1pZyhtoMbsOhW5xHhtmIKxT9GVgr91cctOm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=jMJmdusI; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="jMJmdusI" X-UUID: 77f42946070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=68sSOZnSUXmqiHf+pECQ9+W2kaqKQgCqtFWFG7AgXOE=; b=jMJmdusIsxWZKcQgAFSEOZPl+v6KisW34PjyqOauO82Oc6onpeYYiuKVaLhAC04xip+bTy0G3CarLha9z5d0jxMK2Uh3/lQxRsXSkE1SZNKr9930vrkCKWNBv/fU38JrsC4vv9ta+zCz5YJH0Fy8fYXwjNkrIoOBND6MIBwhVwg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:e0a53a1f-d5dd-4053-a514-fe8210c6904b,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:89c9d04,CLOUDID:fa50d47a-8c8a-4fc4-88c0-3556e7711556,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 77f42946070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 317260869; Wed, 11 Feb 2026 13:42:35 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS09N2.mediatek.inc (172.21.101.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:34 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:33 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 13/14] media: mediatek: decoder: fill av1 buffer size with picinfo Date: Wed, 11 Feb 2026 13:41:40 +0800 Message-ID: <20260211054149.27249-14-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" The buffer size of y and c plane has been calculated in vcp/scp, can fill each frame buffer size with picinfo directly. Signed-off-by: Yunfei Dong Reviewed-by: Nicolas Dufresne --- .../vcodec/decoder/vdec/vdec_av1_req_lat_if.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_r= eq_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_= req_lat_if.c index fd5574ad86ac..d613decae8f8 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_= if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_= if.c @@ -1811,18 +1811,19 @@ static int vdec_av1_slice_setup_core_buffer(struct = vdec_av1_slice_instance *inst { struct vb2_buffer *vb; struct vb2_queue *vq; - int w, h, plane, size; + int plane; int i; =20 plane =3D instance->ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes; - w =3D vsi->frame.uh.upscaled_width; - h =3D vsi->frame.uh.frame_height; - size =3D ALIGN(w, VCODEC_DEC_ALIGNED_64) * ALIGN(h, VCODEC_DEC_ALIGNED_64= ); =20 /* frame buffer */ vsi->fb.y.dma_addr =3D fb->base_y.dma_addr; + + vsi->fb.y.size =3D instance->ctx->picinfo.fb_sz[0]; + vsi->fb.c.size =3D instance->ctx->picinfo.fb_sz[1]; + if (plane =3D=3D 1) - vsi->fb.c.dma_addr =3D fb->base_y.dma_addr + size; + vsi->fb.c.dma_addr =3D fb->base_y.dma_addr + vsi->fb.y.size; else vsi->fb.c.dma_addr =3D fb->base_c.dma_addr; =20 @@ -1845,8 +1846,9 @@ static int vdec_av1_slice_setup_core_buffer(struct vd= ec_av1_slice_instance *inst } =20 vref->y.dma_addr =3D vb2_dma_contig_plane_dma_addr(vb, 0); + vref->y.size =3D vsi->fb.y.size; if (plane =3D=3D 1) - vref->c.dma_addr =3D vref->y.dma_addr + size; + vref->c.dma_addr =3D vref->y.dma_addr + vsi->fb.y.size; else vref->c.dma_addr =3D vb2_dma_contig_plane_dma_addr(vb, 1); } --=20 2.45.2 From nobody Wed Feb 11 10:02:04 2026 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 969F935581D; Wed, 11 Feb 2026 05:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788568; cv=none; b=JOfpMEQBlg+ZaiJ29kdNUJwKqcS9wU+B4eUAqj7vMQcxK02l/DGpFpJVvx2iTY/MjuFdQi4lfzRpqzjtxKAvtJ5O1rAObQlvdN4/t/UNoXbILTPLo32XrPU9jzE3KmJi3mNYaEPKmmCyFPvK/+fqpqy/rRh5cegvabJ64WfUK1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770788568; c=relaxed/simple; bh=Dm62YSP35rO2I3MBXhutYy0Axtp6NdaafYgEv/FqjYE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YBGx9d7IgeJDD2VGtXfrEuf/DDeuJIvjYU7JKLVgDXaXSgByEp2wusguqPl3EU0ZzMbrSRS13ULhgIB4Zq94JHgSiJytNFTL0L28tJzgBalWzV9MU1eGqT/Gpc4+wLSI2B1kySB74p55FrwKHbmVI2L768VFZvi2HUQYJbQuOpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=SDs7BlC1; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="SDs7BlC1" X-UUID: 7896efb4070c11f185319dbc3099e8fb-20260211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=2gIr27ibXlLtUFUdzTrS2GZG197SokLGpR00S8KqYCs=; b=SDs7BlC13ErWkiP77HHbetBNJCYWT5uDsPn3t5ijWx82K1Rw895zBdP5m1xfPWs/hFPyfda1OqiDqtWyXowFmbLXLJCsz75ETHHgBMWZrfukA+5nQGQSPRZZ//Kt1FDz0ig9kWVC4//4TOj8N43+UOMZuXS38gGt23eY1jKSH1o=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:93dfd151-7481-4854-8e33-dcd93113330e,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:89c9d04,CLOUDID:7f788de9-ef90-4382-9c6f-55f2a0689a6b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 7896efb4070c11f185319dbc3099e8fb-20260211 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1929309200; Wed, 11 Feb 2026 13:42:36 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 11 Feb 2026 13:42:35 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 11 Feb 2026 13:42:34 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v3 14/14] media: mediatek: decoder: support av1 extend vsi Date: Wed, 11 Feb 2026 13:41:41 +0800 Message-ID: <20260211054149.27249-15-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20260211054149.27249-1-yunfei.dong@mediatek.com> References: <20260211054149.27249-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" The driver can't access tile buffer address for extend architecture, set tile group information in vcp and share it with kernel. Signed-off-by: Yunfei Dong --- .../vcodec/decoder/vdec/vdec_av1_req_lat_if.c | 59 ++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_r= eq_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_= req_lat_if.c index d613decae8f8..7d112a633484 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_= if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_= if.c @@ -25,6 +25,9 @@ =20 #define AV1_INVALID_IDX -1 =20 +#define AV1_NON_EXT_VSI_SIZE 0xD50 +#define AV1_TILE_SIZE 64 + #define AV1_DIV_ROUND_UP_POW2(value, n) \ ({ \ typeof(n) _n =3D n; \ @@ -641,6 +644,8 @@ struct vdec_av1_slice_fb { * @frame: current frame info * @state: status after decode done * @cur_lst_tile_id: tile id for large scale + * @tile_group: tile group info + * @reserved: reserved */ struct vdec_av1_slice_vsi { /* lat */ @@ -665,6 +670,8 @@ struct vdec_av1_slice_vsi { struct vdec_av1_slice_frame frame; struct vdec_av1_slice_state state; u32 cur_lst_tile_id; + struct vdec_av1_slice_tile_group tile_group; + unsigned int reserved[4]; }; =20 /** @@ -1402,17 +1409,29 @@ static void vdec_av1_slice_setup_uh(struct vdec_av1= _slice_instance *instance, vdec_av1_slice_setup_tile(frame, &ctrl_fh->tile_info); } =20 +static +struct vdec_av1_slice_tile_group *vdec_av1_get_tile_group(struct vdec_av1_= slice_instance *instance, + struct vdec_av1_slice_vsi *vsi) +{ + if (IS_VDEC_SUPPORT_EXT(instance->ctx->dev->dec_capability)) + return &vsi->tile_group; + else + return &instance->tile_group; +} + static int vdec_av1_slice_setup_tile_group(struct vdec_av1_slice_instance = *instance, struct vdec_av1_slice_vsi *vsi) { struct v4l2_ctrl_av1_tile_group_entry *ctrl_tge; - struct vdec_av1_slice_tile_group *tile_group =3D &instance->tile_group; + struct vdec_av1_slice_tile_group *tile_group; struct vdec_av1_slice_uncompressed_header *uh =3D &vsi->frame.uh; struct vdec_av1_slice_tile *tile =3D &uh->tile; struct v4l2_ctrl *ctrl; u32 tge_size; int i; =20 + tile_group =3D vdec_av1_get_tile_group(instance, vsi); + ctrl =3D v4l2_ctrl_find(&instance->ctx->ctrl_hdl, V4L2_CID_STATELESS_AV1_= TILE_GROUP_ENTRY); if (!ctrl) return -EINVAL; @@ -1607,6 +1626,15 @@ static int vdec_av1_slice_setup_pfc(struct vdec_av1_= slice_instance *instance, return ret; } =20 +static u32 vdec_av1_get_tiles_num(struct vdec_av1_slice_instance *instance, + struct vdec_av1_slice_vsi *vsi) +{ + if (IS_VDEC_SUPPORT_EXT(instance->ctx->dev->dec_capability)) + return vsi->tile_group.num_tiles; + else + return instance->tile_group.num_tiles; +} + static void vdec_av1_slice_setup_lat_buffer(struct vdec_av1_slice_instance= *instance, struct vdec_av1_slice_vsi *vsi, struct mtk_vcodec_mem *bs, @@ -1647,12 +1675,18 @@ static void vdec_av1_slice_setup_lat_buffer(struct = vdec_av1_slice_instance *inst =20 vsi->tile.buf =3D instance->tile.dma_addr; vsi->tile.size =3D instance->tile.size; - memcpy(lat_buf->tile_addr.va, instance->tile.va, 64 * instance->tile_grou= p.num_tiles); =20 vsi->cdf_table.buf =3D instance->cdf_table.dma_addr; vsi->cdf_table.size =3D instance->cdf_table.size; vsi->iq_table.buf =3D instance->iq_table.dma_addr; vsi->iq_table.size =3D instance->iq_table.size; + + /* lat_buf is used to share hardware decoder syntax between lat and core, + * there isn't only one. But there is only one tile.va for each instance. + * Need to copy tile information to lat_buf every time. + */ + memcpy(lat_buf->tile_addr.va, instance->tile.va, + AV1_TILE_SIZE * vdec_av1_get_tiles_num(instance, vsi)); } =20 static void vdec_av1_slice_setup_seg_buffer(struct vdec_av1_slice_instance= *instance, @@ -1675,7 +1709,7 @@ static void vdec_av1_slice_setup_tile_buffer(struct v= dec_av1_slice_instance *ins struct vdec_av1_slice_vsi *vsi, struct mtk_vcodec_mem *bs) { - struct vdec_av1_slice_tile_group *tile_group =3D &instance->tile_group; + struct vdec_av1_slice_tile_group *tile_group; struct vdec_av1_slice_uncompressed_header *uh =3D &vsi->frame.uh; struct vdec_av1_slice_tile *tile =3D &uh->tile; u32 tile_num, tile_row, tile_col; @@ -1686,6 +1720,8 @@ static void vdec_av1_slice_setup_tile_buffer(struct v= dec_av1_slice_instance *ins u32 *tile_info_buf =3D instance->tile.va; u64 pa =3D (u64)bs->dma_addr; =20 + tile_group =3D vdec_av1_get_tile_group(instance, vsi); + if (uh->disable_cdf_update =3D=3D 0) allow_update_cdf =3D 1; =20 @@ -1907,7 +1943,7 @@ static int vdec_av1_slice_init(struct mtk_vcodec_dec_= ctx *ctx) struct vdec_av1_slice_instance *instance; struct vdec_av1_slice_init_vsi *vsi; enum mtk_vcodec_fw_type fw_type =3D ctx->dev->fw_handler->type; - int ret; + int ret, vsi_size =3D AV1_NON_EXT_VSI_SIZE; =20 instance =3D kzalloc(sizeof(*instance), GFP_KERNEL); if (!instance) @@ -1941,9 +1977,18 @@ static int vdec_av1_slice_init(struct mtk_vcodec_dec= _ctx *ctx) goto error_vsi; } =20 - if (vsi->vsi_size !=3D sizeof(struct vdec_av1_slice_vsi)) - mtk_vdec_err(ctx, "remote vsi size 0x%x mismatch! expected: 0x%zx\n", - vsi->vsi_size, sizeof(struct vdec_av1_slice_vsi)); + if (IS_VDEC_SUPPORT_EXT(ctx->dev->dec_capability)) { + vsi_size =3D sizeof(struct vdec_av1_slice_vsi); + vsi->iq_table_size =3D AV1_IQ_TABLE_SIZE; + vsi->cdf_table_size =3D AV1_CDF_SIZE; + } + + if (vsi->vsi_size !=3D vsi_size) { + mtk_vdec_err(ctx, "remote vsi size 0x%x mismatch! expected: 0x%x\n", + vsi->vsi_size, vsi_size); + ret =3D -EINVAL; + goto error_vsi; + } =20 instance->irq_enabled =3D 1; instance->inneracing_mode =3D IS_VDEC_INNER_RACING(instance->ctx->dev->de= c_capability); --=20 2.45.2