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

Side by Side Diff: third_party/wayland-protocols/include/protocol/linux-dmabuf-unstable-v1-server-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_SERVER_PROTOCOL_H
27 #define LINUX_DMABUF_UNSTABLE_V1_SERVER_PROTOCOL_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #include <stdint.h>
34 #include <stddef.h>
35 #include "wayland-util.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 * @destroy: unbind the factory
49 * @create_params: create a temporary object for buffer parameters
50 *
51 * Following the interfaces from:
52 * https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_imp ort.txt
53 * and the Linux DRM sub-system's AddFb2 ioctl.
54 *
55 * This interface offers a way to create generic dmabuf-based wl_buffers.
56 * Immediately after a client binds to this interface, the set of supported
57 * formats is sent with 'format' events.
58 *
59 * The following are required from clients:
60 *
61 * - Clients must ensure that either all data in the dma-buf is coherent
62 * for all subsequent read access or that coherency is correctly handled by
63 * the underlying kernel-side dma-buf implementation.
64 *
65 * - Don't make any more attachments after sending the buffer to the
66 * compositor. Making more attachments later increases the risk of the
67 * compositor not being able to use (re-import) an existing dmabuf-based
68 * wl_buffer.
69 *
70 * The underlying graphics stack must ensure the following:
71 *
72 * - The dmabuf file descriptors relayed to the server will stay valid for
73 * the whole lifetime of the wl_buffer. This means the server may at any
74 * time use those fds to import the dmabuf into any kernel sub-system that
75 * might accept it.
76 *
77 * To create a wl_buffer from one or more dmabufs, a client creates a
78 * zwp_linux_dmabuf_params_v1 object with zwp_linux_dmabuf_v1.create_params
79 * request. All planes required by the intended format are added with the
80 * 'add' request. Finally, 'create' request is issued. The server will
81 * reply with either 'created' event which provides the final wl_buffer or
82 * 'failed' event saying that it cannot use the dmabufs provided.
83 *
84 * Warning! The protocol described in this file is experimental and
85 * backward incompatible changes may be made. Backward compatible changes
86 * may be added together with the corresponding interface version bump.
87 * Backward incompatible changes are done by bumping the version number in
88 * the protocol and interface names and resetting the interface version.
89 * Once the protocol is to be declared stable, the 'z' prefix and the
90 * version number in the protocol and interface names are removed and the
91 * interface version number is reset.
92 */
93 struct zwp_linux_dmabuf_v1_interface {
94 /**
95 * destroy - unbind the factory
96 *
97 * Objects created through this interface, especially wl_buffers,
98 * will remain valid.
99 */
100 void (*destroy)(struct wl_client *client,
101 struct wl_resource *resource);
102 /**
103 * create_params - create a temporary object for buffer
104 * parameters
105 * @params_id: the new temporary
106 *
107 * This temporary object is used to collect multiple dmabuf
108 * handles into a single batch to create a wl_buffer. It can only
109 * be used once and should be destroyed after an 'created' or
110 * 'failed' event has been received.
111 */
112 void (*create_params)(struct wl_client *client,
113 struct wl_resource *resource,
114 uint32_t params_id);
115 };
116
117 #define ZWP_LINUX_DMABUF_V1_FORMAT 0
118
119 static inline void
120 zwp_linux_dmabuf_v1_send_format(struct wl_resource *resource_, uint32_t format)
121 {
122 wl_resource_post_event(resource_, ZWP_LINUX_DMABUF_V1_FORMAT, format);
123 }
124
125 #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
126 #define ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM
127 enum zwp_linux_buffer_params_v1_error {
128 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED = 0,
129 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX = 1,
130 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET = 2,
131 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE = 3,
132 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT = 4,
133 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS = 5,
134 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS = 6,
135 };
136 #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ENUM */
137
138 #ifndef ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
139 #define ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM
140 enum zwp_linux_buffer_params_v1_flags {
141 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT = 1,
142 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED = 2,
143 ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST = 4,
144 };
145 #endif /* ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_ENUM */
146
147 /**
148 * zwp_linux_buffer_params_v1 - parameters for creating a dmabuf-based
149 * wl_buffer
150 * @destroy: delete this object, used or not
151 * @add: add a dmabuf to the temporary set
152 * @create: create a wl_buffer from the given dmabufs
153 *
154 * This temporary object is a collection of dmabufs and other parameters
155 * that together form a single logical buffer. The temporary object may
156 * eventually create one wl_buffer unless cancelled by destroying it before
157 * requesting 'create'.
158 *
159 * Single-planar formats only require one dmabuf, however multi-planar
160 * formats may require more than one dmabuf. For all formats, 'add' request
161 * must be called once per plane (even if the underlying dmabuf fd is
162 * identical).
163 *
164 * You must use consecutive plane indices ('plane_idx' argument for 'add')
165 * from zero to the number of planes used by the drm_fourcc format code.
166 * All planes required by the format must be given exactly once, but can be
167 * given in any order. Each plane index can be set only once.
168 */
169 struct zwp_linux_buffer_params_v1_interface {
170 /**
171 * destroy - delete this object, used or not
172 *
173 * Cleans up the temporary data sent to the server for
174 * dmabuf-based wl_buffer creation.
175 */
176 void (*destroy)(struct wl_client *client,
177 struct wl_resource *resource);
178 /**
179 * add - add a dmabuf to the temporary set
180 * @fd: dmabuf fd
181 * @plane_idx: plane index
182 * @offset: offset in bytes
183 * @stride: stride in bytes
184 * @modifier_hi: high 32 bits of layout modifier
185 * @modifier_lo: low 32 bits of layout modifier
186 *
187 * This request adds one dmabuf to the set in this
188 * zwp_linux_buffer_params_v1.
189 *
190 * The 64-bit unsigned value combined from modifier_hi and
191 * modifier_lo is the dmabuf layout modifier. DRM AddFB2 ioctl
192 * calls this the fb modifier, which is defined in drm_mode.h of
193 * Linux UAPI. This is an opaque token. Drivers use this token to
194 * express tiling, compression, etc. driver-specific modifications
195 * to the base format defined by the DRM fourcc code.
196 *
197 * This request raises the PLANE_IDX error if plane_idx is too
198 * large. The error PLANE_SET is raised if attempting to set a
199 * plane that was already set.
200 */
201 void (*add)(struct wl_client *client,
202 struct wl_resource *resource,
203 int32_t fd,
204 uint32_t plane_idx,
205 uint32_t offset,
206 uint32_t stride,
207 uint32_t modifier_hi,
208 uint32_t modifier_lo);
209 /**
210 * create - create a wl_buffer from the given dmabufs
211 * @width: base plane width in pixels
212 * @height: base plane height in pixels
213 * @format: DRM_FORMAT code
214 * @flags: see enum flags
215 *
216 * This asks for creation of a wl_buffer from the added dmabuf
217 * buffers. The wl_buffer is not created immediately but returned
218 * via the 'created' event if the dmabuf sharing succeeds. The
219 * sharing may fail at runtime for reasons a client cannot predict,
220 * in which case the 'failed' event is triggered.
221 *
222 * The 'format' argument is a DRM_FORMAT code, as defined by the
223 * libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the
224 * authoritative source on how the format codes should work.
225 *
226 * The 'flags' is a bitfield of the flags defined in enum "flags".
227 * 'y_invert' means the that the image needs to be y-flipped.
228 *
229 * Flag 'interlaced' means that the frame in the buffer is not
230 * progressive as usual, but interlaced. An interlaced buffer as
231 * supported here must always contain both top and bottom fields.
232 * The top field always begins on the first pixel row. The temporal
233 * ordering between the two fields is top field first, unless
234 * 'bottom_first' is specified. It is undefined whether
235 * 'bottom_first' is ignored if 'interlaced' is not set.
236 *
237 * This protocol does not convey any information about field rate,
238 * duration, or timing, other than the relative ordering between
239 * the two fields in one buffer. A compositor may have to estimate
240 * the intended field rate from the incoming buffer rate. It is
241 * undefined whether the time of receiving wl_surface.commit with a
242 * new buffer attached, applying the wl_surface state,
243 * wl_surface.frame callback trigger, presentation, or any other
244 * point in the compositor cycle is used to measure the frame or
245 * field times. There is no support for detecting missed or late
246 * frames/fields/buffers either, and there is no support whatsoever
247 * for cooperating with interlaced compositor output.
248 *
249 * The composited image quality resulting from the use of
250 * interlaced buffers is explicitly undefined. A compositor may use
251 * elaborate hardware features or software to deinterlace and
252 * create progressive output frames from a sequence of interlaced
253 * input buffers, or it may produce substandard image quality.
254 * However, compositors that cannot guarantee reasonable image
255 * quality in all cases are recommended to just reject all
256 * interlaced buffers.
257 *
258 * Any argument errors, including non-positive width or height,
259 * mismatch between the number of planes and the format, bad
260 * format, bad offset or stride, may be indicated by fatal protocol
261 * errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS,
262 * OUT_OF_BOUNDS.
263 *
264 * Dmabuf import errors in the server that are not obvious client
265 * bugs are returned via the 'failed' event as non-fatal. This
266 * allows attempting dmabuf sharing and falling back in the client
267 * if it fails.
268 *
269 * This request can be sent only once in the object's lifetime,
270 * after which the only legal request is destroy. This object
271 * should be destroyed after issuing 'create' request. Attempting
272 * to use this object after issuing 'create' raises ALREADY_USED
273 * protocol error.
274 *
275 * It is not mandatory to issue 'create'. If a client wants to
276 * cancel the buffer creation, it can just destroy this object.
277 */
278 void (*create)(struct wl_client *client,
279 struct wl_resource *resource,
280 int32_t width,
281 int32_t height,
282 uint32_t format,
283 uint32_t flags);
284 };
285
286 #define ZWP_LINUX_BUFFER_PARAMS_V1_CREATED 0
287 #define ZWP_LINUX_BUFFER_PARAMS_V1_FAILED 1
288
289 static inline void
290 zwp_linux_buffer_params_v1_send_created(struct wl_resource *resource_, struct wl _resource *buffer)
291 {
292 wl_resource_post_event(resource_, ZWP_LINUX_BUFFER_PARAMS_V1_CREATED, bu ffer);
293 }
294
295 static inline void
296 zwp_linux_buffer_params_v1_send_failed(struct wl_resource *resource_)
297 {
298 wl_resource_post_event(resource_, ZWP_LINUX_BUFFER_PARAMS_V1_FAILED);
299 }
300
301 #ifdef __cplusplus
302 }
303 #endif
304
305 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698