From patchwork Mon Sep 11 12:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13379303 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 EA540EEB57D for ; Mon, 11 Sep 2023 13:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=IfYknDeWGTSOqdm+3rBs4Bnlhv7+GxTppJqf/hRMcTw=; b=xzoMx2sY9XX64b r5ko4w0xJAmzqEiErGTmNU/GwKZwbjUYx4BFoWhDFtF2TbPIFb0y2EgvdU8kRmgO4XOkzVv3Yv6DQ CHarKgj8ZhaT9/b2z0FpHwU6o3e+de3b/F21vF/dV748OadL4vZ1T/42L/9zdifUhurnGUyeX73i7 /UorV4sV6DI0eQcbWs7Pc/28Y3dHBKWWKH4nAxj4UO3wEfTWvposdRoquACM3sOoPJBT1BfVsTH8Q FdF4Rkik+aH6ZKhqeqf/oc2vUdS1AO/YXcp3u8wZx6zVyYjqZFcMq0iinkQ+r4dHgqEwqVf8xP8Tt SDILi9zRVa0DTD5yPZ8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfgWY-000XqJ-0L; Mon, 11 Sep 2023 13:00:18 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfgWV-000Xp3-0d; Mon, 11 Sep 2023 13:00:16 +0000 X-UUID: 251ec7b650a311ee86758d4a7c00f3a0-20230911 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:Message-ID:Date:Subject:CC:To:From; bh=h5MlQeYSjp2j/LB9w519bAWy3e+QI9O2SLovvv9dKIs=; b=AbWCZ/B+EqhLS09j9YpCnGhj0+pTRo97qKwvdELJzy3d6N0DqxCc5EpwSjJDERwQy3idDh6CwwilG2/SpRozIKYM8kMFjSVgqpXzruB/47TxmFV1oOrXT6ddtp5NA8lNoQEe0UJrwFAGDxKLqGmVkP+x2bslxf2OB2KSji5zLVw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:85cf14e8-7447-4606-b0b0-50ff546ff34d,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:0ad78a4,CLOUDID:ea3fce13-4929-4845-9571-38c601e9c3c9,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,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 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 251ec7b650a311ee86758d4a7c00f3a0-20230911 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1029850961; Mon, 11 Sep 2023 06:00:12 -0700 Received: from mtkmbs13n2.mediatek.inc (172.21.101.194) 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, 11 Sep 2023 20:59:38 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 11 Sep 2023 20:59:37 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert CC: Chen-Yu Tsai , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , "Steve Cho" , Yunfei Dong , , , , , , Subject: [PATCH 00/14] add driver to support secure video decoder Date: Mon, 11 Sep 2023 20:59:22 +0800 Message-ID: <20230911125936.10648-1-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 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.569700-8.000000 X-TMASE-MatchedRID: /kvX+BAyhRdLbaTfilVXfZqrexa4CbEQUAjrAJWsTe8KA2OoGAlTk54d VMHTNaMULOOktaHND2iW4kxGbzOebKo77AcuQhw7o65WJt1k1O9YMtqMzbYRNmfYlY6RxyOvXA6 qLXqEbYuwDEIJD1Y7K9r7qQBGAlkIi8ICQO6ibxQVglQa/gMvfDFcf92WG8u/EvoxTu3fj1s3Bo tHDlVWrHZmxDzqJ8rQkgebTBpa5lDwOTPseUY5HB+WEMjoO9WWfS0Ip2eEHnz3IzXlXlpamPoLR 4+zsDTtgUicvJ4MChmMp7Dr14nIYnrpZk2SoHtre7MWlND3CeQUtK2l9hQpvBM3tVf09E8l X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.569700-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: B9A27BB1E74839D8447AA282BB12001D619C9E13CF4D50EEB8FA142406C08CEE2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_060015_249332_C6F79EE7 X-CRM114-Status: GOOD ( 12.96 ) 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 In order to support secure video decoder for mt8195/mt8188 h264 driver, need to use tee client interface to communicate with optee-os. Firstly, open tee context and tee session for each hardware. Secondly, allocate two shared memory msg and vsi, msg used to send ipi to optee-os and get ack msg from optee-os, vsi used to store syntax for hardware decoder. Thirdly, adding two CID controls: V4L2_CID_MPEG_MTK_SET_SECURE_MODE and V4L2_CID_MPEG_MTK_GET_SECURE_HANDLE, get secure handle used for user space to convert secure fd to secure handle, set secure mode used to tell decoder driver to initialize tee interface to decode secure video. Lastly, re-construct h264 driver to support secure video decoder. Patch 1~4 initialize tee related interface and parameters. Patch 5~6 allocate/free secure memory. Patch 7 map vsi for secure mode. Patch 8 support one plane capture buffer. Patch 9~10 re-construct h264 driver to support secure mode. patch 11 used to convert secure fd to secure handle. Patch 12 used to set secure decoder mode. Patch 13 disable interrupt. Patch 14 support tee decode --- Reference series: [1]: v1 of this series is submitted by Yong Wu. message-id: 20230911023038.30649-1-yong.wu@mediatek.com Yunfei Dong (14): media: mediatek: vcodec: add tee client interface to communiate with optee-os media: mediatek: vcodec: allocate tee share memory media: mediatek: vcodec: send share memory data to optee media: mediatek: vcodec: initialize msg and vsi information media: mediatek: vcodec: using encoder's device to alloc/free memory media: mediatek: vcodec: add interface to allocate/free secure memory media: mediatek: vcodec: using shared memory as vsi address media: medkatek: vcodec: support one plane capture buffer media: medkatek: vcodec: re-construct h264 driver to support svp mode media: medkatek: vcodec: remove parse nal_info in kernel media: medkatek: vcodec: covert secure fd to secure handle media: medkatek: vcodec: set secure mode to decoder driver media: medkatek: vcodec: disable wait interrupt for svp mode media: medkatek: vcodec: support tee decoder .../media/platform/mediatek/vcodec/Kconfig | 1 + .../mediatek/vcodec/common/mtk_vcodec_util.c | 177 ++++++++- .../mediatek/vcodec/common/mtk_vcodec_util.h | 3 + .../platform/mediatek/vcodec/decoder/Makefile | 1 + .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 24 +- .../vcodec/decoder/mtk_vcodec_dec_drv.c | 9 + .../vcodec/decoder/mtk_vcodec_dec_drv.h | 7 + .../vcodec/decoder/mtk_vcodec_dec_hw.c | 34 +- .../vcodec/decoder/mtk_vcodec_dec_optee.c | 373 ++++++++++++++++++ .../vcodec/decoder/mtk_vcodec_dec_optee.h | 156 ++++++++ .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 80 +++- .../decoder/vdec/vdec_h264_req_common.c | 16 +- .../decoder/vdec/vdec_h264_req_multi_if.c | 334 +++++++++------- .../mediatek/vcodec/decoder/vdec_drv_if.c | 4 +- .../mediatek/vcodec/decoder/vdec_msg_queue.c | 9 +- .../mediatek/vcodec/decoder/vdec_vpu_if.c | 54 ++- .../mediatek/vcodec/decoder/vdec_vpu_if.h | 4 + drivers/media/v4l2-core/v4l2-ctrls-defs.c | 10 + include/uapi/linux/v4l2-controls.h | 5 + 19 files changed, 1110 insertions(+), 191 deletions(-) create mode 100644 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_optee.c create mode 100644 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_optee.h