diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile_Ecore_Wl2.am | 2 | ||||
-rw-r--r-- | src/lib/ecore_wl2/linux-dmabuf-unstable-v1-client-protocol.h | 536 | ||||
-rw-r--r-- | src/lib/ecore_wl2/linux-dmabuf-unstable-v1-protocol.c | 75 | ||||
-rw-r--r-- | src/lib/ecore_wl2/linux-dmabuf-unstable-v1-server-protocol.h | 448 |
4 files changed, 1061 insertions, 0 deletions
diff --git a/src/Makefile_Ecore_Wl2.am b/src/Makefile_Ecore_Wl2.am index 1263ea2..80aabb6 100644 --- a/src/Makefile_Ecore_Wl2.am +++ b/src/Makefile_Ecore_Wl2.am | |||
@@ -14,6 +14,8 @@ lib/ecore_wl2/xdg-shell-client-protocol.h \ | |||
14 | lib/ecore_wl2/xdg-shell-protocol.c \ | 14 | lib/ecore_wl2/xdg-shell-protocol.c \ |
15 | lib/ecore_wl2/www-protocol.h \ | 15 | lib/ecore_wl2/www-protocol.h \ |
16 | lib/ecore_wl2/www-protocol.c \ | 16 | lib/ecore_wl2/www-protocol.c \ |
17 | lib/ecore_wl2/linux-dmabuf-unstable-v1-protocol.c \ | ||
18 | lib/ecore_wl2/linux-dmabuf-unstable-v1-client-protocol.h \ | ||
17 | lib/ecore_wl2/ecore_wl2_seat.c \ | 19 | lib/ecore_wl2/ecore_wl2_seat.c \ |
18 | lib/ecore_wl2/ecore_wl2_subsurf.c \ | 20 | lib/ecore_wl2/ecore_wl2_subsurf.c \ |
19 | lib/ecore_wl2/ecore_wl2_dnd.c \ | 21 | lib/ecore_wl2/ecore_wl2_dnd.c \ |
diff --git a/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-client-protocol.h b/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-client-protocol.h new file mode 100644 index 0000000..f96f26e --- /dev/null +++ b/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-client-protocol.h | |||
@@ -0,0 +1,536 @@ | |||
1 | #ifndef LINUX_DMABUF_UNSTABLE_V1_CLIENT_PROTOCOL_H | ||
2 | #define LINUX_DMABUF_UNSTABLE_V1_CLIENT_PROTOCOL_H | ||
3 | |||
4 | #ifdef __cplusplus | ||
5 | extern "C" { | ||
6 | #endif | ||
7 | |||
8 | #include <stdint.h> | ||
9 | #include <stddef.h> | ||
10 | #include "wayland-client.h" | ||
11 | |||
12 | struct wl_client; | ||
13 | struct wl_resource; | ||
14 | |||
15 | /** | ||
16 | * @page page_linux_dmabuf_unstable_v1 The linux_dmabuf_unstable_v1 protocol | ||
17 | * @section page_ifaces_linux_dmabuf_unstable_v1 Interfaces | ||
18 | * - @subpage page_iface_zwp_linux_dmabuf_v1 - factory for creating dmabuf-based wl_buffers | ||
19 | * - @subpage page_iface_zwp_linux_buffer_params_v1 - parameters for creating a dmabuf-based wl_buffer | ||
20 | * @section page_copyright_linux_dmabuf_unstable_v1 Copyright | ||
21 | * <pre> | ||
22 | * | ||
23 | * Copyright © 2014, 2015 Collabora, Ltd. | ||
24 | * | ||
25 | * Permission to use, copy, modify, distribute, and sell this | ||
26 | * software and its documentation for any purpose is hereby granted | ||
27 | * without fee, provided that the above copyright notice appear in | ||
28 | * all copies and that both that copyright notice and this permission | ||
29 | * notice appear in supporting documentation, and that the name of | ||
30 | * the copyright holders not be used in advertising or publicity | ||
31 | * pertaining to distribution of the software without specific, | ||
32 | * written prior permission. The copyright holders make no | ||
33 | * representations about the suitability of this software for any | ||
34 | * purpose. It is provided "as is" without express or implied | ||
35 | * warranty. | ||
36 | * | ||
37 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS | ||
38 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
39 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
40 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
41 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN | ||
42 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | ||
43 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
44 | * THIS SOFTWARE. | ||
45 | * </pre> | ||
46 | */ | ||
47 | struct wl_buffer; | ||
48 | struct zwp_linux_buffer_params_v1; | ||
49 | struct zwp_linux_dmabuf_v1; | ||
50 | |||
51 | /** | ||
52 | * @page page_iface_zwp_linux_dmabuf_v1 zwp_linux_dmabuf_v1 | ||
53 | * @section page_iface_zwp_linux_dmabuf_v1_desc Description | ||
54 | * | ||
55 | * Following the interfaces from: | ||
56 | * https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt | ||
57 | * and the Linux DRM sub-system's AddFb2 ioctl. | ||
58 | * | ||
59 | * This interface offers a way to create generic dmabuf-based | ||
60 | * wl_buffers. Immediately after a client binds to this interface, | ||
61 | * the set of supported formats is sent with 'format' events. | ||
62 | * | ||
63 | * The following are required from clients: | ||
64 | * | ||
65 | * - Clients must ensure that either all data in the dma-buf is | ||
66 | * coherent for all subsequent read access or that coherency is | ||
67 | * correctly handled by the underlying kernel-side dma-buf | ||
68 | * implementation. | ||
69 | * | ||
70 | * - Don't make any more attachments after sending the buffer to the | ||
71 | * compositor. Making more attachments later increases the risk of | ||
72 | * the compositor not being able to use (re-import) an existing | ||
73 | * dmabuf-based wl_buffer. | ||
74 | * | ||
75 | * The underlying graphics stack must ensure the following: | ||
76 | * | ||
77 | * - The dmabuf file descriptors relayed to the server will stay valid | ||
78 | * for the whole lifetime of the wl_buffer. This means the server may | ||
79 | * at any time use those fds to import the dmabuf into any kernel | ||
80 | * sub-system that might accept it. | ||
81 | * | ||
82 | * To create a wl_buffer from one or more dmabufs, a client creates a | ||
83 | * zwp_linux_dmabuf_params_v1 object with zwp_linux_dmabuf_v1.create_params | ||
84 | * request. All planes required by the intended format are added with | ||
85 | * the 'add' request. Finally, 'create' request is issued. The server | ||
86 | * will reply with either 'created' event which provides the final | ||
87 | * wl_buffer or 'failed' event saying that it cannot use the dmabufs | ||
88 | * provided. | ||
89 | * | ||
90 | * Warning! The protocol described in this file is experimental and | ||
91 | * backward incompatible changes may be made. Backward compatible changes | ||
92 | * may be added together with the corresponding interface version bump. | ||
93 | * Backward incompatible changes are done by bumping the version number in | ||
94 | * the protocol and interface names and resetting the interface version. | ||
95 | * Once the protocol is to be declared stable, the 'z' prefix and the | ||
96 | * version number in the protocol and interface names are removed and the | ||
97 | * interface version number is reset. | ||
98 | * @section page_iface_zwp_linux_dmabuf_v1_api API | ||
99 | * See @ref iface_zwp_linux_dmabuf_v1. | ||
100 | */ | ||
101 | /** | ||
102 | * @defgroup iface_zwp_linux_dmabuf_v1 The zwp_linux_dmabuf_v1 interface | ||
103 | * | ||
104 | * Following the interfaces from: | ||
105 | * https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt | ||
106 | * and the Linux DRM sub-system's AddFb2 ioctl. | ||
107 | * | ||
108 | * This interface offers a way to create generic dmabuf-based | ||
109 | * wl_buffers. Immediately after a client binds to this interface, | ||
110 | * the set of supported formats is sent with 'format' events. | ||
111 | * | ||
112 | * The following are required from clients: | ||
113 | * | ||
114 | * - Clients must ensure that either all data in the dma-buf is | ||
115 | * coherent for all subsequent read access or that coherency is | ||
116 | * correctly handled by the underlying kernel-side dma-buf | ||
117 | * implementation. | ||
118 | * | ||
119 | * - Don't make any more attachments after sending the buffer to the | ||
120 | * compositor. Making more attachments later increases the risk of | ||
121 | * the compositor not being able to use (re-import) an existing | ||
122 | * dmabuf-based wl_buffer. | ||
123 | * | ||
124 | * The underlying graphics stack must ensure the following: | ||
125 | * | ||
126 | * - The dmabuf file descriptors relayed to the server will stay valid | ||
127 | * for the whole lifetime of the wl_buffer. This means the server may | ||
128 | * at any time use those fds to import the dmabuf into any kernel | ||
129 | * sub-system that might accept it. | ||
130 | * | ||
131 | * To create a wl_buffer from one or more dmabufs, a client creates a | ||
132 | * zwp_linux_dmabuf_params_v1 object with zwp_linux_dmabuf_v1.create_params | ||
133 | * request. All planes required by the intended format are added with | ||
134 | * the 'add' request. Finally, 'create' request is issued. The server | ||
135 | * will reply with either 'created' event which provides the final | ||
136 | * wl_buffer or 'failed' event saying that it cannot use the dmabufs | ||
137 | * provided. | ||
138 | * | ||
139 | * Warning! The protocol described in this file is experimental and | ||
140 | * backward incompatible changes may be made. Backward compatible changes | ||
141 | * may be added together with the corresponding interface version bump. | ||
142 | * Backward incompatible changes are done by bumping the version number in | ||
143 | * the protocol and interface names and resetting the interface version. | ||
144 | * Once the protocol is to be declared stable, the 'z' prefix and the | ||
145 | * version number in the protocol and interface names are removed and the | ||
146 | * interface version number is reset. | ||
147 | */ | ||
148 | extern const struct wl_interface zwp_linux_dmabuf_v1_interface; | ||
149 | /** | ||
150 | * @page page_iface_zwp_linux_buffer_params_v1 zwp_linux_buffer_params_v1 | ||
151 | * @section page_iface_zwp_linux_buffer_params_v1_desc Description | ||
152 | * | ||
153 | * This temporary object is a collection of dmabufs and other | ||
154 | * parameters that together form a single logical buffer. The temporary | ||
155 | * object may eventually create one wl_buffer unless cancelled by | ||
156 | * destroying it before requesting 'create'. | ||
157 | * | ||
158 | * Single-planar formats only require one dmabuf, however | ||
159 | * multi-planar formats may require more than one dmabuf. For all | ||
160 | * formats, 'add' request must be called once per plane (even if the | ||
161 | * underlying dmabuf fd is identical). | ||
162 | * | ||
163 | * You must use consecutive plane indices ('plane_idx' argument for 'add') | ||
164 | * from zero to the number of planes used by the drm_fourcc format code. | ||
165 | * All planes required by the format must be given exactly once, but can | ||
166 | * be given in any order. Each plane index can be set only once. | ||
167 | * @section page_iface_zwp_linux_buffer_params_v1_api API | ||
168 | * See @ref iface_zwp_linux_buffer_params_v1. | ||
169 | */ | ||
170 | /** | ||
171 | * @defgroup iface_zwp_linux_buffer_params_v1 The zwp_linux_buffer_params_v1 interface | ||
172 | * | ||
173 | * This temporary object is a collection of dmabufs and other | ||
174 | * parameters that together form a single logical buffer. The temporary | ||
175 | * object may eventually create one wl_buffer unless cancelled by | ||
176 | * destroying it before requesting 'create'. | ||
177 | * | ||
178 | * Single-planar formats only require one dmabuf, however | ||
179 | * multi-planar formats may require more than one dmabuf. For all | ||
180 | * formats, 'add' request must be called once per plane (even if the | ||
181 | * underlying dmabuf fd is identical). | ||
182 | * | ||
183 | * You must use consecutive plane indices ('plane_idx' argument for 'add') | ||
184 | * from zero to the number of planes used by the drm_fourcc format code. | ||
185 | * All planes required by the format must be given exactly once, but can | ||
186 | * be given in any order. Each plane index can be set only once. | ||
187 | */ | ||
188 | extern const struct wl_interface zwp_linux_buffer_params_v1_interface; | ||
189 | |||
190 | /** | ||
191 | * @ingroup iface_zwp_linux_dmabuf_v1 | ||
192 | * @struct zwp_linux_dmabuf_v1_listener | ||
193 | */ | ||
194 | struct zwp_linux_dmabuf_v1_listener { | ||
195 | /** | ||
196 | * supported buffer format | ||
197 | * | ||
198 | * This event advertises one buffer format that the server | ||
199 | * supports. All the supported formats are advertised once when the | ||
200 | * client binds to this interface. A roundtrip after binding | ||
201 | * guarantees, that the client has received all supported formats. | ||
202 | * | ||
203 | * For the definition of the format codes, see create request. | ||
204 | * | ||
205 | * XXX: Can a compositor ever enumerate them? | ||
206 | * @param format DRM_FORMAT code | ||
207 | */ | ||
208 | void (*format)(void *data, | ||
209 | struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1, | ||
210 | uint32_t format); | ||
211 | }; | ||
212 | |||
213 | /** | ||
214 | * @ingroup zwp_linux_dmabuf_v1_iface | ||
215 | */ | ||
216 | static inline int | ||
217 | zwp_linux_dmabuf_v1_add_listener(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1, | ||
218 | const struct zwp_linux_dmabuf_v1_listener *listener, void *data) | ||
219 | { | ||
220 | return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_dmabuf_v1, | ||
221 | (void (**)(void)) listener, data); | ||
222 | } | ||
223 | |||
224 | #define ZWP_LINUX_DMABUF_V1_DESTROY 0 | ||
225 | #define ZWP_LINUX_DMABUF_V1_CREATE_PARAMS 1 | ||
226 | |||
227 | /** | ||
228 | * @ingroup iface_zwp_linux_dmabuf_v1 | ||
229 | */ | ||
230 | #define ZWP_LINUX_DMABUF_V1_DESTROY_SINCE_VERSION 1 | ||
231 | /** | ||
232 | * @ingroup iface_zwp_linux_dmabuf_v1 | ||
233 | */ | ||
234 | #define ZWP_LINUX_DMABUF_V1_CREATE_PARAMS_SINCE_VERSION 1 | ||
235 | |||
236 | /** @ingroup iface_zwp_linux_dmabuf_v1 */ | ||
237 | static inline void | ||
238 | zwp_linux_dmabuf_v1_set_user_data(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1, void *user_data) | ||
239 | { | ||
240 | wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_dmabuf_v1, user_data); | ||
241 | } | ||
242 | |||
243 | /** @ingroup iface_zwp_linux_dmabuf_v1 */ | ||
244 | static inline void * | ||
245 | zwp_linux_dmabuf_v1_get_user_data(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1) | ||
246 | { | ||
247 | return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_dmabuf_v1); | ||
248 | } | ||
249 | |||
250 | static inline uint32_t | ||
251 | zwp_linux_dmabuf_v1_get_version(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1) | ||
252 | { | ||
253 | return wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_v1); | ||
254 | } | ||
255 | |||
256 | /** | ||
257 | * @ingroup iface_zwp_linux_dmabuf_v1 | ||
258 | * | ||
259 | * Objects created through this interface, especially wl_buffers, will | ||
260 | * remain valid. | ||
261 | */ | ||
262 | static inline void | ||
263 | zwp_linux_dmabuf_v1_destroy(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1) | ||
264 | { | ||
265 | wl_proxy_marshal((struct wl_proxy *) zwp_linux_dmabuf_v1, | ||
266 | ZWP_LINUX_DMABUF_V1_DESTROY); | ||
267 | |||
268 | wl_proxy_destroy((struct wl_proxy *) zwp_linux_dmabuf_v1); | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * @ingroup iface_zwp_linux_dmabuf_v1 | ||
273 | * | ||
274 | * This temporary object is used to collect multiple dmabuf handles into | ||
275 | * a single batch to create a wl_buffer. It can only be used once and | ||
276 | * should be destroyed after an 'created' or 'failed' event has been | ||
277 | * received. | ||
278 | */ | ||
279 | static inline struct zwp_linux_buffer_params_v1 * | ||
280 | zwp_linux_dmabuf_v1_create_params(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1) | ||
281 | { | ||
282 | struct wl_proxy *params_id; | ||
283 | |||
284 | params_id = wl_proxy_marshal_constructor((struct wl_proxy *) zwp_linux_dmabuf_v1, | ||
285 | ZWP_LINUX_DMABUF_V1_CREATE_PARAMS, &zwp_linux_buffer_params_v1_interface, NULL); | ||
286 | |||
287 | return (struct zwp_linux_buffer_params_v1 *) params_id; | ||
288 | } | ||
289 | |||
290 | #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM | ||
291 | #define ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM | ||
292 | enum zwp_linux_buffer_params_v1_error { | ||
293 | /** | ||
294 | * the dmabuf_batch object has already been used to create a wl_buffer | ||
295 | */ | ||
296 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED = 0, | ||
297 | /** | ||
298 | * plane index out of bounds | ||
299 | */ | ||
300 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX = 1, | ||
301 | /** | ||
302 | * the plane index was already set | ||
303 | */ | ||
304 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET = 2, | ||
305 | /** | ||
306 | * missing or too many planes to create a buffer | ||
307 | */ | ||
308 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE = 3, | ||
309 | /** | ||
310 | * format not supported | ||
311 | */ | ||
312 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT = 4, | ||
313 | /** | ||
314 | * invalid width or height | ||
315 | */ | ||
316 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS = 5, | ||
317 | /** | ||
318 | * offset + stride * height goes out of dmabuf bounds | ||
319 | */ | ||
320 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS = 6, | ||
321 | }; | ||
322 | #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM */ | ||
323 | |||
324 | #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM | ||
325 | #define ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM | ||
326 | enum zwp_linux_buffer_params_v1_flags { | ||
327 | /** | ||
328 | * contents are y-inverted | ||
329 | */ | ||
330 | ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT = 1, | ||
331 | /** | ||
332 | * content is interlaced | ||
333 | */ | ||
334 | ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED = 2, | ||
335 | /** | ||
336 | * bottom field first | ||
337 | */ | ||
338 | ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST = 4, | ||
339 | }; | ||
340 | #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM */ | ||
341 | |||
342 | /** | ||
343 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
344 | * @struct zwp_linux_buffer_params_v1_listener | ||
345 | */ | ||
346 | struct zwp_linux_buffer_params_v1_listener { | ||
347 | /** | ||
348 | * buffer creation succeeded | ||
349 | * | ||
350 | * This event indicates that the attempted buffer creation was | ||
351 | * successful. It provides the new wl_buffer referencing the | ||
352 | * dmabuf(s). | ||
353 | * | ||
354 | * Upon receiving this event, the client should destroy the | ||
355 | * zlinux_dmabuf_params object. | ||
356 | * @param buffer the newly created wl_buffer | ||
357 | */ | ||
358 | void (*created)(void *data, | ||
359 | struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, | ||
360 | struct wl_buffer *buffer); | ||
361 | /** | ||
362 | * buffer creation failed | ||
363 | * | ||
364 | * This event indicates that the attempted buffer creation has | ||
365 | * failed. It usually means that one of the dmabuf constraints has | ||
366 | * not been fulfilled. | ||
367 | * | ||
368 | * Upon receiving this event, the client should destroy the | ||
369 | * zlinux_buffer_params object. | ||
370 | */ | ||
371 | void (*failed)(void *data, | ||
372 | struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1); | ||
373 | }; | ||
374 | |||
375 | /** | ||
376 | * @ingroup zwp_linux_buffer_params_v1_iface | ||
377 | */ | ||
378 | static inline int | ||
379 | zwp_linux_buffer_params_v1_add_listener(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, | ||
380 | const struct zwp_linux_buffer_params_v1_listener *listener, void *data) | ||
381 | { | ||
382 | return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_buffer_params_v1, | ||
383 | (void (**)(void)) listener, data); | ||
384 | } | ||
385 | |||
386 | #define ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY 0 | ||
387 | #define ZWP_LINUX_BUFFER_PARAMS_V1_ADD 1 | ||
388 | #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE 2 | ||
389 | |||
390 | /** | ||
391 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
392 | */ | ||
393 | #define ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY_SINCE_VERSION 1 | ||
394 | /** | ||
395 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
396 | */ | ||
397 | #define ZWP_LINUX_BUFFER_PARAMS_V1_ADD_SINCE_VERSION 1 | ||
398 | /** | ||
399 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
400 | */ | ||
401 | #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_SINCE_VERSION 1 | ||
402 | |||
403 | /** @ingroup iface_zwp_linux_buffer_params_v1 */ | ||
404 | static inline void | ||
405 | zwp_linux_buffer_params_v1_set_user_data(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, void *user_data) | ||
406 | { | ||
407 | wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_buffer_params_v1, user_data); | ||
408 | } | ||
409 | |||
410 | /** @ingroup iface_zwp_linux_buffer_params_v1 */ | ||
411 | static inline void * | ||
412 | zwp_linux_buffer_params_v1_get_user_data(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1) | ||
413 | { | ||
414 | return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_buffer_params_v1); | ||
415 | } | ||
416 | |||
417 | static inline uint32_t | ||
418 | zwp_linux_buffer_params_v1_get_version(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1) | ||
419 | { | ||
420 | return wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1); | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
425 | * | ||
426 | * Cleans up the temporary data sent to the server for dmabuf-based | ||
427 | * wl_buffer creation. | ||
428 | */ | ||
429 | static inline void | ||
430 | zwp_linux_buffer_params_v1_destroy(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1) | ||
431 | { | ||
432 | wl_proxy_marshal((struct wl_proxy *) zwp_linux_buffer_params_v1, | ||
433 | ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY); | ||
434 | |||
435 | wl_proxy_destroy((struct wl_proxy *) zwp_linux_buffer_params_v1); | ||
436 | } | ||
437 | |||
438 | /** | ||
439 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
440 | * | ||
441 | * This request adds one dmabuf to the set in this | ||
442 | * zwp_linux_buffer_params_v1. | ||
443 | * | ||
444 | * The 64-bit unsigned value combined from modifier_hi and modifier_lo | ||
445 | * is the dmabuf layout modifier. DRM AddFB2 ioctl calls this the | ||
446 | * fb modifier, which is defined in drm_mode.h of Linux UAPI. | ||
447 | * This is an opaque token. Drivers use this token to express tiling, | ||
448 | * compression, etc. driver-specific modifications to the base format | ||
449 | * defined by the DRM fourcc code. | ||
450 | * | ||
451 | * This request raises the PLANE_IDX error if plane_idx is too large. | ||
452 | * The error PLANE_SET is raised if attempting to set a plane that | ||
453 | * was already set. | ||
454 | */ | ||
455 | static inline void | ||
456 | zwp_linux_buffer_params_v1_add(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, int32_t fd, uint32_t plane_idx, uint32_t offset, uint32_t stride, uint32_t modifier_hi, uint32_t modifier_lo) | ||
457 | { | ||
458 | wl_proxy_marshal((struct wl_proxy *) zwp_linux_buffer_params_v1, | ||
459 | ZWP_LINUX_BUFFER_PARAMS_V1_ADD, fd, plane_idx, offset, stride, modifier_hi, modifier_lo); | ||
460 | } | ||
461 | |||
462 | /** | ||
463 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
464 | * | ||
465 | * This asks for creation of a wl_buffer from the added dmabuf | ||
466 | * buffers. The wl_buffer is not created immediately but returned via | ||
467 | * the 'created' event if the dmabuf sharing succeeds. The sharing | ||
468 | * may fail at runtime for reasons a client cannot predict, in | ||
469 | * which case the 'failed' event is triggered. | ||
470 | * | ||
471 | * The 'format' argument is a DRM_FORMAT code, as defined by the | ||
472 | * libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the | ||
473 | * authoritative source on how the format codes should work. | ||
474 | * | ||
475 | * The 'flags' is a bitfield of the flags defined in enum "flags". | ||
476 | * 'y_invert' means the that the image needs to be y-flipped. | ||
477 | * | ||
478 | * Flag 'interlaced' means that the frame in the buffer is not | ||
479 | * progressive as usual, but interlaced. An interlaced buffer as | ||
480 | * supported here must always contain both top and bottom fields. | ||
481 | * The top field always begins on the first pixel row. The temporal | ||
482 | * ordering between the two fields is top field first, unless | ||
483 | * 'bottom_first' is specified. It is undefined whether 'bottom_first' | ||
484 | * is ignored if 'interlaced' is not set. | ||
485 | * | ||
486 | * This protocol does not convey any information about field rate, | ||
487 | * duration, or timing, other than the relative ordering between the | ||
488 | * two fields in one buffer. A compositor may have to estimate the | ||
489 | * intended field rate from the incoming buffer rate. It is undefined | ||
490 | * whether the time of receiving wl_surface.commit with a new buffer | ||
491 | * attached, applying the wl_surface state, wl_surface.frame callback | ||
492 | * trigger, presentation, or any other point in the compositor cycle | ||
493 | * is used to measure the frame or field times. There is no support | ||
494 | * for detecting missed or late frames/fields/buffers either, and | ||
495 | * there is no support whatsoever for cooperating with interlaced | ||
496 | * compositor output. | ||
497 | * | ||
498 | * The composited image quality resulting from the use of interlaced | ||
499 | * buffers is explicitly undefined. A compositor may use elaborate | ||
500 | * hardware features or software to deinterlace and create progressive | ||
501 | * output frames from a sequence of interlaced input buffers, or it | ||
502 | * may produce substandard image quality. However, compositors that | ||
503 | * cannot guarantee reasonable image quality in all cases are recommended | ||
504 | * to just reject all interlaced buffers. | ||
505 | * | ||
506 | * Any argument errors, including non-positive width or height, | ||
507 | * mismatch between the number of planes and the format, bad | ||
508 | * format, bad offset or stride, may be indicated by fatal protocol | ||
509 | * errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, | ||
510 | * OUT_OF_BOUNDS. | ||
511 | * | ||
512 | * Dmabuf import errors in the server that are not obvious client | ||
513 | * bugs are returned via the 'failed' event as non-fatal. This | ||
514 | * allows attempting dmabuf sharing and falling back in the client | ||
515 | * if it fails. | ||
516 | * | ||
517 | * This request can be sent only once in the object's lifetime, after | ||
518 | * which the only legal request is destroy. This object should be | ||
519 | * destroyed after issuing 'create' request. Attempting to use this | ||
520 | * object after issuing 'create' raises ALREADY_USED protocol error. | ||
521 | * | ||
522 | * It is not mandatory to issue 'create'. If a client wants to | ||
523 | * cancel the buffer creation, it can just destroy this object. | ||
524 | */ | ||
525 | static inline void | ||
526 | zwp_linux_buffer_params_v1_create(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, int32_t width, int32_t height, uint32_t format, uint32_t flags) | ||
527 | { | ||
528 | wl_proxy_marshal((struct wl_proxy *) zwp_linux_buffer_params_v1, | ||
529 | ZWP_LINUX_BUFFER_PARAMS_V1_CREATE, width, height, format, flags); | ||
530 | } | ||
531 | |||
532 | #ifdef __cplusplus | ||
533 | } | ||
534 | #endif | ||
535 | |||
536 | #endif | ||
diff --git a/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-protocol.c b/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-protocol.c new file mode 100644 index 0000000..a4c929a --- /dev/null +++ b/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-protocol.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * Copyright © 2014, 2015 Collabora, Ltd. | ||
3 | * | ||
4 | * Permission to use, copy, modify, distribute, and sell this | ||
5 | * software and its documentation for any purpose is hereby granted | ||
6 | * without fee, provided that the above copyright notice appear in | ||
7 | * all copies and that both that copyright notice and this permission | ||
8 | * notice appear in supporting documentation, and that the name of | ||
9 | * the copyright holders not be used in advertising or publicity | ||
10 | * pertaining to distribution of the software without specific, | ||
11 | * written prior permission. The copyright holders make no | ||
12 | * representations about the suitability of this software for any | ||
13 | * purpose. It is provided "as is" without express or implied | ||
14 | * warranty. | ||
15 | * | ||
16 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS | ||
17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
18 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
19 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
20 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN | ||
21 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | ||
22 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
23 | * THIS SOFTWARE. | ||
24 | */ | ||
25 | |||
26 | #include <stdlib.h> | ||
27 | #include <stdint.h> | ||
28 | #include "wayland-util.h" | ||
29 | |||
30 | extern const struct wl_interface wl_buffer_interface; | ||
31 | extern const struct wl_interface zwp_linux_buffer_params_v1_interface; | ||
32 | |||
33 | static const struct wl_interface *types[] = { | ||
34 | NULL, | ||
35 | NULL, | ||
36 | NULL, | ||
37 | NULL, | ||
38 | NULL, | ||
39 | NULL, | ||
40 | &zwp_linux_buffer_params_v1_interface, | ||
41 | &wl_buffer_interface, | ||
42 | }; | ||
43 | |||
44 | static const struct wl_message zwp_linux_dmabuf_v1_requests[] = { | ||
45 | { "destroy", "", types + 0 }, | ||
46 | { "create_params", "n", types + 6 }, | ||
47 | }; | ||
48 | |||
49 | static const struct wl_message zwp_linux_dmabuf_v1_events[] = { | ||
50 | { "format", "u", types + 0 }, | ||
51 | }; | ||
52 | |||
53 | WL_EXPORT const struct wl_interface zwp_linux_dmabuf_v1_interface = { | ||
54 | "zwp_linux_dmabuf_v1", 1, | ||
55 | 2, zwp_linux_dmabuf_v1_requests, | ||
56 | 1, zwp_linux_dmabuf_v1_events, | ||
57 | }; | ||
58 | |||
59 | static const struct wl_message zwp_linux_buffer_params_v1_requests[] = { | ||
60 | { "destroy", "", types + 0 }, | ||
61 | { "add", "huuuuu", types + 0 }, | ||
62 | { "create", "iiuu", types + 0 }, | ||
63 | }; | ||
64 | |||
65 | static const struct wl_message zwp_linux_buffer_params_v1_events[] = { | ||
66 | { "created", "n", types + 7 }, | ||
67 | { "failed", "", types + 0 }, | ||
68 | }; | ||
69 | |||
70 | WL_EXPORT const struct wl_interface zwp_linux_buffer_params_v1_interface = { | ||
71 | "zwp_linux_buffer_params_v1", 1, | ||
72 | 3, zwp_linux_buffer_params_v1_requests, | ||
73 | 2, zwp_linux_buffer_params_v1_events, | ||
74 | }; | ||
75 | |||
diff --git a/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-server-protocol.h b/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-server-protocol.h new file mode 100644 index 0000000..ce1b93d --- /dev/null +++ b/src/lib/ecore_wl2/linux-dmabuf-unstable-v1-server-protocol.h | |||
@@ -0,0 +1,448 @@ | |||
1 | #ifndef LINUX_DMABUF_UNSTABLE_V1_SERVER_PROTOCOL_H | ||
2 | #define LINUX_DMABUF_UNSTABLE_V1_SERVER_PROTOCOL_H | ||
3 | |||
4 | #ifdef __cplusplus | ||
5 | extern "C" { | ||
6 | #endif | ||
7 | |||
8 | #include <stdint.h> | ||
9 | #include <stddef.h> | ||
10 | #include "wayland-server.h" | ||
11 | |||
12 | struct wl_client; | ||
13 | struct wl_resource; | ||
14 | |||
15 | /** | ||
16 | * @page page_linux_dmabuf_unstable_v1 The linux_dmabuf_unstable_v1 protocol | ||
17 | * @section page_ifaces_linux_dmabuf_unstable_v1 Interfaces | ||
18 | * - @subpage page_iface_zwp_linux_dmabuf_v1 - factory for creating dmabuf-based wl_buffers | ||
19 | * - @subpage page_iface_zwp_linux_buffer_params_v1 - parameters for creating a dmabuf-based wl_buffer | ||
20 | * @section page_copyright_linux_dmabuf_unstable_v1 Copyright | ||
21 | * <pre> | ||
22 | * | ||
23 | * Copyright © 2014, 2015 Collabora, Ltd. | ||
24 | * | ||
25 | * Permission to use, copy, modify, distribute, and sell this | ||
26 | * software and its documentation for any purpose is hereby granted | ||
27 | * without fee, provided that the above copyright notice appear in | ||
28 | * all copies and that both that copyright notice and this permission | ||
29 | * notice appear in supporting documentation, and that the name of | ||
30 | * the copyright holders not be used in advertising or publicity | ||
31 | * pertaining to distribution of the software without specific, | ||
32 | * written prior permission. The copyright holders make no | ||
33 | * representations about the suitability of this software for any | ||
34 | * purpose. It is provided "as is" without express or implied | ||
35 | * warranty. | ||
36 | * | ||
37 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS | ||
38 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
39 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
40 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
41 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN | ||
42 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | ||
43 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
44 | * THIS SOFTWARE. | ||
45 | * </pre> | ||
46 | */ | ||
47 | struct wl_buffer; | ||
48 | struct zwp_linux_buffer_params_v1; | ||
49 | struct zwp_linux_dmabuf_v1; | ||
50 | |||
51 | /** | ||
52 | * @page page_iface_zwp_linux_dmabuf_v1 zwp_linux_dmabuf_v1 | ||
53 | * @section page_iface_zwp_linux_dmabuf_v1_desc Description | ||
54 | * | ||
55 | * Following the interfaces from: | ||
56 | * https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt | ||
57 | * and the Linux DRM sub-system's AddFb2 ioctl. | ||
58 | * | ||
59 | * This interface offers a way to create generic dmabuf-based | ||
60 | * wl_buffers. Immediately after a client binds to this interface, | ||
61 | * the set of supported formats is sent with 'format' events. | ||
62 | * | ||
63 | * The following are required from clients: | ||
64 | * | ||
65 | * - Clients must ensure that either all data in the dma-buf is | ||
66 | * coherent for all subsequent read access or that coherency is | ||
67 | * correctly handled by the underlying kernel-side dma-buf | ||
68 | * implementation. | ||
69 | * | ||
70 | * - Don't make any more attachments after sending the buffer to the | ||
71 | * compositor. Making more attachments later increases the risk of | ||
72 | * the compositor not being able to use (re-import) an existing | ||
73 | * dmabuf-based wl_buffer. | ||
74 | * | ||
75 | * The underlying graphics stack must ensure the following: | ||
76 | * | ||
77 | * - The dmabuf file descriptors relayed to the server will stay valid | ||
78 | * for the whole lifetime of the wl_buffer. This means the server may | ||
79 | * at any time use those fds to import the dmabuf into any kernel | ||
80 | * sub-system that might accept it. | ||
81 | * | ||
82 | * To create a wl_buffer from one or more dmabufs, a client creates a | ||
83 | * zwp_linux_dmabuf_params_v1 object with zwp_linux_dmabuf_v1.create_params | ||
84 | * request. All planes required by the intended format are added with | ||
85 | * the 'add' request. Finally, 'create' request is issued. The server | ||
86 | * will reply with either 'created' event which provides the final | ||
87 | * wl_buffer or 'failed' event saying that it cannot use the dmabufs | ||
88 | * provided. | ||
89 | * | ||
90 | * Warning! The protocol described in this file is experimental and | ||
91 | * backward incompatible changes may be made. Backward compatible changes | ||
92 | * may be added together with the corresponding interface version bump. | ||
93 | * Backward incompatible changes are done by bumping the version number in | ||
94 | * the protocol and interface names and resetting the interface version. | ||
95 | * Once the protocol is to be declared stable, the 'z' prefix and the | ||
96 | * version number in the protocol and interface names are removed and the | ||
97 | * interface version number is reset. | ||
98 | * @section page_iface_zwp_linux_dmabuf_v1_api API | ||
99 | * See @ref iface_zwp_linux_dmabuf_v1. | ||
100 | */ | ||
101 | /** | ||
102 | * @defgroup iface_zwp_linux_dmabuf_v1 The zwp_linux_dmabuf_v1 interface | ||
103 | * | ||
104 | * Following the interfaces from: | ||
105 | * https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt | ||
106 | * and the Linux DRM sub-system's AddFb2 ioctl. | ||
107 | * | ||
108 | * This interface offers a way to create generic dmabuf-based | ||
109 | * wl_buffers. Immediately after a client binds to this interface, | ||
110 | * the set of supported formats is sent with 'format' events. | ||
111 | * | ||
112 | * The following are required from clients: | ||
113 | * | ||
114 | * - Clients must ensure that either all data in the dma-buf is | ||
115 | * coherent for all subsequent read access or that coherency is | ||
116 | * correctly handled by the underlying kernel-side dma-buf | ||
117 | * implementation. | ||
118 | * | ||
119 | * - Don't make any more attachments after sending the buffer to the | ||
120 | * compositor. Making more attachments later increases the risk of | ||
121 | * the compositor not being able to use (re-import) an existing | ||
122 | * dmabuf-based wl_buffer. | ||
123 | * | ||
124 | * The underlying graphics stack must ensure the following: | ||
125 | * | ||
126 | * - The dmabuf file descriptors relayed to the server will stay valid | ||
127 | * for the whole lifetime of the wl_buffer. This means the server may | ||
128 | * at any time use those fds to import the dmabuf into any kernel | ||
129 | * sub-system that might accept it. | ||
130 | * | ||
131 | * To create a wl_buffer from one or more dmabufs, a client creates a | ||
132 | * zwp_linux_dmabuf_params_v1 object with zwp_linux_dmabuf_v1.create_params | ||
133 | * request. All planes required by the intended format are added with | ||
134 | * the 'add' request. Finally, 'create' request is issued. The server | ||
135 | * will reply with either 'created' event which provides the final | ||
136 | * wl_buffer or 'failed' event saying that it cannot use the dmabufs | ||
137 | * provided. | ||
138 | * | ||
139 | * Warning! The protocol described in this file is experimental and | ||
140 | * backward incompatible changes may be made. Backward compatible changes | ||
141 | * may be added together with the corresponding interface version bump. | ||
142 | * Backward incompatible changes are done by bumping the version number in | ||
143 | * the protocol and interface names and resetting the interface version. | ||
144 | * Once the protocol is to be declared stable, the 'z' prefix and the | ||
145 | * version number in the protocol and interface names are removed and the | ||
146 | * interface version number is reset. | ||
147 | */ | ||
148 | extern const struct wl_interface zwp_linux_dmabuf_v1_interface; | ||
149 | /** | ||
150 | * @page page_iface_zwp_linux_buffer_params_v1 zwp_linux_buffer_params_v1 | ||
151 | * @section page_iface_zwp_linux_buffer_params_v1_desc Description | ||
152 | * | ||
153 | * This temporary object is a collection of dmabufs and other | ||
154 | * parameters that together form a single logical buffer. The temporary | ||
155 | * object may eventually create one wl_buffer unless cancelled by | ||
156 | * destroying it before requesting 'create'. | ||
157 | * | ||
158 | * Single-planar formats only require one dmabuf, however | ||
159 | * multi-planar formats may require more than one dmabuf. For all | ||
160 | * formats, 'add' request must be called once per plane (even if the | ||
161 | * underlying dmabuf fd is identical). | ||
162 | * | ||
163 | * You must use consecutive plane indices ('plane_idx' argument for 'add') | ||
164 | * from zero to the number of planes used by the drm_fourcc format code. | ||
165 | * All planes required by the format must be given exactly once, but can | ||
166 | * be given in any order. Each plane index can be set only once. | ||
167 | * @section page_iface_zwp_linux_buffer_params_v1_api API | ||
168 | * See @ref iface_zwp_linux_buffer_params_v1. | ||
169 | */ | ||
170 | /** | ||
171 | * @defgroup iface_zwp_linux_buffer_params_v1 The zwp_linux_buffer_params_v1 interface | ||
172 | * | ||
173 | * This temporary object is a collection of dmabufs and other | ||
174 | * parameters that together form a single logical buffer. The temporary | ||
175 | * object may eventually create one wl_buffer unless cancelled by | ||
176 | * destroying it before requesting 'create'. | ||
177 | * | ||
178 | * Single-planar formats only require one dmabuf, however | ||
179 | * multi-planar formats may require more than one dmabuf. For all | ||
180 | * formats, 'add' request must be called once per plane (even if the | ||
181 | * underlying dmabuf fd is identical). | ||
182 | * | ||
183 | * You must use consecutive plane indices ('plane_idx' argument for 'add') | ||
184 | * from zero to the number of planes used by the drm_fourcc format code. | ||
185 | * All planes required by the format must be given exactly once, but can | ||
186 | * be given in any order. Each plane index can be set only once. | ||
187 | */ | ||
188 | extern const struct wl_interface zwp_linux_buffer_params_v1_interface; | ||
189 | |||
190 | /** | ||
191 | * @ingroup iface_zwp_linux_dmabuf_v1 | ||
192 | * @struct zwp_linux_dmabuf_v1_interface | ||
193 | */ | ||
194 | struct zwp_linux_dmabuf_v1_interface { | ||
195 | /** | ||
196 | * unbind the factory | ||
197 | * | ||
198 | * Objects created through this interface, especially wl_buffers, | ||
199 | * will remain valid. | ||
200 | */ | ||
201 | void (*destroy)(struct wl_client *client, | ||
202 | struct wl_resource *resource); | ||
203 | /** | ||
204 | * create a temporary object for buffer parameters | ||
205 | * | ||
206 | * This temporary object is used to collect multiple dmabuf | ||
207 | * handles into a single batch to create a wl_buffer. It can only | ||
208 | * be used once and should be destroyed after an 'created' or | ||
209 | * 'failed' event has been received. | ||
210 | * @param params_id the new temporary | ||
211 | */ | ||
212 | void (*create_params)(struct wl_client *client, | ||
213 | struct wl_resource *resource, | ||
214 | uint32_t params_id); | ||
215 | }; | ||
216 | |||
217 | #define ZWP_LINUX_DMABUF_V1_FORMAT 0 | ||
218 | |||
219 | /** | ||
220 | * @ingroup iface_zwp_linux_dmabuf_v1 | ||
221 | */ | ||
222 | #define ZWP_LINUX_DMABUF_V1_FORMAT_SINCE_VERSION 1 | ||
223 | |||
224 | /** | ||
225 | * @ingroup iface_zwp_linux_dmabuf_v1 | ||
226 | * Sends an format event to the client owning the resource. | ||
227 | * @param resource_ The client's resource | ||
228 | * @param format DRM_FORMAT code | ||
229 | */ | ||
230 | static inline void | ||
231 | zwp_linux_dmabuf_v1_send_format(struct wl_resource *resource_, uint32_t format) | ||
232 | { | ||
233 | wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_V1_FORMAT, format); | ||
234 | } | ||
235 | |||
236 | #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM | ||
237 | #define ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM | ||
238 | enum zwp_linux_buffer_params_v1_error { | ||
239 | /** | ||
240 | * the dmabuf_batch object has already been used to create a wl_buffer | ||
241 | */ | ||
242 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED = 0, | ||
243 | /** | ||
244 | * plane index out of bounds | ||
245 | */ | ||
246 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX = 1, | ||
247 | /** | ||
248 | * the plane index was already set | ||
249 | */ | ||
250 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET = 2, | ||
251 | /** | ||
252 | * missing or too many planes to create a buffer | ||
253 | */ | ||
254 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE = 3, | ||
255 | /** | ||
256 | * format not supported | ||
257 | */ | ||
258 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT = 4, | ||
259 | /** | ||
260 | * invalid width or height | ||
261 | */ | ||
262 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS = 5, | ||
263 | /** | ||
264 | * offset + stride * height goes out of dmabuf bounds | ||
265 | */ | ||
266 | ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS = 6, | ||
267 | }; | ||
268 | #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM */ | ||
269 | |||
270 | #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM | ||
271 | #define ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM | ||
272 | enum zwp_linux_buffer_params_v1_flags { | ||
273 | /** | ||
274 | * contents are y-inverted | ||
275 | */ | ||
276 | ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT = 1, | ||
277 | /** | ||
278 | * content is interlaced | ||
279 | */ | ||
280 | ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED = 2, | ||
281 | /** | ||
282 | * bottom field first | ||
283 | */ | ||
284 | ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST = 4, | ||
285 | }; | ||
286 | #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM */ | ||
287 | |||
288 | /** | ||
289 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
290 | * @struct zwp_linux_buffer_params_v1_interface | ||
291 | */ | ||
292 | struct zwp_linux_buffer_params_v1_interface { | ||
293 | /** | ||
294 | * delete this object, used or not | ||
295 | * | ||
296 | * Cleans up the temporary data sent to the server for | ||
297 | * dmabuf-based wl_buffer creation. | ||
298 | */ | ||
299 | void (*destroy)(struct wl_client *client, | ||
300 | struct wl_resource *resource); | ||
301 | /** | ||
302 | * add a dmabuf to the temporary set | ||
303 | * | ||
304 | * This request adds one dmabuf to the set in this | ||
305 | * zwp_linux_buffer_params_v1. | ||
306 | * | ||
307 | * The 64-bit unsigned value combined from modifier_hi and | ||
308 | * modifier_lo is the dmabuf layout modifier. DRM AddFB2 ioctl | ||
309 | * calls this the fb modifier, which is defined in drm_mode.h of | ||
310 | * Linux UAPI. This is an opaque token. Drivers use this token to | ||
311 | * express tiling, compression, etc. driver-specific modifications | ||
312 | * to the base format defined by the DRM fourcc code. | ||
313 | * | ||
314 | * This request raises the PLANE_IDX error if plane_idx is too | ||
315 | * large. The error PLANE_SET is raised if attempting to set a | ||
316 | * plane that was already set. | ||
317 | * @param fd dmabuf fd | ||
318 | * @param plane_idx plane index | ||
319 | * @param offset offset in bytes | ||
320 | * @param stride stride in bytes | ||
321 | * @param modifier_hi high 32 bits of layout modifier | ||
322 | * @param modifier_lo low 32 bits of layout modifier | ||
323 | */ | ||
324 | void (*add)(struct wl_client *client, | ||
325 | struct wl_resource *resource, | ||
326 | int32_t fd, | ||
327 | uint32_t plane_idx, | ||
328 | uint32_t offset, | ||
329 | uint32_t stride, | ||
330 | uint32_t modifier_hi, | ||
331 | uint32_t modifier_lo); | ||
332 | /** | ||
333 | * create a wl_buffer from the given dmabufs | ||
334 | * | ||
335 | * This asks for creation of a wl_buffer from the added dmabuf | ||
336 | * buffers. The wl_buffer is not created immediately but returned | ||
337 | * via the 'created' event if the dmabuf sharing succeeds. The | ||
338 | * sharing may fail at runtime for reasons a client cannot predict, | ||
339 | * in which case the 'failed' event is triggered. | ||
340 | * | ||
341 | * The 'format' argument is a DRM_FORMAT code, as defined by the | ||
342 | * libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the | ||
343 | * authoritative source on how the format codes should work. | ||
344 | * | ||
345 | * The 'flags' is a bitfield of the flags defined in enum "flags". | ||
346 | * 'y_invert' means the that the image needs to be y-flipped. | ||
347 | * | ||
348 | * Flag 'interlaced' means that the frame in the buffer is not | ||
349 | * progressive as usual, but interlaced. An interlaced buffer as | ||
350 | * supported here must always contain both top and bottom fields. | ||
351 | * The top field always begins on the first pixel row. The temporal | ||
352 | * ordering between the two fields is top field first, unless | ||
353 | * 'bottom_first' is specified. It is undefined whether | ||
354 | * 'bottom_first' is ignored if 'interlaced' is not set. | ||
355 | * | ||
356 | * This protocol does not convey any information about field rate, | ||
357 | * duration, or timing, other than the relative ordering between | ||
358 | * the two fields in one buffer. A compositor may have to estimate | ||
359 | * the intended field rate from the incoming buffer rate. It is | ||
360 | * undefined whether the time of receiving wl_surface.commit with a | ||
361 | * new buffer attached, applying the wl_surface state, | ||
362 | * wl_surface.frame callback trigger, presentation, or any other | ||
363 | * point in the compositor cycle is used to measure the frame or | ||
364 | * field times. There is no support for detecting missed or late | ||
365 | * frames/fields/buffers either, and there is no support whatsoever | ||
366 | * for cooperating with interlaced compositor output. | ||
367 | * | ||
368 | * The composited image quality resulting from the use of | ||
369 | * interlaced buffers is explicitly undefined. A compositor may use | ||
370 | * elaborate hardware features or software to deinterlace and | ||
371 | * create progressive output frames from a sequence of interlaced | ||
372 | * input buffers, or it may produce substandard image quality. | ||
373 | * However, compositors that cannot guarantee reasonable image | ||
374 | * quality in all cases are recommended to just reject all | ||
375 | * interlaced buffers. | ||
376 | * | ||
377 | * Any argument errors, including non-positive width or height, | ||
378 | * mismatch between the number of planes and the format, bad | ||
379 | * format, bad offset or stride, may be indicated by fatal protocol | ||
380 | * errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, | ||
381 | * OUT_OF_BOUNDS. | ||
382 | * | ||
383 | * Dmabuf import errors in the server that are not obvious client | ||
384 | * bugs are returned via the 'failed' event as non-fatal. This | ||
385 | * allows attempting dmabuf sharing and falling back in the client | ||
386 | * if it fails. | ||
387 | * | ||
388 | * This request can be sent only once in the object's lifetime, | ||
389 | * after which the only legal request is destroy. This object | ||
390 | * should be destroyed after issuing 'create' request. Attempting | ||
391 | * to use this object after issuing 'create' raises ALREADY_USED | ||
392 | * protocol error. | ||
393 | * | ||
394 | * It is not mandatory to issue 'create'. If a client wants to | ||
395 | * cancel the buffer creation, it can just destroy this object. | ||
396 | * @param width base plane width in pixels | ||
397 | * @param height base plane height in pixels | ||
398 | * @param format DRM_FORMAT code | ||
399 | * @param flags see enum flags | ||
400 | */ | ||
401 | void (*create)(struct wl_client *client, | ||
402 | struct wl_resource *resource, | ||
403 | int32_t width, | ||
404 | int32_t height, | ||
405 | uint32_t format, | ||
406 | uint32_t flags); | ||
407 | }; | ||
408 | |||
409 | #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATED 0 | ||
410 | #define ZWP_LINUX_BUFFER_PARAMS_V1_FAILED 1 | ||
411 | |||
412 | /** | ||
413 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
414 | */ | ||
415 | #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATED_SINCE_VERSION 1 | ||
416 | /** | ||
417 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
418 | */ | ||
419 | #define ZWP_LINUX_BUFFER_PARAMS_V1_FAILED_SINCE_VERSION 1 | ||
420 | |||
421 | /** | ||
422 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
423 | * Sends an created event to the client owning the resource. | ||
424 | * @param resource_ The client's resource | ||
425 | * @param buffer the newly created wl_buffer | ||
426 | */ | ||
427 | static inline void | ||
428 | zwp_linux_buffer_params_v1_send_created(struct wl_resource *resource_, struct wl_resource *buffer) | ||
429 | { | ||
430 | wl_resource_post_event(resource_, ZWP_LINUX_BUFFER_PARAMS_V1_CREATED, buffer); | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @ingroup iface_zwp_linux_buffer_params_v1 | ||
435 | * Sends an failed event to the client owning the resource. | ||
436 | * @param resource_ The client's resource | ||
437 | */ | ||
438 | static inline void | ||
439 | zwp_linux_buffer_params_v1_send_failed(struct wl_resource *resource_) | ||
440 | { | ||
441 | wl_resource_post_event(resource_, ZWP_LINUX_BUFFER_PARAMS_V1_FAILED); | ||
442 | } | ||
443 | |||
444 | #ifdef __cplusplus | ||
445 | } | ||
446 | #endif | ||
447 | |||
448 | #endif | ||