Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: third_party/wayland-protocols/include/protocol/linux-dmabuf-unstable-v1-client-protocol.h

Issue 1746633002: third_party: Add linux_dmabuf_protocol target to wayland-protocols. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright © 2014, 2015 Collabora, Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this
5 * software and its documentation for any purpose is hereby granted
6 * without fee, provided that the above copyright notice appear in
7 * all copies and that both that copyright notice and this permission
8 * notice appear in supporting documentation, and that the name of
9 * the copyright holders not be used in advertising or publicity
10 * pertaining to distribution of the software without specific,
11 * written prior permission. The copyright holders make no
12 * representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied
14 * warranty.
15 *
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
21 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
23 * THIS SOFTWARE.
24 */
25
26 #ifndef LINUX_DMABUF_UNSTABLE_V1_CLIENT_PROTOCOL_H
27 #define LINUX_DMABUF_UNSTABLE_V1_CLIENT_PROTOCOL_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #include <stdint.h>
34 #include <stddef.h>
35 #include "wayland-client.h"
36
37 struct wl_client;
38 struct wl_resource;
39
40 struct zwp_linux_dmabuf_v1;
41 struct zwp_linux_buffer_params_v1;
42
43 extern const struct wl_interface zwp_linux_dmabuf_v1_interface;
44 extern const struct wl_interface zwp_linux_buffer_params_v1_interface;
45
46 /**
47 * zwp_linux_dmabuf_v1 - factory for creating dmabuf-based wl_buffers
48 * @format: supported buffer format
49 *
50 * Following the interfaces from:
51 * https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_imp ort.txt
52 * and the Linux DRM sub-system's AddFb2 ioctl.
53 *
54 * This interface offers a way to create generic dmabuf-based wl_buffers.
55 * Immediately after a client binds to this interface, the set of supported
56 * formats is sent with 'format' events.
57 *
58 * The following are required from clients:
59 *
60 * - Clients must ensure that either all data in the dma-buf is coherent
61 * for all subsequent read access or that coherency is correctly handled by
62 * the underlying kernel-side dma-buf implementation.
63 *
64 * - Don't make any more attachments after sending the buffer to the
65 * compositor. Making more attachments later increases the risk of the
66 * compositor not being able to use (re-import) an existing dmabuf-based
67 * wl_buffer.
68 *
69 * The underlying graphics stack must ensure the following:
70 *
71 * - The dmabuf file descriptors relayed to the server will stay valid for
72 * the whole lifetime of the wl_buffer. This means the server may at any
73 * time use those fds to import the dmabuf into any kernel sub-system that
74 * might accept it.
75 *
76 * To create a wl_buffer from one or more dmabufs, a client creates a
77 * zwp_linux_dmabuf_params_v1 object with zwp_linux_dmabuf_v1.create_params
78 * request. All planes required by the intended format are added with the
79 * 'add' request. Finally, 'create' request is issued. The server will
80 * reply with either 'created' event which provides the final wl_buffer or
81 * 'failed' event saying that it cannot use the dmabufs provided.
82 *
83 * Warning! The protocol described in this file is experimental and
84 * backward incompatible changes may be made. Backward compatible changes
85 * may be added together with the corresponding interface version bump.
86 * Backward incompatible changes are done by bumping the version number in
87 * the protocol and interface names and resetting the interface version.
88 * Once the protocol is to be declared stable, the 'z' prefix and the
89 * version number in the protocol and interface names are removed and the
90 * interface version number is reset.
91 */
92 struct zwp_linux_dmabuf_v1_listener {
93 /**
94 * format - supported buffer format
95 * @format: DRM_FORMAT code
96 *
97 * This event advertises one buffer format that the server
98 * supports. All the supported formats are advertised once when the
99 * client binds to this interface. A roundtrip after binding
100 * guarantees, that the client has received all supported formats.
101 *
102 * For the definition of the format codes, see create request.
103 *
104 * XXX: Can a compositor ever enumerate them?
105 */
106 void (*format)(void *data,
107 struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1,
108 uint32_t format);
109 };
110
111 static inline int
112 zwp_linux_dmabuf_v1_add_listener(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1 ,
113 const struct zwp_linux_dmabuf_v1_listener *list ener, void *data)
114 {
115 return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_dmabuf_v1,
116 (void (**)(void)) listener, data);
117 }
118
119 #define ZWP_LINUX_DMABUF_V1_DESTROY 0
120 #define ZWP_LINUX_DMABUF_V1_CREATE_PARAMS 1
121
122 static inline void
123 zwp_linux_dmabuf_v1_set_user_data(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v 1, void *user_data)
124 {
125 wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_dmabuf_v1, user_dat a);
126 }
127
128 static inline void *
129 zwp_linux_dmabuf_v1_get_user_data(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v 1)
130 {
131 return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_dmabuf_v1);
132 }
133
134 static inline void
135 zwp_linux_dmabuf_v1_destroy(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1)
136 {
137 wl_proxy_marshal((struct wl_proxy *) zwp_linux_dmabuf_v1,
138 ZWP_LINUX_DMABUF_V1_DESTROY);
139
140 wl_proxy_destroy((struct wl_proxy *) zwp_linux_dmabuf_v1);
141 }
142
143 static inline struct zwp_linux_buffer_params_v1 *
144 zwp_linux_dmabuf_v1_create_params(struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v 1)
145 {
146 struct wl_proxy *params_id;
147
148 params_id = wl_proxy_marshal_constructor((struct wl_proxy *) zwp_linux_d mabuf_v1,
149 ZWP_LINUX_DMABUF_V1_CREATE_PARAMS, &zwp_linux_buffer_pa rams_v1_interface, NULL);
150
151 return (struct zwp_linux_buffer_params_v1 *) params_id;
152 }
153
154 #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
155 #define ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
156 enum zwp_linux_buffer_params_v1_error {
157 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED = 0,
158 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX = 1,
159 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET = 2,
160 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE = 3,
161 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT = 4,
162 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS = 5,
163 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS = 6,
164 };
165 #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM */
166
167 #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
168 #define ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
169 enum zwp_linux_buffer_params_v1_flags {
170 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT = 1,
171 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED = 2,
172 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST = 4,
173 };
174 #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM */
175
176 /**
177 * zwp_linux_buffer_params_v1 - parameters for creating a dmabuf-based
178 * wl_buffer
179 * @created: buffer creation succeeded
180 * @failed: buffer creation failed
181 *
182 * This temporary object is a collection of dmabufs and other parameters
183 * that together form a single logical buffer. The temporary object may
184 * eventually create one wl_buffer unless cancelled by destroying it before
185 * requesting 'create'.
186 *
187 * Single-planar formats only require one dmabuf, however multi-planar
188 * formats may require more than one dmabuf. For all formats, 'add' request
189 * must be called once per plane (even if the underlying dmabuf fd is
190 * identical).
191 *
192 * You must use consecutive plane indices ('plane_idx' argument for 'add')
193 * from zero to the number of planes used by the drm_fourcc format code.
194 * All planes required by the format must be given exactly once, but can be
195 * given in any order. Each plane index can be set only once.
196 */
197 struct zwp_linux_buffer_params_v1_listener {
198 /**
199 * created - buffer creation succeeded
200 * @buffer: the newly created wl_buffer
201 *
202 * This event indicates that the attempted buffer creation was
203 * successful. It provides the new wl_buffer referencing the
204 * dmabuf(s).
205 *
206 * Upon receiving this event, the client should destroy the
207 * zlinux_dmabuf_params object.
208 */
209 void (*created)(void *data,
210 struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_para ms_v1,
211 struct wl_buffer *buffer);
212 /**
213 * failed - buffer creation failed
214 *
215 * This event indicates that the attempted buffer creation has
216 * failed. It usually means that one of the dmabuf constraints has
217 * not been fulfilled.
218 *
219 * Upon receiving this event, the client should destroy the
220 * zlinux_buffer_params object.
221 */
222 void (*failed)(void *data,
223 struct zwp_linux_buffer_params_v1 *zwp_linux_buffer_param s_v1);
224 };
225
226 static inline int
227 zwp_linux_buffer_params_v1_add_listener(struct zwp_linux_buffer_params_v1 *zwp_l inux_buffer_params_v1,
228 const struct zwp_linux_buffer_params_v1_ listener *listener, void *data)
229 {
230 return wl_proxy_add_listener((struct wl_proxy *) zwp_linux_buffer_params _v1,
231 (void (**)(void)) listener, data);
232 }
233
234 #define ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY 0
235 #define ZWP_LINUX_BUFFER_PARAMS_V1_ADD 1
236 #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATE 2
237
238 static inline void
239 zwp_linux_buffer_params_v1_set_user_data(struct zwp_linux_buffer_params_v1 *zwp_ linux_buffer_params_v1, void *user_data)
240 {
241 wl_proxy_set_user_data((struct wl_proxy *) zwp_linux_buffer_params_v1, u ser_data);
242 }
243
244 static inline void *
245 zwp_linux_buffer_params_v1_get_user_data(struct zwp_linux_buffer_params_v1 *zwp_ linux_buffer_params_v1)
246 {
247 return wl_proxy_get_user_data((struct wl_proxy *) zwp_linux_buffer_param s_v1);
248 }
249
250 static inline void
251 zwp_linux_buffer_params_v1_destroy(struct zwp_linux_buffer_params_v1 *zwp_linux_ buffer_params_v1)
252 {
253 wl_proxy_marshal((struct wl_proxy *) zwp_linux_buffer_params_v1,
254 ZWP_LINUX_BUFFER_PARAMS_V1_DESTROY);
255
256 wl_proxy_destroy((struct wl_proxy *) zwp_linux_buffer_params_v1);
257 }
258
259 static inline void
260 zwp_linux_buffer_params_v1_add(struct zwp_linux_buffer_params_v1 *zwp_linux_buff er_params_v1, int32_t fd, uint32_t plane_idx, uint32_t offset, uint32_t stride, uint32_t modifier_hi, uint32_t modifier_lo)
261 {
262 wl_proxy_marshal((struct wl_proxy *) zwp_linux_buffer_params_v1,
263 ZWP_LINUX_BUFFER_PARAMS_V1_ADD, fd, plane_idx, offset, stride, modifier_hi, modifier_lo);
264 }
265
266 static inline void
267 zwp_linux_buffer_params_v1_create(struct zwp_linux_buffer_params_v1 *zwp_linux_b uffer_params_v1, int32_t width, int32_t height, uint32_t format, uint32_t flags)
268 {
269 wl_proxy_marshal((struct wl_proxy *) zwp_linux_buffer_params_v1,
270 ZWP_LINUX_BUFFER_PARAMS_V1_CREATE, width, height, forma t, flags);
271 }
272
273 #ifdef __cplusplus
274 }
275 #endif
276
277 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698