From patchwork Mon Oct 14 07:33:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13834248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF7E3CFC501 for ; Mon, 14 Oct 2024 07:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=oYNoFDKaRYnRQAwQDtPOsylK/E59+JYyEDSYnOZ2pNk=; b=uNSwEITk+iIusz96d0ojjP+K/x etrmEQzL8F6qzk/A8ApeCuW2GpXp+uHkFxoPtjytXBvVIWmor1EgepN1C/HADBIzq2OiLcY33A2p6 zoRRCqHg3VlR6/gbjPLbXqnV6EFUqWZdLzoCgGF6C4kNc+Bnt8gb1BKTS9jDeQgivqXZ4uOQSkOx1 AGry4VA1b+ftfkwBMT44zUAQW4Kb0CLQcHNPWoaPwNNHl1VwToS7936R5IT/q9qf3hBomRNOztnzh b/Jv3aND9S3t43AAVyTYTcpP/QiHofn6fOkCE06+hBrgvYqz+dhArXepuqc6rbAIrXIdiukHfH0xm OA4GZq8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0FiV-000000046XR-490P; Mon, 14 Oct 2024 07:42:11 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0FZy-000000044R8-3Ye4; Mon, 14 Oct 2024 07:33:25 +0000 X-UUID: 92ad0c8089fe11efba0aef63c0775dbf-20241014 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=oYNoFDKaRYnRQAwQDtPOsylK/E59+JYyEDSYnOZ2pNk=; b=P12Ie3j4DEoslkQF7hC8pKNMWXFxTF8B/BtnMhIIczgqT1MCoYK2y5tM5709TcXEc2jpONk3mfwomGFOFQ7bYKPEbTyov6QFYPJYsljRnx5VqsCc+1YwoywJDxtNszhDl3UHGR4gNEND2+OXbMq8maEXKbXQIvfnLgdaeMee/0w=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:ca7f00fe-25b2-4369-9cc0-6777c8a07f1f,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:6dc6a47,CLOUDID:a6423465-444a-4b47-a99a-591ade3b04b2,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,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: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 92ad0c8089fe11efba0aef63c0775dbf-20241014 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1654781658; Mon, 14 Oct 2024 00:33:14 -0700 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.1118.26; Mon, 14 Oct 2024 15:33:12 +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.1118.26 via Frontend Transport; Mon, 14 Oct 2024 15:33:11 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , 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 1/6] media: mediatek: vcodec: extend h264 video share information Date: Mon, 14 Oct 2024 15:33:05 +0800 Message-ID: <20241014073314.18409-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241014073314.18409-1-yunfei.dong@mediatek.com> References: <20241014073314.18409-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_003323_018527_D3DB79CF X-CRM114-Status: GOOD ( 20.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Calculate the working buffer address end with each buffer size when the address end can't be calculated in kernel space. Re-contruct the driver flow when vsi struct is changed for adding the buffer size. Signed-off-by: Yunfei Dong --- .../decoder/vdec/vdec_h264_req_multi_if.c | 274 ++++++++++-------- 1 file changed, 161 insertions(+), 113 deletions(-) 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_h264_req_multi_if.c index 732d78f63e5a..d3f8d62238c0 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c @@ -50,60 +50,76 @@ struct vdec_h264_slice_lat_dec_param { /** * struct vdec_h264_slice_info - decode information * + * @wdma_end_addr_offset: offset from buffer start * @nal_info: nal info of current picture * @timeout: Decode timeout: 1 timeout, 0 no timeout - * @bs_buf_size: bitstream size - * @bs_buf_addr: bitstream buffer dma address - * @y_fb_dma: Y frame buffer dma address - * @c_fb_dma: C frame buffer dma address * @vdec_fb_va: VDEC frame buffer struct virtual address * @crc: Used to check whether hardware's status is right + * @reserved: reserved */ struct vdec_h264_slice_info { + u64 wdma_end_addr_offset; u16 nal_info; u16 timeout; - u32 bs_buf_size; - u64 bs_buf_addr; - u64 y_fb_dma; - u64 c_fb_dma; u64 vdec_fb_va; u32 crc[8]; + u32 reserved; +}; + +/* + * struct vdec_h264_slice_mem - memory address and size + */ +struct vdec_h264_slice_mem { + union { + u64 buf; + u64 dma_addr; + }; + union { + size_t size; + u64 dma_addr_end; + }; +}; + +/** + * struct vdec_h264_slice_fb - frame buffer for decoding + * + * @y: current y buffer address info + * @c: current c buffer address info + */ +struct vdec_h264_slice_fb { + struct vdec_h264_slice_mem y; + struct vdec_h264_slice_mem c; }; /** * struct vdec_h264_slice_vsi - shared memory for decode information exchange * between SCP and Host. * - * @wdma_err_addr: wdma error dma address - * @wdma_start_addr: wdma start dma address - * @wdma_end_addr: wdma end dma address - * @slice_bc_start_addr: slice bc start dma address - * @slice_bc_end_addr: slice bc end dma address - * @row_info_start_addr: row info start dma address - * @row_info_end_addr: row info end dma address - * @trans_start: trans start dma address - * @trans_end: trans end dma address - * @wdma_end_addr_offset: wdma end address offset + * @bs: input buffer info + * @fb: current y/c buffer + * + * @ube: ube buffer + * @trans: transcoded buffer + * @row_info: row info buffer + * @err_map: err map buffer + * @slice_bc: slice buffer * * @mv_buf_dma: HW working motion vector buffer - * dma address (AP-W, VPU-R) - * @dec: decode information (AP-R, VPU-W) - * @h264_slice_params: decode parameters for hw used + * @dec: decode information (AP-R, VPU-W) + * @h264_slice_params: decode parameters for hw used */ struct vdec_h264_slice_vsi { /* LAT dec addr */ - u64 wdma_err_addr; - u64 wdma_start_addr; - u64 wdma_end_addr; - u64 slice_bc_start_addr; - u64 slice_bc_end_addr; - u64 row_info_start_addr; - u64 row_info_end_addr; - u64 trans_start; - u64 trans_end; - u64 wdma_end_addr_offset; + struct vdec_h264_slice_mem bs; + struct vdec_h264_slice_fb fb; + + struct vdec_h264_slice_mem ube; + struct vdec_h264_slice_mem trans; + struct vdec_h264_slice_mem row_info; + struct vdec_h264_slice_mem err_map; + struct vdec_h264_slice_mem slice_bc; - u64 mv_buf_dma[H264_MAX_MV_NUM]; + struct vdec_h264_slice_mem mv_buf_dma[H264_MAX_MV_NUM]; struct vdec_h264_slice_info dec; struct vdec_h264_slice_lat_dec_param h264_slice_params; }; @@ -392,6 +408,98 @@ static void vdec_h264_slice_get_crop_info(struct vdec_h264_slice_inst *inst, cr->left, cr->top, cr->width, cr->height); } +static void vdec_h264_slice_setup_lat_buffer(struct vdec_h264_slice_inst *inst, + struct mtk_vcodec_mem *bs, + struct vdec_lat_buf *lat_buf) +{ + struct mtk_vcodec_mem *mem; + int i; + + inst->vsi->bs.dma_addr = (u64)bs->dma_addr; + inst->vsi->bs.size = bs->size; + + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi->mv_buf_dma[i].dma_addr = mem->dma_addr; + inst->vsi->mv_buf_dma[i].size = mem->size; + } + inst->vsi->ube.dma_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr; + inst->vsi->ube.size = lat_buf->ctx->msg_queue.wdma_addr.size; + + inst->vsi->row_info.dma_addr = 0; + inst->vsi->row_info.size = 0; + + inst->vsi->err_map.dma_addr = lat_buf->wdma_err_addr.dma_addr; + inst->vsi->err_map.size = lat_buf->wdma_err_addr.size; + + inst->vsi->slice_bc.dma_addr = lat_buf->slice_bc_addr.dma_addr; + inst->vsi->slice_bc.size = lat_buf->slice_bc_addr.size; + + inst->vsi->trans.dma_addr_end = inst->ctx->msg_queue.wdma_rptr_addr; + inst->vsi->trans.dma_addr = inst->ctx->msg_queue.wdma_wptr_addr; +} + +static int vdec_h264_slice_setup_core_buffer(struct vdec_h264_slice_inst *inst, + struct vdec_h264_slice_share_info *share_info, + struct vdec_lat_buf *lat_buf) +{ + struct mtk_vcodec_mem *mem; + struct mtk_vcodec_dec_ctx *ctx = inst->ctx; + struct vb2_v4l2_buffer *vb2_v4l2; + struct vdec_fb *fb; + u64 y_fb_dma, c_fb_dma = 0; + int i; + + fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx); + if (!fb) { + mtk_vdec_err(ctx, "fb buffer is NULL"); + return -EBUSY; + } + + y_fb_dma = (u64)fb->base_y.dma_addr; + if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 1) + c_fb_dma = + y_fb_dma + inst->ctx->picinfo.buf_w * inst->ctx->picinfo.buf_h; + else + c_fb_dma = (u64)fb->base_c.dma_addr; + + mtk_vdec_debug(ctx, "[h264-core] y/c addr = 0x%llx 0x%llx", y_fb_dma, c_fb_dma); + + inst->vsi_core->fb.y.dma_addr = y_fb_dma; + inst->vsi_core->fb.y.size = ctx->picinfo.fb_sz[0]; + inst->vsi_core->fb.c.dma_addr = c_fb_dma; + inst->vsi_core->fb.c.size = ctx->picinfo.fb_sz[1]; + + inst->vsi_core->dec.vdec_fb_va = (unsigned long)fb; + inst->vsi_core->dec.nal_info = share_info->nal_info; + + inst->vsi_core->ube.dma_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr; + inst->vsi_core->ube.size = lat_buf->ctx->msg_queue.wdma_addr.size; + + inst->vsi_core->err_map.dma_addr = lat_buf->wdma_err_addr.dma_addr; + inst->vsi_core->err_map.size = lat_buf->wdma_err_addr.size; + + inst->vsi_core->slice_bc.dma_addr = lat_buf->slice_bc_addr.dma_addr; + inst->vsi_core->slice_bc.size = lat_buf->slice_bc_addr.size; + + inst->vsi_core->row_info.dma_addr = 0; + inst->vsi_core->row_info.size = 0; + + inst->vsi_core->trans.dma_addr = share_info->trans_start; + inst->vsi_core->trans.dma_addr_end = share_info->trans_end; + + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi_core->mv_buf_dma[i].dma_addr = mem->dma_addr; + inst->vsi_core->mv_buf_dma[i].size = mem->size; + } + + vb2_v4l2 = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); + v4l2_m2m_buf_copy_metadata(&lat_buf->ts_info, vb2_v4l2, true); + + return 0; +} + static int vdec_h264_slice_init(struct mtk_vcodec_dec_ctx *ctx) { struct vdec_h264_slice_inst *inst; @@ -452,64 +560,22 @@ static void vdec_h264_slice_deinit(void *h_vdec) static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf) { - struct vdec_fb *fb; - u64 vdec_fb_va; - u64 y_fb_dma, c_fb_dma; - int err, timeout, i; + int err, timeout; struct mtk_vcodec_dec_ctx *ctx = lat_buf->ctx; struct vdec_h264_slice_inst *inst = ctx->drv_handle; - struct vb2_v4l2_buffer *vb2_v4l2; struct vdec_h264_slice_share_info *share_info = lat_buf->private_data; - struct mtk_vcodec_mem *mem; struct vdec_vpu_inst *vpu = &inst->vpu; mtk_vdec_debug(ctx, "[h264-core] vdec_h264 core decode"); memcpy(&inst->vsi_core->h264_slice_params, &share_info->h264_slice_params, sizeof(share_info->h264_slice_params)); - fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx); - if (!fb) { - err = -EBUSY; - mtk_vdec_err(ctx, "fb buffer is NULL"); + err = vdec_h264_slice_setup_core_buffer(inst, share_info, lat_buf); + if (err) goto vdec_dec_end; - } - - vdec_fb_va = (unsigned long)fb; - y_fb_dma = (u64)fb->base_y.dma_addr; - if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 1) - c_fb_dma = - y_fb_dma + inst->ctx->picinfo.buf_w * inst->ctx->picinfo.buf_h; - else - c_fb_dma = (u64)fb->base_c.dma_addr; - - mtk_vdec_debug(ctx, "[h264-core] y/c addr = 0x%llx 0x%llx", y_fb_dma, c_fb_dma); - - inst->vsi_core->dec.y_fb_dma = y_fb_dma; - inst->vsi_core->dec.c_fb_dma = c_fb_dma; - inst->vsi_core->dec.vdec_fb_va = vdec_fb_va; - inst->vsi_core->dec.nal_info = share_info->nal_info; - inst->vsi_core->wdma_start_addr = - lat_buf->ctx->msg_queue.wdma_addr.dma_addr; - inst->vsi_core->wdma_end_addr = - lat_buf->ctx->msg_queue.wdma_addr.dma_addr + - lat_buf->ctx->msg_queue.wdma_addr.size; - inst->vsi_core->wdma_err_addr = lat_buf->wdma_err_addr.dma_addr; - inst->vsi_core->slice_bc_start_addr = lat_buf->slice_bc_addr.dma_addr; - inst->vsi_core->slice_bc_end_addr = lat_buf->slice_bc_addr.dma_addr + - lat_buf->slice_bc_addr.size; - inst->vsi_core->trans_start = share_info->trans_start; - inst->vsi_core->trans_end = share_info->trans_end; - for (i = 0; i < H264_MAX_MV_NUM; i++) { - mem = &inst->mv_buf[i]; - inst->vsi_core->mv_buf_dma[i] = mem->dma_addr; - } - - vb2_v4l2 = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); - v4l2_m2m_buf_copy_metadata(&lat_buf->ts_info, vb2_v4l2, true); vdec_h264_slice_fill_decode_reflist(inst, &inst->vsi_core->h264_slice_params, share_info); - err = vpu_dec_core(vpu); if (err) { mtk_vdec_err(ctx, "core decode err=%d", err); @@ -568,12 +634,11 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, struct vdec_h264_slice_inst *inst = h_vdec; struct vdec_vpu_inst *vpu = &inst->vpu; struct mtk_video_dec_buf *src_buf_info; - int nal_start_idx, err, timeout = 0, i; + int nal_start_idx, err, timeout = 0; unsigned int data[2]; struct vdec_lat_buf *lat_buf; struct vdec_h264_slice_share_info *share_info; unsigned char *buf; - struct mtk_vcodec_mem *mem; if (vdec_msg_queue_init(&inst->ctx->msg_queue, inst->ctx, vdec_h264_slice_core_decode, @@ -615,9 +680,6 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, vdec_h264_insert_startcode(inst->ctx->dev, buf, &bs->size, &share_info->h264_slice_params.pps); - inst->vsi->dec.bs_buf_addr = (uint64_t)bs->dma_addr; - inst->vsi->dec.bs_buf_size = bs->size; - *res_chg = inst->resolution_changed; if (inst->resolution_changed) { mtk_vdec_debug(inst->ctx, "- resolution changed -"); @@ -629,30 +691,15 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, } inst->resolution_changed = false; } - for (i = 0; i < H264_MAX_MV_NUM; i++) { - mem = &inst->mv_buf[i]; - inst->vsi->mv_buf_dma[i] = mem->dma_addr; - } - inst->vsi->wdma_start_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr; - inst->vsi->wdma_end_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr + - lat_buf->ctx->msg_queue.wdma_addr.size; - inst->vsi->wdma_err_addr = lat_buf->wdma_err_addr.dma_addr; - inst->vsi->slice_bc_start_addr = lat_buf->slice_bc_addr.dma_addr; - inst->vsi->slice_bc_end_addr = lat_buf->slice_bc_addr.dma_addr + - lat_buf->slice_bc_addr.size; - - inst->vsi->trans_end = inst->ctx->msg_queue.wdma_rptr_addr; - inst->vsi->trans_start = inst->ctx->msg_queue.wdma_wptr_addr; - mtk_vdec_debug(inst->ctx, "lat:trans(0x%llx 0x%llx) err:0x%llx", - inst->vsi->wdma_start_addr, - inst->vsi->wdma_end_addr, - inst->vsi->wdma_err_addr); - - mtk_vdec_debug(inst->ctx, "slice(0x%llx 0x%llx) rprt((0x%llx 0x%llx))", - inst->vsi->slice_bc_start_addr, - inst->vsi->slice_bc_end_addr, - inst->vsi->trans_start, - inst->vsi->trans_end); + + vdec_h264_slice_setup_lat_buffer(inst, bs, lat_buf); + mtk_vdec_debug(inst->ctx, "lat:trans(0x%llx 0x%lx) err:0x%llx", + inst->vsi->ube.dma_addr, (unsigned long)inst->vsi->ube.size, + inst->vsi->err_map.dma_addr); + + mtk_vdec_debug(inst->ctx, "slice(0x%llx 0x%lx) rprt((0x%llx 0x%llx))", + inst->vsi->slice_bc.dma_addr, (unsigned long)inst->vsi->slice_bc.size, + inst->vsi->trans.dma_addr, inst->vsi->trans.dma_addr_end); err = vpu_dec_start(vpu, data, 2); if (err) { mtk_vdec_debug(inst->ctx, "lat decode err: %d", err); @@ -660,7 +707,8 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, } share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr + - inst->vsi->wdma_end_addr_offset; + inst->vsi->dec.wdma_end_addr_offset; + share_info->trans_start = inst->ctx->msg_queue.wdma_wptr_addr; share_info->nal_info = inst->vsi->dec.nal_info; @@ -687,7 +735,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, } share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr + - inst->vsi->wdma_end_addr_offset; + inst->vsi->dec.wdma_end_addr_offset; vdec_msg_queue_update_ube_wptr(&lat_buf->ctx->msg_queue, share_info->trans_end); if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability)) { @@ -737,10 +785,10 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx c_dma=%llx", inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma); - inst->vsi_ctx.dec.bs_buf_addr = (u64)bs->dma_addr; - inst->vsi_ctx.dec.bs_buf_size = bs->size; - inst->vsi_ctx.dec.y_fb_dma = y_fb_dma; - inst->vsi_ctx.dec.c_fb_dma = c_fb_dma; + inst->vsi_ctx.bs.dma_addr = (u64)bs->dma_addr; + inst->vsi_ctx.bs.size = bs->size; + inst->vsi_ctx.fb.y.dma_addr = y_fb_dma; + inst->vsi_ctx.fb.c.dma_addr = c_fb_dma; inst->vsi_ctx.dec.vdec_fb_va = (u64)(uintptr_t)fb; v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, @@ -770,7 +818,7 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs for (i = 0; i < H264_MAX_MV_NUM; i++) { mem = &inst->mv_buf[i]; - inst->vsi_ctx.mv_buf_dma[i] = mem->dma_addr; + inst->vsi_ctx.mv_buf_dma[i].dma_addr = mem->dma_addr; } } From patchwork Mon Oct 14 07:33:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13834245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61C8ACFC502 for ; Mon, 14 Oct 2024 07:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yQGHPt3KcqeuyJTv2IwPmg6XGUAfOEVOUAK1IJGPSDo=; b=BmQo0TjtSkoPOIH2SEOT9uBUiT xhDEXfCHT+D+S8QtS8lgPeaGFAzs9nuwqubeJLa2TA/+pApjYDtqbOLZBBfw+qptbSFeWfA13Ek/0 7GDzg/RlSbOoTN4Ejeyd3M5JX5bvAtV+w8u+HANS5EdQlbCXJuNSYKxWa7K148ztNZIAvV6BeD61I ulMEAJDU4H4YvLRmfVdZR8ISschQElkMiyRXhdQ0yqokiiP5PpeCP5otEdcu8wGkLfbAJ35V/tASl w1pVKKbpAfr0RVT4eFywrpbUvr7FtEuj1cNhzYL1sp9/+TFqg5D8sN2dxWbmWDTgvLEpCAwuZHP3Y 6iGlWHqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0FeJ-000000045L7-3ozw; Mon, 14 Oct 2024 07:37:51 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0FZy-000000044RZ-1Tv7; Mon, 14 Oct 2024 07:33:24 +0000 X-UUID: 9344ed3489fe11efba0aef63c0775dbf-20241014 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=yQGHPt3KcqeuyJTv2IwPmg6XGUAfOEVOUAK1IJGPSDo=; b=bKJ5JoCCa/gWLL1+JL7HLdNaUnhGY1MWKTANQUAYqQq/mVrmIvjjNP5XZG4JIgW4x5NCrUPUMY5nGoKe2oK3rY8cFm6GIjN+TN3XZIlggxyLPMv1WKGzdpTmNcMPZWdlk0na93KE8LVmPIz6s/8U8hmk+bzUt2lUq0r5wb8xdhk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:2f906fa9-c764-4f65-af1a-436f9a868d23,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:6dc6a47,CLOUDID:d2913641-8751-41b2-98dd-475503d45150,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,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: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 9344ed3489fe11efba0aef63c0775dbf-20241014 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1811796128; Mon, 14 Oct 2024 00:33:15 -0700 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.1118.26; Mon, 14 Oct 2024 00:33:13 -0700 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.1118.26 via Frontend Transport; Mon, 14 Oct 2024 15:33:12 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , 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 2/6] media: mediatek: vcodec: remove parse nal info in kernel Date: Mon, 14 Oct 2024 15:33:06 +0800 Message-ID: <20241014073314.18409-3-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241014073314.18409-1-yunfei.dong@mediatek.com> References: <20241014073314.18409-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_003323_014072_891D8E0A X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hardware can parse the slice synatx to get nal information in scp, needn't to parse it in kernel again. Signed-off-by: Yunfei Dong --- .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) 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_h264_req_multi_if.c index d3f8d62238c0..76b96924a2a7 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c @@ -634,11 +634,10 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, struct vdec_h264_slice_inst *inst = h_vdec; struct vdec_vpu_inst *vpu = &inst->vpu; struct mtk_video_dec_buf *src_buf_info; - int nal_start_idx, err, timeout = 0; + int err, timeout = 0; unsigned int data[2]; struct vdec_lat_buf *lat_buf; struct vdec_h264_slice_share_info *share_info; - unsigned char *buf; if (vdec_msg_queue_init(&inst->ctx->msg_queue, inst->ctx, vdec_h264_slice_core_decode, @@ -662,14 +661,6 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, share_info = lat_buf->private_data; src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); - buf = (unsigned char *)bs->va; - nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); - if (nal_start_idx < 0) { - err = -EINVAL; - goto err_free_fb_out; - } - - inst->vsi->dec.nal_info = buf[nal_start_idx]; lat_buf->vb2_v4l2_src = &src_buf_info->m2m_buf.vb; v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, &lat_buf->ts_info, true); @@ -677,7 +668,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, if (err) goto err_free_fb_out; - vdec_h264_insert_startcode(inst->ctx->dev, buf, &bs->size, + vdec_h264_insert_startcode(inst->ctx->dev, bs->va, &bs->size, &share_info->h264_slice_params.pps); *res_chg = inst->resolution_changed; From patchwork Mon Oct 14 07:33:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13834246 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A963CFC500 for ; Mon, 14 Oct 2024 07:39:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YZXjZ2gAHgp0+xo3WWjS1eWXo3ndI/jilYVGWevQwk4=; b=2hI/A9AunCGTcpYrKUkgwZpvA3 DP9T3gTrt3xmgznc37nDvdfra/obsblgVWDw64D3RGjwQ+bedzxN/rsDu7cJeUwpqzvKEcqYuJmiB zwjNE/ukJXhbrAACAWpvCSFX5o4RPKxrAswMLhl45mHRTSRtsF9fK1KnYvOd2UdvrHP490P0A7Kde So40riG189X2BYGHtLYylmNopTHb3C2RU5dmCfNCHkpG8EVqxU/Yx9wdZ6nfnnACDDNPFnK96Kdjo sCJoX9AjCTo2lxLbPyN4EbQs+59bHgtcGZKIYZCljSfk7hhCytvDPV4INlDX/qG2mh/cOCj5IqQ+s Aqz1640w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Ffi-000000045h7-0GFj; Mon, 14 Oct 2024 07:39:18 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0FZz-000000044SK-1YvC; Mon, 14 Oct 2024 07:33:25 +0000 X-UUID: 93eae6a889fe11efba0aef63c0775dbf-20241014 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=YZXjZ2gAHgp0+xo3WWjS1eWXo3ndI/jilYVGWevQwk4=; b=qlEG9kG8S7UrzodL5GH8Kvk3CM8LrXsODuzzfPmnCKho27cHqRnSkm/KJQQohaivFHVNfq/MaYrCqQqQ04xAGwcolSGnCCRxrRZ6l5GO8ralbQP/Lx1ot2KdfAmCQ+lcNi5Ia7W4+Iwwo1E/PRo4xv68FXI0HRFqbhf0UqqVQRw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:eeedc40d-bd22-40b4-8e7d-e5a75b7464ad,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:6dc6a47,CLOUDID:43923641-8751-41b2-98dd-475503d45150,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,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: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 93eae6a889fe11efba0aef63c0775dbf-20241014 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 680888227; Mon, 14 Oct 2024 00:33:16 -0700 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.1118.26; Mon, 14 Oct 2024 15:33:14 +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.1118.26 via Frontend Transport; Mon, 14 Oct 2024 15:33:13 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , 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 3/6] media: mediatek: vcodec: remove vsi operation in common interface Date: Mon, 14 Oct 2024 15:33:07 +0800 Message-ID: <20241014073314.18409-4-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241014073314.18409-1-yunfei.dong@mediatek.com> References: <20241014073314.18409-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_003323_500950_7A569F7C X-CRM114-Status: GOOD ( 12.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Remove vsi related operation in common interface to make sure the interface can be called by different architecture at the same time. Signed-off-by: Yunfei Dong --- .../decoder/vdec/vdec_h264_req_multi_if.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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_h264_req_multi_if.c index 76b96924a2a7..02ad579bfe8e 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c @@ -187,9 +187,9 @@ struct vdec_h264_slice_inst { }; static int vdec_h264_slice_fill_decode_parameters(struct vdec_h264_slice_inst *inst, - struct vdec_h264_slice_share_info *share_info) + struct vdec_h264_slice_share_info *share_info, + struct vdec_h264_slice_lat_dec_param *slice_data) { - struct vdec_h264_slice_lat_dec_param *slice_param = &inst->vsi->h264_slice_params; const struct v4l2_ctrl_h264_decode_params *dec_params; const struct v4l2_ctrl_h264_scaling_matrix *src_matrix; const struct v4l2_ctrl_h264_sps *sps; @@ -219,9 +219,9 @@ static int vdec_h264_slice_fill_decode_parameters(struct vdec_h264_slice_inst *i return -EINVAL; } - mtk_vdec_h264_copy_sps_params(&slice_param->sps, sps); - mtk_vdec_h264_copy_pps_params(&slice_param->pps, pps); - mtk_vdec_h264_copy_scaling_matrix(&slice_param->scaling_matrix, src_matrix); + mtk_vdec_h264_copy_sps_params(&slice_data->sps, sps); + mtk_vdec_h264_copy_pps_params(&slice_data->pps, pps); + mtk_vdec_h264_copy_scaling_matrix(&slice_data->scaling_matrix, src_matrix); memcpy(&share_info->sps, sps, sizeof(*sps)); memcpy(&share_info->dec_params, dec_params, sizeof(*dec_params)); @@ -282,9 +282,6 @@ static int get_vdec_sig_decode_parameters(struct vdec_h264_slice_inst *inst) mtk_vdec_h264_get_ref_list(b0_reflist, v4l2_b0_reflist, reflist_builder.num_valid); mtk_vdec_h264_get_ref_list(b1_reflist, v4l2_b1_reflist, reflist_builder.num_valid); - memcpy(&inst->vsi_ctx.h264_slice_params, slice_param, - sizeof(inst->vsi_ctx.h264_slice_params)); - return 0; } @@ -664,7 +661,8 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, lat_buf->vb2_v4l2_src = &src_buf_info->m2m_buf.vb; v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, &lat_buf->ts_info, true); - err = vdec_h264_slice_fill_decode_parameters(inst, share_info); + err = vdec_h264_slice_fill_decode_parameters(inst, share_info, + &inst->vsi->h264_slice_params); if (err) goto err_free_fb_out; @@ -788,6 +786,9 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs if (err) goto err_free_fb_out; + memcpy(&inst->vsi_ctx.h264_slice_params, &inst->h264_slice_param, + sizeof(inst->vsi_ctx.h264_slice_params)); + buf = (unsigned char *)bs->va; nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); if (nal_start_idx < 0) { From patchwork Mon Oct 14 07:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13834239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F274CFC500 for ; Mon, 14 Oct 2024 07:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ov16ZM53mRuDaJHl1pyn/DVxtQkrwl3v1MRkNhTGYmk=; b=qC7avC6ZIibiEcuQX+Z8KdheF4 LAfiBjhqVNamxsCY//DeFkW9KTjRvXa5iZpxIqfDtWGF01tW0ZAf2Jycr3YeJ5bsAlgmt1g2YAcfX W+Iybo35Bo2hyORb2c689c1oSdH2oI0T2J5zKL1JUW538INqsrLPGgi6VprSZOFCunScsOSHU10B2 4EPxtzl0f+fPYNSmJUkhGKlOQmOybIzq1tGAifBOaLZ6Jq4VTioR07f/MVoSzQvz3OOhsX8GNkkR+ bDJeZbZEZNZOCVM1aUH4eDT9N+2YQkmKnhBlTYrnj6sac5C+tY3r5dsl8gNj6WybazLUu/jRf50RR 5RWDX1dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Fcz-0000000459C-0tNH; Mon, 14 Oct 2024 07:36:29 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0FZx-000000044R7-2Bmn; Mon, 14 Oct 2024 07:33:23 +0000 X-UUID: 93a7988089fe11efba0aef63c0775dbf-20241014 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=ov16ZM53mRuDaJHl1pyn/DVxtQkrwl3v1MRkNhTGYmk=; b=Vf57hruwCC1TPcU48rhWuYQkdhxqtKTgFCaVOML0UsU422VNCdN0FL5v0PWxKngYKZKj8cq0OyKhTM0iQbW7XFaf3pvdIURtB6hPR3AA1CVaD66cYHNvT8408bk+HbDxgd3Bs8Q0KRQxaEXarrTBBylJ4+BEWSOnXid0mpYjInA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:7836ff40-b056-4707-ae77-25ccfb87a227,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:6dc6a47,CLOUDID:246fbe06-3d5c-41f6-8d90-a8be388b5b5b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,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: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 93a7988089fe11efba0aef63c0775dbf-20241014 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1050015152; Mon, 14 Oct 2024 00:33:16 -0700 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.1118.26; Mon, 14 Oct 2024 00:33:15 -0700 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.1118.26 via Frontend Transport; Mon, 14 Oct 2024 15:33:14 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , 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 4/6] media: mediatek: vcodec: rename vsi to extend vsi Date: Mon, 14 Oct 2024 15:33:08 +0800 Message-ID: <20241014073314.18409-5-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241014073314.18409-1-yunfei.dong@mediatek.com> References: <20241014073314.18409-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_003321_608723_110CCC12 X-CRM114-Status: GOOD ( 15.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rename vsi struct to extend vsi to support extend architecture. Signed-off-by: Yunfei Dong --- .../decoder/vdec/vdec_h264_req_multi_if.c | 167 +++++++++--------- 1 file changed, 85 insertions(+), 82 deletions(-) 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_h264_req_multi_if.c index 02ad579bfe8e..ba7fd3200d98 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c @@ -48,7 +48,7 @@ struct vdec_h264_slice_lat_dec_param { }; /** - * struct vdec_h264_slice_info - decode information + * struct vdec_h264_slice_info_ex - extend decode information * * @wdma_end_addr_offset: offset from buffer start * @nal_info: nal info of current picture @@ -57,7 +57,7 @@ struct vdec_h264_slice_lat_dec_param { * @crc: Used to check whether hardware's status is right * @reserved: reserved */ -struct vdec_h264_slice_info { +struct vdec_h264_slice_info_ex { u64 wdma_end_addr_offset; u16 nal_info; u16 timeout; @@ -92,7 +92,7 @@ struct vdec_h264_slice_fb { }; /** - * struct vdec_h264_slice_vsi - shared memory for decode information exchange + * struct vdec_h264_slice_vsi_ex - extend shared memory for decode information exchange * between SCP and Host. * * @bs: input buffer info @@ -108,7 +108,7 @@ struct vdec_h264_slice_fb { * @dec: decode information (AP-R, VPU-W) * @h264_slice_params: decode parameters for hw used */ -struct vdec_h264_slice_vsi { +struct vdec_h264_slice_vsi_ex { /* LAT dec addr */ struct vdec_h264_slice_mem bs; struct vdec_h264_slice_fb fb; @@ -120,7 +120,7 @@ struct vdec_h264_slice_vsi { struct vdec_h264_slice_mem slice_bc; struct vdec_h264_slice_mem mv_buf_dma[H264_MAX_MV_NUM]; - struct vdec_h264_slice_info dec; + struct vdec_h264_slice_info_ex dec; struct vdec_h264_slice_lat_dec_param h264_slice_params; }; @@ -152,10 +152,10 @@ struct vdec_h264_slice_share_info { * @pred_buf: HW working prediction buffer * @mv_buf: HW working motion vector buffer * @vpu: VPU instance - * @vsi: vsi used for lat - * @vsi_core: vsi used for core + * @vsi_ex: extend vsi used for lat + * @vsi_core_ex: extend vsi used for core * - * @vsi_ctx: Local VSI data for this decoding context + * @vsi_ctx_ex: Local extend vsi data for this decoding context * @h264_slice_param: the parameters that hardware use to decode * * @resolution_changed:resolution changed @@ -172,10 +172,10 @@ struct vdec_h264_slice_inst { struct mtk_vcodec_mem pred_buf; struct mtk_vcodec_mem mv_buf[H264_MAX_MV_NUM]; struct vdec_vpu_inst vpu; - struct vdec_h264_slice_vsi *vsi; - struct vdec_h264_slice_vsi *vsi_core; + struct vdec_h264_slice_vsi_ex *vsi_ex; + struct vdec_h264_slice_vsi_ex *vsi_core_ex; - struct vdec_h264_slice_vsi vsi_ctx; + struct vdec_h264_slice_vsi_ex vsi_ctx_ex; struct vdec_h264_slice_lat_dec_param h264_slice_param; unsigned int resolution_changed; @@ -412,28 +412,28 @@ static void vdec_h264_slice_setup_lat_buffer(struct vdec_h264_slice_inst *inst, struct mtk_vcodec_mem *mem; int i; - inst->vsi->bs.dma_addr = (u64)bs->dma_addr; - inst->vsi->bs.size = bs->size; + inst->vsi_ex->bs.dma_addr = (u64)bs->dma_addr; + inst->vsi_ex->bs.size = bs->size; for (i = 0; i < H264_MAX_MV_NUM; i++) { mem = &inst->mv_buf[i]; - inst->vsi->mv_buf_dma[i].dma_addr = mem->dma_addr; - inst->vsi->mv_buf_dma[i].size = mem->size; + inst->vsi_ex->mv_buf_dma[i].dma_addr = mem->dma_addr; + inst->vsi_ex->mv_buf_dma[i].size = mem->size; } - inst->vsi->ube.dma_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr; - inst->vsi->ube.size = lat_buf->ctx->msg_queue.wdma_addr.size; + inst->vsi_ex->ube.dma_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr; + inst->vsi_ex->ube.size = lat_buf->ctx->msg_queue.wdma_addr.size; - inst->vsi->row_info.dma_addr = 0; - inst->vsi->row_info.size = 0; + inst->vsi_ex->row_info.dma_addr = 0; + inst->vsi_ex->row_info.size = 0; - inst->vsi->err_map.dma_addr = lat_buf->wdma_err_addr.dma_addr; - inst->vsi->err_map.size = lat_buf->wdma_err_addr.size; + inst->vsi_ex->err_map.dma_addr = lat_buf->wdma_err_addr.dma_addr; + inst->vsi_ex->err_map.size = lat_buf->wdma_err_addr.size; - inst->vsi->slice_bc.dma_addr = lat_buf->slice_bc_addr.dma_addr; - inst->vsi->slice_bc.size = lat_buf->slice_bc_addr.size; + inst->vsi_ex->slice_bc.dma_addr = lat_buf->slice_bc_addr.dma_addr; + inst->vsi_ex->slice_bc.size = lat_buf->slice_bc_addr.size; - inst->vsi->trans.dma_addr_end = inst->ctx->msg_queue.wdma_rptr_addr; - inst->vsi->trans.dma_addr = inst->ctx->msg_queue.wdma_wptr_addr; + inst->vsi_ex->trans.dma_addr_end = inst->ctx->msg_queue.wdma_rptr_addr; + inst->vsi_ex->trans.dma_addr = inst->ctx->msg_queue.wdma_wptr_addr; } static int vdec_h264_slice_setup_core_buffer(struct vdec_h264_slice_inst *inst, @@ -462,33 +462,33 @@ static int vdec_h264_slice_setup_core_buffer(struct vdec_h264_slice_inst *inst, mtk_vdec_debug(ctx, "[h264-core] y/c addr = 0x%llx 0x%llx", y_fb_dma, c_fb_dma); - inst->vsi_core->fb.y.dma_addr = y_fb_dma; - inst->vsi_core->fb.y.size = ctx->picinfo.fb_sz[0]; - inst->vsi_core->fb.c.dma_addr = c_fb_dma; - inst->vsi_core->fb.c.size = ctx->picinfo.fb_sz[1]; + inst->vsi_core_ex->fb.y.dma_addr = y_fb_dma; + inst->vsi_core_ex->fb.y.size = ctx->picinfo.fb_sz[0]; + inst->vsi_core_ex->fb.c.dma_addr = c_fb_dma; + inst->vsi_core_ex->fb.c.size = ctx->picinfo.fb_sz[1]; - inst->vsi_core->dec.vdec_fb_va = (unsigned long)fb; - inst->vsi_core->dec.nal_info = share_info->nal_info; + inst->vsi_core_ex->dec.vdec_fb_va = (unsigned long)fb; + inst->vsi_core_ex->dec.nal_info = share_info->nal_info; - inst->vsi_core->ube.dma_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr; - inst->vsi_core->ube.size = lat_buf->ctx->msg_queue.wdma_addr.size; + inst->vsi_core_ex->ube.dma_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr; + inst->vsi_core_ex->ube.size = lat_buf->ctx->msg_queue.wdma_addr.size; - inst->vsi_core->err_map.dma_addr = lat_buf->wdma_err_addr.dma_addr; - inst->vsi_core->err_map.size = lat_buf->wdma_err_addr.size; + inst->vsi_core_ex->err_map.dma_addr = lat_buf->wdma_err_addr.dma_addr; + inst->vsi_core_ex->err_map.size = lat_buf->wdma_err_addr.size; - inst->vsi_core->slice_bc.dma_addr = lat_buf->slice_bc_addr.dma_addr; - inst->vsi_core->slice_bc.size = lat_buf->slice_bc_addr.size; + inst->vsi_core_ex->slice_bc.dma_addr = lat_buf->slice_bc_addr.dma_addr; + inst->vsi_core_ex->slice_bc.size = lat_buf->slice_bc_addr.size; - inst->vsi_core->row_info.dma_addr = 0; - inst->vsi_core->row_info.size = 0; + inst->vsi_core_ex->row_info.dma_addr = 0; + inst->vsi_core_ex->row_info.size = 0; - inst->vsi_core->trans.dma_addr = share_info->trans_start; - inst->vsi_core->trans.dma_addr_end = share_info->trans_end; + inst->vsi_core_ex->trans.dma_addr = share_info->trans_start; + inst->vsi_core_ex->trans.dma_addr_end = share_info->trans_end; for (i = 0; i < H264_MAX_MV_NUM; i++) { mem = &inst->mv_buf[i]; - inst->vsi_core->mv_buf_dma[i].dma_addr = mem->dma_addr; - inst->vsi_core->mv_buf_dma[i].size = mem->size; + inst->vsi_core_ex->mv_buf_dma[i].dma_addr = mem->dma_addr; + inst->vsi_core_ex->mv_buf_dma[i].size = mem->size; } vb2_v4l2 = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); @@ -520,10 +520,10 @@ static int vdec_h264_slice_init(struct mtk_vcodec_dec_ctx *ctx) goto error_free_inst; } - vsi_size = round_up(sizeof(struct vdec_h264_slice_vsi), VCODEC_DEC_ALIGNED_64); - inst->vsi = inst->vpu.vsi; - inst->vsi_core = - (struct vdec_h264_slice_vsi *)(((char *)inst->vpu.vsi) + vsi_size); + vsi_size = round_up(sizeof(struct vdec_h264_slice_vsi_ex), VCODEC_DEC_ALIGNED_64); + inst->vsi_ex = inst->vpu.vsi; + inst->vsi_core_ex = + (struct vdec_h264_slice_vsi_ex *)(((char *)inst->vpu.vsi) + vsi_size); inst->resolution_changed = true; inst->realloc_mv_buf = true; @@ -564,14 +564,14 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf) struct vdec_vpu_inst *vpu = &inst->vpu; mtk_vdec_debug(ctx, "[h264-core] vdec_h264 core decode"); - memcpy(&inst->vsi_core->h264_slice_params, &share_info->h264_slice_params, + memcpy(&inst->vsi_core_ex->h264_slice_params, &share_info->h264_slice_params, sizeof(share_info->h264_slice_params)); err = vdec_h264_slice_setup_core_buffer(inst, share_info, lat_buf); if (err) goto vdec_dec_end; - vdec_h264_slice_fill_decode_reflist(inst, &inst->vsi_core->h264_slice_params, + vdec_h264_slice_fill_decode_reflist(inst, &inst->vsi_core_ex->h264_slice_params, share_info); err = vpu_dec_core(vpu); if (err) { @@ -584,15 +584,15 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf) WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE); if (timeout) mtk_vdec_err(ctx, "core decode timeout: pic_%d", ctx->decoded_frame_cnt); - inst->vsi_core->dec.timeout = !!timeout; + inst->vsi_core_ex->dec.timeout = !!timeout; vpu_dec_core_end(vpu); mtk_vdec_debug(ctx, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", ctx->decoded_frame_cnt, - inst->vsi_core->dec.crc[0], inst->vsi_core->dec.crc[1], - inst->vsi_core->dec.crc[2], inst->vsi_core->dec.crc[3], - inst->vsi_core->dec.crc[4], inst->vsi_core->dec.crc[5], - inst->vsi_core->dec.crc[6], inst->vsi_core->dec.crc[7]); + inst->vsi_core_ex->dec.crc[0], inst->vsi_core_ex->dec.crc[1], + inst->vsi_core_ex->dec.crc[2], inst->vsi_core_ex->dec.crc[3], + inst->vsi_core_ex->dec.crc[4], inst->vsi_core_ex->dec.crc[5], + inst->vsi_core_ex->dec.crc[6], inst->vsi_core_ex->dec.crc[7]); vdec_dec_end: vdec_msg_queue_update_ube_rptr(&lat_buf->ctx->msg_queue, share_info->trans_end); @@ -662,7 +662,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, &lat_buf->ts_info, true); err = vdec_h264_slice_fill_decode_parameters(inst, share_info, - &inst->vsi->h264_slice_params); + &inst->vsi_ex->h264_slice_params); if (err) goto err_free_fb_out; @@ -683,12 +683,13 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, vdec_h264_slice_setup_lat_buffer(inst, bs, lat_buf); mtk_vdec_debug(inst->ctx, "lat:trans(0x%llx 0x%lx) err:0x%llx", - inst->vsi->ube.dma_addr, (unsigned long)inst->vsi->ube.size, - inst->vsi->err_map.dma_addr); + inst->vsi_ex->ube.dma_addr, (unsigned long)inst->vsi_ex->ube.size, + inst->vsi_ex->err_map.dma_addr); mtk_vdec_debug(inst->ctx, "slice(0x%llx 0x%lx) rprt((0x%llx 0x%llx))", - inst->vsi->slice_bc.dma_addr, (unsigned long)inst->vsi->slice_bc.size, - inst->vsi->trans.dma_addr, inst->vsi->trans.dma_addr_end); + inst->vsi_ex->slice_bc.dma_addr, (unsigned long)inst->vsi_ex->slice_bc.size, + inst->vsi_ex->trans.dma_addr, inst->vsi_ex->trans.dma_addr_end); + err = vpu_dec_start(vpu, data, 2); if (err) { mtk_vdec_debug(inst->ctx, "lat decode err: %d", err); @@ -696,13 +697,13 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, } share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr + - inst->vsi->dec.wdma_end_addr_offset; + inst->vsi_ex->dec.wdma_end_addr_offset; share_info->trans_start = inst->ctx->msg_queue.wdma_wptr_addr; - share_info->nal_info = inst->vsi->dec.nal_info; + share_info->nal_info = inst->vsi_ex->dec.nal_info; if (IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability)) { - memcpy(&share_info->h264_slice_params, &inst->vsi->h264_slice_params, + memcpy(&share_info->h264_slice_params, &inst->vsi_ex->h264_slice_params, sizeof(share_info->h264_slice_params)); vdec_msg_queue_qbuf(&inst->ctx->msg_queue.core_ctx, lat_buf); } @@ -712,7 +713,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, WAIT_INTR_TIMEOUT_MS, MTK_VDEC_LAT0); if (timeout) mtk_vdec_err(inst->ctx, "lat decode timeout: pic_%d", inst->slice_dec_num); - inst->vsi->dec.timeout = !!timeout; + inst->vsi_ex->dec.timeout = !!timeout; err = vpu_dec_end(vpu); if (err == SLICE_HEADER_FULL || err == TRANS_BUFFER_FULL) { @@ -724,16 +725,18 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, } share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr + - inst->vsi->dec.wdma_end_addr_offset; + inst->vsi_ex->dec.wdma_end_addr_offset; + vdec_msg_queue_update_ube_wptr(&lat_buf->ctx->msg_queue, share_info->trans_end); if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability)) { - memcpy(&share_info->h264_slice_params, &inst->vsi->h264_slice_params, + memcpy(&share_info->h264_slice_params, &inst->vsi_ex->h264_slice_params, sizeof(share_info->h264_slice_params)); vdec_msg_queue_qbuf(&inst->ctx->msg_queue.core_ctx, lat_buf); } mtk_vdec_debug(inst->ctx, "dec num: %d lat crc: 0x%x 0x%x 0x%x", inst->slice_dec_num, - inst->vsi->dec.crc[0], inst->vsi->dec.crc[1], inst->vsi->dec.crc[2]); + inst->vsi_ex->dec.crc[0], inst->vsi_ex->dec.crc[1], + inst->vsi_ex->dec.crc[2]); inst->slice_dec_num++; return 0; @@ -774,11 +777,11 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx c_dma=%llx", inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma); - inst->vsi_ctx.bs.dma_addr = (u64)bs->dma_addr; - inst->vsi_ctx.bs.size = bs->size; - inst->vsi_ctx.fb.y.dma_addr = y_fb_dma; - inst->vsi_ctx.fb.c.dma_addr = c_fb_dma; - inst->vsi_ctx.dec.vdec_fb_va = (u64)(uintptr_t)fb; + inst->vsi_ctx_ex.bs.dma_addr = (u64)bs->dma_addr; + inst->vsi_ctx_ex.bs.size = bs->size; + inst->vsi_ctx_ex.fb.y.dma_addr = y_fb_dma; + inst->vsi_ctx_ex.fb.c.dma_addr = c_fb_dma; + inst->vsi_ctx_ex.dec.vdec_fb_va = (u64)(uintptr_t)fb; v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, &dst_buf_info->m2m_buf.vb, true); @@ -786,8 +789,8 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs if (err) goto err_free_fb_out; - memcpy(&inst->vsi_ctx.h264_slice_params, &inst->h264_slice_param, - sizeof(inst->vsi_ctx.h264_slice_params)); + memcpy(&inst->vsi_ctx_ex.h264_slice_params, &inst->h264_slice_param, + sizeof(inst->vsi_ctx_ex.h264_slice_params)); buf = (unsigned char *)bs->va; nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); @@ -795,7 +798,7 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs err = -EINVAL; goto err_free_fb_out; } - inst->vsi_ctx.dec.nal_info = buf[nal_start_idx]; + inst->vsi_ctx_ex.dec.nal_info = buf[nal_start_idx]; *res_chg = inst->resolution_changed; if (inst->resolution_changed) { @@ -810,11 +813,11 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs for (i = 0; i < H264_MAX_MV_NUM; i++) { mem = &inst->mv_buf[i]; - inst->vsi_ctx.mv_buf_dma[i].dma_addr = mem->dma_addr; + inst->vsi_ctx_ex.mv_buf_dma[i].dma_addr = mem->dma_addr; } } - memcpy(inst->vpu.vsi, &inst->vsi_ctx, sizeof(inst->vsi_ctx)); + memcpy(inst->vpu.vsi, &inst->vsi_ctx_ex, sizeof(inst->vsi_ctx_ex)); err = vpu_dec_start(vpu, data, 2); if (err) goto err_free_fb_out; @@ -825,18 +828,18 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs if (err) mtk_vdec_err(inst->ctx, "decode timeout: pic_%d", inst->ctx->decoded_frame_cnt); - inst->vsi->dec.timeout = !!err; + inst->vsi_ex->dec.timeout = !!err; err = vpu_dec_end(vpu); if (err) goto err_free_fb_out; - memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx)); + memcpy(&inst->vsi_ctx_ex, inst->vpu.vsi, sizeof(inst->vsi_ctx_ex)); mtk_vdec_debug(inst->ctx, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inst->ctx->decoded_frame_cnt, - inst->vsi_ctx.dec.crc[0], inst->vsi_ctx.dec.crc[1], - inst->vsi_ctx.dec.crc[2], inst->vsi_ctx.dec.crc[3], - inst->vsi_ctx.dec.crc[4], inst->vsi_ctx.dec.crc[5], - inst->vsi_ctx.dec.crc[6], inst->vsi_ctx.dec.crc[7]); + inst->vsi_ctx_ex.dec.crc[0], inst->vsi_ctx_ex.dec.crc[1], + inst->vsi_ctx_ex.dec.crc[2], inst->vsi_ctx_ex.dec.crc[3], + inst->vsi_ctx_ex.dec.crc[4], inst->vsi_ctx_ex.dec.crc[5], + inst->vsi_ctx_ex.dec.crc[6], inst->vsi_ctx_ex.dec.crc[7]); inst->ctx->decoded_frame_cnt++; return 0; From patchwork Mon Oct 14 07:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13834247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 984BECFC501 for ; Mon, 14 Oct 2024 07:40:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sHIKlEGQc1gMljjo6XctvH3MyRQKPj0bj6tE3zjFyEg=; b=i4h1OfXhphvguZnTrjfZHIJWfW lZBBcGotN+jrfzwM3/iDKtjjP3Q/X43o0ckrktJBTaIyya1zrHkUHOdTA2DwYmwgIYKGoEa50eUle 9D1f9a8Wt8l9q3n5tbwva4cuLvssx9AjE67q755sSqziwFme9biHinnM/7fgRx3EQyMIQHWQ4kQUL 1g8x0trJr++amLwXJLWEHyhF3lxLr/C0aecQWGBhYzkMaKR7FH57jEjgcP+ZYZT3h6YvpCJe5bo5L 15QJcTk+bUooc6rRbL1yhBZeI1+zetSSjCpPHttSPmWppp3x8NkvJc6Bv4jS9DdzHDUBGhxZ61Ts9 Fn+v/JWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Fh7-0000000468i-0UTW; Mon, 14 Oct 2024 07:40:45 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0FZy-000000044R6-3oND; Mon, 14 Oct 2024 07:33:25 +0000 X-UUID: 955b36c889fe11efba0aef63c0775dbf-20241014 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=sHIKlEGQc1gMljjo6XctvH3MyRQKPj0bj6tE3zjFyEg=; b=iFzjLr8CxnuK4P6wd0HW9Rl4C9ASVWDnE6eFPZl+P2m5tFj5yCUQXe572eVdDDdK0bBVUhc4nF3QtECTFdtG9ysO4ZzEci8OoZyoY6IB4AP89rMOgt/EGmjC0KFeqeOeKFUxDoFI820s/um2jXl6RjHVw9P+GpnQrpeWZwpeHiI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:81636433-2e5a-4da5-9230-be41d4e81059,IP:0,U RL:0,TC:0,Content:0,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:25 X-CID-META: VersionHash:6dc6a47,CLOUDID:8f6fbe06-3d5c-41f6-8d90-a8be388b5b5b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:5,IP:nil,UR L:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,S PR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 955b36c889fe11efba0aef63c0775dbf-20241014 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1817581006; Mon, 14 Oct 2024 00:33:19 -0700 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.1118.26; Mon, 14 Oct 2024 15:33:16 +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.1118.26 via Frontend Transport; Mon, 14 Oct 2024 15:33:15 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , 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 5/6] media: mediatek: vcodec: adding non extend struct Date: Mon, 14 Oct 2024 15:33:09 +0800 Message-ID: <20241014073314.18409-6-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241014073314.18409-1-yunfei.dong@mediatek.com> References: <20241014073314.18409-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--8.865500-8.000000 X-TMASE-MatchedRID: SJCrnFkDoFsQ5hxJOM7hQxlckvO1m+JcTJDl9FKHbrkS+jFO7d+PW4XU efEuqZPbprivVPtMHvYgtOjYSVCcGMZR5zLxbV5qSHCU59h5KrHEoDEGChh7CQoDY6gYCVOTWLm v5Mq0iytzQGdyGqOMPYAy6p60ZV62fJ5/bZ6npdjKayT/BQTiGhsMr2aelUWF66AX8NMCygLa1t TiSs0wA9D8gdPbakiJ3KstBC/47ng= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.865500-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: A81E988DBF4D0C9E3BCA885B5E5AAA3B44D34589CF95CCF41E60A04EF21469B32000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_003323_069757_D3666CF9 X-CRM114-Status: GOOD ( 12.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Adding non extend struct to support old architecture to calculate address end in kernel. Signed-off-by: Yunfei Dong --- .../decoder/vdec/vdec_h264_req_multi_if.c | 76 ++++++++++++++++++- 1 file changed, 73 insertions(+), 3 deletions(-) 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_h264_req_multi_if.c index ba7fd3200d98..d6dc1cc5a712 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c @@ -66,6 +66,29 @@ struct vdec_h264_slice_info_ex { u32 reserved; }; +/** + * struct vdec_h264_slice_info - decode information + * + * @nal_info: nal info of current picture + * @timeout: Decode timeout: 1 timeout, 0 no timeount + * @bs_buf_size: bitstream size + * @bs_buf_addr: bitstream buffer dma address + * @y_fb_dma: Y frame buffer dma address + * @c_fb_dma: C frame buffer dma address + * @vdec_fb_va: VDEC frame buffer struct virtual address + * @crc: Used to check whether hardware's status is right + */ +struct vdec_h264_slice_info { + u16 nal_info; + u16 timeout; + u32 bs_buf_size; + u64 bs_buf_addr; + u64 y_fb_dma; + u64 c_fb_dma; + u64 vdec_fb_va; + u32 crc[8]; +}; + /* * struct vdec_h264_slice_mem - memory address and size */ @@ -124,6 +147,44 @@ struct vdec_h264_slice_vsi_ex { struct vdec_h264_slice_lat_dec_param h264_slice_params; }; +/** + * struct vdec_h264_slice_vsi - shared memory for decode information exchange + * between SCP and Host. + * + * @wdma_err_addr: wdma error dma address + * @wdma_start_addr: wdma start dma address + * @wdma_end_addr: wdma end dma address + * @slice_bc_start_addr: slice bc start dma address + * @slice_bc_end_addr: slice bc end dma address + * @row_info_start_addr: row info start dma address + * @row_info_end_addr: row info end dma address + * @trans_start: trans start dma address + * @trans_end: trans end dma address + * @wdma_end_addr_offset: wdma end address offset + * + * @mv_buf_dma: HW working motion vector buffer + * dma address (AP-W, VPU-R) + * @dec: decode information (AP-R, VPU-W) + * @h264_slice_params: decode parameters for hw used + */ +struct vdec_h264_slice_vsi { + /* LAT dec addr */ + u64 wdma_err_addr; + u64 wdma_start_addr; + u64 wdma_end_addr; + u64 slice_bc_start_addr; + u64 slice_bc_end_addr; + u64 row_info_start_addr; + u64 row_info_end_addr; + u64 trans_start; + u64 trans_end; + u64 wdma_end_addr_offset; + + u64 mv_buf_dma[H264_MAX_MV_NUM]; + struct vdec_h264_slice_info dec; + struct vdec_h264_slice_lat_dec_param h264_slice_params; +}; + /** * struct vdec_h264_slice_share_info - shared information used to exchange * message between lat and core @@ -172,10 +233,19 @@ struct vdec_h264_slice_inst { struct mtk_vcodec_mem pred_buf; struct mtk_vcodec_mem mv_buf[H264_MAX_MV_NUM]; struct vdec_vpu_inst vpu; - struct vdec_h264_slice_vsi_ex *vsi_ex; - struct vdec_h264_slice_vsi_ex *vsi_core_ex; + union { + struct vdec_h264_slice_vsi_ex *vsi_ex; + struct vdec_h264_slice_vsi *vsi; + }; + union { + struct vdec_h264_slice_vsi_ex *vsi_core_ex; + struct vdec_h264_slice_vsi *vsi_core; + }; - struct vdec_h264_slice_vsi_ex vsi_ctx_ex; + union { + struct vdec_h264_slice_vsi_ex vsi_ctx_ex; + struct vdec_h264_slice_vsi vsi_ctx; + }; struct vdec_h264_slice_lat_dec_param h264_slice_param; unsigned int resolution_changed; From patchwork Mon Oct 14 07:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13834251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B56CCCFC500 for ; Mon, 14 Oct 2024 07:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JQFF5lwEKMXWavizCwOCi6GLo/NXGgvmJOoS6LS9+kA=; b=i+gfgMkziXfF6+e1JdazsUpKCJ LbzXAirv51yZ0Qv/Y29gjRRH6EDXyRtIA6CP2KgVEjxRvmgYmzAU3lCuOkpB/xzB0+qFPLYtjR4Ny LbfRnpICgE3UQ3njgv2Mn6rQyK4cEDdoOy/0I4xlLnlbrysvNZczbJqzQPBYumpu5vWIgbX3KSVF2 pWgmKTJ7jypT1vbNu31943OiBKhiZ/qLVn1Q3SF1GM7Jembmjl0MR55nyVku0IUHLo11yM754Mhdq 0Z4OjRLcFzPTMF8WbkafrowvFFBCcfYVispdgVkmF3MXmzkxyw5SpxCqbQ47lsh8uoDCVQsS1IINa q1t8jb7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Fjt-000000046rZ-3Efn; Mon, 14 Oct 2024 07:43:37 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0Fa0-000000044RZ-2aDR; Mon, 14 Oct 2024 07:33:26 +0000 X-UUID: 95be11bc89fe11efba0aef63c0775dbf-20241014 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=JQFF5lwEKMXWavizCwOCi6GLo/NXGgvmJOoS6LS9+kA=; b=HEhrk6hSlzKgdynpQCtQy5DiZkUlUH+NzIjiVkp+eObqv+vZcQuqdITbxWQxm5VqG8ryeFdYQa2NI+JJN+sEPAf6aVro6CU2fBymxBdabaf0YwfzhKqTi0CpqkrTGX8meKB1PHerlmogSIi7IF33+LA6y974ZDTnmVhwXAdH91A=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:d128933d-a723-4d82-8e26-4e74898e5a18,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:6dc6a47,CLOUDID:d86fbe06-3d5c-41f6-8d90-a8be388b5b5b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,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: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 95be11bc89fe11efba0aef63c0775dbf-20241014 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2023186670; Mon, 14 Oct 2024 00:33:19 -0700 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.1118.26; Mon, 14 Oct 2024 15:33:17 +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.1118.26 via Frontend Transport; Mon, 14 Oct 2024 15:33:16 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , 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 6/6] media: mediatek: vcodec: support extend h264 driver Date: Mon, 14 Oct 2024 15:33:10 +0800 Message-ID: <20241014073314.18409-7-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241014073314.18409-1-yunfei.dong@mediatek.com> References: <20241014073314.18409-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--10.369500-8.000000 X-TMASE-MatchedRID: M+1zxOMnjnnpuI4DF8FKRo+YSzwl92XTuLwbhNl9B5VEv26FkhjLXSDY qYUJWlkTlTJXKqh1ne0Gts3gBnpCcwfOWObyORhFoprTEHvewADt/okBLaEo+BS11FlOYRohWIN 4hZGO5GxtiFlpOAkr544K+5U79wEWMWZZmYy5XmYCg1rav4R3DeWNJG9Iamrc82HMiBe0UlWlHj sjMHC3hr6Fb9LVNYcnWG1zHa+3pOvMXKkorvNQjqSkqjfmd3aeYQXxsZnRwoKJoFTGeLN6N5wNy 2jM59Dx3wRvo7D+BFnIhb5ceJvuqZO1eXsst5WcSDkh6bW+bcd9LQinZ4QefJOK2Na/r7MIF70J Bot7Y8/3FLeZXNZS4KBkcgGnJ4WmATHAvd0eAnynaqUE0suhlXL8Wfj+XNvZMvy24V4e+tV+3Bn dfXUhXQ== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--10.369500-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 7320157F2FC85AE2507886B08ABE501F44C6E8FA13BBF7A05CDCD5AFA3A17A2D2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_003324_707635_C5F3BFF8 X-CRM114-Status: GOOD ( 18.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rename the extend interface with _ex and sync the non extend driver. Adding capability to separate extend and non extend driver. Signed-off-by: Yunfei Dong --- .../vcodec/decoder/mtk_vcodec_dec_drv.h | 2 + .../decoder/vdec/vdec_h264_req_multi_if.c | 377 +++++++++++++++++- 2 files changed, 367 insertions(+), 12 deletions(-) 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 886fa385e2e6..1e697bc810b0 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 @@ -17,6 +17,7 @@ #define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE) #define IS_VDEC_INNER_RACING(capability) ((capability) & MTK_VCODEC_INNER_RACING) +#define IS_VDEC_SUPPORT_EX(capability) ((capability) & MTK_VDEC_IS_SUPPORT_EX) enum mtk_vcodec_dec_chip_name { MTK_VDEC_INVAL = 0, @@ -42,6 +43,7 @@ enum mtk_vdec_format_types { MTK_VDEC_FORMAT_HEVC_FRAME = 0x1000, MTK_VCODEC_INNER_RACING = 0x20000, MTK_VDEC_IS_SUPPORT_10BIT = 0x40000, + MTK_VDEC_IS_SUPPORT_EX = 0x80000, }; /* 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_h264_req_multi_if.c index d6dc1cc5a712..94be1ad394c9 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c @@ -571,6 +571,7 @@ static int vdec_h264_slice_init(struct mtk_vcodec_dec_ctx *ctx) { struct vdec_h264_slice_inst *inst; int err, vsi_size; + unsigned char *temp; inst = kzalloc(sizeof(*inst), GFP_KERNEL); if (!inst) @@ -590,10 +591,21 @@ static int vdec_h264_slice_init(struct mtk_vcodec_dec_ctx *ctx) goto error_free_inst; } - vsi_size = round_up(sizeof(struct vdec_h264_slice_vsi_ex), VCODEC_DEC_ALIGNED_64); - inst->vsi_ex = inst->vpu.vsi; - inst->vsi_core_ex = - (struct vdec_h264_slice_vsi_ex *)(((char *)inst->vpu.vsi) + vsi_size); + if (IS_VDEC_SUPPORT_EX(ctx->dev->dec_capability)) { + vsi_size = sizeof(struct vdec_h264_slice_vsi_ex); + + vsi_size = round_up(vsi_size, VCODEC_DEC_ALIGNED_64); + inst->vsi_ex = inst->vpu.vsi; + temp = (unsigned char *)inst->vsi_ex; + inst->vsi_core_ex = (struct vdec_h264_slice_vsi_ex *)(temp + vsi_size); + } else { + vsi_size = sizeof(struct vdec_h264_slice_vsi); + + vsi_size = round_up(vsi_size, VCODEC_DEC_ALIGNED_64); + inst->vsi = inst->vpu.vsi; + temp = (unsigned char *)inst->vsi; + inst->vsi_core = (struct vdec_h264_slice_vsi *)(temp + vsi_size); + } inst->resolution_changed = true; inst->realloc_mv_buf = true; @@ -625,7 +637,7 @@ static void vdec_h264_slice_deinit(void *h_vdec) kfree(inst); } -static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf) +static int vdec_h264_slice_core_decode_ex(struct vdec_lat_buf *lat_buf) { int err, timeout; struct mtk_vcodec_dec_ctx *ctx = lat_buf->ctx; @@ -672,6 +684,95 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf) return 0; } +static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf) +{ + struct vdec_fb *fb; + u64 vdec_fb_va; + u64 y_fb_dma, c_fb_dma; + int err, timeout, i; + struct mtk_vcodec_dec_ctx *ctx = lat_buf->ctx; + struct vdec_h264_slice_inst *inst = ctx->drv_handle; + struct vb2_v4l2_buffer *vb2_v4l2; + struct vdec_h264_slice_share_info *share_info = lat_buf->private_data; + struct mtk_vcodec_mem *mem; + struct vdec_vpu_inst *vpu = &inst->vpu; + + mtk_vdec_debug(ctx, "[h264-core] vdec_h264 core decode"); + memcpy(&inst->vsi_core->h264_slice_params, &share_info->h264_slice_params, + sizeof(share_info->h264_slice_params)); + + fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx); + if (!fb) { + err = -EBUSY; + mtk_vdec_err(ctx, "fb buffer is NULL"); + goto vdec_dec_end; + } + + vdec_fb_va = (unsigned long)fb; + y_fb_dma = (u64)fb->base_y.dma_addr; + if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 1) + c_fb_dma = + y_fb_dma + inst->ctx->picinfo.buf_w * inst->ctx->picinfo.buf_h; + else + c_fb_dma = (u64)fb->base_c.dma_addr; + + mtk_vdec_debug(ctx, "[h264-core] y/c addr = 0x%llx 0x%llx", y_fb_dma, c_fb_dma); + + inst->vsi_core->dec.y_fb_dma = y_fb_dma; + inst->vsi_core->dec.c_fb_dma = c_fb_dma; + inst->vsi_core->dec.vdec_fb_va = vdec_fb_va; + inst->vsi_core->dec.nal_info = share_info->nal_info; + inst->vsi_core->wdma_start_addr = + lat_buf->ctx->msg_queue.wdma_addr.dma_addr; + inst->vsi_core->wdma_end_addr = + lat_buf->ctx->msg_queue.wdma_addr.dma_addr + + lat_buf->ctx->msg_queue.wdma_addr.size; + inst->vsi_core->wdma_err_addr = lat_buf->wdma_err_addr.dma_addr; + inst->vsi_core->slice_bc_start_addr = lat_buf->slice_bc_addr.dma_addr; + inst->vsi_core->slice_bc_end_addr = lat_buf->slice_bc_addr.dma_addr + + lat_buf->slice_bc_addr.size; + inst->vsi_core->trans_start = share_info->trans_start; + inst->vsi_core->trans_end = share_info->trans_end; + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi_core->mv_buf_dma[i] = mem->dma_addr; + } + + vb2_v4l2 = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); + v4l2_m2m_buf_copy_metadata(&lat_buf->ts_info, vb2_v4l2, true); + + vdec_h264_slice_fill_decode_reflist(inst, &inst->vsi_core->h264_slice_params, + share_info); + + err = vpu_dec_core(vpu); + if (err) { + mtk_vdec_err(ctx, "core decode err=%d", err); + goto vdec_dec_end; + } + + /* wait decoder done interrupt */ + timeout = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED, + WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE); + if (timeout) + mtk_vdec_err(ctx, "core decode timeout: pic_%d", ctx->decoded_frame_cnt); + inst->vsi_core->dec.timeout = !!timeout; + + vpu_dec_core_end(vpu); + mtk_vdec_debug(ctx, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", + ctx->decoded_frame_cnt, + inst->vsi_core->dec.crc[0], inst->vsi_core->dec.crc[1], + inst->vsi_core->dec.crc[2], inst->vsi_core->dec.crc[3], + inst->vsi_core->dec.crc[4], inst->vsi_core->dec.crc[5], + inst->vsi_core->dec.crc[6], inst->vsi_core->dec.crc[7]); + +vdec_dec_end: + vdec_msg_queue_update_ube_rptr(&lat_buf->ctx->msg_queue, share_info->trans_end); + ctx->dev->vdec_pdata->cap_to_disp(ctx, !!err, lat_buf->vb2_v4l2_src); + mtk_vdec_debug(ctx, "core decode done err=%d", err); + ctx->decoded_frame_cnt++; + return 0; +} + static void vdec_h264_insert_startcode(struct mtk_vcodec_dec_dev *vcodec_dev, unsigned char *buf, size_t *bs_size, struct mtk_h264_pps_param *pps) { @@ -695,8 +796,8 @@ static void vdec_h264_insert_startcode(struct mtk_vcodec_dec_dev *vcodec_dev, un (*bs_size) += 4; } -static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, - struct vdec_fb *fb, bool *res_chg) +static int vdec_h264_slice_lat_decode_ex(void *h_vdec, struct mtk_vcodec_mem *bs, + struct vdec_fb *fb, bool *res_chg) { struct vdec_h264_slice_inst *inst = h_vdec; struct vdec_vpu_inst *vpu = &inst->vpu; @@ -707,7 +808,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, struct vdec_h264_slice_share_info *share_info; if (vdec_msg_queue_init(&inst->ctx->msg_queue, inst->ctx, - vdec_h264_slice_core_decode, + vdec_h264_slice_core_decode_ex, sizeof(*share_info))) return -ENOMEM; @@ -816,8 +917,153 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, return err; } -static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs, - struct vdec_fb *unused, bool *res_chg) +static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, + struct vdec_fb *fb, bool *res_chg) +{ + struct vdec_h264_slice_inst *inst = h_vdec; + struct vdec_vpu_inst *vpu = &inst->vpu; + struct mtk_video_dec_buf *src_buf_info; + int nal_start_idx, err, timeout = 0, i; + unsigned int data[2]; + struct vdec_lat_buf *lat_buf; + struct vdec_h264_slice_share_info *share_info; + unsigned char *buf; + struct mtk_vcodec_mem *mem; + + if (vdec_msg_queue_init(&inst->ctx->msg_queue, inst->ctx, + vdec_h264_slice_core_decode, + sizeof(*share_info))) + return -ENOMEM; + + /* bs NULL means flush decoder */ + if (!bs) { + vdec_msg_queue_wait_lat_buf_full(&inst->ctx->msg_queue); + return vpu_dec_reset(vpu); + } + + if (inst->is_field_bitstream) + return -EINVAL; + + lat_buf = vdec_msg_queue_dqbuf(&inst->ctx->msg_queue.lat_ctx); + if (!lat_buf) { + mtk_vdec_debug(inst->ctx, "failed to get lat buffer"); + return -EAGAIN; + } + share_info = lat_buf->private_data; + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); + + buf = (unsigned char *)bs->va; + nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); + if (nal_start_idx < 0) { + err = -EINVAL; + goto err_free_fb_out; + } + + inst->vsi->dec.nal_info = buf[nal_start_idx]; + lat_buf->vb2_v4l2_src = &src_buf_info->m2m_buf.vb; + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, &lat_buf->ts_info, true); + + err = vdec_h264_slice_fill_decode_parameters(inst, share_info, + &inst->vsi->h264_slice_params); + if (err) + goto err_free_fb_out; + + vdec_h264_insert_startcode(inst->ctx->dev, buf, &bs->size, + &share_info->h264_slice_params.pps); + + inst->vsi->dec.bs_buf_addr = (uint64_t)bs->dma_addr; + inst->vsi->dec.bs_buf_size = bs->size; + + *res_chg = inst->resolution_changed; + if (inst->resolution_changed) { + mtk_vdec_debug(inst->ctx, "- resolution changed -"); + if (inst->realloc_mv_buf) { + err = vdec_h264_slice_alloc_mv_buf(inst, &inst->ctx->picinfo); + inst->realloc_mv_buf = false; + if (err) + goto err_free_fb_out; + } + inst->resolution_changed = false; + } + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi->mv_buf_dma[i] = mem->dma_addr; + } + inst->vsi->wdma_start_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr; + inst->vsi->wdma_end_addr = lat_buf->ctx->msg_queue.wdma_addr.dma_addr + + lat_buf->ctx->msg_queue.wdma_addr.size; + inst->vsi->wdma_err_addr = lat_buf->wdma_err_addr.dma_addr; + inst->vsi->slice_bc_start_addr = lat_buf->slice_bc_addr.dma_addr; + inst->vsi->slice_bc_end_addr = lat_buf->slice_bc_addr.dma_addr + + lat_buf->slice_bc_addr.size; + + inst->vsi->trans_end = inst->ctx->msg_queue.wdma_rptr_addr; + inst->vsi->trans_start = inst->ctx->msg_queue.wdma_wptr_addr; + mtk_vdec_debug(inst->ctx, "lat:trans(0x%llx 0x%llx) err:0x%llx", + inst->vsi->wdma_start_addr, + inst->vsi->wdma_end_addr, + inst->vsi->wdma_err_addr); + + mtk_vdec_debug(inst->ctx, "slice(0x%llx 0x%llx) rprt((0x%llx 0x%llx))", + inst->vsi->slice_bc_start_addr, + inst->vsi->slice_bc_end_addr, + inst->vsi->trans_start, + inst->vsi->trans_end); + err = vpu_dec_start(vpu, data, 2); + if (err) { + mtk_vdec_debug(inst->ctx, "lat decode err: %d", err); + goto err_free_fb_out; + } + + share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr + + inst->vsi->wdma_end_addr_offset; + share_info->trans_start = inst->ctx->msg_queue.wdma_wptr_addr; + share_info->nal_info = inst->vsi->dec.nal_info; + + if (IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability)) { + memcpy(&share_info->h264_slice_params, &inst->vsi->h264_slice_params, + sizeof(share_info->h264_slice_params)); + vdec_msg_queue_qbuf(&inst->ctx->msg_queue.core_ctx, lat_buf); + } + + /* wait decoder done interrupt */ + timeout = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED, + WAIT_INTR_TIMEOUT_MS, MTK_VDEC_LAT0); + if (timeout) + mtk_vdec_err(inst->ctx, "lat decode timeout: pic_%d", inst->slice_dec_num); + inst->vsi->dec.timeout = !!timeout; + + err = vpu_dec_end(vpu); + if (err == SLICE_HEADER_FULL || err == TRANS_BUFFER_FULL) { + if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability)) + vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf); + inst->slice_dec_num++; + mtk_vdec_err(inst->ctx, "lat dec fail: pic_%d err:%d", inst->slice_dec_num, err); + return -EINVAL; + } + + share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr + + inst->vsi->wdma_end_addr_offset; + vdec_msg_queue_update_ube_wptr(&lat_buf->ctx->msg_queue, share_info->trans_end); + + if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability)) { + memcpy(&share_info->h264_slice_params, &inst->vsi->h264_slice_params, + sizeof(share_info->h264_slice_params)); + vdec_msg_queue_qbuf(&inst->ctx->msg_queue.core_ctx, lat_buf); + } + mtk_vdec_debug(inst->ctx, "dec num: %d lat crc: 0x%x 0x%x 0x%x", inst->slice_dec_num, + inst->vsi->dec.crc[0], inst->vsi->dec.crc[1], inst->vsi->dec.crc[2]); + + inst->slice_dec_num++; + return 0; +err_free_fb_out: + vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf); + mtk_vdec_err(inst->ctx, "slice dec number: %d err: %d", inst->slice_dec_num, err); + return err; +} + +static int vdec_h264_slice_single_decode_ex(void *h_vdec, struct mtk_vcodec_mem *bs, + struct vdec_fb *unused, bool *res_chg) { struct vdec_h264_slice_inst *inst = h_vdec; struct vdec_vpu_inst *vpu = &inst->vpu; @@ -919,6 +1165,104 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs return err; } +static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs, + struct vdec_fb *unused, bool *res_chg) +{ + struct vdec_h264_slice_inst *inst = h_vdec; + struct vdec_vpu_inst *vpu = &inst->vpu; + struct mtk_video_dec_buf *src_buf_info, *dst_buf_info; + struct vdec_fb *fb; + unsigned char *buf; + unsigned int data[2], i; + u64 y_fb_dma, c_fb_dma; + struct mtk_vcodec_mem *mem; + int err, nal_start_idx; + + /* bs NULL means flush decoder */ + if (!bs) + return vpu_dec_reset(vpu); + + fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx); + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); + dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); + + y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; + c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; + mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx c_dma=%llx", + inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma); + + inst->vsi_ctx.dec.bs_buf_addr = (u64)bs->dma_addr; + inst->vsi_ctx.dec.bs_buf_size = bs->size; + inst->vsi_ctx.dec.y_fb_dma = y_fb_dma; + inst->vsi_ctx.dec.c_fb_dma = c_fb_dma; + inst->vsi_ctx.dec.vdec_fb_va = (u64)(uintptr_t)fb; + + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, + &dst_buf_info->m2m_buf.vb, true); + err = get_vdec_sig_decode_parameters(inst); + if (err) + goto err_free_fb_out; + + memcpy(&inst->vsi_ctx.h264_slice_params, &inst->h264_slice_param, + sizeof(inst->vsi_ctx.h264_slice_params)); + + buf = (unsigned char *)bs->va; + nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); + if (nal_start_idx < 0) { + err = -EINVAL; + goto err_free_fb_out; + } + inst->vsi_ctx.dec.nal_info = buf[nal_start_idx]; + + *res_chg = inst->resolution_changed; + if (inst->resolution_changed) { + mtk_vdec_debug(inst->ctx, "- resolution changed -"); + if (inst->realloc_mv_buf) { + err = vdec_h264_slice_alloc_mv_buf(inst, &inst->ctx->picinfo); + inst->realloc_mv_buf = false; + if (err) + goto err_free_fb_out; + } + inst->resolution_changed = false; + + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi_ctx.mv_buf_dma[i] = mem->dma_addr; + } + } + + memcpy(inst->vpu.vsi, &inst->vsi_ctx, sizeof(inst->vsi_ctx)); + err = vpu_dec_start(vpu, data, 2); + if (err) + goto err_free_fb_out; + + /* wait decoder done interrupt */ + err = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED, + WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE); + if (err) + mtk_vdec_err(inst->ctx, "decode timeout: pic_%d", inst->ctx->decoded_frame_cnt); + + inst->vsi->dec.timeout = !!err; + err = vpu_dec_end(vpu); + if (err) + goto err_free_fb_out; + + memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx)); + mtk_vdec_debug(inst->ctx, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", + inst->ctx->decoded_frame_cnt, + inst->vsi_ctx.dec.crc[0], inst->vsi_ctx.dec.crc[1], + inst->vsi_ctx.dec.crc[2], inst->vsi_ctx.dec.crc[3], + inst->vsi_ctx.dec.crc[4], inst->vsi_ctx.dec.crc[5], + inst->vsi_ctx.dec.crc[6], inst->vsi_ctx.dec.crc[7]); + + inst->ctx->decoded_frame_cnt++; + return 0; + +err_free_fb_out: + mtk_vdec_err(inst->ctx, "dec frame number: %d err: %d", inst->ctx->decoded_frame_cnt, err); + return err; +} + static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, struct vdec_fb *unused, bool *res_chg) { @@ -928,8 +1272,17 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, if (!h_vdec) return -EINVAL; - if (inst->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_PURE_SINGLE_CORE) - ret = vdec_h264_slice_single_decode(h_vdec, bs, unused, res_chg); + if (inst->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_PURE_SINGLE_CORE) { + if (IS_VDEC_SUPPORT_EX(inst->ctx->dev->dec_capability)) + ret = vdec_h264_slice_single_decode_ex(h_vdec, bs, unused, res_chg); + else + ret = vdec_h264_slice_single_decode(h_vdec, bs, unused, res_chg); + + return ret; + } + + if (IS_VDEC_SUPPORT_EX(inst->ctx->dev->dec_capability)) + ret = vdec_h264_slice_lat_decode_ex(h_vdec, bs, unused, res_chg); else ret = vdec_h264_slice_lat_decode(h_vdec, bs, unused, res_chg);