From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: "Yunfei Dong" <yunfei.dong@mediatek.com>,
"Nícolas F . R . A . Prado" <nfraprado@collabora.com>,
"Sebastian Fricke" <sebastian.fricke@collabora.com>,
"Hans Verkuil" <hverkuil-cisco@xs4all.nl>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Benjamin Gaignard" <benjamin.gaignard@collabora.com>,
"Nathan Hebert" <nhebert@chromium.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>
Cc: Hsin-Yi Wang <hsinyi@chromium.org>,
Fritz Koenig <frkoenig@chromium.org>,
Daniel Vetter <daniel@ffwll.ch>,
Steve Cho <stevecho@chromium.org>,
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,
Project_Global_Chrome_Upstream_Group@mediatek.com
Subject: Re: [PATCH v2 04/14] media: mediatek: vcodec: add driver to support vcp encoder
Date: Fri, 28 Nov 2025 15:05:01 -0500 [thread overview]
Message-ID: <f606c4f24df8392a5aab9205eaf1627c8f30bad4.camel@collabora.com> (raw)
In-Reply-To: <20250815085232.30240-5-yunfei.dong@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 6914 bytes --]
Le vendredi 15 août 2025 à 16:52 +0800, Yunfei Dong a écrit :
> Encoder also need to call vcp interface to communicate with vcp,
> add driver to support encoder.
>
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> ---
> .../vcodec/common/mtk_vcodec_fw_vcp.c | 40 +++++++++++++++----
> .../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, 36 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c
> index 227310c116c6..c9e5cde40aef 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 @@
>
> #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"
>
> #define IPI_SEND_TIMEOUT_MS 100U
> @@ -189,8 +191,8 @@ static int mtk_vcodec_vcp_msg_ipi_send(struct mtk_vcodec_fw *fw, int id, void *b
> }
>
> mutex_lock(msg_mutex);
> - feature_id = VDEC_FEATURE_ID;
> - mailbox_id = IPI_OUT_VDEC_1;
> + feature_id = (fw->fw_use == ENCODER) ? VENC_FEATURE_ID : VDEC_FEATURE_ID;
> + mailbox_id = (fw->fw_use == ENCODER) ? IPI_OUT_VENC_0 : IPI_OUT_VDEC_1;
>
> timeout_jiffies = jiffies + msecs_to_jiffies(VCP_SYNC_TIMEOUT_MS);
> while (!vcp_device->ops->vcp_is_ready(feature_id)) {
> @@ -300,10 +302,10 @@ static int mtk_vcodec_vcp_load_firmware(struct mtk_vcodec_fw *fw)
>
> vcp_device = fw->vcp->vcp_device;
>
> - feature_id = VDEC_FEATURE_ID;
> - mem_id = VDEC_MEM_ID;
> - mailbox_id = IPI_IN_VDEC_1;
> - ipi_id = VCP_IPI_LAT_DECODER;
> + feature_id = fw->fw_use == ENCODER ? VENC_FEATURE_ID : VDEC_FEATURE_ID;
> + mem_id = fw->fw_use == ENCODER ? VENC_MEM_ID : VDEC_MEM_ID;
> + mailbox_id = fw->fw_use == ENCODER ? IPI_IN_VENC_0 : IPI_IN_VDEC_1;
> + ipi_id = fw->fw_use == ENCODER ? VCP_IPI_ENCODER : VCP_IPI_LAT_DECODER;
That is hard to read, please make a branch with a scope, something like:
if (fw->fw_use == ENCODER) {
feature_id = VENC_FEATURE_ID;
mem_id = VENC_MEM_ID;
mailbox_id = IPI_IN_VENC_0;
ipi_id = VCP_IPI_ENCODER;
} else {
feature_id = VDEC_FEATURE_ID;
mem_id = VDEC_MEM_ID;
mailbox_id = IPI_IN_VDEC_1;
ipi_id = VCP_IPI_LAT_DECODER;
}
Same applies elsewhere.
>
> ret = mtk_vcp_mbox_ipc_register(vcp_get_ipidev(vcp_device), mailbox_id,
> mtk_vcodec_vcp_msg_ack_isr, fw, &fw->vcp->share_data);
> @@ -322,6 +324,20 @@ static int mtk_vcodec_vcp_load_firmware(struct mtk_vcodec_fw *fw)
> mutex_init(&fw->vcp->ipi_desc[ipi_id].lock);
> mutex_init(&fw->vcp->ipi_mutex);
>
> + if (fw->fw_use == ENCODER) {
> + kthread_run(mtk_vcodec_vcp_msg_process_thread, fw, "vcp_enc_msq_thread");
> +
> + fw->vcp->vsi_addr = vcp_device->ops->vcp_get_mem_virt(mem_id);
> + fw->vcp->vsi_size = vcp_device->ops->vcp_get_mem_size(mem_id);
> + fw->vcp->iova_addr = vcp_device->ops->vcp_get_mem_iova(mem_id);
> +
> + dev_dbg(&fw->pdev->dev, "enc vcp init done => va: %p size:0x%x iova:%pad.\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");
>
> fw->vcp->vsi_addr = vcp_device->ops->vcp_get_mem_virt(mem_id);
> @@ -345,6 +361,11 @@ static unsigned int mtk_vcodec_vcp_get_vdec_capa(struct mtk_vcodec_fw *fw)
> MTK_VDEC_IS_SUPPORT_10BIT | MTK_VDEC_IS_SUPPORT_EXT;
> }
>
> +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_dmem_addr)
> {
> return NULL;
> @@ -396,6 +417,7 @@ static void mtk_vcodec_vcp_release(struct mtk_vcodec_fw *fw)
> static const struct mtk_vcodec_fw_ops mtk_vcodec_vcp_msg = {
> .load_firmware = mtk_vcodec_vcp_load_firmware,
> .get_vdec_capa = mtk_vcodec_vcp_get_vdec_capa,
> + .get_venc_capa = mtk_vcodec_vcp_get_venc_capa,
> .map_dm_addr = mtk_vcodec_vcp_dm_addr,
> .ipi_register = mtk_vcodec_vcp_set_ipi_register,
> .ipi_send = mtk_vcodec_vcp_ipi_send,
> @@ -409,7 +431,11 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_vcp_init(void *priv, enum mtk_vcodec_fw_use
> struct mtk_vcodec_fw *fw;
> int i;
>
> - if (fw_use == DECODER) {
> + if (fw_use == ENCODER) {
> + struct mtk_vcodec_enc_dev *enc_dev = priv;
> +
> + plat_dev = enc_dev->plat_dev;
> + } else if (fw_use == DECODER) {
> struct mtk_vcodec_dec_dev *dec_dev = priv;
>
> plat_dev = dec_dev->plat_dev;
> diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.h
> index 40f5481d1889..53080ed12c69 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 int len, void *priv);
>
> /* 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 a01dc25a7699..dcafb1303c29 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 @@
>
> #define MTK_DEFAULT_FRAMERATE_NUM 1001
> #define MTK_DEFAULT_FRAMERATE_DENOM 30000
> -#define MTK_VENC_4K_CAPABILITY_ENABLE BIT(0)
>
> static void mtk_venc_worker(struct work_struct *work);
>
> 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
>
> +#define MTK_VENC_4K_CAPABILITY_ENABLE BIT(0)
> +
> /**
> * struct mtk_video_enc_buf - Private data related to each VB2 buffer.
> * @m2m_buf: M2M buffer
regards,
Nicolas
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-11-28 20:05 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 8:52 [PATCH v2 00/14] media: mediatek: vcodec: support video decoder in mt8196 Yunfei Dong
2025-08-15 8:52 ` [PATCH v2 01/14] dt-bindings: media: mediatek: vcodec: add decoder dt-bindings for mt8196 Yunfei Dong
2025-08-19 9:01 ` Krzysztof Kozlowski
2025-08-19 9:05 ` Krzysztof Kozlowski
2025-11-28 19:32 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 02/14] media: mediatek: vcodec: add decoder compatible to support mt8196 Yunfei Dong
2025-11-28 19:34 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 03/14] media: mediatek: vcodec: add driver to support vcp Yunfei Dong
2025-11-28 20:01 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 04/14] media: mediatek: vcodec: add driver to support vcp encoder Yunfei Dong
2025-11-28 20:05 ` Nicolas Dufresne [this message]
2025-08-15 8:52 ` [PATCH v2 05/14] media: mediatek: vcodec: get different firmware ipi id Yunfei Dong
2025-11-28 20:07 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 06/14] media: mediatek: vcodec: get share memory address Yunfei Dong
2025-11-28 20:12 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 07/14] media: mediatek: vcodec: define MT8196 vcodec levels Yunfei Dong
2025-11-28 19:37 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 08/14] media: mediatek: vcodec: support vcp architecture Yunfei Dong
2025-11-28 20:14 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 09/14] media: mediatek: vcodec: support 36bit iova address Yunfei Dong
2025-11-28 20:15 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 10/14] media: mediatek: vcodec: clean xpc status Yunfei Dong
2025-11-28 20:19 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 11/14] media: mediatek: vcodec: add debug information Yunfei Dong
2025-11-28 20:20 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 12/14] media: mediatek: vcodec: send share memory address to vcp Yunfei Dong
2025-11-28 20:22 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 13/14] media: mediatek: decoder: fill av1 buffer size with picinfo Yunfei Dong
2025-11-28 20:23 ` Nicolas Dufresne
2025-08-15 8:52 ` [PATCH v2 14/14] media: mediatek: decoder: support av1 extend vsi Yunfei Dong
2025-11-28 20:26 ` Nicolas Dufresne
2025-11-28 19:30 ` [PATCH v2 00/14] media: mediatek: vcodec: support video decoder in mt8196 Nicolas Dufresne
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=f606c4f24df8392a5aab9205eaf1627c8f30bad4.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=benjamin.gaignard@collabora.com \
--cc=daniel.almeida@collabora.com \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=frkoenig@chromium.org \
--cc=hsinyi@chromium.org \
--cc=hverkuil-cisco@xs4all.nl \
--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=nfraprado@collabora.com \
--cc=nhebert@chromium.org \
--cc=sebastian.fricke@collabora.com \
--cc=stevecho@chromium.org \
--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®