[PATCH v9 07/14] media: mediatek: vcodec: send share memory address to vcp

From: Kyrie Wu

Date: Mon Nov 16 2026 - 22:31:16 EST


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: Kyrie Wu <kyrie.wu@xxxxxxxxxxxx>
---
.../platform/mediatek/vcodec/decoder/vdec_ipi_msg.h | 2 ++
.../media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c | 9 ++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)

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 c2c2a3a63..8b771d470 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;
};

/**
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 cdb673e6b..50f1e1613 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
@@ -4,6 +4,8 @@
* Author: PC Chen <pc.chen@xxxxxxxxxxxx>
*/

+#include <linux/stddef.h>
+
#include "mtk_vcodec_dec_drv.h"
#include "vdec_drv_if.h"
#include "vdec_ipi_msg.h"
@@ -210,6 +212,7 @@ static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, unsigned int msg_id)
int vpu_dec_init(struct vdec_vpu_inst *vpu)
{
struct vdec_ap_ipi_init msg = { };
+ size_t msg_size = offsetof(struct vdec_ap_ipi_init, shared_iova);
int err;

init_waitqueue_head(&vpu->wq);
@@ -236,10 +239,14 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu)
msg.msg_id = AP_IPIMSG_DEC_INIT;
msg.ap_inst_addr = (unsigned long)vpu;
msg.codec_type = vpu->codec_type;
+ if (mtk_vcodec_fw_get_type(vpu->ctx->dev->fw_handler) == VCP) {
+ msg.shared_iova = vpu->ctx->dev->fw_handler->vcp->iova_addr;
+ msg_size = sizeof(msg);
+ }

mtk_vdec_debug(vpu->ctx, "vdec_inst=%p", vpu);

- err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
+ err = vcodec_vpu_send_msg(vpu, (void *)&msg, msg_size);

if (IS_ERR_OR_NULL(vpu->vsi)) {
mtk_vdec_err(vpu->ctx, "invalid vdec vsi, status=%d", err);
--
2.51.0.windows.2