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_IPI_MSG_H_
8 #define _VDEC_IPI_MSG_H_
9 
10 /*
11  * enum vdec_ipi_msgid - message id between AP and VPU
12  * @AP_IPIMSG_XXX	: AP to VPU cmd message id
13  * @VPU_IPIMSG_XXX_ACK	: VPU ack AP cmd message id
14  */
15 enum vdec_ipi_msgid {
16 	AP_IPIMSG_DEC_INIT = 0xA000,
17 	AP_IPIMSG_DEC_START = 0xA001,
18 	AP_IPIMSG_DEC_END = 0xA002,
19 	AP_IPIMSG_DEC_DEINIT = 0xA003,
20 	AP_IPIMSG_DEC_RESET = 0xA004,
21 	AP_IPIMSG_DEC_CORE = 0xA005,
22 	AP_IPIMSG_DEC_CORE_END = 0xA006,
23 	AP_IPIMSG_DEC_GET_PARAM = 0xA007,
24 
25 	VPU_IPIMSG_DEC_INIT_ACK = 0xB000,
26 	VPU_IPIMSG_DEC_START_ACK = 0xB001,
27 	VPU_IPIMSG_DEC_END_ACK = 0xB002,
28 	VPU_IPIMSG_DEC_DEINIT_ACK = 0xB003,
29 	VPU_IPIMSG_DEC_RESET_ACK = 0xB004,
30 	VPU_IPIMSG_DEC_CORE_ACK = 0xB005,
31 	VPU_IPIMSG_DEC_CORE_END_ACK = 0xB006,
32 	VPU_IPIMSG_DEC_GET_PARAM_ACK = 0xB007,
33 };
34 
35 /**
36  * struct vdec_ap_ipi_cmd - generic AP to VPU ipi command format
37  * @msg_id	: vdec_ipi_msgid
38  * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2.
39  * @inst_id     : instance ID. Used if the ABI version >= 2.
40  * @codec_type	: codec fourcc
41  * @reserved	: reserved param
42  */
43 struct vdec_ap_ipi_cmd {
44 	uint32_t msg_id;
45 	union {
46 		uint32_t vpu_inst_addr;
47 		uint32_t inst_id;
48 	};
49 	u32 codec_type;
50 	u32 reserved;
51 };
52 
53 /**
54  * struct vdec_vpu_ipi_ack - generic VPU to AP ipi command format
55  * @msg_id	: vdec_ipi_msgid
56  * @status	: VPU exeuction result
57  * @ap_inst_addr	: AP video decoder instance address
58  */
59 struct vdec_vpu_ipi_ack {
60 	uint32_t msg_id;
61 	int32_t status;
62 	uint64_t ap_inst_addr;
63 };
64 
65 /**
66  * struct vdec_ap_ipi_init - for AP_IPIMSG_DEC_INIT
67  * @msg_id	: AP_IPIMSG_DEC_INIT
68  * @codec_type	: codec fourcc
69  * @ap_inst_addr	: AP video decoder instance address
70  */
71 struct vdec_ap_ipi_init {
72 	uint32_t msg_id;
73 	u32 codec_type;
74 	uint64_t ap_inst_addr;
75 };
76 
77 /**
78  * struct vdec_ap_ipi_dec_start - for AP_IPIMSG_DEC_START
79  * @msg_id	: AP_IPIMSG_DEC_START
80  * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2.
81  * @inst_id     : instance ID. Used if the ABI version >= 2.
82  * @data	: Header info
83  *	H264 decoder [0]:buf_sz [1]:nal_start
84  *	VP8 decoder  [0]:width/height
85  *	VP9 decoder  [0]:profile, [1][2] width/height
86  * @codec_type	: codec fourcc
87  */
88 struct vdec_ap_ipi_dec_start {
89 	uint32_t msg_id;
90 	union {
91 		uint32_t vpu_inst_addr;
92 		uint32_t inst_id;
93 	};
94 	uint32_t data[3];
95 	u32 codec_type;
96 };
97 
98 /**
99  * struct vdec_vpu_ipi_init_ack - for VPU_IPIMSG_DEC_INIT_ACK
100  * @msg_id	: VPU_IPIMSG_DEC_INIT_ACK
101  * @status	: VPU exeuction result
102  * @ap_inst_addr	: AP vcodec_vpu_inst instance address
103  * @vpu_inst_addr	: VPU decoder instance address
104  * @vdec_abi_version:	ABI version of the firmware. Kernel can use it to
105  *			ensure that it is compatible with the firmware.
106  *			This field is not valid for MT8173 and must not be
107  *			accessed for this chip.
108  * @inst_id     : instance ID. Valid only if the ABI version >= 2.
109  */
110 struct vdec_vpu_ipi_init_ack {
111 	uint32_t msg_id;
112 	int32_t status;
113 	uint64_t ap_inst_addr;
114 	uint32_t vpu_inst_addr;
115 	uint32_t vdec_abi_version;
116 	uint32_t inst_id;
117 };
118 
119 /**
120  * struct vdec_ap_ipi_get_param - for AP_IPIMSG_DEC_GET_PARAM
121  * @msg_id	: AP_IPIMSG_DEC_GET_PARAM
122  * @inst_id     : instance ID. Used if the ABI version >= 2.
123  * @data	: picture information
124  * @param_type	: get param type
125  * @codec_type	: Codec fourcc
126  */
127 struct vdec_ap_ipi_get_param {
128 	u32 msg_id;
129 	u32 inst_id;
130 	u32 data[4];
131 	u32 param_type;
132 	u32 codec_type;
133 };
134 
135 /**
136  * struct vdec_vpu_ipi_get_param_ack - for VPU_IPIMSG_DEC_GET_PARAM_ACK
137  * @msg_id	: VPU_IPIMSG_DEC_GET_PARAM_ACK
138  * @status	: VPU execution result
139  * @ap_inst_addr	: AP vcodec_vpu_inst instance address
140  * @data     : picture information from SCP.
141  * @param_type	: get param type
142  * @reserved : reserved param
143  */
144 struct vdec_vpu_ipi_get_param_ack {
145 	u32 msg_id;
146 	s32 status;
147 	u64 ap_inst_addr;
148 	u32 data[4];
149 	u32 param_type;
150 	u32 reserved;
151 };
152 
153 #endif
154