linux-dmabuf-client-protocol.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. /* Generated by wayland-scanner 1.26.0 */
  2. #ifndef LINUX_DMABUF_V1_CLIENT_PROTOCOL_H
  3. #define LINUX_DMABUF_V1_CLIENT_PROTOCOL_H
  4. #include <stdint.h>
  5. #include <stddef.h>
  6. #include "wayland-client.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /**
  11. * @page page_linux_dmabuf_v1 The linux_dmabuf_v1 protocol
  12. * @section page_ifaces_linux_dmabuf_v1 Interfaces
  13. * - @subpage page_iface_zwp_linux_dmabuf_v1 - factory for creating dmabuf-based wl_buffers
  14. * - @subpage page_iface_zwp_linux_buffer_params_v1 - parameters for creating a dmabuf-based wl_buffer
  15. * - @subpage page_iface_zwp_linux_dmabuf_feedback_v1 - dmabuf feedback
  16. * @section page_copyright_linux_dmabuf_v1 Copyright
  17. * <pre>
  18. *
  19. * Copyright © 2014, 2015 Collabora, Ltd.
  20. *
  21. * Permission is hereby granted, free of charge, to any person obtaining a
  22. * copy of this software and associated documentation files (the "Software"),
  23. * to deal in the Software without restriction, including without limitation
  24. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  25. * and/or sell copies of the Software, and to permit persons to whom the
  26. * Software is furnished to do so, subject to the following conditions:
  27. *
  28. * The above copyright notice and this permission notice (including the next
  29. * paragraph) shall be included in all copies or substantial portions of the
  30. * Software.
  31. *
  32. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  34. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  35. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  36. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  37. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  38. * DEALINGS IN THE SOFTWARE.
  39. * </pre>
  40. */
  41. struct wl_buffer;
  42. struct wl_surface;
  43. struct zwp_linux_buffer_params_v1;
  44. struct zwp_linux_dmabuf_feedback_v1;
  45. struct zwp_linux_dmabuf_v1;
  46. #ifndef ZWP_LINUX_DMABUF_V1_INTERFACE
  47. #define ZWP_LINUX_DMABUF_V1_INTERFACE
  48. /**
  49. * @page page_iface_zwp_linux_dmabuf_v1 zwp_linux_dmabuf_v1
  50. * @section page_iface_zwp_linux_dmabuf_v1_desc Description
  51. *
  52. * This interface offers ways to create generic dmabuf-based wl_buffers.
  53. *
  54. * For more information about dmabuf, see:
  55. * https://www.kernel.org/doc/html/next/userspace-api/dma-buf-alloc-exchange.html
  56. *
  57. * Clients can use the get_surface_feedback request to get dmabuf feedback
  58. * for a particular surface. If the client wants to retrieve feedback not
  59. * tied to a surface, they can use the get_default_feedback request.
  60. *
  61. * The following are required from clients:
  62. *
  63. * - Clients must ensure that either all data in the dma-buf is
  64. * coherent for all subsequent read access or that coherency is
  65. * correctly handled by the underlying kernel-side dma-buf
  66. * implementation.
  67. *
  68. * - Don't make any more attachments after sending the buffer to the
  69. * compositor. Making more attachments later increases the risk of
  70. * the compositor not being able to use (re-import) an existing
  71. * dmabuf-based wl_buffer.
  72. *
  73. * The underlying graphics stack must ensure the following:
  74. *
  75. * - The dmabuf file descriptors relayed to the server will stay valid
  76. * for the whole lifetime of the wl_buffer. This means the server may
  77. * at any time use those fds to import the dmabuf into any kernel
  78. * sub-system that might accept it.
  79. *
  80. * However, when the underlying graphics stack fails to deliver the
  81. * promise, because of e.g. a device hot-unplug which raises internal
  82. * errors, after the wl_buffer has been successfully created the
  83. * compositor must not raise protocol errors to the client when dmabuf
  84. * import later fails.
  85. *
  86. * To create a wl_buffer from one or more dmabufs, a client creates a
  87. * zwp_linux_buffer_params_v1 object with a zwp_linux_dmabuf_v1.create_params
  88. * request. All planes required by the intended format are added with
  89. * the 'add' request. Finally, a 'create' or 'create_immed' request is
  90. * issued, which has the following outcome depending on the import success.
  91. *
  92. * The 'create' request,
  93. * - on success, triggers a 'created' event which provides the final
  94. * wl_buffer to the client.
  95. * - on failure, triggers a 'failed' event to convey that the server
  96. * cannot use the dmabufs received from the client.
  97. *
  98. * For the 'create_immed' request,
  99. * - on success, the server immediately imports the added dmabufs to
  100. * create a wl_buffer. No event is sent from the server in this case.
  101. * - on failure, the server can choose to either:
  102. * - terminate the client by raising a fatal error.
  103. * - mark the wl_buffer as failed, and send a 'failed' event to the
  104. * client. If the client uses a failed wl_buffer as an argument to any
  105. * request, the behaviour is compositor implementation-defined.
  106. *
  107. * For all DRM formats and unless specified in another protocol extension,
  108. * pre-multiplied alpha is used for pixel values.
  109. *
  110. * Unless specified otherwise in another protocol extension, implicit
  111. * synchronization is used. In other words, compositors and clients must
  112. * wait and signal fences implicitly passed via the DMA-BUF's reservation
  113. * mechanism.
  114. * @section page_iface_zwp_linux_dmabuf_v1_api API
  115. * See @ref iface_zwp_linux_dmabuf_v1.
  116. */
  117. /**
  118. * @defgroup iface_zwp_linux_dmabuf_v1 The zwp_linux_dmabuf_v1 interface
  119. *
  120. * This interface offers ways to create generic dmabuf-based wl_buffers.
  121. *
  122. * For more information about dmabuf, see:
  123. * https://www.kernel.org/doc/html/next/userspace-api/dma-buf-alloc-exchange.html
  124. *
  125. * Clients can use the get_surface_feedback request to get dmabuf feedback
  126. * for a particular surface. If the client wants to retrieve feedback not
  127. * tied to a surface, they can use the get_default_feedback request.
  128. *
  129. * The following are required from clients:
  130. *
  131. * - Clients must ensure that either all data in the dma-buf is
  132. * coherent for all subsequent read access or that coherency is
  133. * correctly handled by the underlying kernel-side dma-buf
  134. * implementation.
  135. *
  136. * - Don't make any more attachments after sending the buffer to the
  137. * compositor. Making more attachments later increases the risk of
  138. * the compositor not being able to use (re-import) an existing
  139. * dmabuf-based wl_buffer.
  140. *
  141. * The underlying graphics stack must ensure the following:
  142. *
  143. * - The dmabuf file descriptors relayed to the server will stay valid
  144. * for the whole lifetime of the wl_buffer. This means the server may
  145. * at any time use those fds to import the dmabuf into any kernel
  146. * sub-system that might accept it.
  147. *
  148. * However, when the underlying graphics stack fails to deliver the
  149. * promise, because of e.g. a device hot-unplug which raises internal
  150. * errors, after the wl_buffer has been successfully created the
  151. * compositor must not raise protocol errors to the client when dmabuf
  152. * import later fails.
  153. *
  154. * To create a wl_buffer from one or more dmabufs, a client creates a
  155. * zwp_linux_buffer_params_v1 object with a zwp_linux_dmabuf_v1.create_params
  156. * request. All planes required by the intended format are added with
  157. * the 'add' request. Finally, a 'create' or 'create_immed' request is
  158. * issued, which has the following outcome depending on the import success.
  159. *
  160. * The 'create' request,
  161. * - on success, triggers a 'created' event which provides the final
  162. * wl_buffer to the client.
  163. * - on failure, triggers a 'failed' event to convey that the server
  164. * cannot use the dmabufs received from the client.
  165. *
  166. * For the 'create_immed' request,
  167. * - on success, the server immediately imports the added dmabufs to
  168. * create a wl_buffer. No event is sent from the server in this case.
  169. * - on failure, the server can choose to either:
  170. * - terminate the client by raising a fatal error.
  171. * - mark the wl_buffer as failed, and send a 'failed' event to the
  172. * client. If the client uses a failed wl_buffer as an argument to any
  173. * request, the behaviour is compositor implementation-defined.
  174. *
  175. * For all DRM formats and unless specified in another protocol extension,
  176. * pre-multiplied alpha is used for pixel values.
  177. *
  178. * Unless specified otherwise in another protocol extension, implicit
  179. * synchronization is used. In other words, compositors and clients must
  180. * wait and signal fences implicitly passed via the DMA-BUF's reservation
  181. * mechanism.
  182. */
  183. extern const struct wl_interface zwp_linux_dmabuf_v1_interface;
  184. #endif
  185. #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_INTERFACE
  186. #define ZWP_LINUX_BUFFER_PARAMS_V1_INTERFACE
  187. /**
  188. * @page page_iface_zwp_linux_buffer_params_v1 zwp_linux_buffer_params_v1
  189. * @section page_iface_zwp_linux_buffer_params_v1_desc Description
  190. *
  191. * This temporary object is a collection of dmabufs and other
  192. * parameters that together form a single logical buffer. The temporary
  193. * object may eventually create one wl_buffer unless cancelled by
  194. * destroying it before requesting 'create'.
  195. *
  196. * Single-planar formats only require one dmabuf, however
  197. * multi-planar formats may require more than one dmabuf. For all
  198. * formats, an 'add' request must be called once per plane (even if the
  199. * underlying dmabuf fd is identical).
  200. *
  201. * You must use consecutive plane indices ('plane_idx' argument for 'add')
  202. * from zero to the number of planes used by the drm_fourcc format code.
  203. * All planes required by the format must be given exactly once, but can
  204. * be given in any order. Each plane index can only be set once; subsequent
  205. * calls with a plane index which has already been set will result in a
  206. * plane_set error being generated.
  207. * @section page_iface_zwp_linux_buffer_params_v1_api API
  208. * See @ref iface_zwp_linux_buffer_params_v1.
  209. */
  210. /**
  211. * @defgroup iface_zwp_linux_buffer_params_v1 The zwp_linux_buffer_params_v1 interface
  212. *
  213. * This temporary object is a collection of dmabufs and other
  214. * parameters that together form a single logical buffer. The temporary
  215. * object may eventually create one wl_buffer unless cancelled by
  216. * destroying it before requesting 'create'.
  217. *
  218. * Single-planar formats only require one dmabuf, however
  219. * multi-planar formats may require more than one dmabuf. For all
  220. * formats, an 'add' request must be called once per plane (even if the
  221. * underlying dmabuf fd is identical).
  222. *
  223. * You must use consecutive plane indices ('plane_idx' argument for 'add')
  224. * from zero to the number of planes used by the drm_fourcc format code.
  225. * All planes required by the format must be given exactly once, but can
  226. * be given in any order. Each plane index can only be set once; subsequent
  227. * calls with a plane index which has already been set will result in a
  228. * plane_set error being generated.
  229. */
  230. extern const struct wl_interface zwp_linux_buffer_params_v1_interface;
  231. #endif
  232. #ifndef ZWP_LINUX_DMABUF_FEEDBACK_V1_INTERFACE
  233. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_INTERFACE
  234. /**
  235. * @page page_iface_zwp_linux_dmabuf_feedback_v1 zwp_linux_dmabuf_feedback_v1
  236. * @section page_iface_zwp_linux_dmabuf_feedback_v1_desc Description
  237. *
  238. * This object advertises dmabuf parameters feedback. This includes the
  239. * preferred devices and the supported formats/modifiers.
  240. *
  241. * The parameters are sent once when this object is created and whenever they
  242. * change. The done event is always sent once after all parameters have been
  243. * sent. When a single parameter changes, all parameters are re-sent by the
  244. * compositor.
  245. *
  246. * Compositors can re-send the parameters when the current client buffer
  247. * allocations are sub-optimal. Compositors should not re-send the
  248. * parameters if re-allocating the buffers would not result in a more optimal
  249. * configuration. In particular, compositors should avoid sending the exact
  250. * same parameters multiple times in a row.
  251. *
  252. * The tranche_target_device and tranche_formats events are grouped by
  253. * tranches of preference. For each tranche, a tranche_target_device, one
  254. * tranche_flags and one or more tranche_formats events are sent, followed
  255. * by a tranche_done event finishing the list. The tranches are sent in
  256. * descending order of preference. All formats and modifiers in the same
  257. * tranche have the same preference.
  258. *
  259. * To send parameters, the compositor sends one main_device event (unless
  260. * the client bound version 6 or above), tranches (each consisting of one
  261. * tranche_target_device event, one tranche_flags event, tranche_formats
  262. * events and then a tranche_done event), then one done event.
  263. *
  264. * With version 6 and above, the compositor must always advertise at least
  265. * one tranche with the sampling flag set.
  266. *
  267. * The compositor sends a format_table event at least once for each dmabuf
  268. * parameters feedback object, before any tranche events. Unless the format
  269. * table contents change later, the compositor is free not to send another
  270. * format_table event for the same dmabuf parameters feedback object.
  271. * @section page_iface_zwp_linux_dmabuf_feedback_v1_api API
  272. * See @ref iface_zwp_linux_dmabuf_feedback_v1.
  273. */
  274. /**
  275. * @defgroup iface_zwp_linux_dmabuf_feedback_v1 The zwp_linux_dmabuf_feedback_v1 interface
  276. *
  277. * This object advertises dmabuf parameters feedback. This includes the
  278. * preferred devices and the supported formats/modifiers.
  279. *
  280. * The parameters are sent once when this object is created and whenever they
  281. * change. The done event is always sent once after all parameters have been
  282. * sent. When a single parameter changes, all parameters are re-sent by the
  283. * compositor.
  284. *
  285. * Compositors can re-send the parameters when the current client buffer
  286. * allocations are sub-optimal. Compositors should not re-send the
  287. * parameters if re-allocating the buffers would not result in a more optimal
  288. * configuration. In particular, compositors should avoid sending the exact
  289. * same parameters multiple times in a row.
  290. *
  291. * The tranche_target_device and tranche_formats events are grouped by
  292. * tranches of preference. For each tranche, a tranche_target_device, one
  293. * tranche_flags and one or more tranche_formats events are sent, followed
  294. * by a tranche_done event finishing the list. The tranches are sent in
  295. * descending order of preference. All formats and modifiers in the same
  296. * tranche have the same preference.
  297. *
  298. * To send parameters, the compositor sends one main_device event (unless
  299. * the client bound version 6 or above), tranches (each consisting of one
  300. * tranche_target_device event, one tranche_flags event, tranche_formats
  301. * events and then a tranche_done event), then one done event.
  302. *
  303. * With version 6 and above, the compositor must always advertise at least
  304. * one tranche with the sampling flag set.
  305. *
  306. * The compositor sends a format_table event at least once for each dmabuf
  307. * parameters feedback object, before any tranche events. Unless the format
  308. * table contents change later, the compositor is free not to send another
  309. * format_table event for the same dmabuf parameters feedback object.
  310. */
  311. extern const struct wl_interface zwp_linux_dmabuf_feedback_v1_interface;
  312. #endif
  313. /**
  314. * @ingroup iface_zwp_linux_dmabuf_v1
  315. * @struct zwp_linux_dmabuf_v1_listener
  316. */
  317. struct zwp_linux_dmabuf_v1_listener {
  318. /**
  319. * supported buffer format
  320. *
  321. * This event advertises one buffer format that the server
  322. * supports. All the supported formats are advertised once when the
  323. * client binds to this interface. A roundtrip after binding
  324. * guarantees that the client has received all supported formats.
  325. *
  326. * For the definition of the format codes, see the
  327. * zwp_linux_buffer_params_v1::create request.
  328. *
  329. * Starting version 4, the format event is deprecated and must not
  330. * be sent by compositors. Instead, use get_default_feedback or
  331. * get_surface_feedback.
  332. * @param format DRM_FORMAT code
  333. * @deprecated Deprecated since version 4
  334. */
  335. void (*format)(void *data,
  336. struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1,
  337. uint32_t format);
  338. /**
  339. * supported buffer format modifier
  340. *
  341. * This event advertises the formats that the server supports,
  342. * along with the modifiers supported for each format. All the
  343. * supported modifiers for all the supported formats are advertised
  344. * once when the client binds to this interface. A roundtrip after
  345. * binding guarantees that the client has received all supported
  346. * format-modifier pairs.
  347. *
  348. * For legacy support, DRM_FORMAT_MOD_INVALID (that is, modifier_hi
  349. * == 0x00ffffff and modifier_lo == 0xffffffff) is allowed in this
  350. * event. It indicates that the server can support the format with
  351. * an implicit modifier. When a plane has DRM_FORMAT_MOD_INVALID as
  352. * its modifier, it is as if no explicit modifier is specified. The
  353. * effective modifier will be derived from the dmabuf.
  354. *
  355. * A compositor that sends valid modifiers and
  356. * DRM_FORMAT_MOD_INVALID for a given format supports both explicit
  357. * modifiers and implicit modifiers.
  358. *
  359. * For the definition of the format and modifier codes, see the
  360. * zwp_linux_buffer_params_v1::create and
  361. * zwp_linux_buffer_params_v1::add requests.
  362. *
  363. * Starting version 4, the modifier event is deprecated and must
  364. * not be sent by compositors. Instead, use get_default_feedback or
  365. * get_surface_feedback.
  366. * @param format DRM_FORMAT code
  367. * @param modifier_hi high 32 bits of layout modifier
  368. * @param modifier_lo low 32 bits of layout modifier
  369. * @since 3
  370. * @deprecated Deprecated since version 4
  371. */
  372. void (*modifier)(void *data,
  373. struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1,
  374. uint32_t format,
  375. uint32_t modifier_hi,
  376. uint32_t modifier_lo);
  377. };
  378. /**
  379. * @ingroup iface_zwp_linux_dmabuf_v1
  380. */
  381. static inline int
  382. zwp_linux_dmabuf_v1_add_listener(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1,
  383. const struct zwp_linux_dmabuf_v1_listener *listener, void *data)
  384. {
  385. return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_dmabuf_v1,
  386. (void (**)(void)) listener, data);
  387. }
  388. #define ZWP_LINUX_DMABUF_V1_DESTROY 0
  389. #define ZWP_LINUX_DMABUF_V1_CREATE_PARAMS 1
  390. #define ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK 2
  391. #define ZWP_LINUX_DMABUF_V1_GET_SURFACE_FEEDBACK 3
  392. /**
  393. * @ingroup iface_zwp_linux_dmabuf_v1
  394. */
  395. #define ZWP_LINUX_DMABUF_V1_FORMAT_SINCE_VERSION 1
  396. /**
  397. * @ingroup iface_zwp_linux_dmabuf_v1
  398. */
  399. #define ZWP_LINUX_DMABUF_V1_MODIFIER_SINCE_VERSION 3
  400. /**
  401. * @ingroup iface_zwp_linux_dmabuf_v1
  402. */
  403. #define ZWP_LINUX_DMABUF_V1_DESTROY_SINCE_VERSION 1
  404. /**
  405. * @ingroup iface_zwp_linux_dmabuf_v1
  406. */
  407. #define ZWP_LINUX_DMABUF_V1_CREATE_PARAMS_SINCE_VERSION 1
  408. /**
  409. * @ingroup iface_zwp_linux_dmabuf_v1
  410. */
  411. #define ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK_SINCE_VERSION 4
  412. /**
  413. * @ingroup iface_zwp_linux_dmabuf_v1
  414. */
  415. #define ZWP_LINUX_DMABUF_V1_GET_SURFACE_FEEDBACK_SINCE_VERSION 4
  416. /** @ingroup iface_zwp_linux_dmabuf_v1 */
  417. static inline void
  418. zwp_linux_dmabuf_v1_set_user_data(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1, void *user_data)
  419. {
  420. wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_dmabuf_v1, user_data);
  421. }
  422. /** @ingroup iface_zwp_linux_dmabuf_v1 */
  423. static inline void *
  424. zwp_linux_dmabuf_v1_get_user_data(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
  425. {
  426. return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_dmabuf_v1);
  427. }
  428. static inline uint32_t
  429. zwp_linux_dmabuf_v1_get_version(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
  430. {
  431. return wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_v1);
  432. }
  433. /**
  434. * @ingroup iface_zwp_linux_dmabuf_v1
  435. *
  436. * Objects created through this interface, especially wl_buffers, will
  437. * remain valid.
  438. */
  439. static inline void
  440. zwp_linux_dmabuf_v1_destroy(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
  441. {
  442. wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_dmabuf_v1,
  443. ZWP_LINUX_DMABUF_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_v1), WL_MARSHAL_FLAG_DESTROY);
  444. }
  445. /**
  446. * @ingroup iface_zwp_linux_dmabuf_v1
  447. *
  448. * This temporary object is used to collect multiple dmabuf handles into
  449. * a single batch to create a wl_buffer. It can only be used once and
  450. * should be destroyed after a 'created' or 'failed' event has been
  451. * received.
  452. */
  453. static inline struct zwp_linux_buffer_params_v1 *
  454. zwp_linux_dmabuf_v1_create_params(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
  455. {
  456. struct wl_proxy *params_id;
  457. params_id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_dmabuf_v1,
  458. 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);
  459. return (struct zwp_linux_buffer_params_v1 *) params_id;
  460. }
  461. /**
  462. * @ingroup iface_zwp_linux_dmabuf_v1
  463. *
  464. * This request creates a new zwp_linux_dmabuf_feedback_v1 object not bound
  465. * to a particular surface. This object will deliver feedback about dmabuf
  466. * parameters to use if the client doesn't support per-surface feedback
  467. * (see get_surface_feedback).
  468. */
  469. static inline struct zwp_linux_dmabuf_feedback_v1 *
  470. zwp_linux_dmabuf_v1_get_default_feedback(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
  471. {
  472. struct wl_proxy *id;
  473. id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_dmabuf_v1,
  474. ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK, &zwp_linux_dmabuf_feedback_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_v1), 0, NULL);
  475. return (struct zwp_linux_dmabuf_feedback_v1 *) id;
  476. }
  477. /**
  478. * @ingroup iface_zwp_linux_dmabuf_v1
  479. *
  480. * This request creates a new zwp_linux_dmabuf_feedback_v1 object for the
  481. * specified wl_surface. This object will deliver feedback about dmabuf
  482. * parameters to use for buffers attached to this surface.
  483. *
  484. * If the surface is destroyed before the zwp_linux_dmabuf_feedback_v1 object,
  485. * the feedback object becomes inert.
  486. */
  487. static inline struct zwp_linux_dmabuf_feedback_v1 *
  488. zwp_linux_dmabuf_v1_get_surface_feedback(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1, struct wl_surface *surface)
  489. {
  490. struct wl_proxy *id;
  491. id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_dmabuf_v1,
  492. ZWP_LINUX_DMABUF_V1_GET_SURFACE_FEEDBACK, &zwp_linux_dmabuf_feedback_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_v1), 0, NULL, surface);
  493. return (struct zwp_linux_dmabuf_feedback_v1 *) id;
  494. }
  495. #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
  496. #define ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
  497. enum zwp_linux_buffer_params_v1_error {
  498. /**
  499. * the zwp_linux_buffer_params_v1 object has already been used to create a wl_buffer
  500. */
  501. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED = 0,
  502. /**
  503. * plane index out of bounds
  504. */
  505. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX = 1,
  506. /**
  507. * the plane index was already set
  508. */
  509. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET = 2,
  510. /**
  511. * missing or too many planes to create a buffer
  512. */
  513. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE = 3,
  514. /**
  515. * format not supported
  516. */
  517. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT = 4,
  518. /**
  519. * invalid width or height
  520. */
  521. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS = 5,
  522. /**
  523. * offset + stride * height goes out of dmabuf bounds
  524. */
  525. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS = 6,
  526. /**
  527. * invalid wl_buffer resulted from importing dmabufs via the create_immed request on given buffer_params
  528. */
  529. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_WL_BUFFER = 7,
  530. /**
  531. * an array with mismatching size for a dev_t was used
  532. */
  533. ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DEV_T_SIZE = 8,
  534. };
  535. #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM */
  536. #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
  537. #define ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
  538. enum zwp_linux_buffer_params_v1_flags {
  539. /**
  540. * contents are y-inverted
  541. */
  542. ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT = 1,
  543. /**
  544. * content is interlaced
  545. */
  546. ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED = 2,
  547. /**
  548. * bottom field first
  549. */
  550. ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST = 4,
  551. };
  552. #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM */
  553. /**
  554. * @ingroup iface_zwp_linux_buffer_params_v1
  555. * @struct zwp_linux_buffer_params_v1_listener
  556. */
  557. struct zwp_linux_buffer_params_v1_listener {
  558. /**
  559. * buffer creation succeeded
  560. *
  561. * This event indicates that the attempted buffer creation was
  562. * successful. It provides the new wl_buffer referencing the
  563. * dmabuf(s).
  564. *
  565. * Upon receiving this event, the client should destroy the
  566. * zwp_linux_buffer_params_v1 object.
  567. * @param buffer id for the the newly created wl_buffer
  568. */
  569. void (*created)(void *data,
  570. struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1,
  571. struct wl_buffer *buffer);
  572. /**
  573. * buffer creation failed
  574. *
  575. * This event indicates that the attempted buffer creation has
  576. * failed. It usually means that one of the dmabuf constraints has
  577. * not been fulfilled.
  578. *
  579. * Upon receiving this event, the client should destroy the
  580. * zwp_linux_buffer_params_v1 object.
  581. */
  582. void (*failed)(void *data,
  583. struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1);
  584. };
  585. /**
  586. * @ingroup iface_zwp_linux_buffer_params_v1
  587. */
  588. static inline int
  589. zwp_linux_buffer_params_v1_add_listener(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1,
  590. const struct zwp_linux_buffer_params_v1_listener *listener, void *data)
  591. {
  592. return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_buffer_params_v1,
  593. (void (**)(void)) listener, data);
  594. }
  595. #define ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY 0
  596. #define ZWP_LINUX_BUFFER_PARAMS_V1_ADD 1
  597. #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE 2
  598. #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_IMMED 3
  599. #define ZWP_LINUX_BUFFER_PARAMS_V1_SET_SAMPLING_DEVICE 4
  600. /**
  601. * @ingroup iface_zwp_linux_buffer_params_v1
  602. */
  603. #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATED_SINCE_VERSION 1
  604. /**
  605. * @ingroup iface_zwp_linux_buffer_params_v1
  606. */
  607. #define ZWP_LINUX_BUFFER_PARAMS_V1_FAILED_SINCE_VERSION 1
  608. /**
  609. * @ingroup iface_zwp_linux_buffer_params_v1
  610. */
  611. #define ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY_SINCE_VERSION 1
  612. /**
  613. * @ingroup iface_zwp_linux_buffer_params_v1
  614. */
  615. #define ZWP_LINUX_BUFFER_PARAMS_V1_ADD_SINCE_VERSION 1
  616. /**
  617. * @ingroup iface_zwp_linux_buffer_params_v1
  618. */
  619. #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_SINCE_VERSION 1
  620. /**
  621. * @ingroup iface_zwp_linux_buffer_params_v1
  622. */
  623. #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE_IMMED_SINCE_VERSION 2
  624. /**
  625. * @ingroup iface_zwp_linux_buffer_params_v1
  626. */
  627. #define ZWP_LINUX_BUFFER_PARAMS_V1_SET_SAMPLING_DEVICE_SINCE_VERSION 6
  628. /** @ingroup iface_zwp_linux_buffer_params_v1 */
  629. static inline void
  630. zwp_linux_buffer_params_v1_set_user_data(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, void *user_data)
  631. {
  632. wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_buffer_params_v1, user_data);
  633. }
  634. /** @ingroup iface_zwp_linux_buffer_params_v1 */
  635. static inline void *
  636. zwp_linux_buffer_params_v1_get_user_data(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1)
  637. {
  638. return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_buffer_params_v1);
  639. }
  640. static inline uint32_t
  641. zwp_linux_buffer_params_v1_get_version(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1)
  642. {
  643. return wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1);
  644. }
  645. /**
  646. * @ingroup iface_zwp_linux_buffer_params_v1
  647. *
  648. * Cleans up the temporary data sent to the server for dmabuf-based
  649. * wl_buffer creation.
  650. */
  651. static inline void
  652. zwp_linux_buffer_params_v1_destroy(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1)
  653. {
  654. wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
  655. ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1), WL_MARSHAL_FLAG_DESTROY);
  656. }
  657. /**
  658. * @ingroup iface_zwp_linux_buffer_params_v1
  659. *
  660. * This request adds one dmabuf to the set in this
  661. * zwp_linux_buffer_params_v1.
  662. *
  663. * The 64-bit unsigned value combined from modifier_hi and modifier_lo
  664. * is the dmabuf layout modifier. DRM AddFB2 ioctl calls this the
  665. * fb modifier, which is defined in drm_mode.h of Linux UAPI.
  666. * This is an opaque token. Drivers use this token to express tiling,
  667. * compression, etc. driver-specific modifications to the base format
  668. * defined by the DRM fourcc code.
  669. *
  670. * Starting from version 4, the invalid_format protocol error is sent if
  671. * the format + modifier pair was not advertised as supported.
  672. *
  673. * Starting from version 5, the invalid_format protocol error is sent if
  674. * all planes don't use the same modifier.
  675. *
  676. * This request raises the PLANE_IDX error if plane_idx is too large.
  677. * The error PLANE_SET is raised if attempting to set a plane that
  678. * was already set.
  679. */
  680. static inline void
  681. 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)
  682. {
  683. wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
  684. 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);
  685. }
  686. /**
  687. * @ingroup iface_zwp_linux_buffer_params_v1
  688. *
  689. * This asks for creation of a wl_buffer from the added dmabuf
  690. * buffers. The wl_buffer is not created immediately but returned via
  691. * the 'created' event if the dmabuf sharing succeeds. The sharing
  692. * may fail at runtime for reasons a client cannot predict, in
  693. * which case the 'failed' event is triggered.
  694. *
  695. * The 'format' argument is a DRM_FORMAT code, as defined by the
  696. * libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the
  697. * authoritative source on how the format codes should work.
  698. *
  699. * The 'flags' is a bitfield of the flags defined in enum "flags".
  700. * 'y_invert' means that the image needs to be y-flipped.
  701. *
  702. * Flag 'interlaced' means that the frame in the buffer is not
  703. * progressive as usual, but interlaced. An interlaced buffer as
  704. * supported here must always contain both top and bottom fields.
  705. * The top field always begins on the first pixel row. The temporal
  706. * ordering between the two fields is top field first, unless
  707. * 'bottom_first' is specified. It is undefined whether 'bottom_first'
  708. * is ignored if 'interlaced' is not set.
  709. *
  710. * This protocol does not convey any information about field rate,
  711. * duration, or timing, other than the relative ordering between the
  712. * two fields in one buffer. A compositor may have to estimate the
  713. * intended field rate from the incoming buffer rate. It is undefined
  714. * whether the time of receiving wl_surface.commit with a new buffer
  715. * attached, applying the wl_surface state, wl_surface.frame callback
  716. * trigger, presentation, or any other point in the compositor cycle
  717. * is used to measure the frame or field times. There is no support
  718. * for detecting missed or late frames/fields/buffers either, and
  719. * there is no support whatsoever for cooperating with interlaced
  720. * compositor output.
  721. *
  722. * The composited image quality resulting from the use of interlaced
  723. * buffers is explicitly undefined. A compositor may use elaborate
  724. * hardware features or software to deinterlace and create progressive
  725. * output frames from a sequence of interlaced input buffers, or it
  726. * may produce substandard image quality. However, compositors that
  727. * cannot guarantee reasonable image quality in all cases are recommended
  728. * to just reject all interlaced buffers.
  729. *
  730. * Any argument errors, including non-positive width or height,
  731. * mismatch between the number of planes and the format, bad
  732. * format, bad offset or stride, may be indicated by fatal protocol
  733. * errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS,
  734. * OUT_OF_BOUNDS.
  735. *
  736. * Dmabuf import errors in the server that are not obvious client
  737. * bugs are returned via the 'failed' event as non-fatal. This
  738. * allows attempting dmabuf sharing and falling back in the client
  739. * if it fails.
  740. *
  741. * This request can be sent only once in the object's lifetime, after
  742. * which the only legal request is destroy. This object should be
  743. * destroyed after issuing a 'create' request. Attempting to use this
  744. * object after issuing 'create' raises the ALREADY_USED protocol error.
  745. *
  746. * It is not mandatory to issue 'create'. If a client wants to
  747. * cancel the buffer creation, it can just destroy this object.
  748. */
  749. static inline void
  750. 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)
  751. {
  752. wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
  753. ZWP_LINUX_BUFFER_PARAMS_V1_CREATE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1), 0, width, height, format, flags);
  754. }
  755. /**
  756. * @ingroup iface_zwp_linux_buffer_params_v1
  757. *
  758. * This asks for immediate creation of a wl_buffer by importing the
  759. * added dmabufs.
  760. *
  761. * In case of import success, no event is sent from the server, and the
  762. * wl_buffer is ready to be used by the client.
  763. *
  764. * Upon import failure, either of the following may happen, as seen fit
  765. * by the implementation:
  766. * - the client is terminated with one of the following fatal protocol
  767. * errors:
  768. * - INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, OUT_OF_BOUNDS,
  769. * in case of argument errors such as mismatch between the number
  770. * of planes and the format, bad format, non-positive width or
  771. * height, or bad offset or stride.
  772. * - INVALID_WL_BUFFER, in case the cause for failure is unknown or
  773. * platform specific.
  774. * - the server creates an invalid wl_buffer, marks it as failed and
  775. * sends a 'failed' event to the client. The result of using this
  776. * invalid wl_buffer as an argument in any request by the client is
  777. * defined by the compositor implementation.
  778. *
  779. * This takes the same arguments as a 'create' request, and obeys the
  780. * same restrictions.
  781. */
  782. static inline struct wl_buffer *
  783. 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)
  784. {
  785. struct wl_proxy *buffer_id;
  786. buffer_id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
  787. 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);
  788. return (struct wl_buffer *) buffer_id;
  789. }
  790. /**
  791. * @ingroup iface_zwp_linux_buffer_params_v1
  792. *
  793. * Set the device the compositor should import the dmabufs to for sampling
  794. * in the next create or create_immed request.
  795. *
  796. * To avoid race conditions when the compositor removes a device from the
  797. * tranches, it is not a protocol error if the device hasn't been advertised
  798. * by the compositor in a tranche with the sampling flag, but the import is
  799. * likely to fail in that case.
  800. *
  801. * If the client doesn't know a suitable target device, it shouldn't set one,
  802. * and the compositor should attempt import on all devices it supports.
  803. *
  804. * If the array is too small to contain a dev_t or larger than required, the
  805. * invalid_dev_t_size error will be emitted.
  806. */
  807. static inline void
  808. zwp_linux_buffer_params_v1_set_sampling_device(struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_params_v1, struct wl_array *device)
  809. {
  810. wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_buffer_params_v1,
  811. ZWP_LINUX_BUFFER_PARAMS_V1_SET_SAMPLING_DEVICE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_buffer_params_v1), 0, device);
  812. }
  813. #ifndef ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM
  814. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM
  815. enum zwp_linux_dmabuf_feedback_v1_tranche_flags {
  816. /**
  817. * direct scan-out tranche
  818. *
  819. * The scanout flag is a hint that direct scan-out may be
  820. * attempted by the compositor on the target device if the client
  821. * appropriately allocates a buffer. How to allocate a buffer that
  822. * can be scanned out on the target device is
  823. * implementation-defined.
  824. * @since 4
  825. */
  826. ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT = 1,
  827. /**
  828. * sampling tranche
  829. *
  830. * The sampling flag describes that the compositor is able to
  831. * efficiently sample from buffers imported to the target device if
  832. * the client appropriately allocates a buffer. How to allocate a
  833. * buffer that can be efficiently sampled on the target device is
  834. * implementation defined.
  835. * @since 6
  836. */
  837. ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SAMPLING = 2,
  838. };
  839. /**
  840. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  841. */
  842. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT_SINCE_VERSION 4
  843. /**
  844. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  845. */
  846. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SAMPLING_SINCE_VERSION 6
  847. #endif /* ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_ENUM */
  848. /**
  849. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  850. * @struct zwp_linux_dmabuf_feedback_v1_listener
  851. */
  852. struct zwp_linux_dmabuf_feedback_v1_listener {
  853. /**
  854. * all feedback has been sent
  855. *
  856. * This event is sent after all parameters of a
  857. * zwp_linux_dmabuf_feedback_v1 object have been sent.
  858. *
  859. * This allows changes to the zwp_linux_dmabuf_feedback_v1
  860. * parameters to be seen as atomic, even if they happen via
  861. * multiple events.
  862. */
  863. void (*done)(void *data,
  864. struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1);
  865. /**
  866. * format and modifier table
  867. *
  868. * This event provides a file descriptor which can be
  869. * memory-mapped to access the format and modifier table.
  870. *
  871. * The table contains a tightly packed array of consecutive format
  872. * + modifier pairs. Each pair is 16 bytes wide. It contains a
  873. * format as a 32-bit unsigned integer, followed by 4 bytes of
  874. * unused padding, and a modifier as a 64-bit unsigned integer. The
  875. * native endianness is used.
  876. *
  877. * The client must map the file descriptor in read-only private
  878. * mode.
  879. *
  880. * Compositors are not allowed to mutate the table file contents
  881. * once this event has been sent. Instead, compositors must create
  882. * a new, separate table file and re-send feedback parameters.
  883. * Compositors are allowed to store duplicate format + modifier
  884. * pairs in the table.
  885. * @param fd table file descriptor
  886. * @param size table size, in bytes
  887. */
  888. void (*format_table)(void *data,
  889. struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
  890. int32_t fd,
  891. uint32_t size);
  892. /**
  893. * preferred main device
  894. *
  895. * This event advertises the main device that the server prefers
  896. * to use when direct scan-out to the target device isn't possible.
  897. * The advertised main device may be different for each
  898. * zwp_linux_dmabuf_feedback_v1 object, and may change over time.
  899. *
  900. * There is exactly one main device. The compositor must send at
  901. * least one preference tranche with tranche_target_device equal to
  902. * main_device.
  903. *
  904. * Clients need to create buffers that the main device can import
  905. * and read from, otherwise creating the dmabuf wl_buffer will fail
  906. * (see the zwp_linux_buffer_params_v1.create and create_immed
  907. * requests for details). The main device will also likely be kept
  908. * active by the compositor, so clients can use it instead of
  909. * waking up another device for power savings.
  910. *
  911. * In general the device is a DRM node. The DRM node type (primary
  912. * vs. render) is unspecified. Clients must not rely on the
  913. * compositor sending a particular node type. Clients cannot check
  914. * two devices for equality by comparing the dev_t value.
  915. *
  916. * If explicit modifiers are not supported and the client performs
  917. * buffer allocations on a different device than the main device,
  918. * then the client must force the buffer to have a linear layout.
  919. *
  920. * With version 6 and above, this event is no longer sent. Clients
  921. * should use a device with the sampling flag in the tranches
  922. * instead.
  923. * @param device device dev_t value
  924. * @deprecated Deprecated since version 6
  925. */
  926. void (*main_device)(void *data,
  927. struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
  928. struct wl_array *device);
  929. /**
  930. * a preference tranche has been sent
  931. *
  932. * This event splits tranche_target_device and tranche_formats
  933. * events into preference tranches. It is sent after a set of
  934. * tranche_target_device and tranche_formats events; it represents
  935. * the end of a tranche. The next tranche will have a lower
  936. * preference.
  937. */
  938. void (*tranche_done)(void *data,
  939. struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1);
  940. /**
  941. * target device
  942. *
  943. * This event advertises the target device that the server
  944. * prefers to use for a buffer created given this tranche. The
  945. * advertised target device may be different for each preference
  946. * tranche, and may change over time.
  947. *
  948. * There is exactly one target device per tranche.
  949. *
  950. * The target device may be a scan-out device, for example if the
  951. * compositor prefers to directly scan-out a buffer created given
  952. * this tranche. The target device may be a rendering device, for
  953. * example if the compositor prefers to texture from said buffer.
  954. *
  955. * The client can use this hint to allocate the buffer in a way
  956. * that makes it accessible from the target device, ideally
  957. * directly. The buffer must still be accessible from a device with
  958. * the sampling flag, either through direct import or a potentially
  959. * more expensive fallback path. If the buffer can't be directly
  960. * imported for sampling, then clients must be prepared for the
  961. * compositor changing the tranche priority or making wl_buffer
  962. * creation fail (see the zwp_linux_buffer_params_v1.create and
  963. * create_immed requests for details).
  964. *
  965. * If the device is a DRM node, the DRM node type (primary vs.
  966. * render) is unspecified. Clients must not rely on the compositor
  967. * sending a particular node type. Clients cannot check two devices
  968. * for equality by comparing the dev_t value.
  969. *
  970. * This event is tied to a preference tranche, see the tranche_done
  971. * event.
  972. * @param device device dev_t value
  973. */
  974. void (*tranche_target_device)(void *data,
  975. struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
  976. struct wl_array *device);
  977. /**
  978. * supported buffer format modifiers
  979. *
  980. * This event advertises the format + modifier combinations that
  981. * the compositor supports.
  982. *
  983. * It carries an array of indices, each referring to a format +
  984. * modifier pair in the last received format table (see the
  985. * format_table event). Each index is a 16-bit unsigned integer in
  986. * native endianness.
  987. *
  988. * For legacy support, DRM_FORMAT_MOD_INVALID is an allowed
  989. * modifier. It indicates that the server can support the format
  990. * with an implicit modifier. When a buffer has
  991. * DRM_FORMAT_MOD_INVALID as its modifier, it is as if no explicit
  992. * modifier is specified. The effective modifier will be derived
  993. * from the dmabuf.
  994. *
  995. * A compositor that sends valid modifiers and
  996. * DRM_FORMAT_MOD_INVALID for a given format supports both explicit
  997. * modifiers and implicit modifiers.
  998. *
  999. * Compositors must not send duplicate format + modifier pairs
  1000. * within the same tranche or across two different tranches with
  1001. * the same target device and flags.
  1002. *
  1003. * This event is tied to a preference tranche, see the tranche_done
  1004. * event.
  1005. *
  1006. * For the definition of the format and modifier codes, see the
  1007. * zwp_linux_buffer_params_v1.create request.
  1008. * @param indices array of 16-bit indexes
  1009. */
  1010. void (*tranche_formats)(void *data,
  1011. struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
  1012. struct wl_array *indices);
  1013. /**
  1014. * tranche flags
  1015. *
  1016. * This event sets tranche-specific flags. This event is tied to
  1017. * a preference tranche, see the tranche_done event. With version 6
  1018. * and above, the compositor must set at least one flag in each
  1019. * tranche.
  1020. * @param flags tranche flags
  1021. */
  1022. void (*tranche_flags)(void *data,
  1023. struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
  1024. uint32_t flags);
  1025. };
  1026. /**
  1027. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1028. */
  1029. static inline int
  1030. zwp_linux_dmabuf_feedback_v1_add_listener(struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
  1031. const struct zwp_linux_dmabuf_feedback_v1_listener *listener, void *data)
  1032. {
  1033. return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_dmabuf_feedback_v1,
  1034. (void (**)(void)) listener, data);
  1035. }
  1036. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_DESTROY 0
  1037. /**
  1038. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1039. */
  1040. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_DONE_SINCE_VERSION 1
  1041. /**
  1042. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1043. */
  1044. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_FORMAT_TABLE_SINCE_VERSION 1
  1045. /**
  1046. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1047. */
  1048. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_MAIN_DEVICE_SINCE_VERSION 1
  1049. /**
  1050. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1051. */
  1052. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_DONE_SINCE_VERSION 1
  1053. /**
  1054. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1055. */
  1056. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_TARGET_DEVICE_SINCE_VERSION 1
  1057. /**
  1058. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1059. */
  1060. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FORMATS_SINCE_VERSION 1
  1061. /**
  1062. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1063. */
  1064. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SINCE_VERSION 1
  1065. /**
  1066. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1067. */
  1068. #define ZWP_LINUX_DMABUF_FEEDBACK_V1_DESTROY_SINCE_VERSION 1
  1069. /** @ingroup iface_zwp_linux_dmabuf_feedback_v1 */
  1070. static inline void
  1071. zwp_linux_dmabuf_feedback_v1_set_user_data(struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1, void *user_data)
  1072. {
  1073. wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_dmabuf_feedback_v1, user_data);
  1074. }
  1075. /** @ingroup iface_zwp_linux_dmabuf_feedback_v1 */
  1076. static inline void *
  1077. zwp_linux_dmabuf_feedback_v1_get_user_data(struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
  1078. {
  1079. return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_dmabuf_feedback_v1);
  1080. }
  1081. static inline uint32_t
  1082. zwp_linux_dmabuf_feedback_v1_get_version(struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
  1083. {
  1084. return wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_feedback_v1);
  1085. }
  1086. /**
  1087. * @ingroup iface_zwp_linux_dmabuf_feedback_v1
  1088. *
  1089. * Using this request a client can tell the server that it is not going to
  1090. * use the zwp_linux_dmabuf_feedback_v1 object anymore.
  1091. */
  1092. static inline void
  1093. zwp_linux_dmabuf_feedback_v1_destroy(struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
  1094. {
  1095. wl_proxy_marshal_flags((struct wl_proxy *) zwp_linux_dmabuf_feedback_v1,
  1096. ZWP_LINUX_DMABUF_FEEDBACK_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_linux_dmabuf_feedback_v1), WL_MARSHAL_FLAG_DESTROY);
  1097. }
  1098. #ifdef __cplusplus
  1099. }
  1100. #endif
  1101. #endif