Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp248843lqo; Thu, 16 May 2024 05:28:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFsgrG7UgASZ56ZK5HmR/GbzRXRoAFa0Tcjx4m0UuHBPdPhbcw0MvZ7Ww7K9e0r3lSvhdsO0OZji3gBpqfgz7ZbAGGJ7K6PbqHQc01Fw== X-Google-Smtp-Source: AGHT+IFm/ehCghNNJP4wVjdz+mZ9qOQ9ULcKS+lSkUSkHdvtmbD+nGfS5hz0Nnu3THuRmHtwfzWw X-Received: by 2002:a05:6870:944f:b0:23f:ba54:5f41 with SMTP id 586e51a60fabf-24172a3f4d5mr22147530fac.1.1715862511892; Thu, 16 May 2024 05:28:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715862511; cv=pass; d=google.com; s=arc-20160816; b=IuAXpg71TMtgD19aAsuULL0Yu7OsAbMa9IxM0JezjlnFH3Ogs5qzjAE5vq8xSh7Ozx zZK2TA8ZBO7W6W1xh8TkjJCA3bmzJ6b+ip4RU2+GvPHJ6uy21CmlQJP3bhee4gY8bZ/G ARZK9pM0F4B/nFOkzwCnidVxVQw67Pi/+1Fd35Z1ykV0lRwE3BoMpBfMsUHRL9Y737Og GfSR5God9Hhw/ResFTuE/+WIUNNLm8IwfjqecM1VItCxug3dT8L6gJk3Gu7ppYrBMxW3 wNI6ZpEMRV1noy51aeZEMuBcmTByqt3SCOSUTour6pXA0rLskacQw9COEjM30TiiwUYU s0vQ== 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=UQkYraUh+VR3KSqY1bOqPlw2ThOBwrkSGU/3tYE6QxM=; fh=+3keNzaSOvsaq+BXFM2IqKmKMiZV6QsxTCb//k4Cpek=; b=imPTF0753AKCYdpNBVEFdOw1QwksFi9oC6dtEj//FT8J5QLWro02efzB6sIpJS5V6O ufOG/ndAaEFP429WpcZ3LkkLX/y/fHll0bODeQN5HZ+7IJU+btiKc4SebQzjhM2qlX2Z m9Og+QsAxrL/K77IiA53/ere4DH0gMlexfdxP7TJZe1iTIx6lvi09xX2+zy22AX4BgNs Xk+K8PmB9+kTcpguB4WMOq6j4S6xuAwRxbycfUmsjYJBoShofOy9vtLAoOAYAuTlr17m m4U8+aBf23oZn6TVhI1gm3nLBIlciYvp5MZuiT8TSsuS6n16tY3eAI1lmsD12q3YbMLJ JKkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="mFrZt/HD"; 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-181017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181017-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-65a1da593desi1232477a12.792.2024.05.16.05.28.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 05:28:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="mFrZt/HD"; 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-181017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181017-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 8C9F02814CE for ; Thu, 16 May 2024 12:27:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63385155381; Thu, 16 May 2024 12:21:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="mFrZt/HD" 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 23413154BFF; Thu, 16 May 2024 12:21:46 +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=1715862109; cv=none; b=RlmHaHooPWeHf8U3yrhV8RvCMLVMz5wVq5aeD6twXNhh4rVLtJVbZv3/1ET6dtySf06e9xMp4ppgRLRO28Mp72ZeazIQxTUi1Ol9NF/uEPUSdNZJq4AQlRj/6ZfvN5H4/Upj+eWPzekdcVSJ6yVOHn8cNrD+ZwyS4hiORsdYoas= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715862109; c=relaxed/simple; bh=2bGodGnGf5asJwDEHGcEkg4YL3orUzf3kbzsd7+Vt28=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MPHfyxnxwKe59kDGponL29whSAOfQ6tZGj9Y6F8j7u34Idwv+de30Ca3tUtW22wwiYZ6Fg23YPClVH6qoJDpMWiEnuY71dIQXxaWAMh2vb2OjYpI2D2RLzFoZzdezD75FU3eKzOFVpFRvaVMUT/JwNzC/CnkBKmfzV5P4qnxSlk= 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=mFrZt/HD; 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: db3a2aec137e11efb92737409a0e9459-20240516 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=UQkYraUh+VR3KSqY1bOqPlw2ThOBwrkSGU/3tYE6QxM=; b=mFrZt/HDef9ZO8WWI1sMjwtcHcsF9i5n56JIGarJggvlAyGtzio520AZvsC69MVONY8vlPM77GRPke/8WnzZ67OdL/tihIAgRc40EMB2IpUJba3CtcmTWCNZj+E0WBWPwInHofHm4pMkzs355/Y6oYDXv00Ii9FzRlds8os3PaU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:b2c4a958-934b-46c2-93e7-4a170d39a088,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:82c5f88,CLOUDID:63547087-8d4f-477b-89d2-1e3bdbef96d1,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 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: db3a2aec137e11efb92737409a0e9459-20240516 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 392386969; Thu, 16 May 2024 20:21:43 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 16 May 2024 20:21:42 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 16 May 2024 20:21:40 +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 v6,24/24] media: mediatek: vcodec: support vp9 svp decoder for mt8188 Date: Thu, 16 May 2024 20:21:02 +0800 Message-ID: <20240516122102.16379-25-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240516122102.16379-1-yunfei.dong@mediatek.com> References: <20240516122102.16379-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--7.657800-8.000000 X-TMASE-MatchedRID: HoXpZE+zCqGvVT6bfkFW/gI0yP/uoH+DHgnyJJNAX/iHlDUCu0I+XO2V VVLUIzQwF8NKa4AxCmAQpIoQW/1YOanYP7KwFAZ5cxGQfOZHrIeb/LTS0T1K1gqiCYa6w8tvQ09 1A4TyNprg7PmXyAh8kTPJqcmWDFTSh9pkVp8w2GGzI1v7J4hECryfV74eQpk+JLfQYoCQHFYeLm tuLpfaHVC328Q62M/LPgtqcrmKGX5AJLhqw2sfjQKDWtq/hHcNfS0Ip2eEHnz3IzXlXlpamPoLR 4+zsDTtgUicvJ4MChlmkKAb78lpPCgFRdomK13NCZOaCXkIOrbiTN07XYlCmWEoVHihj+TK X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.657800-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: F4626B6E365A9173E1C350264DEA213655DFD8901F0433337935FCF6B5C850862000:8 X-MTK: N From: Yilong Zhou Change vp9 driver to support secure video playback(svp) for mt8188. Need to map shared memory with optee interface and wait interrupt in optee-os. Signed-off-by: Yilong Zhou Signed-off-by: Yunfei Dong --- .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 91 ++++++++++++------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c index cf48d09b78d7..9f64661800af 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c @@ -141,6 +141,7 @@ struct vdec_vp9_slice_frame_counts { * @skip: skip counts. * @y_mode: Y prediction mode counts. * @filter: interpolation filter counts. + * @mv_joint: motion vector joint counts. * @sign: motion vector sign counts. * @classes: motion vector class counts. * @class0: motion vector class0 bit counts. @@ -804,6 +805,9 @@ static void vdec_vp9_slice_setup_frame_ctx(struct vdec_vp9_slice_instance *insta error_resilient_mode = HDR_FLAG(ERROR_RESILIENT); reset_frame_context = uh->reset_frame_context; + if (instance->ctx->is_secure_playback) + return; + /* * according to "6.2 Uncompressed header syntax" in * "VP9 Bitstream & Decoding Process Specification", @@ -818,8 +822,7 @@ static void vdec_vp9_slice_setup_frame_ctx(struct vdec_vp9_slice_instance *insta * 2 resets just the context specified in the frame header * 3 resets all contexts */ - if (key_frame || error_resilient_mode || - reset_frame_context == 3) { + if (key_frame || error_resilient_mode || reset_frame_context == 3) { /* use default table */ for (i = 0; i < 4; i++) instance->dirty[i] = 0; @@ -1042,6 +1045,9 @@ static void vdec_vp9_slice_setup_seg_buffer(struct vdec_vp9_slice_instance *inst { struct vdec_vp9_slice_uncompressed_header *uh; + if (instance->ctx->is_secure_playback) + return; + /* reset segment buffer */ uh = &vsi->frame.uh; if (uh->frame_type == 0 || @@ -1172,15 +1178,16 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance, vdec_vp9_slice_setup_seg_buffer(instance, vsi, &instance->seg[0]); - /* setup prob/tile buffers for LAT */ - - ret = vdec_vp9_slice_setup_prob_buffer(instance, vsi); - if (ret) - goto err; + if (!instance->ctx->is_secure_playback) { + /* setup prob/tile buffers for LAT */ + ret = vdec_vp9_slice_setup_prob_buffer(instance, vsi); + if (ret) + goto err; - ret = vdec_vp9_slice_setup_tile_buffer(instance, vsi, bs); - if (ret) - goto err; + ret = vdec_vp9_slice_setup_tile_buffer(instance, vsi, bs); + if (ret) + goto err; + } return 0; @@ -1599,7 +1606,8 @@ static int vdec_vp9_slice_update_single(struct vdec_vp9_slice_instance *instance pfc->seq, vsi->state.crc[4], vsi->state.crc[5], vsi->state.crc[6], vsi->state.crc[7]); - vdec_vp9_slice_update_prob(instance, vsi); + if (!instance->ctx->is_secure_playback) + vdec_vp9_slice_update_prob(instance, vsi); instance->width = vsi->frame.uh.frame_width; instance->height = vsi->frame.uh.frame_height; @@ -1632,7 +1640,8 @@ static int vdec_vp9_slice_update_lat(struct vdec_vp9_slice_instance *instance, return -EAGAIN; } - vdec_vp9_slice_update_prob(instance, vsi); + if (!instance->ctx->is_secure_playback) + vdec_vp9_slice_update_prob(instance, vsi); instance->width = vsi->frame.uh.frame_width; instance->height = vsi->frame.uh.frame_height; @@ -1694,8 +1703,13 @@ static int vdec_vp9_slice_setup_core_buffer(struct vdec_vp9_slice_instance *inst return -EINVAL; /* update internal buffer's width/height */ - instance->dpb[vb->index].width = w; - instance->dpb[vb->index].height = h; + for (i = 0; i < vq->num_buffers; i++) { + if (vb == vq->bufs[i]) { + instance->dpb[i].width = w; + instance->dpb[i].height = h; + break; + } + } /* * get buffer's width/height from instance @@ -1779,7 +1793,8 @@ static int vdec_vp9_slice_setup_core(struct vdec_vp9_slice_instance *instance, if (ret) goto err; - vdec_vp9_slice_setup_seg_buffer(instance, vsi, &instance->seg[1]); + if (!instance->ctx->is_secure_playback) + vdec_vp9_slice_setup_seg_buffer(instance, vsi, &instance->seg[1]); return 0; @@ -1874,19 +1889,31 @@ static int vdec_vp9_slice_init(struct mtk_vcodec_dec_ctx *ctx) goto error_vsi; } instance->init_vsi = vsi; - instance->core_vsi = mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, - (u32)vsi->core_vsi); - if (!instance->core_vsi) { - mtk_vdec_err(ctx, "failed to get VP9 core vsi\n"); - ret = -EINVAL; - goto error_vsi; - } - instance->irq = 1; + if (ctx->is_secure_playback) { + instance->core_vsi = + mtk_vcodec_dec_get_shm_buffer_va(ctx->dev->optee_private, MTK_VDEC_CORE, + OPTEE_DATA_INDEX); + if (!instance->core_vsi) { + mtk_vdec_err(ctx, "failed to get VP9 svp core vsi\n"); + ret = -EINVAL; + goto error_vsi; + } + instance->irq = 0; + } else { + instance->core_vsi = mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, + (u32)vsi->core_vsi); + if (!instance->core_vsi) { + mtk_vdec_err(ctx, "failed to get VP9 normal core vsi\n"); + ret = -EINVAL; + goto error_vsi; + } + instance->irq = 1; - ret = vdec_vp9_slice_init_default_frame_ctx(instance); - if (ret) - goto error_default_frame_ctx; + ret = vdec_vp9_slice_init_default_frame_ctx(instance); + if (ret) + goto error_default_frame_ctx; + } ctx->drv_handle = instance; @@ -2101,9 +2128,12 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, (unsigned long)pfc->vsi.trans.dma_addr, (unsigned long)pfc->vsi.trans.dma_addr_end); - vdec_msg_queue_update_ube_wptr(&ctx->msg_queue, - vsi->trans.dma_addr_end + - ctx->msg_queue.wdma_addr.dma_addr); + if (!instance->ctx->is_secure_playback) { + vsi->trans.dma_addr_end += ctx->msg_queue.wdma_addr.dma_addr; + mtk_vdec_debug(ctx, "core dma_addr_end 0x%lx\n", + (unsigned long)pfc->vsi.trans.dma_addr_end); + } + vdec_msg_queue_update_ube_wptr(&ctx->msg_queue, vsi->trans.dma_addr_end); vdec_msg_queue_qbuf(&ctx->msg_queue.core_ctx, lat_buf); return 0; @@ -2183,9 +2213,6 @@ static int vdec_vp9_slice_core_decode(struct vdec_lat_buf *lat_buf) goto err; } - pfc->vsi.trans.dma_addr_end += ctx->msg_queue.wdma_addr.dma_addr; - mtk_vdec_debug(ctx, "core dma_addr_end 0x%lx\n", - (unsigned long)pfc->vsi.trans.dma_addr_end); vdec_msg_queue_update_ube_rptr(&ctx->msg_queue, pfc->vsi.trans.dma_addr_end); ctx->dev->vdec_pdata->cap_to_disp(ctx, 0, lat_buf->src_buf_req); -- 2.25.1