Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp21499lql; Fri, 12 Apr 2024 02:15:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+F9PR5lhLXW+0Q046Uk9Zns7cUfZU4+T3iQfIX/1Mab29wb39XIDCLYsf8qcnr15efPhyHQbN6UpDSdWxNT5yVRDmCf/2scIWePK8ZA== X-Google-Smtp-Source: AGHT+IEtluzHOemN1aeQ6sK+g9zRVcl0WdpM+EwQsXlFQ1TQC82F7y2/IiFRF0Qg3jspLK4NTcXg X-Received: by 2002:a05:6a21:3e02:b0:1a3:52ef:cc84 with SMTP id bk2-20020a056a213e0200b001a352efcc84mr2105183pzc.60.1712913356162; Fri, 12 Apr 2024 02:15:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712913356; cv=pass; d=google.com; s=arc-20160816; b=zi8RW1YBkJmtnkiZmLQZM/AFWod7bmiDf5dcfb19a219OHnTzepNQ2AFrd2TX0Ucoe Dtekc3KKQupCryPhp2cWwGXvy3YA/hkQ8Nc3EbdE1AzDyGBptMQcl6b2BCPUgJksdKnh nSC+ZKXhKJScufakGmQzgjXHb56UIgOfifIKNwjEI1q1G+f4lciFoZ7dFcHTA6PdWxtQ 8LeOs099BAFUzSxBQNGLQ7v0+ztgkWtraR0lX4J9xZHFhXjG9qREFQhyFDuLdqou5S2f c10a30T7vVGHQk+nWewKCS4Nu6FcyoUtw0YPnTffnpDy1cialKj5TV3ehBnI1fwe4aH+ +IYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=T4pfNXBdeJu05PM6xLFCH744A/zaKT3Z10Xq4uN7ZJY=; fh=+3keNzaSOvsaq+BXFM2IqKmKMiZV6QsxTCb//k4Cpek=; b=YaEmtU8xLa8AxRjEhrAHB1KzPPOkof5LHfxOQqtrTe4dvLBGK7SY/ppWXJ8PiEVW92 C2TIZKo3x9WyuhV4Jvmv6j9Rd9YHm4DO6CHS0x99mU5CzonaxMcNH6pxDotSGHksHWZI tUXCY6WDijbtkq1o106Oxh81rg82e076pcJGHS6bno9zyWzOs3Qsx8xI0P3cTLeJ3Y/C 2XBUt4bnxuaSHnAkHazlRa93XrpY/2m3o2Q92uhlfQmB/x2L1rCfH9M5L4BprN4wF867 CZj8gy5E7fkwzUoCV70DPX5CxzJHuItSe5oQXVr+uNsDTDXyJc4mOTE5jSw92zGiB9dA 2sZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=WY5dZ2Ez; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-142357-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142357-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x15-20020a63fe4f000000b005f3ffb036c8si2844578pgj.104.2024.04.12.02.15.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 02:15:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142357-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=WY5dZ2Ez; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-142357-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142357-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7CE44281596 for ; Fri, 12 Apr 2024 09:13:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35FDD5B697; Fri, 12 Apr 2024 09:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="WY5dZ2Ez" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3026359B71; Fri, 12 Apr 2024 09:09:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712912967; cv=none; b=fIDLodVdFKMMIhV50znLfroaUmzNycnbIh+BqV0Uv8DbICqDxq2J1C4X6slUfCSNmlTmRvYaBcitTuRan6ZWMBUbjeJMWngwSY9aTpk0Cx9UVCzmv3+f3XP8drHxJh1GUiXOkQdm7kwS7x9m2g8gFyJb8WkaT0MGpYYGGEsDmmE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712912967; c=relaxed/simple; bh=YE/5P77Hl9OcxtWOZtCHKATesnaryzm90vD56CHtakE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bw9IoSz/gCPBD500G4DctvtDFPjxErU+/VthKFjcQTGfVq5NHR5rfe+1RoZyGTGyz58RDn6gtb9qrXL4/Z8mbqomW4KZ1a4QUslqlamgZYigJVLqSIjDYcgz+pFfiyuiySTdLP/u/+lWoB70g7ItZdB7b95s0m4AGo1sOqxfKMs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=WY5dZ2Ez; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 58db21b0f8ac11eeb8927bc1f75efef4-20240412 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=T4pfNXBdeJu05PM6xLFCH744A/zaKT3Z10Xq4uN7ZJY=; b=WY5dZ2EzLhXnNg6iiSPp4u5EuDj6QUZZ2Zqa/o714CxjHuqlXdkr359pgNHLaKO6Pe2LTgzbMy64smOxXYipYO3d1t2xuueSlaV19kSOCXLA5ff3WT4KJjxZO1C0olPEI6KRz6uL3lHz7tsc0U2oySoNzJdU6zF6+BwFi796yKo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:9c1a4104-64fe-4b90-9190-8466db41d976,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:6f543d0,CLOUDID:45e5d5fa-ed05-4274-9204-014369d201e8,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,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 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 58db21b0f8ac11eeb8927bc1f75efef4-20240412 Received: from mtkmbs09n2.mediatek.inc [(172.21.101.94)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 841535157; Fri, 12 Apr 2024 17:09:20 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N2.mediatek.inc (172.21.101.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 12 Apr 2024 17:09:18 +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; Fri, 12 Apr 2024 17:09:17 +0800 From: Yunfei Dong To: Jeffrey Kardatzke , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Nathan Hebert , "Nicolas Dufresne" , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Sebastian Fricke , Tomasz Figa , "Mauro Carvalho Chehab" , Marek Szyprowski 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 v5,16/23] media: mediatek: vcodec: support one plane capture buffer Date: Fri, 12 Apr 2024 17:08:44 +0800 Message-ID: <20240412090851.24999-17-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240412090851.24999-1-yunfei.dong@mediatek.com> References: <20240412090851.24999-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--8.238200-8.000000 X-TMASE-MatchedRID: IdwiQWGfGmyON+GapO42vQI0yP/uoH+Dh+w9Wz/xXDr7efdnqtsaE5kC erFMaabilTJXKqh1ne29cOdjc/43lUMpVZZsZyZGHPYwOJi6PLmBHKTJ+sfXGfNhzIgXtFJVJkA T6PZqtWG0gVrq9RizuWF6wLzbAtAr7U4NkBX42MYQ9/tMNQ4aiuWNJG9IamrcGM7yl/HgfuBLbT Uf+O4SvG0xs/kJ5jkfbhGQTDKMjW9sQJ9Z3jpPTZ4CIKY/Hg3AGdQnQSTrKGPEQdG7H66TyMdRT 5TQAJnAtIVAr8bWpo6qbS1Co4fFlcG4KqvREx4WrqlPoKKlLlieqD9WtJkSIw== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.238200-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: D4484D3B5B841A5022055B3603681AB3B2118773658F37CA414028B92E599E1F2000:8 X-MTK: N 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 | 18 ++++++------- .../mediatek/vcodec/decoder/vdec_drv_if.c | 4 +-- 4 files changed, 31 insertions(+), 24 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 192b01ff3ede..ebe21064616c 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 || ctx->is_secure_playback) + 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 fbea00517565..a1a99878f2c6 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..5e0d55218363 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,15 @@ 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); - 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 - 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 = vb2_dma_contig_plane_dma_addr(vb, 0); + if (!ctx->is_secure_playback) { + 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 + h264_dpb_info[index].c_dma_addr = + 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