1*0934d375SYunfei Dong /* SPDX-License-Identifier: GPL-2.0 */ 2*0934d375SYunfei Dong /* 3*0934d375SYunfei Dong * Copyright (c) 2016 MediaTek Inc. 4*0934d375SYunfei Dong * Author: Jungchang Tsao <jungchang.tsao@mediatek.com> 5*0934d375SYunfei Dong * Daniel Hsiao <daniel.hsiao@mediatek.com> 6*0934d375SYunfei Dong * Tiffany Lin <tiffany.lin@mediatek.com> 7*0934d375SYunfei Dong */ 8*0934d375SYunfei Dong 9*0934d375SYunfei Dong #ifndef _VENC_IPI_MSG_H_ 10*0934d375SYunfei Dong #define _VENC_IPI_MSG_H_ 11*0934d375SYunfei Dong 12*0934d375SYunfei Dong #define AP_IPIMSG_VENC_BASE 0xC000 13*0934d375SYunfei Dong #define VPU_IPIMSG_VENC_BASE 0xD000 14*0934d375SYunfei Dong 15*0934d375SYunfei Dong /* 16*0934d375SYunfei Dong * enum venc_ipi_msg_id - message id between AP and VPU 17*0934d375SYunfei Dong * (ipi stands for inter-processor interrupt) 18*0934d375SYunfei Dong * @AP_IPIMSG_ENC_XXX: AP to VPU cmd message id 19*0934d375SYunfei Dong * @VPU_IPIMSG_ENC_XXX_DONE: VPU ack AP cmd message id 20*0934d375SYunfei Dong */ 21*0934d375SYunfei Dong enum venc_ipi_msg_id { 22*0934d375SYunfei Dong AP_IPIMSG_ENC_INIT = AP_IPIMSG_VENC_BASE, 23*0934d375SYunfei Dong AP_IPIMSG_ENC_SET_PARAM, 24*0934d375SYunfei Dong AP_IPIMSG_ENC_ENCODE, 25*0934d375SYunfei Dong AP_IPIMSG_ENC_DEINIT, 26*0934d375SYunfei Dong 27*0934d375SYunfei Dong VPU_IPIMSG_ENC_INIT_DONE = VPU_IPIMSG_VENC_BASE, 28*0934d375SYunfei Dong VPU_IPIMSG_ENC_SET_PARAM_DONE, 29*0934d375SYunfei Dong VPU_IPIMSG_ENC_ENCODE_DONE, 30*0934d375SYunfei Dong VPU_IPIMSG_ENC_DEINIT_DONE, 31*0934d375SYunfei Dong }; 32*0934d375SYunfei Dong 33*0934d375SYunfei Dong /** 34*0934d375SYunfei Dong * struct venc_ap_ipi_msg_init - AP to VPU init cmd structure 35*0934d375SYunfei Dong * @msg_id: message id (AP_IPIMSG_XXX_ENC_INIT) 36*0934d375SYunfei Dong * @reserved: reserved for future use. vpu is running in 32bit. Without 37*0934d375SYunfei Dong * this reserved field, if kernel run in 64bit. this struct size 38*0934d375SYunfei Dong * will be different between kernel and vpu 39*0934d375SYunfei Dong * @venc_inst: AP encoder instance 40*0934d375SYunfei Dong * (struct venc_vp8_inst/venc_h264_inst *) 41*0934d375SYunfei Dong */ 42*0934d375SYunfei Dong struct venc_ap_ipi_msg_init { 43*0934d375SYunfei Dong uint32_t msg_id; 44*0934d375SYunfei Dong uint32_t reserved; 45*0934d375SYunfei Dong uint64_t venc_inst; 46*0934d375SYunfei Dong }; 47*0934d375SYunfei Dong 48*0934d375SYunfei Dong /** 49*0934d375SYunfei Dong * struct venc_ap_ipi_msg_set_param - AP to VPU set_param cmd structure 50*0934d375SYunfei Dong * @msg_id: message id (AP_IPIMSG_XXX_ENC_SET_PARAM) 51*0934d375SYunfei Dong * @vpu_inst_addr: VPU encoder instance addr 52*0934d375SYunfei Dong * (struct venc_vp8_vsi/venc_h264_vsi *) 53*0934d375SYunfei Dong * @param_id: parameter id (venc_set_param_type) 54*0934d375SYunfei Dong * @data_item: number of items in the data array 55*0934d375SYunfei Dong * @data: data array to store the set parameters 56*0934d375SYunfei Dong */ 57*0934d375SYunfei Dong struct venc_ap_ipi_msg_set_param { 58*0934d375SYunfei Dong uint32_t msg_id; 59*0934d375SYunfei Dong uint32_t vpu_inst_addr; 60*0934d375SYunfei Dong uint32_t param_id; 61*0934d375SYunfei Dong uint32_t data_item; 62*0934d375SYunfei Dong uint32_t data[8]; 63*0934d375SYunfei Dong }; 64*0934d375SYunfei Dong 65*0934d375SYunfei Dong struct venc_ap_ipi_msg_set_param_ext { 66*0934d375SYunfei Dong struct venc_ap_ipi_msg_set_param base; 67*0934d375SYunfei Dong uint32_t data_ext[24]; 68*0934d375SYunfei Dong }; 69*0934d375SYunfei Dong 70*0934d375SYunfei Dong /** 71*0934d375SYunfei Dong * struct venc_ap_ipi_msg_enc - AP to VPU enc cmd structure 72*0934d375SYunfei Dong * @msg_id: message id (AP_IPIMSG_XXX_ENC_ENCODE) 73*0934d375SYunfei Dong * @vpu_inst_addr: VPU encoder instance addr 74*0934d375SYunfei Dong * (struct venc_vp8_vsi/venc_h264_vsi *) 75*0934d375SYunfei Dong * @bs_mode: bitstream mode for h264 76*0934d375SYunfei Dong * (H264_BS_MODE_SPS/H264_BS_MODE_PPS/H264_BS_MODE_FRAME) 77*0934d375SYunfei Dong * @input_addr: pointer to input image buffer plane 78*0934d375SYunfei Dong * @bs_addr: pointer to output bit stream buffer 79*0934d375SYunfei Dong * @bs_size: bit stream buffer size 80*0934d375SYunfei Dong */ 81*0934d375SYunfei Dong struct venc_ap_ipi_msg_enc { 82*0934d375SYunfei Dong uint32_t msg_id; 83*0934d375SYunfei Dong uint32_t vpu_inst_addr; 84*0934d375SYunfei Dong uint32_t bs_mode; 85*0934d375SYunfei Dong uint32_t input_addr[3]; 86*0934d375SYunfei Dong uint32_t bs_addr; 87*0934d375SYunfei Dong uint32_t bs_size; 88*0934d375SYunfei Dong }; 89*0934d375SYunfei Dong 90*0934d375SYunfei Dong /** 91*0934d375SYunfei Dong * struct venc_ap_ipi_msg_enc_ext - AP to SCP extended enc cmd structure 92*0934d375SYunfei Dong * 93*0934d375SYunfei Dong * @base: base msg structure 94*0934d375SYunfei Dong * @data_item: number of items in the data array 95*0934d375SYunfei Dong * @data: data array to store the set parameters 96*0934d375SYunfei Dong */ 97*0934d375SYunfei Dong struct venc_ap_ipi_msg_enc_ext { 98*0934d375SYunfei Dong struct venc_ap_ipi_msg_enc base; 99*0934d375SYunfei Dong uint32_t data_item; 100*0934d375SYunfei Dong uint32_t data[32]; 101*0934d375SYunfei Dong }; 102*0934d375SYunfei Dong 103*0934d375SYunfei Dong /** 104*0934d375SYunfei Dong * struct venc_ap_ipi_msg_enc_ext_34 - AP to SCP extended enc cmd structure 105*0934d375SYunfei Dong * @msg_id: message id (AP_IPIMSG_XXX_ENC_ENCODE) 106*0934d375SYunfei Dong * @vpu_inst_addr: VPU encoder instance addr 107*0934d375SYunfei Dong * @bs_mode: bitstream mode for h264 108*0934d375SYunfei Dong * @reserved: for struct padding 109*0934d375SYunfei Dong * @input_addr: input frame buffer 34 bit address 110*0934d375SYunfei Dong * @bs_addr: output bitstream buffer 34 bit address 111*0934d375SYunfei Dong * @bs_size: bitstream buffer size 112*0934d375SYunfei Dong * @data_item: number of items in the data array 113*0934d375SYunfei Dong * @data: data array to store the set parameters 114*0934d375SYunfei Dong */ 115*0934d375SYunfei Dong struct venc_ap_ipi_msg_enc_ext_34 { 116*0934d375SYunfei Dong u32 msg_id; 117*0934d375SYunfei Dong u32 vpu_inst_addr; 118*0934d375SYunfei Dong u32 bs_mode; 119*0934d375SYunfei Dong u32 reserved; 120*0934d375SYunfei Dong u64 input_addr[3]; 121*0934d375SYunfei Dong u64 bs_addr; 122*0934d375SYunfei Dong u32 bs_size; 123*0934d375SYunfei Dong u32 data_item; 124*0934d375SYunfei Dong u32 data[32]; 125*0934d375SYunfei Dong }; 126*0934d375SYunfei Dong 127*0934d375SYunfei Dong /** 128*0934d375SYunfei Dong * struct venc_ap_ipi_msg_deinit - AP to VPU deinit cmd structure 129*0934d375SYunfei Dong * @msg_id: message id (AP_IPIMSG_XXX_ENC_DEINIT) 130*0934d375SYunfei Dong * @vpu_inst_addr: VPU encoder instance addr 131*0934d375SYunfei Dong * (struct venc_vp8_vsi/venc_h264_vsi *) 132*0934d375SYunfei Dong */ 133*0934d375SYunfei Dong struct venc_ap_ipi_msg_deinit { 134*0934d375SYunfei Dong uint32_t msg_id; 135*0934d375SYunfei Dong uint32_t vpu_inst_addr; 136*0934d375SYunfei Dong }; 137*0934d375SYunfei Dong 138*0934d375SYunfei Dong /* 139*0934d375SYunfei Dong * enum venc_ipi_msg_status - VPU ack AP cmd status 140*0934d375SYunfei Dong */ 141*0934d375SYunfei Dong enum venc_ipi_msg_status { 142*0934d375SYunfei Dong VENC_IPI_MSG_STATUS_OK, 143*0934d375SYunfei Dong VENC_IPI_MSG_STATUS_FAIL, 144*0934d375SYunfei Dong }; 145*0934d375SYunfei Dong 146*0934d375SYunfei Dong /** 147*0934d375SYunfei Dong * struct venc_vpu_ipi_msg_common - VPU ack AP cmd common structure 148*0934d375SYunfei Dong * @msg_id: message id (VPU_IPIMSG_XXX_DONE) 149*0934d375SYunfei Dong * @status: cmd status (venc_ipi_msg_status) 150*0934d375SYunfei Dong * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *) 151*0934d375SYunfei Dong */ 152*0934d375SYunfei Dong struct venc_vpu_ipi_msg_common { 153*0934d375SYunfei Dong uint32_t msg_id; 154*0934d375SYunfei Dong uint32_t status; 155*0934d375SYunfei Dong uint64_t venc_inst; 156*0934d375SYunfei Dong }; 157*0934d375SYunfei Dong 158*0934d375SYunfei Dong /** 159*0934d375SYunfei Dong * struct venc_vpu_ipi_msg_init - VPU ack AP init cmd structure 160*0934d375SYunfei Dong * @msg_id: message id (VPU_IPIMSG_XXX_ENC_SET_PARAM_DONE) 161*0934d375SYunfei Dong * @status: cmd status (venc_ipi_msg_status) 162*0934d375SYunfei Dong * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *) 163*0934d375SYunfei Dong * @vpu_inst_addr: VPU encoder instance addr 164*0934d375SYunfei Dong * (struct venc_vp8_vsi/venc_h264_vsi *) 165*0934d375SYunfei Dong * @venc_abi_version: ABI version of the firmware. Kernel can use it to 166*0934d375SYunfei Dong * ensure that it is compatible with the firmware. 167*0934d375SYunfei Dong * For MT8173 the value of this field is undefined and 168*0934d375SYunfei Dong * should not be used. 169*0934d375SYunfei Dong */ 170*0934d375SYunfei Dong struct venc_vpu_ipi_msg_init { 171*0934d375SYunfei Dong uint32_t msg_id; 172*0934d375SYunfei Dong uint32_t status; 173*0934d375SYunfei Dong uint64_t venc_inst; 174*0934d375SYunfei Dong uint32_t vpu_inst_addr; 175*0934d375SYunfei Dong uint32_t venc_abi_version; 176*0934d375SYunfei Dong }; 177*0934d375SYunfei Dong 178*0934d375SYunfei Dong /** 179*0934d375SYunfei Dong * struct venc_vpu_ipi_msg_set_param - VPU ack AP set_param cmd structure 180*0934d375SYunfei Dong * @msg_id: message id (VPU_IPIMSG_XXX_ENC_SET_PARAM_DONE) 181*0934d375SYunfei Dong * @status: cmd status (venc_ipi_msg_status) 182*0934d375SYunfei Dong * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *) 183*0934d375SYunfei Dong * @param_id: parameter id (venc_set_param_type) 184*0934d375SYunfei Dong * @data_item: number of items in the data array 185*0934d375SYunfei Dong * @data: data array to store the return result 186*0934d375SYunfei Dong */ 187*0934d375SYunfei Dong struct venc_vpu_ipi_msg_set_param { 188*0934d375SYunfei Dong uint32_t msg_id; 189*0934d375SYunfei Dong uint32_t status; 190*0934d375SYunfei Dong uint64_t venc_inst; 191*0934d375SYunfei Dong uint32_t param_id; 192*0934d375SYunfei Dong uint32_t data_item; 193*0934d375SYunfei Dong uint32_t data[6]; 194*0934d375SYunfei Dong }; 195*0934d375SYunfei Dong 196*0934d375SYunfei Dong /** 197*0934d375SYunfei Dong * enum venc_ipi_msg_enc_state - Type of encode state 198*0934d375SYunfei Dong * @VEN_IPI_MSG_ENC_STATE_FRAME: one frame being encoded 199*0934d375SYunfei Dong * @VEN_IPI_MSG_ENC_STATE_PART: bit stream buffer full 200*0934d375SYunfei Dong * @VEN_IPI_MSG_ENC_STATE_SKIP: encoded skip frame 201*0934d375SYunfei Dong * @VEN_IPI_MSG_ENC_STATE_ERROR: encounter error 202*0934d375SYunfei Dong */ 203*0934d375SYunfei Dong enum venc_ipi_msg_enc_state { 204*0934d375SYunfei Dong VEN_IPI_MSG_ENC_STATE_FRAME, 205*0934d375SYunfei Dong VEN_IPI_MSG_ENC_STATE_PART, 206*0934d375SYunfei Dong VEN_IPI_MSG_ENC_STATE_SKIP, 207*0934d375SYunfei Dong VEN_IPI_MSG_ENC_STATE_ERROR, 208*0934d375SYunfei Dong }; 209*0934d375SYunfei Dong 210*0934d375SYunfei Dong /** 211*0934d375SYunfei Dong * struct venc_vpu_ipi_msg_enc - VPU ack AP enc cmd structure 212*0934d375SYunfei Dong * @msg_id: message id (VPU_IPIMSG_XXX_ENC_ENCODE_DONE) 213*0934d375SYunfei Dong * @status: cmd status (venc_ipi_msg_status) 214*0934d375SYunfei Dong * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *) 215*0934d375SYunfei Dong * @state: encode state (venc_ipi_msg_enc_state) 216*0934d375SYunfei Dong * @is_key_frm: whether the encoded frame is key frame 217*0934d375SYunfei Dong * @bs_size: encoded bitstream size 218*0934d375SYunfei Dong * @reserved: reserved for future use. vpu is running in 32bit. Without 219*0934d375SYunfei Dong * this reserved field, if kernel run in 64bit. this struct size 220*0934d375SYunfei Dong * will be different between kernel and vpu 221*0934d375SYunfei Dong */ 222*0934d375SYunfei Dong struct venc_vpu_ipi_msg_enc { 223*0934d375SYunfei Dong uint32_t msg_id; 224*0934d375SYunfei Dong uint32_t status; 225*0934d375SYunfei Dong uint64_t venc_inst; 226*0934d375SYunfei Dong uint32_t state; 227*0934d375SYunfei Dong uint32_t is_key_frm; 228*0934d375SYunfei Dong uint32_t bs_size; 229*0934d375SYunfei Dong uint32_t reserved; 230*0934d375SYunfei Dong }; 231*0934d375SYunfei Dong 232*0934d375SYunfei Dong /** 233*0934d375SYunfei Dong * struct venc_vpu_ipi_msg_deinit - VPU ack AP deinit cmd structure 234*0934d375SYunfei Dong * @msg_id: message id (VPU_IPIMSG_XXX_ENC_DEINIT_DONE) 235*0934d375SYunfei Dong * @status: cmd status (venc_ipi_msg_status) 236*0934d375SYunfei Dong * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *) 237*0934d375SYunfei Dong */ 238*0934d375SYunfei Dong struct venc_vpu_ipi_msg_deinit { 239*0934d375SYunfei Dong uint32_t msg_id; 240*0934d375SYunfei Dong uint32_t status; 241*0934d375SYunfei Dong uint64_t venc_inst; 242*0934d375SYunfei Dong }; 243*0934d375SYunfei Dong 244*0934d375SYunfei Dong #endif /* _VENC_IPI_MSG_H_ */ 245