1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #if !defined(WFC_IPC_H) |
29 | #define WFC_IPC_H |
30 | |
31 | #include "interface/vcos/vcos.h" |
32 | #include "interface/khronos/include/WF/wfc.h" |
33 | #include "interface/khronos/wf/wfc_int.h" |
34 | #include "interface/khronos/wf/wfc_server_api.h" |
35 | #include "interface/khronos/include/EGL/eglext.h" |
36 | |
37 | #define WFC_IPC_CONTROL_FOURCC() VCHIQ_MAKE_FOURCC('W','F','C','I') |
38 | |
39 | /* Define the current version number of the IPC API that the host library of VC |
40 | * server is built against. |
41 | */ |
42 | /* The current IPC version number */ |
43 | #define WFC_IPC_VER_CURRENT 8 |
44 | |
45 | /* The minimum version number for backwards compatibility */ |
46 | #ifndef WFC_IPC_VER_MINIMUM |
47 | #define WFC_IPC_VER_MINIMUM 5 |
48 | #endif |
49 | |
50 | /** Definitions of messages used for implementing the WFC API on the server. |
51 | * |
52 | * These are passed to the server thread via VCHIQ. |
53 | */ |
54 | |
55 | typedef enum { |
56 | WFC_IPC_MSG_SET_CLIENT_PID, |
57 | WFC_IPC_MSG_GET_VERSION, /**< Returns major, minor and minimum values */ |
58 | WFC_IPC_MSG_CREATE_CONTEXT, /**< Returns uint32_t */ |
59 | WFC_IPC_MSG_DESTROY_CONTEXT, |
60 | WFC_IPC_MSG_COMMIT_SCENE, |
61 | WFC_IPC_MSG_ACTIVATE, |
62 | WFC_IPC_MSG_DEACTIVATE, |
63 | WFC_IPC_MSG_SET_DEFERRAL_STREAM, |
64 | WFC_IPC_MSG_SS_CREATE, /**< Returns WFCNativeStreamType */ |
65 | WFC_IPC_MSG_SS_DESTROY, |
66 | WFC_IPC_MSG_SS_ON_RECTS_CHANGE, |
67 | WFC_IPC_MSG_SS_GET_RECTS, |
68 | WFC_IPC_MSG_SS_IS_IN_USE, /**< Returns uint32_t */ |
69 | WFC_IPC_MSG_SS_ALLOCATE_IMAGES, /**< Returns uint32_t */ |
70 | WFC_IPC_MSG_SS_SIGNAL_EGLIMAGE_DATA, |
71 | WFC_IPC_MSG_SS_SIGNAL_MM_IMAGE_DATA, |
72 | WFC_IPC_MSG_SS_SIGNAL_RAW_PIXELS, |
73 | WFC_IPC_MSG_SS_REGISTER, |
74 | WFC_IPC_MSG_SS_UNREGISTER, |
75 | WFC_IPC_MSG_SS_ON_IMAGE_AVAILABLE, |
76 | WFC_IPC_MSG_SS_SIGNAL_IMAGE, /**< Signal to update the front buffer of a generic image stream */ |
77 | WFC_IPC_MSG_SS_CREATE_INFO, /**< Returns WFCNativeStreamType */ |
78 | WFC_IPC_MSG_SS_GET_INFO, /**< Get stream configuration information */ |
79 | |
80 | WFC_IPC_MSG_COUNT, /**< Always immediately after last client message type */ |
81 | |
82 | WFC_IPC_MSG_CALLBACK, /**< Sent from server to complete callback */ |
83 | |
84 | |
85 | WFC_IPC_MSG_MAX = 0x7FFFFFFF /**< Force type to be 32-bit */ |
86 | } WFC_IPC_MSG_TYPE; |
87 | |
88 | /** Padded pointer type, for when client and server have different size pointers. |
89 | * Set the padding field type to be big enough on both to hold a pointer. |
90 | */ |
91 | #define WFC_IPC_PTR_T(T) union { uint32_t padding; T ptr; } |
92 | typedef WFC_IPC_PTR_T(WFC_CALLBACK_T) WFC_IPC_CALLBACK_T; |
93 | typedef WFC_IPC_PTR_T(void *) WFC_IPC_VOID_PTR_T; |
94 | |
95 | /** The message header. All messages must start with this structure. */ |
96 | typedef struct |
97 | { |
98 | uint32_t magic; /**< Sentinel value to perform simple validation */ |
99 | WFC_IPC_MSG_TYPE type; /**< The type of the message */ |
100 | |
101 | /** Opaque client pointer, passed back in a reply */ |
102 | WFC_IPC_PTR_T(struct WFC_WAITER_T *) waiter; |
103 | } ; |
104 | |
105 | /** General purpose message, for passing just a uint32_t. */ |
106 | typedef struct { |
107 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
108 | |
109 | uint32_t value; |
110 | } WFC_IPC_MSG_UINT32_T; |
111 | |
112 | /** General purpose message, for passing just a context. */ |
113 | typedef struct { |
114 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
115 | |
116 | WFCContext context; |
117 | } WFC_IPC_MSG_CONTEXT_T; |
118 | |
119 | /** General purpose message, for passing just a stream. */ |
120 | typedef struct { |
121 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
122 | |
123 | WFCNativeStreamType stream; |
124 | } WFC_IPC_MSG_STREAM_T; |
125 | |
126 | /** General purpose message, for calling a client provided callback. */ |
127 | typedef struct { |
128 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
129 | |
130 | WFC_IPC_CALLBACK_T callback_fn; /**< Opaque client function pointer */ |
131 | WFC_IPC_VOID_PTR_T callback_data; /**< Opaque client data */ |
132 | } WFC_IPC_MSG_CALLBACK_T; |
133 | |
134 | /** Set client process identifier message */ |
135 | typedef struct { |
136 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
137 | |
138 | uint32_t pid_lo; |
139 | uint32_t pid_hi; |
140 | } WFC_IPC_MSG_SET_CLIENT_PID_T; |
141 | |
142 | /** Get version reply message */ |
143 | typedef struct { |
144 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
145 | |
146 | uint32_t major; |
147 | uint32_t minor; |
148 | uint32_t minimum; |
149 | } WFC_IPC_MSG_GET_VERSION_T; |
150 | |
151 | /** Create context message */ |
152 | typedef struct { |
153 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
154 | |
155 | WFCContext context; |
156 | uint32_t context_type; |
157 | uint32_t screen_or_stream_num; |
158 | uint32_t pid_lo; |
159 | uint32_t pid_hi; |
160 | } WFC_IPC_MSG_CREATE_CONTEXT_T; |
161 | |
162 | /** Compose scene message */ |
163 | typedef struct { |
164 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
165 | |
166 | WFC_IPC_CALLBACK_T scene_taken_cb; /**< Opaque client function pointer */ |
167 | WFC_IPC_VOID_PTR_T scene_taken_data; /**< Opaque client data */ |
168 | WFCContext context; |
169 | uint32_t flags; |
170 | WFC_SCENE_T scene; |
171 | } WFC_IPC_MSG_COMMIT_SCENE_T; |
172 | |
173 | /** Set deferral stream message */ |
174 | typedef struct { |
175 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
176 | |
177 | WFCContext context; |
178 | WFCNativeStreamType stream; |
179 | } WFC_IPC_MSG_SET_DEFERRAL_STREAM_T; |
180 | |
181 | /** Create stream message */ |
182 | typedef struct { |
183 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
184 | |
185 | WFCNativeStreamType stream; |
186 | uint32_t flags; |
187 | uint32_t pid_lo; |
188 | uint32_t pid_hi; |
189 | } WFC_IPC_MSG_SS_CREATE_T; |
190 | |
191 | /** Create stream using info block message */ |
192 | typedef struct { |
193 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
194 | |
195 | WFCNativeStreamType stream; |
196 | WFC_STREAM_INFO_T info; |
197 | uint32_t pid_lo; |
198 | uint32_t pid_hi; |
199 | } WFC_IPC_MSG_SS_CREATE_INFO_T; |
200 | |
201 | /** Destroy stream message */ |
202 | typedef struct { |
203 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
204 | |
205 | WFCNativeStreamType stream; |
206 | uint32_t pid_lo; |
207 | uint32_t pid_hi; |
208 | } WFC_IPC_MSG_SS_DESTROY_T; |
209 | |
210 | /** Set stream rectangle update callback message */ |
211 | typedef struct { |
212 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
213 | |
214 | WFCNativeStreamType stream; |
215 | WFC_IPC_CALLBACK_T rects_change_cb; /**< Opaque client function pointer */ |
216 | WFC_IPC_VOID_PTR_T rects_change_data; /**< Opaque client data */ |
217 | } WFC_IPC_MSG_SS_ON_RECTS_CHANGE_T; |
218 | |
219 | /** Get rectangles reply message */ |
220 | typedef struct { |
221 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
222 | |
223 | uint32_t result; |
224 | int32_t rects[WFC_SERVER_STREAM_RECTS_SIZE]; |
225 | } WFC_IPC_MSG_SS_GET_RECTS_T; |
226 | |
227 | /** Allocate stream target images message */ |
228 | typedef struct { |
229 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
230 | |
231 | WFCNativeStreamType stream; |
232 | uint32_t width; |
233 | uint32_t height; |
234 | uint32_t nbufs; |
235 | } WFC_IPC_MSG_SS_ALLOCATE_IMAGES_T; |
236 | |
237 | /** Signal new EGLImage image message */ |
238 | typedef struct { |
239 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
240 | |
241 | WFCNativeStreamType stream; |
242 | uint32_t ustorage; |
243 | uint32_t width; |
244 | uint32_t height; |
245 | uint32_t stride; |
246 | uint32_t offset; |
247 | uint32_t format; |
248 | uint32_t flags; |
249 | bool flip; |
250 | } WFC_IPC_MSG_SS_SIGNAL_EGLIMAGE_DATA_T; |
251 | |
252 | /** Signal new multimedia image message */ |
253 | typedef struct { |
254 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
255 | |
256 | WFCNativeStreamType stream; |
257 | uint32_t image_handle; |
258 | } WFC_IPC_MSG_SS_SIGNAL_MM_IMAGE_DATA_T; |
259 | |
260 | /** Signal new raw pixel image message */ |
261 | typedef struct { |
262 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
263 | |
264 | WFCNativeStreamType stream; |
265 | uint32_t handle; |
266 | uint32_t format; |
267 | uint32_t width; |
268 | uint32_t height; |
269 | uint32_t pitch; |
270 | uint32_t vpitch; |
271 | } WFC_IPC_MSG_SS_SIGNAL_RAW_PIXELS_T; |
272 | |
273 | /** Signals a new image buffer */ |
274 | typedef struct { |
275 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
276 | WFCNativeStreamType stream; |
277 | |
278 | /**< Descibes the image buffer. |
279 | * image.length initialised to sizeof(WFC_STREAM_IMAGE_T) */ |
280 | WFC_STREAM_IMAGE_T image; |
281 | |
282 | } WFC_IPC_MSG_SS_SIGNAL_IMAGE_T; |
283 | |
284 | /** Register stream as owned by process message */ |
285 | typedef struct { |
286 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
287 | |
288 | WFCNativeStreamType stream; |
289 | uint32_t pid_lo; |
290 | uint32_t pid_hi; |
291 | } WFC_IPC_MSG_SS_REGISTER_T; |
292 | |
293 | /** Unregister stream as owned by process message */ |
294 | typedef struct { |
295 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
296 | |
297 | WFCNativeStreamType stream; |
298 | uint32_t pid_lo; |
299 | uint32_t pid_hi; |
300 | } WFC_IPC_MSG_SS_UNREGISTER_T; |
301 | |
302 | typedef struct { |
303 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
304 | |
305 | uint32_t result; |
306 | WFC_STREAM_INFO_T info; |
307 | } WFC_IPC_MSG_SS_GET_INFO_T; |
308 | |
309 | /** Set stream image available callback message */ |
310 | typedef struct { |
311 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
312 | |
313 | WFCNativeStreamType stream; |
314 | WFC_IPC_CALLBACK_T image_available_cb; /**< Opaque client function pointer */ |
315 | WFC_IPC_VOID_PTR_T image_available_data; /**< Opaque client data */ |
316 | } WFC_IPC_MSG_SS_ON_IMAGE_AVAILABLE_T; |
317 | |
318 | |
319 | /** All messages sent between the client and server must be represented in |
320 | * this union. |
321 | */ |
322 | typedef union |
323 | { |
324 | WFC_IPC_MSG_HEADER_T ; /**< All messages start with a header */ |
325 | |
326 | WFC_IPC_MSG_UINT32_T u32_msg; |
327 | WFC_IPC_MSG_CONTEXT_T context; |
328 | WFC_IPC_MSG_STREAM_T stream; |
329 | WFC_IPC_MSG_CREATE_CONTEXT_T create_context; |
330 | WFC_IPC_MSG_COMMIT_SCENE_T commit_scene; |
331 | WFC_IPC_MSG_SET_DEFERRAL_STREAM_T set_deferral_stream; |
332 | WFC_IPC_MSG_SS_CREATE_T ss_create; |
333 | WFC_IPC_MSG_SS_CREATE_INFO_T ss_create_info; |
334 | WFC_IPC_MSG_SS_DESTROY_T ss_destroy; |
335 | WFC_IPC_MSG_SS_ON_RECTS_CHANGE_T ss_on_rects_change; |
336 | WFC_IPC_MSG_SS_ALLOCATE_IMAGES_T ss_allocate_images; |
337 | WFC_IPC_MSG_SS_SIGNAL_EGLIMAGE_DATA_T ss_signal_eglimage_data; |
338 | WFC_IPC_MSG_SS_SIGNAL_MM_IMAGE_DATA_T ss_signal_mm_image_data; |
339 | WFC_IPC_MSG_SS_SIGNAL_RAW_PIXELS_T ss_signal_raw_image_data; |
340 | WFC_IPC_MSG_SS_REGISTER_T ss_register; |
341 | WFC_IPC_MSG_SS_UNREGISTER_T ss_unregister; |
342 | WFC_IPC_MSG_SS_ON_IMAGE_AVAILABLE_T ss_on_image_available; |
343 | WFC_IPC_MSG_GET_VERSION_T get_version; |
344 | WFC_IPC_MSG_SS_GET_RECTS_T ss_get_rects; |
345 | WFC_IPC_MSG_SS_SIGNAL_IMAGE_T ss_signal_image; |
346 | } WFC_IPC_MSG_T; |
347 | |
348 | #define WFC_IPC_MSG_MAGIC VCHIQ_MAKE_FOURCC('W', 'F', 'C', 'm') |
349 | |
350 | #endif /* WFC_IPC_H */ |
351 | |