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@xxxxxxxxxxxx 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 -- 2.18.0