From: Alexandre Courbot <acourbot@chromium.org> To: Tiffany Lin <tiffany.lin@mediatek.com>, Andrew-CT Chen <andrew-ct.chen@mediatek.com>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, Dafna Hirschfeld <dafna.hirschfeld@collabora.com>, Yunfei Dong <yunfei.dong@mediatek.com> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Alexandre Courbot <acourbot@chromium.org> Subject: [PATCH v5 08/14] media: mtk-vcodec: support version 2 of decoder firmware ABI Date: Wed, 19 May 2021 23:30:05 +0900 [thread overview] Message-ID: <20210519143011.1175546-9-acourbot@chromium.org> (raw) In-Reply-To: <20210519143011.1175546-1-acourbot@chromium.org> Add support for decoder firmware version 2, which makes the kernel responsible for managing the VSI context and is used for stateless codecs. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> --- .../media/platform/mtk-vcodec/vdec_ipi_msg.h | 18 +++++++++--- .../media/platform/mtk-vcodec/vdec_vpu_if.c | 28 +++++++++++++++---- .../media/platform/mtk-vcodec/vdec_vpu_if.h | 5 ++++ 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h index eb66729fda63..a0e773ae3ab3 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h +++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h @@ -29,11 +29,15 @@ enum vdec_ipi_msgid { /** * struct vdec_ap_ipi_cmd - generic AP to VPU ipi command format * @msg_id : vdec_ipi_msgid - * @vpu_inst_addr : VPU decoder instance address + * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2. + * @inst_id : instance ID. Used if the ABI version >= 2. */ struct vdec_ap_ipi_cmd { uint32_t msg_id; - uint32_t vpu_inst_addr; + union { + uint32_t vpu_inst_addr; + uint32_t inst_id; + }; }; /** @@ -63,7 +67,8 @@ struct vdec_ap_ipi_init { /** * struct vdec_ap_ipi_dec_start - for AP_IPIMSG_DEC_START * @msg_id : AP_IPIMSG_DEC_START - * @vpu_inst_addr : VPU decoder instance address + * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2. + * @inst_id : instance ID. Used if the ABI version >= 2. * @data : Header info * H264 decoder [0]:buf_sz [1]:nal_start * VP8 decoder [0]:width/height @@ -72,7 +77,10 @@ struct vdec_ap_ipi_init { */ struct vdec_ap_ipi_dec_start { uint32_t msg_id; - uint32_t vpu_inst_addr; + union { + uint32_t vpu_inst_addr; + uint32_t inst_id; + }; uint32_t data[3]; uint32_t reserved; }; @@ -87,6 +95,7 @@ struct vdec_ap_ipi_dec_start { * ensure that it is compatible with the firmware. * This field is not valid for MT8173 and must not be * accessed for this chip. + * @inst_id : instance ID. Valid only if the ABI version >= 2. */ struct vdec_vpu_ipi_init_ack { uint32_t msg_id; @@ -94,6 +103,7 @@ struct vdec_vpu_ipi_init_ack { uint64_t ap_inst_addr; uint32_t vpu_inst_addr; uint32_t vdec_abi_version; + uint32_t inst_id; }; #endif diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c index 203089213e67..5dffc459a33d 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c @@ -25,18 +25,30 @@ static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg) mtk_vcodec_debug(vpu, "- vpu_inst_addr = 0x%x", vpu->inst_addr); + /* Set default ABI version if dealing with unversioned firmware. */ + vpu->fw_abi_version = 0; + /* + * Instance ID is only used if ABI version >= 2. Initialize it with + * garbage by default. + */ + vpu->inst_id = 0xdeadbeef; + /* Firmware version field does not exist on MT8173. */ if (vpu->ctx->dev->vdec_pdata->chip == MTK_MT8173) return; /* Check firmware version. */ - mtk_vcodec_debug(vpu, "firmware version 0x%x\n", msg->vdec_abi_version); - switch (msg->vdec_abi_version) { + vpu->fw_abi_version = msg->vdec_abi_version; + mtk_vcodec_debug(vpu, "firmware version 0x%x\n", vpu->fw_abi_version); + switch (vpu->fw_abi_version) { case 1: break; + case 2: + vpu->inst_id = msg->inst_id; + break; default: mtk_vcodec_err(vpu, "unhandled firmware version 0x%x\n", - msg->vdec_abi_version); + vpu->fw_abi_version); vpu->failure = 1; break; } @@ -113,7 +125,10 @@ static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, unsigned int msg_id) memset(&msg, 0, sizeof(msg)); msg.msg_id = msg_id; - msg.vpu_inst_addr = vpu->inst_addr; + if (vpu->fw_abi_version < 2) + msg.vpu_inst_addr = vpu->inst_addr; + else + msg.inst_id = vpu->inst_id; err = vcodec_vpu_send_msg(vpu, &msg, sizeof(msg)); mtk_vcodec_debug(vpu, "- id=%X ret=%d", msg_id, err); @@ -163,7 +178,10 @@ int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len) memset(&msg, 0, sizeof(msg)); msg.msg_id = AP_IPIMSG_DEC_START; - msg.vpu_inst_addr = vpu->inst_addr; + if (vpu->fw_abi_version < 2) + msg.vpu_inst_addr = vpu->inst_addr; + else + msg.inst_id = vpu->inst_id; for (i = 0; i < len; i++) msg.data[i] = data[i]; diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h index 85224eb7e34b..c2ed5b6cab8b 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h +++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h @@ -18,6 +18,9 @@ struct mtk_vcodec_ctx; * for control and info share * @failure : VPU execution result status, 0: success, others: fail * @inst_addr : VPU decoder instance address + * @fw_abi_version : ABI version of the firmware. + * @inst_id : if fw_abi_version >= 2, contains the instance ID to be given + * in place of inst_addr in messages. * @signaled : 1 - Host has received ack message from VPU, 0 - not received * @ctx : context for v4l2 layer integration * @dev : platform device of VPU @@ -29,6 +32,8 @@ struct vdec_vpu_inst { void *vsi; int32_t failure; uint32_t inst_addr; + uint32_t fw_abi_version; + uint32_t inst_id; unsigned int signaled; struct mtk_vcodec_ctx *ctx; wait_queue_head_t wq; -- 2.31.1.751.gd2f1c929bd-goog
WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Courbot <acourbot@chromium.org> To: Tiffany Lin <tiffany.lin@mediatek.com>, Andrew-CT Chen <andrew-ct.chen@mediatek.com>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, Dafna Hirschfeld <dafna.hirschfeld@collabora.com>, Yunfei Dong <yunfei.dong@mediatek.com> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Alexandre Courbot <acourbot@chromium.org> Subject: [PATCH v5 08/14] media: mtk-vcodec: support version 2 of decoder firmware ABI Date: Wed, 19 May 2021 23:30:05 +0900 [thread overview] Message-ID: <20210519143011.1175546-9-acourbot@chromium.org> (raw) In-Reply-To: <20210519143011.1175546-1-acourbot@chromium.org> Add support for decoder firmware version 2, which makes the kernel responsible for managing the VSI context and is used for stateless codecs. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> --- .../media/platform/mtk-vcodec/vdec_ipi_msg.h | 18 +++++++++--- .../media/platform/mtk-vcodec/vdec_vpu_if.c | 28 +++++++++++++++---- .../media/platform/mtk-vcodec/vdec_vpu_if.h | 5 ++++ 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h index eb66729fda63..a0e773ae3ab3 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h +++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h @@ -29,11 +29,15 @@ enum vdec_ipi_msgid { /** * struct vdec_ap_ipi_cmd - generic AP to VPU ipi command format * @msg_id : vdec_ipi_msgid - * @vpu_inst_addr : VPU decoder instance address + * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2. + * @inst_id : instance ID. Used if the ABI version >= 2. */ struct vdec_ap_ipi_cmd { uint32_t msg_id; - uint32_t vpu_inst_addr; + union { + uint32_t vpu_inst_addr; + uint32_t inst_id; + }; }; /** @@ -63,7 +67,8 @@ struct vdec_ap_ipi_init { /** * struct vdec_ap_ipi_dec_start - for AP_IPIMSG_DEC_START * @msg_id : AP_IPIMSG_DEC_START - * @vpu_inst_addr : VPU decoder instance address + * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2. + * @inst_id : instance ID. Used if the ABI version >= 2. * @data : Header info * H264 decoder [0]:buf_sz [1]:nal_start * VP8 decoder [0]:width/height @@ -72,7 +77,10 @@ struct vdec_ap_ipi_init { */ struct vdec_ap_ipi_dec_start { uint32_t msg_id; - uint32_t vpu_inst_addr; + union { + uint32_t vpu_inst_addr; + uint32_t inst_id; + }; uint32_t data[3]; uint32_t reserved; }; @@ -87,6 +95,7 @@ struct vdec_ap_ipi_dec_start { * ensure that it is compatible with the firmware. * This field is not valid for MT8173 and must not be * accessed for this chip. + * @inst_id : instance ID. Valid only if the ABI version >= 2. */ struct vdec_vpu_ipi_init_ack { uint32_t msg_id; @@ -94,6 +103,7 @@ struct vdec_vpu_ipi_init_ack { uint64_t ap_inst_addr; uint32_t vpu_inst_addr; uint32_t vdec_abi_version; + uint32_t inst_id; }; #endif diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c index 203089213e67..5dffc459a33d 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c @@ -25,18 +25,30 @@ static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg) mtk_vcodec_debug(vpu, "- vpu_inst_addr = 0x%x", vpu->inst_addr); + /* Set default ABI version if dealing with unversioned firmware. */ + vpu->fw_abi_version = 0; + /* + * Instance ID is only used if ABI version >= 2. Initialize it with + * garbage by default. + */ + vpu->inst_id = 0xdeadbeef; + /* Firmware version field does not exist on MT8173. */ if (vpu->ctx->dev->vdec_pdata->chip == MTK_MT8173) return; /* Check firmware version. */ - mtk_vcodec_debug(vpu, "firmware version 0x%x\n", msg->vdec_abi_version); - switch (msg->vdec_abi_version) { + vpu->fw_abi_version = msg->vdec_abi_version; + mtk_vcodec_debug(vpu, "firmware version 0x%x\n", vpu->fw_abi_version); + switch (vpu->fw_abi_version) { case 1: break; + case 2: + vpu->inst_id = msg->inst_id; + break; default: mtk_vcodec_err(vpu, "unhandled firmware version 0x%x\n", - msg->vdec_abi_version); + vpu->fw_abi_version); vpu->failure = 1; break; } @@ -113,7 +125,10 @@ static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, unsigned int msg_id) memset(&msg, 0, sizeof(msg)); msg.msg_id = msg_id; - msg.vpu_inst_addr = vpu->inst_addr; + if (vpu->fw_abi_version < 2) + msg.vpu_inst_addr = vpu->inst_addr; + else + msg.inst_id = vpu->inst_id; err = vcodec_vpu_send_msg(vpu, &msg, sizeof(msg)); mtk_vcodec_debug(vpu, "- id=%X ret=%d", msg_id, err); @@ -163,7 +178,10 @@ int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len) memset(&msg, 0, sizeof(msg)); msg.msg_id = AP_IPIMSG_DEC_START; - msg.vpu_inst_addr = vpu->inst_addr; + if (vpu->fw_abi_version < 2) + msg.vpu_inst_addr = vpu->inst_addr; + else + msg.inst_id = vpu->inst_id; for (i = 0; i < len; i++) msg.data[i] = data[i]; diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h index 85224eb7e34b..c2ed5b6cab8b 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h +++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h @@ -18,6 +18,9 @@ struct mtk_vcodec_ctx; * for control and info share * @failure : VPU execution result status, 0: success, others: fail * @inst_addr : VPU decoder instance address + * @fw_abi_version : ABI version of the firmware. + * @inst_id : if fw_abi_version >= 2, contains the instance ID to be given + * in place of inst_addr in messages. * @signaled : 1 - Host has received ack message from VPU, 0 - not received * @ctx : context for v4l2 layer integration * @dev : platform device of VPU @@ -29,6 +32,8 @@ struct vdec_vpu_inst { void *vsi; int32_t failure; uint32_t inst_addr; + uint32_t fw_abi_version; + uint32_t inst_id; unsigned int signaled; struct mtk_vcodec_ctx *ctx; wait_queue_head_t wq; -- 2.31.1.751.gd2f1c929bd-goog _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2021-05-19 14:31 UTC|newest] Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-19 14:29 [PATCH v5 00/14] media: mtk-vcodec: support for MT8183 decoder Alexandre Courbot 2021-05-19 14:29 ` Alexandre Courbot 2021-05-19 14:29 ` [PATCH v5 01/14] media: mtk-vcodec: vdec: Support H264 profile control Alexandre Courbot 2021-05-19 14:29 ` Alexandre Courbot 2021-05-21 13:36 ` Tzung-Bi Shih 2021-05-21 13:36 ` Tzung-Bi Shih 2021-05-19 14:29 ` [PATCH v5 02/14] media: mtk-vcodec: vdec: use helpers in VIDIOC_(TRY_)DECODER_CMD Alexandre Courbot 2021-05-19 14:29 ` Alexandre Courbot 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-19 14:30 ` [PATCH v5 03/14] media: mtk-vcodec: vdec: clamp OUTPUT resolution to hardware limits Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-19 14:30 ` [PATCH v5 04/14] media: mtk-vcodec: make flush buffer reusable by encoder Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-19 14:30 ` [PATCH v5 05/14] media: mtk-vcodec: venc: support START and STOP commands Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-27 10:10 ` Alexandre Courbot 2021-05-27 10:10 ` Alexandre Courbot 2021-05-28 7:03 ` Dafna Hirschfeld 2021-05-28 7:03 ` Dafna Hirschfeld 2021-05-28 7:43 ` Dafna Hirschfeld 2021-05-28 7:43 ` Dafna Hirschfeld 2021-07-05 5:04 ` Alexandre Courbot 2021-07-05 5:04 ` Alexandre Courbot 2021-07-05 5:04 ` Alexandre Courbot 2021-07-05 5:04 ` Alexandre Courbot 2021-07-06 15:17 ` Enric Balletbo Serra 2021-07-06 15:17 ` Enric Balletbo Serra 2021-05-19 14:30 ` [PATCH v5 06/14] media: mtk-vcodec: vdec: move stateful ops into their own file Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-27 10:10 ` Alexandre Courbot 2021-05-27 10:10 ` Alexandre Courbot 2021-05-19 14:30 ` [PATCH v5 07/14] media: mtk-vcodec: vdec: handle firmware version field Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-19 14:30 ` Alexandre Courbot [this message] 2021-05-19 14:30 ` [PATCH v5 08/14] media: mtk-vcodec: support version 2 of decoder firmware ABI Alexandre Courbot 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-19 14:30 ` [PATCH v5 09/14] media: add Mediatek's MM21 format Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-21 13:37 ` Tzung-Bi Shih 2021-05-19 14:30 ` [PATCH v5 10/14] media: mtk-vcodec: vdec: support stateless API Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:38 ` Tzung-Bi Shih 2021-05-21 13:38 ` Tzung-Bi Shih 2021-05-19 14:30 ` [PATCH v5 11/14] media: mtk-vcodec: vdec: support stateless H.264 decoding Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:38 ` Tzung-Bi Shih 2021-05-21 13:38 ` Tzung-Bi Shih 2021-05-27 10:10 ` Alexandre Courbot 2021-05-27 10:10 ` Alexandre Courbot 2021-05-19 14:30 ` [PATCH v5 12/14] media: mtk-vcodec: vdec: add media device if using stateless api Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:38 ` Tzung-Bi Shih 2021-05-21 13:38 ` Tzung-Bi Shih 2021-05-19 14:30 ` [PATCH v5 13/14] dt-bindings: media: document mediatek,mt8183-vcodec-dec Alexandre Courbot 2021-05-19 14:30 ` [PATCH v5 13/14] dt-bindings: media: document mediatek, mt8183-vcodec-dec Alexandre Courbot 2021-05-19 14:30 ` [PATCH v5 14/14] media: mtk-vcodec: enable MT8183 decoder Alexandre Courbot 2021-05-19 14:30 ` Alexandre Courbot 2021-05-21 13:38 ` Tzung-Bi Shih 2021-05-21 13:38 ` Tzung-Bi Shih 2021-05-27 8:08 ` [PATCH v5 00/14] media: mtk-vcodec: support for " Hans Verkuil 2021-05-27 8:08 ` Hans Verkuil 2021-05-27 10:10 ` Alexandre Courbot 2021-05-27 10:10 ` Alexandre Courbot 2021-05-27 10:18 ` Hans Verkuil 2021-05-27 10:18 ` Hans Verkuil
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=20210519143011.1175546-9-acourbot@chromium.org \ --to=acourbot@chromium.org \ --cc=andrew-ct.chen@mediatek.com \ --cc=dafna.hirschfeld@collabora.com \ --cc=hverkuil-cisco@xs4all.nl \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=linux-mediatek@lists.infradead.org \ --cc=mchehab@kernel.org \ --cc=tiffany.lin@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.