blob: 162ff58676f0f20222a620df5966e580e4036d25 [file] [log] [blame]
Pekka Paalanen230f3b12014-09-29 14:18:40 -04001/*
2 * Copyright © 2014, 2015 Collabora, Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 */
22
23#ifndef WESTON_LINUX_DMABUF_H
24#define WESTON_LINUX_DMABUF_H
25
26#include <stdint.h>
27
28#define MAX_DMABUF_PLANES 4
29
30struct linux_dmabuf_buffer;
31typedef void (*dmabuf_user_data_destroy_func)(
32 struct linux_dmabuf_buffer *buffer);
33
34struct linux_dmabuf_buffer {
35 struct wl_resource *buffer_resource;
36 struct wl_resource *params_resource;
37 struct weston_compositor *compositor;
38 int32_t width;
39 int32_t height;
40 uint32_t format;
41 uint32_t flags; /* enum zlinux_buffer_params_flags */
42 int n_planes;
43 int dmabuf_fd[MAX_DMABUF_PLANES];
44 uint32_t offset[MAX_DMABUF_PLANES];
45 uint32_t stride[MAX_DMABUF_PLANES];
46 uint64_t modifier[MAX_DMABUF_PLANES];
47
48 void *user_data;
49 dmabuf_user_data_destroy_func user_data_destroy_func;
50
51 /* XXX:
52 *
53 * Add backend private data. This would be for the backend
54 * to do all additional imports it might ever use in advance.
55 * The basic principle, even if not implemented in drivers today,
56 * is that dmabufs are first attached, but the actual allocation
57 * is deferred to first use. This would allow the exporter and all
58 * attachers to agree on how to allocate.
59 *
60 * The DRM backend would use this to create drmFBs for each
61 * dmabuf_buffer, just in case at some point it would become
62 * feasible to scan it out directly. This would improve the
63 * possibilities to successfully scan out, avoiding compositing.
64 */
65};
66
67int
68linux_dmabuf_setup(struct weston_compositor *compositor);
69
70struct linux_dmabuf_buffer *
71linux_dmabuf_buffer_get(struct wl_resource *resource);
72
73void
74linux_dmabuf_buffer_set_user_data(struct linux_dmabuf_buffer *buffer,
75 void *data,
76 dmabuf_user_data_destroy_func func);
77void *
78linux_dmabuf_buffer_get_user_data(struct linux_dmabuf_buffer *buffer);
79
80void
81linux_dmabuf_buffer_send_server_error(struct linux_dmabuf_buffer *buffer,
82 const char *msg);
83
84#endif /* WESTON_LINUX_DMABUF_H */