1 /*
2  * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
3  * Copyright (C) 2017 Linaro Ltd.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 and
7  * only version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15 #ifndef __VENUS_HFI_CMDS_H__
16 #define __VENUS_HFI_CMDS_H__
17 
18 #include "hfi.h"
19 
20 /* commands */
21 #define HFI_CMD_SYS_INIT			0x10001
22 #define HFI_CMD_SYS_PC_PREP			0x10002
23 #define HFI_CMD_SYS_SET_RESOURCE		0x10003
24 #define HFI_CMD_SYS_RELEASE_RESOURCE		0x10004
25 #define HFI_CMD_SYS_SET_PROPERTY		0x10005
26 #define HFI_CMD_SYS_GET_PROPERTY		0x10006
27 #define HFI_CMD_SYS_SESSION_INIT		0x10007
28 #define HFI_CMD_SYS_SESSION_END			0x10008
29 #define HFI_CMD_SYS_SET_BUFFERS			0x10009
30 #define HFI_CMD_SYS_TEST_SSR			0x10101
31 
32 #define HFI_CMD_SESSION_SET_PROPERTY		0x11001
33 #define HFI_CMD_SESSION_SET_BUFFERS		0x11002
34 #define HFI_CMD_SESSION_GET_SEQUENCE_HEADER	0x11003
35 
36 #define HFI_CMD_SYS_SESSION_ABORT		0x210001
37 #define HFI_CMD_SYS_PING			0x210002
38 
39 #define HFI_CMD_SESSION_LOAD_RESOURCES		0x211001
40 #define HFI_CMD_SESSION_START			0x211002
41 #define HFI_CMD_SESSION_STOP			0x211003
42 #define HFI_CMD_SESSION_EMPTY_BUFFER		0x211004
43 #define HFI_CMD_SESSION_FILL_BUFFER		0x211005
44 #define HFI_CMD_SESSION_SUSPEND			0x211006
45 #define HFI_CMD_SESSION_RESUME			0x211007
46 #define HFI_CMD_SESSION_FLUSH			0x211008
47 #define HFI_CMD_SESSION_GET_PROPERTY		0x211009
48 #define HFI_CMD_SESSION_PARSE_SEQUENCE_HEADER	0x21100a
49 #define HFI_CMD_SESSION_RELEASE_BUFFERS		0x21100b
50 #define HFI_CMD_SESSION_RELEASE_RESOURCES	0x21100c
51 #define HFI_CMD_SESSION_CONTINUE		0x21100d
52 #define HFI_CMD_SESSION_SYNC			0x21100e
53 
54 /* command packets */
55 struct hfi_sys_init_pkt {
56 	struct hfi_pkt_hdr hdr;
57 	u32 arch_type;
58 };
59 
60 struct hfi_sys_pc_prep_pkt {
61 	struct hfi_pkt_hdr hdr;
62 };
63 
64 struct hfi_sys_set_resource_pkt {
65 	struct hfi_pkt_hdr hdr;
66 	u32 resource_handle;
67 	u32 resource_type;
68 	u32 resource_data[1];
69 };
70 
71 struct hfi_sys_release_resource_pkt {
72 	struct hfi_pkt_hdr hdr;
73 	u32 resource_type;
74 	u32 resource_handle;
75 };
76 
77 struct hfi_sys_set_property_pkt {
78 	struct hfi_pkt_hdr hdr;
79 	u32 num_properties;
80 	u32 data[1];
81 };
82 
83 struct hfi_sys_get_property_pkt {
84 	struct hfi_pkt_hdr hdr;
85 	u32 num_properties;
86 	u32 data[1];
87 };
88 
89 struct hfi_sys_set_buffers_pkt {
90 	struct hfi_pkt_hdr hdr;
91 	u32 buffer_type;
92 	u32 buffer_size;
93 	u32 num_buffers;
94 	u32 buffer_addr[1];
95 };
96 
97 struct hfi_sys_ping_pkt {
98 	struct hfi_pkt_hdr hdr;
99 	u32 client_data;
100 };
101 
102 struct hfi_session_init_pkt {
103 	struct hfi_session_hdr_pkt shdr;
104 	u32 session_domain;
105 	u32 session_codec;
106 };
107 
108 struct hfi_session_end_pkt {
109 	struct hfi_session_hdr_pkt shdr;
110 };
111 
112 struct hfi_session_abort_pkt {
113 	struct hfi_session_hdr_pkt shdr;
114 };
115 
116 struct hfi_session_set_property_pkt {
117 	struct hfi_session_hdr_pkt shdr;
118 	u32 num_properties;
119 	u32 data[0];
120 };
121 
122 struct hfi_session_set_buffers_pkt {
123 	struct hfi_session_hdr_pkt shdr;
124 	u32 buffer_type;
125 	u32 buffer_size;
126 	u32 extradata_size;
127 	u32 min_buffer_size;
128 	u32 num_buffers;
129 	u32 buffer_info[1];
130 };
131 
132 struct hfi_session_get_sequence_header_pkt {
133 	struct hfi_session_hdr_pkt shdr;
134 	u32 buffer_len;
135 	u32 packet_buffer;
136 };
137 
138 struct hfi_session_load_resources_pkt {
139 	struct hfi_session_hdr_pkt shdr;
140 };
141 
142 struct hfi_session_start_pkt {
143 	struct hfi_session_hdr_pkt shdr;
144 };
145 
146 struct hfi_session_stop_pkt {
147 	struct hfi_session_hdr_pkt shdr;
148 };
149 
150 struct hfi_session_empty_buffer_compressed_pkt {
151 	struct hfi_session_hdr_pkt shdr;
152 	u32 time_stamp_hi;
153 	u32 time_stamp_lo;
154 	u32 flags;
155 	u32 mark_target;
156 	u32 mark_data;
157 	u32 offset;
158 	u32 alloc_len;
159 	u32 filled_len;
160 	u32 input_tag;
161 	u32 packet_buffer;
162 	u32 extradata_buffer;
163 	u32 data[1];
164 };
165 
166 struct hfi_session_empty_buffer_uncompressed_plane0_pkt {
167 	struct hfi_session_hdr_pkt shdr;
168 	u32 view_id;
169 	u32 time_stamp_hi;
170 	u32 time_stamp_lo;
171 	u32 flags;
172 	u32 mark_target;
173 	u32 mark_data;
174 	u32 alloc_len;
175 	u32 filled_len;
176 	u32 offset;
177 	u32 input_tag;
178 	u32 packet_buffer;
179 	u32 extradata_buffer;
180 	u32 data[1];
181 };
182 
183 struct hfi_session_empty_buffer_uncompressed_plane1_pkt {
184 	u32 flags;
185 	u32 alloc_len;
186 	u32 filled_len;
187 	u32 offset;
188 	u32 packet_buffer2;
189 	u32 data[1];
190 };
191 
192 struct hfi_session_empty_buffer_uncompressed_plane2_pkt {
193 	u32 flags;
194 	u32 alloc_len;
195 	u32 filled_len;
196 	u32 offset;
197 	u32 packet_buffer3;
198 	u32 data[1];
199 };
200 
201 struct hfi_session_fill_buffer_pkt {
202 	struct hfi_session_hdr_pkt shdr;
203 	u32 stream_id;
204 	u32 offset;
205 	u32 alloc_len;
206 	u32 filled_len;
207 	u32 output_tag;
208 	u32 packet_buffer;
209 	u32 extradata_buffer;
210 	u32 data[1];
211 };
212 
213 struct hfi_session_flush_pkt {
214 	struct hfi_session_hdr_pkt shdr;
215 	u32 flush_type;
216 };
217 
218 struct hfi_session_suspend_pkt {
219 	struct hfi_session_hdr_pkt shdr;
220 };
221 
222 struct hfi_session_resume_pkt {
223 	struct hfi_session_hdr_pkt shdr;
224 };
225 
226 struct hfi_session_get_property_pkt {
227 	struct hfi_session_hdr_pkt shdr;
228 	u32 num_properties;
229 	u32 data[1];
230 };
231 
232 struct hfi_session_release_buffer_pkt {
233 	struct hfi_session_hdr_pkt shdr;
234 	u32 buffer_type;
235 	u32 buffer_size;
236 	u32 extradata_size;
237 	u32 response_req;
238 	u32 num_buffers;
239 	u32 buffer_info[1];
240 };
241 
242 struct hfi_session_release_resources_pkt {
243 	struct hfi_session_hdr_pkt shdr;
244 };
245 
246 struct hfi_session_parse_sequence_header_pkt {
247 	struct hfi_session_hdr_pkt shdr;
248 	u32 header_len;
249 	u32 packet_buffer;
250 };
251 
252 struct hfi_sfr {
253 	u32 buf_size;
254 	u8 data[1];
255 };
256 
257 struct hfi_sys_test_ssr_pkt {
258 	struct hfi_pkt_hdr hdr;
259 	u32 trigger_type;
260 };
261 
262 void pkt_set_version(enum hfi_version version);
263 
264 void pkt_sys_init(struct hfi_sys_init_pkt *pkt, u32 arch_type);
265 void pkt_sys_pc_prep(struct hfi_sys_pc_prep_pkt *pkt);
266 void pkt_sys_idle_indicator(struct hfi_sys_set_property_pkt *pkt, u32 enable);
267 void pkt_sys_power_control(struct hfi_sys_set_property_pkt *pkt, u32 enable);
268 int pkt_sys_set_resource(struct hfi_sys_set_resource_pkt *pkt, u32 id, u32 size,
269 			 u32 addr, void *cookie);
270 int pkt_sys_unset_resource(struct hfi_sys_release_resource_pkt *pkt, u32 id,
271 			   u32 size, void *cookie);
272 void pkt_sys_debug_config(struct hfi_sys_set_property_pkt *pkt, u32 mode,
273 			  u32 config);
274 void pkt_sys_coverage_config(struct hfi_sys_set_property_pkt *pkt, u32 mode);
275 void pkt_sys_ping(struct hfi_sys_ping_pkt *pkt, u32 cookie);
276 void pkt_sys_image_version(struct hfi_sys_get_property_pkt *pkt);
277 int pkt_sys_ssr_cmd(struct hfi_sys_test_ssr_pkt *pkt, u32 trigger_type);
278 int pkt_session_init(struct hfi_session_init_pkt *pkt, void *cookie,
279 		     u32 session_type, u32 codec);
280 void pkt_session_cmd(struct hfi_session_pkt *pkt, u32 pkt_type, void *cookie);
281 int pkt_session_set_buffers(struct hfi_session_set_buffers_pkt *pkt,
282 			    void *cookie, struct hfi_buffer_desc *bd);
283 int pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt *pkt,
284 			      void *cookie, struct hfi_buffer_desc *bd);
285 int pkt_session_etb_decoder(struct hfi_session_empty_buffer_compressed_pkt *pkt,
286 			    void *cookie, struct hfi_frame_data *input_frame);
287 int pkt_session_etb_encoder(
288 		struct hfi_session_empty_buffer_uncompressed_plane0_pkt *pkt,
289 		void *cookie, struct hfi_frame_data *input_frame);
290 int pkt_session_ftb(struct hfi_session_fill_buffer_pkt *pkt,
291 		    void *cookie, struct hfi_frame_data *output_frame);
292 int pkt_session_parse_seq_header(
293 		struct hfi_session_parse_sequence_header_pkt *pkt,
294 		void *cookie, u32 seq_hdr, u32 seq_hdr_len);
295 int pkt_session_get_seq_hdr(struct hfi_session_get_sequence_header_pkt *pkt,
296 			    void *cookie, u32 seq_hdr, u32 seq_hdr_len);
297 int pkt_session_flush(struct hfi_session_flush_pkt *pkt, void *cookie,
298 		      u32 flush_mode);
299 int pkt_session_get_property(struct hfi_session_get_property_pkt *pkt,
300 			     void *cookie, u32 ptype);
301 int pkt_session_set_property(struct hfi_session_set_property_pkt *pkt,
302 			     void *cookie, u32 ptype, void *pdata);
303 
304 #endif
305