1 /* Generated by wayland-scanner 1.22.0 */
2
3 #ifndef LINUX_DMABUF_UNSTABLE_V1_CLIENT_PROTOCOL_H
4 #define LINUX_DMABUF_UNSTABLE_V1_CLIENT_PROTOCOL_H
5
6 #include <stdint.h>
7 #include <stddef.h>
8 #include "wayland-client.h"
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 /**
15 * @page page_linux_dmabuf_unstable_v1 The linux_dmabuf_unstable_v1 protocol
16 * @section page_ifaces_linux_dmabuf_unstable_v1 Interfaces
17 * - @subpage page_iface_zwp_linux_dmabuf_v1 - factory for creating dmabuf-based wl_buffers
18 * - @subpage page_iface_zwp_linux_buffer_params_v1 - parameters for creating a dmabuf-based wl_buffer
19 * @section page_copyright_linux_dmabuf_unstable_v1 Copyright
20 * <pre>
21 *
22 * Copyright © 2014, 2015 Collabora, Ltd.
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the "Software"),
26 * to deal in the Software without restriction, including without limitation
27 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
28 * and/or sell copies of the Software, and to permit persons to whom the
29 * Software is furnished to do so, subject to the following conditions:
30 *
31 * The above copyright notice and this permission notice (including the next
32 * paragraph) shall be included in all copies or substantial portions of the
33 * Software.
34 *
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
40 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
41 * DEALINGS IN THE SOFTWARE.
42 * </pre>
43 */
44 struct wl_buffer;
45 struct zwp_linux_buffer_params_v1;
46 struct zwp_linux_dmabuf_v1;
47
48 #ifndef ZWP_LINUX_DMABUF_V1_INTERFACE
49 #define ZWP_LINUX_DMABUF_V1_INTERFACE
50 /**
51 * @page page_iface_zwp_linux_dmabuf_v1 zwp_linux_dmabuf_v1
52 * @section page_iface_zwp_linux_dmabuf_v1_desc Description
53 *
54 * Following the interfaces from:
55 * https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
56 * https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
57 * and the Linux DRM sub-system's AddFb2 ioctl.
58 *
59 * This interface offers ways to create generic dmabuf-based
60 * wl_buffers. Immediately after a client binds to this interface,
61 * the set of supported formats and format modifiers is sent with
62 * 'format' and 'modifier' events.
63 *
64 * The following are required from clients:
65 *
66 * - Clients must ensure that either all data in the dma-buf is
67 * coherent for all subsequent read access or that coherency is
68 * correctly handled by the underlying kernel-side dma-buf
69 * implementation.
70 *
71 * - Don't make any more attachments after sending the buffer to the
72 * compositor. Making more attachments later increases the risk of
73 * the compositor not being able to use (re-import) an existing
74 * dmabuf-based wl_buffer.
75 *
76 * The underlying graphics stack must ensure the following:
77 *
78 * - The dmabuf file descriptors relayed to the server will stay valid
79 * for the whole lifetime of the wl_buffer. This means the server may
80 * at any time use those fds to import the dmabuf into any kernel
81 * sub-system that might accept it.
82 *
83 * However, when the underlying graphics stack fails to deliver the
84 * promise, because of e.g. a device hot-unplug which raises internal
85 * errors, after the wl_buffer has been successfully created the
86 * compositor must not raise protocol errors to the client when dmabuf
87 * import later fails.
88 *
89 * To create a wl_buffer from one or more dmabufs, a client creates a
90 * zwp_linux_dmabuf_params_v1 object with a zwp_linux_dmabuf_v1.create_params
91 * request. All planes required by the intended format are added with
92 * the 'add' request. Finally, a 'create' or 'create_immed' request is
93 * issued, which has the following outcome depending on the import success.
94 *
95 * The 'create' request,
96 * - on success, triggers a 'created' event which provides the final
97 * wl_buffer to the client.
98 * - on failure, triggers a 'failed' event to convey that the server
99 * cannot use the dmabufs received from the client.
100 *
101 * For the 'create_immed' request,
102 * - on success, the server immediately imports the added dmabufs to
103 * create a wl_buffer. No event is sent from the server in this case.
104 * - on failure, the server can choose to either:
105 * - terminate the client by raising a fatal error.
106 * - mark the wl_buffer as failed, and send a 'failed' event to the
107 * client. If the client uses a failed wl_buffer as an argument to any
108 * request, the behaviour is compositor implementation-defined.
109 *
110 * Warning! The protocol described in this file is experimental and
111 * backward incompatible changes may be made. Backward compatible changes
112 * may be added together with the corresponding interface version bump.
113 * Backward incompatible changes are done by bumping the version number in
114 * the protocol and interface names and resetting the interface version.
115 * Once the protocol is to be declared stable, the 'z' prefix and the
116 * version number in the protocol and interface names are removed and the
117 * interface version number is reset.
118 * @section page_iface_zwp_linux_dmabuf_v1_api API
119 * See @ref iface_zwp_linux_dmabuf_v1.
120 */
121 /**
122 * @defgroup iface_zwp_linux_dmabuf_v1 The zwp_linux_dmabuf_v1 interface
123 *
124 * Following the interfaces from:
125 * https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
126 * https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
127 * and the Linux DRM sub-system's AddFb2 ioctl.
128 *
129 * This interface offers ways to create generic dmabuf-based
130 * wl_buffers. Immediately after a client binds to this interface,
131 * the set of supported formats and format modifiers is sent with
132 * 'format' and 'modifier' events.
133 *
134 * The following are required from clients:
135 *
136 * - Clients must ensure that either all data in the dma-buf is
137 * coherent for all subsequent read access or that coherency is
138 * correctly handled by the underlying kernel-side dma-buf
139 * implementation.
140 *
141 * - Don't make any more attachments after sending the buffer to the
142 * compositor. Making more attachments later increases the risk of
143 * the compositor not being able to use (re-import) an existing
144 * dmabuf-based wl_buffer.
145 *
146 * The underlying graphics stack must ensure the following:
147 *
148 * - The dmabuf file descriptors relayed to the server will stay valid
149 * for the whole lifetime of the wl_buffer. This means the server may
150 * at any time use those fds to import the dmabuf into any kernel
151 * sub-system that might accept it.
152 *
153 * However, when the underlying graphics stack fails to deliver the
154 * promise, because of e.g. a device hot-unplug which raises internal
155 * errors, after the wl_buffer has been successfully created the
156 * compositor must not raise protocol errors to the client when dmabuf
157 * import later fails.
158 *
159 * To create a wl_buffer from one or more dmabufs, a client creates a
160 * zwp_linux_dmabuf_params_v1 object with a zwp_linux_dmabuf_v1.create_params
161 * request. All planes required by the intended format are added with
162 * the 'add' request. Finally, a 'create' or 'create_immed' request is
163 * issued, which has the following outcome depending on the import success.
164 *
165 * The 'create' request,
166 * - on success, triggers a 'created' event which provides the final
167 * wl_buffer to the client.
168 * - on failure, triggers a 'failed' event to convey that the server
169 * cannot use the dmabufs received from the client.
170 *
171 * For the 'create_immed' request,
172 * - on success, the server immediately imports the added dmabufs to
173 * create a wl_buffer. No event is sent from the server in this case.
174 * - on failure, the server can choose to either:
175 * - terminate the client by raising a fatal error.
176 * - mark the wl_buffer as failed, and send a 'failed' event to the
177 * client. If the client uses a failed wl_buffer as an argument to any
178 * request, the behaviour is compositor implementation-defined.
179 *
180 * Warning! The protocol described in this file is experimental and
181 * backward incompatible changes may be made. Backward compatible changes
182 * may be added together with the corresponding interface version bump.
183 * Backward incompatible changes are done by bumping the version number in
184 * the protocol and interface names and resetting the interface version.
185 * Once the protocol is to be declared stable, the 'z' prefix and the
186 * version number in the protocol and interface names are removed and the
187 * interface version number is reset.
188 */
189 extern const struct wl_interface zwp_linux_dmabuf_v1_interface;
190 #endif
191 #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_INTERFACE
192 #define ZWP_LINUX_BUFFER_PARAMS_V1_INTERFACE
193 /**
194 * @page page_iface_zwp_linux_buffer_params_v1 zwp_linux_buffer_params_v1
195 * @section page_iface_zwp_linux_buffer_params_v1_desc Description
196 *
197 * This temporary object is a collection of dmabufs and other
198 * parameters that together form a single logical buffer. The temporary
199 * object may eventually create one wl_buffer unless cancelled by
200 * destroying it before requesting 'create'.
201 *
202 * Single-planar formats only require one dmabuf, however
203 * multi-planar formats may require more than one dmabuf. For all
204 * formats, an 'add' request must be called once per plane (even if the
205 * underlying dmabuf fd is identical).
206 *
207 * You must use consecutive plane indices ('plane_idx' argument for 'add')
208 * from zero to the number of planes used by the drm_fourcc format code.
209 * All planes required by the format must be given exactly once, but can
210 * be given in any order. Each plane index can be set only once.
211 * @section page_iface_zwp_linux_buffer_params_v1_api API
212 * See @ref iface_zwp_linux_buffer_params_v1.
213 */
214 /**
215 * @defgroup iface_zwp_linux_buffer_params_v1 The zwp_linux_buffer_params_v1 interface
216 *
217 * This temporary object is a collection of dmabufs and other
218 * parameters that together form a single logical buffer. The temporary
219 * object may eventually create one wl_buffer unless cancelled by
220 * destroying it before requesting 'create'.
221 *
222 * Single-planar formats only require one dmabuf, however
223 * multi-planar formats may require more than one dmabuf. For all
224 * formats, an 'add' request must be called once per plane (even if the
225 * underlying dmabuf fd is identical).
226 *
227 * You must use consecutive plane indices ('plane_idx' argument for 'add')
228 * from zero to the number of planes used by the drm_fourcc format code.
229 * All planes required by the format must be given exactly once, but can
230 * be given in any order. Each plane index can be set only once.
231 */
232 extern const struct wl_interface zwp_linux_buffer_params_v1_interface;
233 #endif
234
235 /**
236 * @ingroup iface_zwp_linux_dmabuf_v1
237 * @struct zwp_linux_dmabuf_v1_listener
238 */
239 struct zwp_linux_dmabuf_v1_listener {
240 /**
241 * supported buffer format
242 *
243 * This event advertises one buffer format that the server
244 * supports. All the supported formats are advertised once when the
245 * client binds to this interface. A roundtrip after binding
246 * guarantees that the client has received all supported formats.
247 *
248 * For the definition of the format codes, see the
249 * zwp_linux_buffer_params_v1::create request.
250 *
251 * Warning: the 'format' event is likely to be deprecated and
252 * replaced with the 'modifier' event introduced in
253 * zwp_linux_dmabuf_v1 version 3, described below. Please refrain
254 * from using the information received from this event.
255 * @param format DRM_FORMAT code
256 */
257 void (*format)(void *data,
258 struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1,
259 uint32_t format);
260 /**
261 * supported buffer format modifier
262 *
263 * This event advertises the formats that the server supports,
264 * along with the modifiers supported for each format. All the
265 * supported modifiers for all the supported formats are advertised
266 * once when the client binds to this interface. A roundtrip after
267 * binding guarantees that the client has received all supported
268 * format-modifier pairs.
269 *
270 * For legacy support, DRM_FORMAT_MOD_INVALID (that is, modifier_hi
271 * == 0x00ffffff and modifier_lo == 0xffffffff) is allowed in this
272 * event. It indicates that the server can support the format with
273 * an implicit modifier. When a plane has DRM_FORMAT_MOD_INVALID as
274 * its modifier, it is as if no explicit modifier is specified. The
275 * effective modifier will be derived from the dmabuf.
276 *
277 * A compositor that sends valid modifiers and
278 * DRM_FORMAT_MOD_INVALID for a given format supports both explicit
279 * modifiers and implicit modifiers.
280 *
281 * For the definition of the format and modifier codes, see the
282 * zwp_linux_buffer_params_v1::create and
283 * zwp_linux_buffer_params_v1::add requests.
284 * @param format DRM_FORMAT code
285 * @param modifier_hi high 32 bits of layout modifier
286 * @param modifier_lo low 32 bits of layout modifier
287 * @since 3
288 */
289 void (*modifier)(void *data,
290 struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1,
291 uint32_t format,
292 uint32_t modifier_hi,
293 uint32_t modifier_lo);
294 };
295
296 /**
297 * @ingroup iface_zwp_linux_dmabuf_v1
298 */
299 static inline int
zwp_linux_dmabuf_v1_add_listener(struct zwp_linux_dmabuf_v1 * zwp_linux_dmabuf_v1,const struct zwp_linux_dmabuf_v1_listener * listener,void * data)300 zwp_linux_dmabuf_v1_add_listener(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1,
301 const struct zwp_linux_dmabuf_v1_listener *listener, void *data)
302 {
303 return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_dmabuf_v1,
304 (void (**)(void)) listener, data);
305 }
306
307 #define ZWP_LINUX_DMABUF_V1_DESTROY 0
308 #define ZWP_LINUX_DMABUF_V1_CREATE_PARAMS 1
309
310 /**
311 * @ingroup iface_zwp_linux_dmabuf_v1
312 */
313 #define ZWP_LINUX_DMABUF_V1_FORMAT_SINCE_VERSION 1
314 /**
315 * @ingroup iface_zwp_linux_dmabuf_v1
316 */
317 #define ZWP_LINUX_DMABUF_V1_MODIFIER_SINCE_VERSION 3
318
319 /**
320 * @ingroup iface_zwp_linux_dmabuf_v1
321 */
322 #define ZWP_LINUX_DMABUF_V1_DESTROY_SINCE_VERSION 1
323 /**
324 * @ingroup iface_zwp_linux_dmabuf_v1
325 */
326 #define ZWP_LINUX_DMABUF_V1_CREATE_PARAMS_SINCE_VERSION 1
327
328 /** @ingroup iface_zwp_linux_dmabuf_v1 */
329 static inline void
zwp_linux_dmabuf_v1_set_user_data(struct zwp_linux_dmabuf_v1 * zwp_linux_dmabuf_v1,void * user_data)330 zwp_linux_dmabuf_v1_set_user_data(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1, void *user_data)
331 {
332 wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_dmabuf_v1, user_data);
333 }
334
335 /** @ingroup iface_zwp_linux_dmabuf_v1 */
336 static inline void *
zwp_linux_dmabuf_v1_get_user_data(struct zwp_linux_dmabuf_v1 * zwp_linux_dmabuf_v1)337 zwp_linux_dmabuf_v1_get_user_data(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
338 {
339 return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_dmabuf_v1);
340 }
341
342 static inline uint32_t
zwp_linux_dmabuf_v1_get_version(struct zwp_linux_dmabuf_v1 * zwp_linux_dmabuf_v1)343 zwp_linux_dmabuf_v1_get_version(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
344 {
345 return wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_v1);
346 }
347
348 /**
349 * @ingroup iface_zwp_linux_dmabuf_v1
350 *
351 * Objects created through this interface, especially wl_buffers, will
352 * remain valid.
353 */
354 static inline void
zwp_linux_dmabuf_v1_destroy(struct zwp_linux_dmabuf_v1 * zwp_linux_dmabuf_v1)355 zwp_linux_dmabuf_v1_destroy(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
356 {
357 wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_dmabuf_v1,
358 ZWP_LINUX_DMABUF_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_v1), WL_MARSHAL_FLAG_DESTROY);
359 }
360
361 /**
362 * @ingroup iface_zwp_linux_dmabuf_v1
363 *
364 * This temporary object is used to collect multiple dmabuf handles into
365 * a single batch to create a wl_buffer. It can only be used once and
366 * should be destroyed after a 'created' or 'failed' event has been
367 * received.
368 */
369 static inline struct zwp_linux_buffer_params_v1 *
zwp_linux_dmabuf_v1_create_params(struct zwp_linux_dmabuf_v1 * zwp_linux_dmabuf_v1)370 zwp_linux_dmabuf_v1_create_params(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
371 {
372 struct wl_proxy *params_id;
373
374 params_id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_dmabuf_v1,
375 ZWP_LINUX_DMABUF_V1_CREATE_PARAMS, &zwp_linux_buffer_params_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_v1), 0, NULL);
376
377 return (struct zwp_linux_buffer_params_v1 *) params_id;
378 }
379
380 #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
381 #define ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
382 enum zwp_linux_buffer_params_v1_error {
383 /**
384 * the dmabuf_batch object has already been used to create a wl_buffer
385 */
386 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED = 0,
387 /**
388 * plane index out of bounds
389 */
390 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX = 1,
391 /**
392 * the plane index was already set
393 */
394 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET = 2,
395 /**
396 * missing or too many planes to create a buffer
397 */
398 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE = 3,
399 /**
400 * format not supported
401 */
402 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT = 4,
403 /**
404 * invalid width or height
405 */
406 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS = 5,
407 /**
408 * offset + stride * height goes out of dmabuf bounds
409 */
410 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS = 6,
411 /**
412 * invalid wl_buffer resulted from importing dmabufs via the create_immed request on given buffer_params
413 */
414 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_WL_BUFFER = 7,
415 };
416 #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM */
417
418 #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
419 #define ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
420 enum zwp_linux_buffer_params_v1_flags {
421 /**
422 * contents are y-inverted
423 */
424 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT = 1,
425 /**
426 * content is interlaced
427 */
428 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED = 2,
429 /**
430 * bottom field first
431 */
432 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST = 4,
433 };
434 #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM */
435
436 /**
437 * @ingroup iface_zwp_linux_buffer_params_v1
438 * @struct zwp_linux_buffer_params_v1_listener
439 */
440 struct zwp_linux_buffer_params_v1_listener {
441 /**
442 * buffer creation succeeded
443 *
444 * This event indicates that the attempted buffer creation was
445 * successful. It provides the new wl_buffer referencing the
446 * dmabuf(s).
447 *
448 * Upon receiving this event, the client should destroy the
449 * zlinux_dmabuf_params object.
450 * @param buffer the newly created wl_buffer
451 */
452 void (*created)(void *data,
453 struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1,
454 struct wl_buffer *buffer);
455 /**
456 * buffer creation failed
457 *
458 * This event indicates that the attempted buffer creation has
459 * failed. It usually means that one of the dmabuf constraints has
460 * not been fulfilled.
461 *
462 * Upon receiving this event, the client should destroy the
463 * zlinux_buffer_params object.
464 */
465 void (*failed)(void *data,
466 struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1);
467 };
468
469 /**
470 * @ingroup iface_zwp_linux_buffer_params_v1
471 */
472 static inline int
zwp_linux_buffer_params_v1_add_listener(struct zwp_linux_buffer_params_v1 * zwp_linux_buffer_params_v1,const struct zwp_linux_buffer_params_v1_listener * listener,void * data)473 zwp_linux_buffer_params_v1_add_listener(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1,
474 const struct zwp_linux_buffer_params_v1_listener *listener, void *data)
475 {
476 return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_buffer_params_v1,
477 (void (**)(void)) listener, data);
478 }
479
480 #define ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY 0
481 #define ZWP_LINUX_BUFFER_PARAMS_V1_ADD 1
482 #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE 2
483 #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_IMMED 3
484
485 /**
486 * @ingroup iface_zwp_linux_buffer_params_v1
487 */
488 #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATED_SINCE_VERSION 1
489 /**
490 * @ingroup iface_zwp_linux_buffer_params_v1
491 */
492 #define ZWP_LINUX_BUFFER_PARAMS_V1_FAILED_SINCE_VERSION 1
493
494 /**
495 * @ingroup iface_zwp_linux_buffer_params_v1
496 */
497 #define ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY_SINCE_VERSION 1
498 /**
499 * @ingroup iface_zwp_linux_buffer_params_v1
500 */
501 #define ZWP_LINUX_BUFFER_PARAMS_V1_ADD_SINCE_VERSION 1
502 /**
503 * @ingroup iface_zwp_linux_buffer_params_v1
504 */
505 #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_SINCE_VERSION 1
506 /**
507 * @ingroup iface_zwp_linux_buffer_params_v1
508 */
509 #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_IMMED_SINCE_VERSION 2
510
511 /** @ingroup iface_zwp_linux_buffer_params_v1 */
512 static inline void
zwp_linux_buffer_params_v1_set_user_data(struct zwp_linux_buffer_params_v1 * zwp_linux_buffer_params_v1,void * user_data)513 zwp_linux_buffer_params_v1_set_user_data(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, void *user_data)
514 {
515 wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_buffer_params_v1, user_data);
516 }
517
518 /** @ingroup iface_zwp_linux_buffer_params_v1 */
519 static inline void *
zwp_linux_buffer_params_v1_get_user_data(struct zwp_linux_buffer_params_v1 * zwp_linux_buffer_params_v1)520 zwp_linux_buffer_params_v1_get_user_data(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1)
521 {
522 return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_buffer_params_v1);
523 }
524
525 static inline uint32_t
zwp_linux_buffer_params_v1_get_version(struct zwp_linux_buffer_params_v1 * zwp_linux_buffer_params_v1)526 zwp_linux_buffer_params_v1_get_version(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1)
527 {
528 return wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1);
529 }
530
531 /**
532 * @ingroup iface_zwp_linux_buffer_params_v1
533 *
534 * Cleans up the temporary data sent to the server for dmabuf-based
535 * wl_buffer creation.
536 */
537 static inline void
zwp_linux_buffer_params_v1_destroy(struct zwp_linux_buffer_params_v1 * zwp_linux_buffer_params_v1)538 zwp_linux_buffer_params_v1_destroy(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1)
539 {
540 wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
541 ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1), WL_MARSHAL_FLAG_DESTROY);
542 }
543
544 /**
545 * @ingroup iface_zwp_linux_buffer_params_v1
546 *
547 * This request adds one dmabuf to the set in this
548 * zwp_linux_buffer_params_v1.
549 *
550 * The 64-bit unsigned value combined from modifier_hi and modifier_lo
551 * is the dmabuf layout modifier. DRM AddFB2 ioctl calls this the
552 * fb modifier, which is defined in drm_mode.h of Linux UAPI.
553 * This is an opaque token. Drivers use this token to express tiling,
554 * compression, etc. driver-specific modifications to the base format
555 * defined by the DRM fourcc code.
556 *
557 * Warning: It should be an error if the format/modifier pair was not
558 * advertised with the modifier event. This is not enforced yet because
559 * some implementations always accept DRM_FORMAT_MOD_INVALID. Also
560 * version 2 of this protocol does not have the modifier event.
561 *
562 * This request raises the PLANE_IDX error if plane_idx is too large.
563 * The error PLANE_SET is raised if attempting to set a plane that
564 * was already set.
565 */
566 static inline void
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)567 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)
568 {
569 wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
570 ZWP_LINUX_BUFFER_PARAMS_V1_ADD, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1), 0, fd, plane_idx, offset, stride, modifier_hi, modifier_lo);
571 }
572
573 /**
574 * @ingroup iface_zwp_linux_buffer_params_v1
575 *
576 * This asks for creation of a wl_buffer from the added dmabuf
577 * buffers. The wl_buffer is not created immediately but returned via
578 * the 'created' event if the dmabuf sharing succeeds. The sharing
579 * may fail at runtime for reasons a client cannot predict, in
580 * which case the 'failed' event is triggered.
581 *
582 * The 'format' argument is a DRM_FORMAT code, as defined by the
583 * libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the
584 * authoritative source on how the format codes should work.
585 *
586 * The 'flags' is a bitfield of the flags defined in enum "flags".
587 * 'y_invert' means the that the image needs to be y-flipped.
588 *
589 * Flag 'interlaced' means that the frame in the buffer is not
590 * progressive as usual, but interlaced. An interlaced buffer as
591 * supported here must always contain both top and bottom fields.
592 * The top field always begins on the first pixel row. The temporal
593 * ordering between the two fields is top field first, unless
594 * 'bottom_first' is specified. It is undefined whether 'bottom_first'
595 * is ignored if 'interlaced' is not set.
596 *
597 * This protocol does not convey any information about field rate,
598 * duration, or timing, other than the relative ordering between the
599 * two fields in one buffer. A compositor may have to estimate the
600 * intended field rate from the incoming buffer rate. It is undefined
601 * whether the time of receiving wl_surface.commit with a new buffer
602 * attached, applying the wl_surface state, wl_surface.frame callback
603 * trigger, presentation, or any other point in the compositor cycle
604 * is used to measure the frame or field times. There is no support
605 * for detecting missed or late frames/fields/buffers either, and
606 * there is no support whatsoever for cooperating with interlaced
607 * compositor output.
608 *
609 * The composited image quality resulting from the use of interlaced
610 * buffers is explicitly undefined. A compositor may use elaborate
611 * hardware features or software to deinterlace and create progressive
612 * output frames from a sequence of interlaced input buffers, or it
613 * may produce substandard image quality. However, compositors that
614 * cannot guarantee reasonable image quality in all cases are recommended
615 * to just reject all interlaced buffers.
616 *
617 * Any argument errors, including non-positive width or height,
618 * mismatch between the number of planes and the format, bad
619 * format, bad offset or stride, may be indicated by fatal protocol
620 * errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS,
621 * OUT_OF_BOUNDS.
622 *
623 * Dmabuf import errors in the server that are not obvious client
624 * bugs are returned via the 'failed' event as non-fatal. This
625 * allows attempting dmabuf sharing and falling back in the client
626 * if it fails.
627 *
628 * This request can be sent only once in the object's lifetime, after
629 * which the only legal request is destroy. This object should be
630 * destroyed after issuing a 'create' request. Attempting to use this
631 * object after issuing 'create' raises ALREADY_USED protocol error.
632 *
633 * It is not mandatory to issue 'create'. If a client wants to
634 * cancel the buffer creation, it can just destroy this object.
635 */
636 static inline void
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)637 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)
638 {
639 wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
640 ZWP_LINUX_BUFFER_PARAMS_V1_CREATE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1), 0, width, height, format, flags);
641 }
642
643 /**
644 * @ingroup iface_zwp_linux_buffer_params_v1
645 *
646 * This asks for immediate creation of a wl_buffer by importing the
647 * added dmabufs.
648 *
649 * In case of import success, no event is sent from the server, and the
650 * wl_buffer is ready to be used by the client.
651 *
652 * Upon import failure, either of the following may happen, as seen fit
653 * by the implementation:
654 * - the client is terminated with one of the following fatal protocol
655 * errors:
656 * - INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, OUT_OF_BOUNDS,
657 * in case of argument errors such as mismatch between the number
658 * of planes and the format, bad format, non-positive width or
659 * height, or bad offset or stride.
660 * - INVALID_WL_BUFFER, in case the cause for failure is unknown or
661 * plaform specific.
662 * - the server creates an invalid wl_buffer, marks it as failed and
663 * sends a 'failed' event to the client. The result of using this
664 * invalid wl_buffer as an argument in any request by the client is
665 * defined by the compositor implementation.
666 *
667 * This takes the same arguments as a 'create' request, and obeys the
668 * same restrictions.
669 */
670 static inline struct wl_buffer *
zwp_linux_buffer_params_v1_create_immed(struct zwp_linux_buffer_params_v1 * zwp_linux_buffer_params_v1,int32_t width,int32_t height,uint32_t format,uint32_t flags)671 zwp_linux_buffer_params_v1_create_immed(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, int32_t width, int32_t height, uint32_t format, uint32_t flags)
672 {
673 struct wl_proxy *buffer_id;
674
675 buffer_id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
676 ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_IMMED, &wl_buffer_interface, wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1), 0, NULL, width, height, format, flags);
677
678 return (struct wl_buffer *) buffer_id;
679 }
680
681 #ifdef __cplusplus
682 }
683 #endif
684
685 #endif
686