Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp820401rdb; Wed, 6 Dec 2023 00:17:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5k+PxFBVd5qcwtY4lcVwBNswyUXN5XxoCcycvHgd6wUcdvEFBPnLZKOAq68T/SLkpwmmj X-Received: by 2002:a17:90b:38cc:b0:286:c5ae:5264 with SMTP id nn12-20020a17090b38cc00b00286c5ae5264mr254525pjb.31.1701850636603; Wed, 06 Dec 2023 00:17:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701850636; cv=none; d=google.com; s=arc-20160816; b=av4Y9kkw1wv/dkdgyWr3jrPkfJKDdcKaC6pZxNfHRhRWth1xPmCERVAPi/s9txkyr9 BQ49yLsSRjy2bIDWXUw0v9bUHIrzPjWGfkIecRgxmXqObNsNojE/ayKJt4eVv/96zxkV FVP/yQ0sZ9cHm1eQUIOxS+5Fjobz11H4BssLKJnyc2zpVtKv4PVeRtAsgmO/NOMfg4wf Z8w9dXAsz2jZO06jaI+DdDY8Tx32vNV1pOLP5ithH+c0iangJRLTA/xhAKTA+AtvRykk hHZYL/piYKaYgnNXWFYUfNnEr9ohaMI4XQKZoqQEw114nMEqoMAEz9p0Q3hNtNUWu5NC lyMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lPwo9LNvB2FbQZZUU/VdB7YQJTuTNN5gXoP5cMTC8VQ=; fh=Jm1zUP85NkLhaS8mFbLRiIHu8uZd7NKlphUk8mYvM1c=; b=b6pJpgkMsn1EZKvI7DgsUF7lF8quoPqWyas5YQT1gs1i5Xbpk5OcdduFzWJnOlmXFc 2wYuBMdpmZXfIBHbtEWQmVwFRT/XNRiAup1EwGby3FiIar38mkvnxGxagM5HiwqjtGw+ g0Y3xSj18ikoj+G4iWDJWfIo9eVIUBdxmUCJnpk3ikxcEmsAZVyH4SxQsQX/cG42v/fd 2wcPq9t9AXZQwT5fUL/YtSB7ZfbQQju7wD5a//f85l1S7JUI7HjzfKFY8YH/vlC6ue3+ yWenllMhC4ku64A5yEm4VSkgcv0urN7FXTf2QU4G7yKGTjJgI+Q2kVzQmzfcuNumC7RI vyEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="XTrpao/X"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g15-20020a17090a300f00b002867730cb3esi6690991pjb.34.2023.12.06.00.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 00:17:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="XTrpao/X"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 63F15802C8F6; Wed, 6 Dec 2023 00:17:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377173AbjLFIRC (ORCPT + 99 others); Wed, 6 Dec 2023 03:17:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377264AbjLFIQ1 (ORCPT ); Wed, 6 Dec 2023 03:16:27 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88FB410FB; Wed, 6 Dec 2023 00:16:09 -0800 (PST) X-UUID: b18fc312940f11eea33bb35ae8d461a2-20231206 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=lPwo9LNvB2FbQZZUU/VdB7YQJTuTNN5gXoP5cMTC8VQ=; b=XTrpao/XBs1eOkC0/C1qzb58VfaR5neZGTjghzAIlKPdLNrBVDo0l9UHolMgkfMsJJGfOfGgbByvTrVTcG2ACJrYfhSbQnuPhqjRgYk8IwGD1iLkpRJNqSgs8OmaYoc5pzhzixB+6V7j+Ppt+qRcnHomlQYLfx6cmooLLLqWcxQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.34,REQID:09c72963-5583-4a9d-8c4d-6f43397696e4,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:abefa75,CLOUDID:b979e060-c89d-4129-91cb-8ebfae4653fc,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File: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 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_ULN,TF_CID_SPAM_SNR X-UUID: b18fc312940f11eea33bb35ae8d461a2-20231206 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 817340102; Wed, 06 Dec 2023 16:16:01 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 6 Dec 2023 16:16:01 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 6 Dec 2023 16:15:59 +0800 From: Yunfei Dong To: Jeffrey Kardatzke , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert CC: Chen-Yu Tsai , Yong Wu , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , Sumit Semwal , Brian Starkey , John Stultz , "T . J . Mercier" , =?UTF-8?q?Christian=20K=C3=B6nig?= , Matthias Brugger , , , , , , , Subject: [PATCH v3,16/21] media: medkatek: vcodec: support one plane capture buffer Date: Wed, 6 Dec 2023 16:15:33 +0800 Message-ID: <20231206081538.17056-17-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231206081538.17056-1-yunfei.dong@mediatek.com> References: <20231206081538.17056-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 00:17:15 -0800 (PST) The capture buffer has two planes for format MM21, but user space only allocate secure memory for plane[0], and the size is Y data + uv data. The driver need to support one plane decoder for svp mode. Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 7 ++++- .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 26 ++++++++++--------- .../decoder/vdec/vdec_h264_req_common.c | 11 +++----- .../mediatek/vcodec/decoder/vdec_drv_if.c | 4 +-- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c index 604fdc8ee3ce..ab922e8d2d37 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c @@ -653,7 +653,12 @@ static int vidioc_vdec_g_fmt(struct file *file, void *priv, * So we just return picinfo yet, and update picinfo in * stop_streaming hook function */ - q_data->sizeimage[0] = ctx->picinfo.fb_sz[0]; + + if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 1) + q_data->sizeimage[0] = ctx->picinfo.fb_sz[0] + ctx->picinfo.fb_sz[1]; + else + q_data->sizeimage[0] = ctx->picinfo.fb_sz[0]; + q_data->sizeimage[1] = ctx->picinfo.fb_sz[1]; q_data->bytesperline[0] = ctx->last_decoded_picinfo.buf_w; q_data->bytesperline[1] = ctx->last_decoded_picinfo.buf_w; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c index cc42c942eb8a..707ed57a412e 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c @@ -285,14 +285,14 @@ static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_dec_ctx *ctx) framebuf = container_of(vb2_v4l2, struct mtk_video_dec_buf, m2m_buf.vb); pfb = &framebuf->frame_buffer; - pfb->base_y.va = vb2_plane_vaddr(dst_buf, 0); + if (!ctx->is_secure_playback) + pfb->base_y.va = vb2_plane_vaddr(dst_buf, 0); pfb->base_y.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0); pfb->base_y.size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[0]; - if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2) { + if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2 && !ctx->is_secure_playback) { pfb->base_c.va = vb2_plane_vaddr(dst_buf, 1); - pfb->base_c.dma_addr = - vb2_dma_contig_plane_dma_addr(dst_buf, 1); + pfb->base_c.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 1); pfb->base_c.size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[1]; } mtk_v4l2_vdec_dbg(1, ctx, @@ -339,16 +339,18 @@ static void mtk_vdec_worker(struct work_struct *work) mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d, vb=%p", ctx->id, vb2_src->vb2_queue->type, vb2_src->index, vb2_src); - bs_src->va = vb2_plane_vaddr(vb2_src, 0); - bs_src->dma_addr = vb2_dma_contig_plane_dma_addr(vb2_src, 0); - bs_src->size = (size_t)vb2_src->planes[0].bytesused; - if (!bs_src->va) { - v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); - mtk_v4l2_vdec_err(ctx, "[%d] id=%d source buffer is NULL", ctx->id, - vb2_src->index); - return; + if (!ctx->is_secure_playback) { + bs_src->va = vb2_plane_vaddr(vb2_src, 0); + if (!bs_src->va) { + v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); + mtk_v4l2_vdec_err(ctx, "[%d] id=%d source buffer is NULL", ctx->id, + vb2_src->index); + return; + } } + bs_src->dma_addr = vb2_dma_contig_plane_dma_addr(vb2_src, 0); + bs_src->size = (size_t)vb2_src->planes[0].bytesused; mtk_v4l2_vdec_dbg(3, ctx, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p", ctx->id, bs_src->va, &bs_src->dma_addr, bs_src->size, vb2_src); /* Apply request controls. */ diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_common.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_common.c index 5ca20d75dc8e..2a57e689ec07 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_common.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_common.c @@ -79,15 +79,12 @@ void mtk_vdec_h264_fill_dpb_info(struct mtk_vcodec_dec_ctx *ctx, vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf); h264_dpb_info[index].field = vb2_v4l2->field; - h264_dpb_info[index].y_dma_addr = - vb2_dma_contig_plane_dma_addr(vb, 0); + h264_dpb_info[index].y_dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0); if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2) + h264_dpb_info[index].c_dma_addr = vb2_dma_contig_plane_dma_addr(vb, 1); + else if (!ctx->is_secure_playback) h264_dpb_info[index].c_dma_addr = - vb2_dma_contig_plane_dma_addr(vb, 1); - else - h264_dpb_info[index].c_dma_addr = - h264_dpb_info[index].y_dma_addr + - ctx->picinfo.fb_sz[0]; + h264_dpb_info[index].y_dma_addr + ctx->picinfo.fb_sz[0]; } } diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c index d0b459b1603f..fb3e4f75ed93 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c @@ -73,14 +73,14 @@ int vdec_if_decode(struct mtk_vcodec_dec_ctx *ctx, struct mtk_vcodec_mem *bs, { int ret = 0; - if (bs) { + if (bs && !ctx->is_secure_playback) { if ((bs->dma_addr & 63) != 0) { mtk_v4l2_vdec_err(ctx, "bs dma_addr should 64 byte align"); return -EINVAL; } } - if (fb) { + if (fb && !ctx->is_secure_playback) { if (((fb->base_y.dma_addr & 511) != 0) || ((fb->base_c.dma_addr & 511) != 0)) { mtk_v4l2_vdec_err(ctx, "frame buffer dma_addr should 512 byte align"); -- 2.18.0