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