From: Kyrie Wu <kyrie.wu@mediatek.com>
To: Tiffany Lin <tiffany.lin@mediatek.com>,
Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
Yunfei Dong <yunfei.dong@mediatek.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Kyrie Wu <kyrie.wu@mediatek.com>,
Hans Verkuil <hverkuil@xs4all.nl>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Nathan Hebert <nhebert@chromium.org>,
Arnd Bergmann <arnd@arndb.de>, Irui Wang <irui.wang@mediatek.com>,
George Sun <george.sun@mediatek.com>,
<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>,
Yilong Zhou <yilong.zhou@mediatek.com>
Subject: [PATCH v10 03/10] media: mediatek: decoder: Move firmware selection to platform data
Date: Wed, 23 Sep 2026 16:12:39 +0800 [thread overview]
Message-ID: <20260923081246.268182-4-kyrie.wu@mediatek.com> (raw)
In-Reply-To: <20260923081246.268182-1-kyrie.wu@mediatek.com>
The decoder currently selects its firmware backend by testing optional
mediatek,vpu, mediatek,scp, and mediatek,vcp properties in the device
tree. The firmware backend is, however, fixed by the decoder compatible.
Add the firmware type and initialization callback to the decoder platform
data, initialize them for each supported SoC, and use the callback from
the platform data at probe time. This matches the existing encoder
platform-data design and removes the DT-property dependency.
Fixes: bf1d556ad4e0 ("media: mtk-vcodec: abstract firmware interface")
Fixes: c7244811b1c9 ("media: mtk-vcodec: add SCP firmware ops")
Fixes: c3da5e939cbc ("media: mediatek: vcodec: support vcp architecture")
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
---
.../vcodec/decoder/mtk_vcodec_dec_drv.c | 21 ++-----------------
.../vcodec/decoder/mtk_vcodec_dec_drv.h | 7 +++++--
.../vcodec/decoder/mtk_vcodec_dec_stateful.c | 2 ++
.../vcodec/decoder/mtk_vcodec_dec_stateless.c | 12 +++++++++++
4 files changed, 21 insertions(+), 21 deletions(-)
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 8642947af7e5..62e7bbbe95c3 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
@@ -340,8 +340,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
{
struct mtk_vcodec_dec_dev *dev;
struct video_device *vfd_dec;
- phandle rproc_phandle;
- enum mtk_vcodec_fw_type fw_type;
int i, ret;
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -353,22 +351,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
dev->vdec_pdata = of_device_get_match_data(&pdev->dev);
mtk_vcodec_dec_get_chip_model(dev);
- if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
- &rproc_phandle)) {
- fw_type = VPU;
- dev->fw_init = mtk_vcodec_fw_vpu_init;
- } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp",
- &rproc_phandle)) {
- fw_type = SCP;
- dev->fw_init = mtk_vcodec_fw_scp_init;
- } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vcp",
- &rproc_phandle)) {
- fw_type = VCP;
- dev->fw_init = mtk_vcodec_fw_vcp_init;
- } else {
- dev_dbg(&pdev->dev, "Could not get vdec IPI device");
- return -ENODEV;
- }
dma_set_max_seg_size(&pdev->dev, UINT_MAX);
if (dev->chip_model == 8196) {
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(36));
@@ -378,7 +360,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
}
}
- dev->fw_handler = mtk_vcodec_fw_select(dev, DECODER, dev->fw_init);
+ dev->fw_handler = mtk_vcodec_fw_select(dev, DECODER,
+ dev->vdec_pdata->fw_init);
if (IS_ERR(dev->fw_handler))
return PTR_ERR(dev->fw_handler);
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 153c617df78d..d7ed7bfe7d50 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
@@ -97,6 +97,8 @@ struct vdec_pic_info {
*
* @is_subdev_supported: whether support parent-node architecture(subdev)
* @uses_stateless_api: whether the decoder uses the stateless API with requests
+ * @fw_type: firmware type (VPU, SCP, or VCP)
+ * @fw_init: firmware-specific initialization callback
* @chip_model: platforms configuration values
*/
struct mtk_vcodec_dec_pdata {
@@ -119,6 +121,9 @@ struct mtk_vcodec_dec_pdata {
bool is_subdev_supported;
bool uses_stateless_api;
+ enum mtk_vcodec_fw_type fw_type;
+ struct mtk_vcodec_fw *(*fw_init)(void *priv,
+ enum mtk_vcodec_fw_use fw_use);
unsigned int chip_model;
};
@@ -243,7 +248,6 @@ struct mtk_vcodec_dec_ctx {
* @vdecsys_regmap: VDEC_SYS register space passed through syscon
*
* @fw_handler: used to communicate with the firmware.
- * @fw_init: firmware-specific init callback selected at probe time
* @id_counter: used to identify current opened instance
*
* @dec_mutex: decoder hardware lock
@@ -285,7 +289,6 @@ struct mtk_vcodec_dec_dev {
struct regmap *vdecsys_regmap;
struct mtk_vcodec_fw *fw_handler;
- struct mtk_vcodec_fw *(*fw_init)(void *priv, enum mtk_vcodec_fw_use fw_use);
u64 id_counter;
/* decoder hardware mutex lock */
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c
index 0e702d6a43ed..e7ae90e8238e 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c
@@ -618,5 +618,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = false,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .fw_type = VPU,
+ .fw_init = mtk_vcodec_fw_vpu_init,
.chip_model = 8173,
};
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 5ecbfc169805..2a03395ab30b 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
@@ -935,6 +935,8 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.get_cap_buffer = vdec_get_cap_buffer,
.is_subdev_supported = false,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8183,
};
@@ -974,24 +976,32 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8188,
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8192,
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8195,
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .fw_type = VCP,
+ .fw_init = mtk_vcodec_fw_vcp_init,
.chip_model = 8196,
};
@@ -1015,5 +1025,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = {
const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8186,
};
--
2.51.0.windows.2
next prev parent reply other threads:[~2026-09-23 8:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 8:12 [PATCH v10 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 02/10] media: mediatek: decoder: Add a new platform data member Kyrie Wu
2026-09-23 9:49 ` AngeloGioacchino Del Regno
2026-09-23 8:12 ` Kyrie Wu [this message]
2026-09-23 9:49 ` [PATCH v10 03/10] media: mediatek: decoder: Move firmware selection to platform data AngeloGioacchino Del Regno
2026-09-23 8:12 ` [PATCH v10 04/10] media: mediatek: vcodec: Refactor Decoder profile & level Handling Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 05/10] media: mediatek: vcodec: Add VP9 Probability Size Configuration Kyrie Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923081246.268182-4-kyrie.wu@mediatek.com \
--to=kyrie.wu@mediatek.com \
--cc=andrew-ct.chen@mediatek.com \
--cc=andrzejtp2010@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=arnd@arndb.de \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=george.sun@mediatek.com \
--cc=hverkuil@xs4all.nl \
--cc=irui.wang@mediatek.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=nhebert@chromium.org \
--cc=nicolas.dufresne@collabora.com \
--cc=robh@kernel.org \
--cc=tiffany.lin@mediatek.com \
--cc=yilong.zhou@mediatek.com \
--cc=yunfei.dong@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®