1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2016 MediaTek Inc. 4 * Author: PC Chen <pc.chen@mediatek.com> 5 */ 6 7 #ifndef _VDEC_VPU_IF_H_ 8 #define _VDEC_VPU_IF_H_ 9 10 struct mtk_vcodec_dec_ctx; 11 12 /** 13 * struct vdec_vpu_inst - VPU instance for video codec 14 * @id : ipi msg id for each decoder 15 * @core_id : core id used to separate different hardware 16 * @vsi : driver structure allocated by VPU side and shared to AP side 17 * for control and info share 18 * @failure : VPU execution result status, 0: success, others: fail 19 * @inst_addr : VPU decoder instance address 20 * @fw_abi_version : ABI version of the firmware. 21 * @inst_id : if fw_abi_version >= 2, contains the instance ID to be given 22 * in place of inst_addr in messages. 23 * @signaled : 1 - Host has received ack message from VPU, 0 - not received 24 * @ctx : context for v4l2 layer integration 25 * @wq : wait queue to wait VPU message ack 26 * @handler : ipi handler for each decoder 27 * @codec_type : use codec type to separate different codecs 28 * @capture_type: used capture type to separate different capture format 29 * @fb_sz : frame buffer size of each plane 30 */ 31 struct vdec_vpu_inst { 32 int id; 33 int core_id; 34 void *vsi; 35 int32_t failure; 36 uint32_t inst_addr; 37 uint32_t fw_abi_version; 38 uint32_t inst_id; 39 unsigned int signaled; 40 struct mtk_vcodec_dec_ctx *ctx; 41 wait_queue_head_t wq; 42 mtk_vcodec_ipi_handler handler; 43 unsigned int codec_type; 44 unsigned int capture_type; 45 unsigned int fb_sz[2]; 46 }; 47 48 /** 49 * vpu_dec_init - init decoder instance and allocate required resource in VPU. 50 * 51 * @vpu: instance for vdec_vpu_inst 52 */ 53 int vpu_dec_init(struct vdec_vpu_inst *vpu); 54 55 /** 56 * vpu_dec_start - start decoding, basically the function will be invoked once 57 * every frame. 58 * 59 * @vpu : instance for vdec_vpu_inst 60 * @data: meta data to pass bitstream info to VPU decoder 61 * @len : meta data length 62 */ 63 int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len); 64 65 /** 66 * vpu_dec_end - end decoding, basically the function will be invoked once 67 * when HW decoding done interrupt received successfully. The 68 * decoder in VPU will continue to do reference frame management 69 * and check if there is a new decoded frame available to display. 70 * 71 * @vpu : instance for vdec_vpu_inst 72 */ 73 int vpu_dec_end(struct vdec_vpu_inst *vpu); 74 75 /** 76 * vpu_dec_deinit - deinit decoder instance and resource freed in VPU. 77 * 78 * @vpu: instance for vdec_vpu_inst 79 */ 80 int vpu_dec_deinit(struct vdec_vpu_inst *vpu); 81 82 /** 83 * vpu_dec_reset - reset decoder, use for flush decoder when end of stream or 84 * seek. Remaining non displayed frame will be pushed to display. 85 * 86 * @vpu: instance for vdec_vpu_inst 87 */ 88 int vpu_dec_reset(struct vdec_vpu_inst *vpu); 89 90 /** 91 * vpu_dec_core - core start decoding, basically the function will be invoked once 92 * every frame. 93 * 94 * @vpu : instance for vdec_vpu_inst 95 */ 96 int vpu_dec_core(struct vdec_vpu_inst *vpu); 97 98 /** 99 * vpu_dec_core_end - core end decoding, basically the function will be invoked once 100 * when core HW decoding done and receive interrupt successfully. The 101 * decoder in VPU will update hardware information and deinit hardware 102 * and check if there is a new decoded frame available to display. 103 * 104 * @vpu : instance for vdec_vpu_inst 105 */ 106 int vpu_dec_core_end(struct vdec_vpu_inst *vpu); 107 108 /** 109 * vpu_dec_get_param - get param from scp 110 * 111 * @vpu : instance for vdec_vpu_inst 112 * @data: meta data to pass bitstream info to VPU decoder 113 * @len : meta data length 114 * @param_type : get param type 115 */ 116 int vpu_dec_get_param(struct vdec_vpu_inst *vpu, uint32_t *data, 117 unsigned int len, unsigned int param_type); 118 119 #endif 120