Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2069989rdf; Mon, 6 Nov 2023 04:05:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQuq9Z+uwbpUr0xLSVs2YoiSl+F4TR+sXmUVabqW7tz7aVClqTrRU/DHC6IvIK8p7QIm5C X-Received: by 2002:a05:6a21:789c:b0:13a:59b1:c884 with SMTP id bf28-20020a056a21789c00b0013a59b1c884mr36890438pzc.40.1699272344120; Mon, 06 Nov 2023 04:05:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699272344; cv=none; d=google.com; s=arc-20160816; b=zwjsKWtluBf9m/6WlkNbzzBB7w8ceNROD7hrqdUk7U4XD8p2eZ5EvXGkd1KDYWh9Ml BSMldjGQGLoAaCqxNYLcbwOPZAP7OMd6lTd+zkJ8vkgXMf7NAhxfUadm4IsgxKg2Ke46 6At4/ONO9MYCnPIkqN6CDQqvlaVKhksthPOToNP/OhuYnLmsAFnTIIju87RQtOFrqI0H HtBiaR8lMpQ3jW6ulyuDFYMb/HxMoAG8G1pyzWc4G15SvBGzBilUzOwFSfqR67PgmR8f Q10DZwgNVXxTeCqISac8WPf680dj9/ChQOaN7FH0D7QRMEFQQp+PZw6I9S+2VqWTsJGe 6OLQ== 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=tVaVgcWmYIHj2pHGluQbn0rpuoRR+zljiuHJ/MBOFCw=; fh=HMoU6Z0fAVEi/36PnBTb4UQLM/fqzPQmIZjxf5hFbO0=; b=E7JNu141kyLF9+WA9kZFo+l6ux8PNXhxP3ZxLf4W4c16MigfxpAS2Har1XeCGx4rWm gxra7SLVVCt3QUt1V0yMi7Kq99Os2gu6cRDxEjUep9FwG35ElN2w5c/XNznP89JlA3bg e2UDJjmhQFfmVSAZGvmAVWwpMeGvbSLCZ06zuLsb7RudMgb8dMOFcmtlfA2tMipZTts6 ol8s25HRfCk56SlXxDWca2JeXTfuOFLSjJCr1Q60jLtYPT3KOBt8h8wbsOa5vd179lQc YbRRze+lPgkO+xD2PySURXNkDA280HPTrSXbsB5xxZWYQ2rmCBgdBIXOfVP6h3UdWI+/ /ucQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=M8f6eEkb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q20-20020a056a00151400b006bde4f430afsi8051611pfu.70.2023.11.06.04.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 04:05:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=M8f6eEkb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 EC546802A6D8; Mon, 6 Nov 2023 04:05:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbjKFMFT (ORCPT + 99 others); Mon, 6 Nov 2023 07:05:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbjKFMEq (ORCPT ); Mon, 6 Nov 2023 07:04:46 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11B78191; Mon, 6 Nov 2023 04:04:42 -0800 (PST) X-UUID: a8a239ae7c9c11eea33bb35ae8d461a2-20231106 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=tVaVgcWmYIHj2pHGluQbn0rpuoRR+zljiuHJ/MBOFCw=; b=M8f6eEkb1DUhNWjtAOWZ4rzmkDTVkoVhrf6DYKfxigsHYdut7aIyoK51OvPV5f3bHPbMwOXnPODKz/Rqo21PwWXX5GSe1R7Ce/k6BG2rGfrx4wzr8DMW6hyrmGJ3N543+vGzfhfFl3YUrVXsa5rja+kDBwNf5ZFaBKrhr7Yw3Jw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:fbff8b09-b2f0-4bb9-9d79-0715c243ad80,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:364b77b,CLOUDID:49e51195-10ce-4e4b-85c2-c9b5229ff92b,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,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: a8a239ae7c9c11eea33bb35ae8d461a2-20231106 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1955877027; Mon, 06 Nov 2023 20:04:38 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) 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; Mon, 6 Nov 2023 20:04:37 +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; Mon, 6 Nov 2023 20:04:36 +0800 From: Yunfei Dong To: Jeffrey Kardatzke , "T . J . Mercier" , John Stultz , Yong Wu , =?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 , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , "Steve Cho" , Yunfei Dong , , , , , , Subject: [PATCH v2,11/21] media: mediatek: vcodec: initialize msg and vsi information Date: Mon, 6 Nov 2023 20:04:13 +0800 Message-ID: <20231106120423.23364-12-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231106120423.23364-1-yunfei.dong@mediatek.com> References: <20231106120423.23364-1-yunfei.dong@mediatek.com> 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.774500-8.000000 X-TMASE-MatchedRID: VIoFwzWR3P4iRWw1gHaWSxuZoNKc6pl+MJlSCRpjLV32MjGUf5GHsWb6 PphVtfZgVkkQSrH2rvhtS1CTbpfjUP/Js/ghYmSK7spMO3HwKCARWG8HyxfLI7lmMfLNiukaG/k B0flY/cWGe+0MUSZloS2Rxuw/iP4W2HzzjwqZ3wJPuMJi/ZAk8V3HHpZF/7mw/RM/+SKR6qe25B ylI3cMJL1QsHlkpLKtihP7kE5hi1yxP8oxx7elnqngbqTYC4GHfS0Ip2eEHnz3IzXlXlpamPoLR 4+zsDTtJLIWFE2XGROOsz0bfyUKqPA/0LVjLQbAtIKt2xWbYd4XLAtmd93HrVZca9RSYo/b X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.774500-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 5DDA425E4D4C3F6E5CB842B0964AD12BAB325EF28E55F76735815215484D039F2000:8 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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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]); Mon, 06 Nov 2023 04:05:35 -0800 (PST) Need to initialize msg and vsi information before sending to optee-os, then calling optee invoke command to send the information to optee-os. For the optee communication interface is different with scp, using flag to separate them. Signed-off-by: Yunfei Dong --- .../vcodec/decoder/mtk_vcodec_dec_drv.h | 2 + .../mediatek/vcodec/decoder/vdec_vpu_if.c | 49 ++++++++++++++++--- .../mediatek/vcodec/decoder/vdec_vpu_if.h | 4 ++ 3 files changed, 49 insertions(+), 6 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 7a320d1e37e8..ce05e403553e 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 @@ -165,6 +165,7 @@ struct mtk_vcodec_dec_pdata { * @vpu_inst: vpu instance pointer. * * @is_10bit_bitstream: set to true if it's 10bit bitstream + * @is_secure_playback: Secure Video Playback (SVP) mode */ struct mtk_vcodec_dec_ctx { enum mtk_instance_type type; @@ -210,6 +211,7 @@ struct mtk_vcodec_dec_ctx { void *vpu_inst; bool is_10bit_bitstream; + bool is_secure_playback; }; /** diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c index 82e57ae983d5..5336769a3fb5 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c @@ -148,7 +148,10 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv) static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len) { - int err, id, msgid; + struct mtk_vdec_optee_data_to_shm *optee_data; + int data_size, id, hw_id, msgid; + void *ack_msg, *data_msg; + int err; msgid = *(uint32_t *)msg; mtk_vdec_debug(vpu->ctx, "id=%X", msgid); @@ -158,16 +161,46 @@ static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len) if (vpu->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_LAT_SINGLE_CORE) { if (msgid == AP_IPIMSG_DEC_CORE || - msgid == AP_IPIMSG_DEC_CORE_END) + msgid == AP_IPIMSG_DEC_CORE_END) { + optee_data = &vpu->core_optee_info; id = vpu->core_id; - else + } else { + optee_data = &vpu->lat_optee_info; id = vpu->id; + } } else { + optee_data = &vpu->lat_optee_info; id = vpu->id; } - err = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, id, msg, - len, 2000); + if (!vpu->ctx->is_secure_playback) { + err = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, id, msg, len, 2000); + } else { + hw_id = (id == SCP_IPI_VDEC_LAT) ? MTK_VDEC_LAT0 : MTK_VDEC_CORE; + + mtk_vcodec_dec_optee_set_data(optee_data, msg, len, OPTEE_MSG_INDEX); + + /* There is no need to copy the data (VSI) message to shared memory, + * but we still need to set the buffer size to a non-zero value. + */ + if (msgid == AP_IPIMSG_DEC_CORE || msgid == AP_IPIMSG_DEC_START) { + data_msg = mtk_vcodec_dec_get_shm_buffer_va(vpu->ctx->dev->optee_private, + hw_id, OPTEE_DATA_INDEX); + data_size = mtk_vcodec_dec_get_shm_buffer_size(vpu->ctx->dev->optee_private, + hw_id, OPTEE_DATA_INDEX); + mtk_vcodec_dec_optee_set_data(optee_data, data_msg, data_size, + OPTEE_DATA_INDEX); + } + + err = mtk_vcodec_dec_optee_invokd_cmd(vpu->ctx->dev->optee_private, + hw_id, optee_data); + vpu->failure = err; + + ack_msg = mtk_vcodec_dec_get_shm_buffer_va(vpu->ctx->dev->optee_private, hw_id, + OPTEE_MSG_INDEX); + vpu_dec_ipi_handler(ack_msg, 0, vpu->ctx->dev); + } + if (err) { mtk_vdec_err(vpu->ctx, "send fail vpu_id=%d msg_id=%X status=%d", id, msgid, err); @@ -213,7 +246,11 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu) return err; } - if (vpu->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_LAT_SINGLE_CORE) { + /* Using tee interface to communicate with optee os directly for SVP mode, + * fw ipi interface is used for normal playback. + */ + if (vpu->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_LAT_SINGLE_CORE && + !vpu->ctx->is_secure_playback) { err = mtk_vcodec_fw_ipi_register(vpu->ctx->dev->fw_handler, vpu->core_id, vpu->handler, "vdec", vpu->ctx->dev); diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h index fbb3f34a73f0..946e5abcc7d3 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h @@ -28,6 +28,8 @@ struct mtk_vcodec_dec_ctx; * @codec_type : use codec type to separate different codecs * @capture_type: used capture type to separate different capture format * @fb_sz : frame buffer size of each plane + * @lat_optee_info : used to send msg to optee shm buffer + * @core_optee_info : used to send msg to optee shm buffer */ struct vdec_vpu_inst { int id; @@ -44,6 +46,8 @@ struct vdec_vpu_inst { unsigned int codec_type; unsigned int capture_type; unsigned int fb_sz[2]; + struct mtk_vdec_optee_data_to_shm lat_optee_info; + struct mtk_vdec_optee_data_to_shm core_optee_info; }; /** -- 2.18.0