wayland: Don't rely on static variable for identifying wl_drm buffers
[mesa.git] / src / egl / wayland / wayland-drm / wayland-drm.h
1 #ifndef WAYLAND_DRM_H
2 #define WAYLAND_DRM_H
3
4 #include <wayland-server.h>
5
6 #ifndef WL_DRM_FORMAT_ENUM
7 #define WL_DRM_FORMAT_ENUM
8 enum wl_drm_format {
9 WL_DRM_FORMAT_C8 = 0x20203843,
10 WL_DRM_FORMAT_RGB332 = 0x38424752,
11 WL_DRM_FORMAT_BGR233 = 0x38524742,
12 WL_DRM_FORMAT_XRGB4444 = 0x32315258,
13 WL_DRM_FORMAT_XBGR4444 = 0x32314258,
14 WL_DRM_FORMAT_RGBX4444 = 0x32315852,
15 WL_DRM_FORMAT_BGRX4444 = 0x32315842,
16 WL_DRM_FORMAT_ARGB4444 = 0x32315241,
17 WL_DRM_FORMAT_ABGR4444 = 0x32314241,
18 WL_DRM_FORMAT_RGBA4444 = 0x32314152,
19 WL_DRM_FORMAT_BGRA4444 = 0x32314142,
20 WL_DRM_FORMAT_XRGB1555 = 0x35315258,
21 WL_DRM_FORMAT_XBGR1555 = 0x35314258,
22 WL_DRM_FORMAT_RGBX5551 = 0x35315852,
23 WL_DRM_FORMAT_BGRX5551 = 0x35315842,
24 WL_DRM_FORMAT_ARGB1555 = 0x35315241,
25 WL_DRM_FORMAT_ABGR1555 = 0x35314241,
26 WL_DRM_FORMAT_RGBA5551 = 0x35314152,
27 WL_DRM_FORMAT_BGRA5551 = 0x35314142,
28 WL_DRM_FORMAT_RGB565 = 0x36314752,
29 WL_DRM_FORMAT_BGR565 = 0x36314742,
30 WL_DRM_FORMAT_RGB888 = 0x34324752,
31 WL_DRM_FORMAT_BGR888 = 0x34324742,
32 WL_DRM_FORMAT_XRGB8888 = 0x34325258,
33 WL_DRM_FORMAT_XBGR8888 = 0x34324258,
34 WL_DRM_FORMAT_RGBX8888 = 0x34325852,
35 WL_DRM_FORMAT_BGRX8888 = 0x34325842,
36 WL_DRM_FORMAT_ARGB8888 = 0x34325241,
37 WL_DRM_FORMAT_ABGR8888 = 0x34324241,
38 WL_DRM_FORMAT_RGBA8888 = 0x34324152,
39 WL_DRM_FORMAT_BGRA8888 = 0x34324142,
40 WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
41 WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
42 WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
43 WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
44 WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
45 WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
46 WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
47 WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
48 WL_DRM_FORMAT_YUYV = 0x56595559,
49 WL_DRM_FORMAT_YVYU = 0x55595659,
50 WL_DRM_FORMAT_UYVY = 0x59565955,
51 WL_DRM_FORMAT_VYUY = 0x59555956,
52 WL_DRM_FORMAT_AYUV = 0x56555941,
53 WL_DRM_FORMAT_NV12 = 0x3231564e,
54 WL_DRM_FORMAT_NV21 = 0x3132564e,
55 WL_DRM_FORMAT_NV16 = 0x3631564e,
56 WL_DRM_FORMAT_NV61 = 0x3136564e,
57 WL_DRM_FORMAT_YUV410 = 0x39565559,
58 WL_DRM_FORMAT_YVU410 = 0x39555659,
59 WL_DRM_FORMAT_YUV411 = 0x31315559,
60 WL_DRM_FORMAT_YVU411 = 0x31315659,
61 WL_DRM_FORMAT_YUV420 = 0x32315559,
62 WL_DRM_FORMAT_YVU420 = 0x32315659,
63 WL_DRM_FORMAT_YUV422 = 0x36315559,
64 WL_DRM_FORMAT_YVU422 = 0x36315659,
65 WL_DRM_FORMAT_YUV444 = 0x34325559,
66 WL_DRM_FORMAT_YVU444 = 0x34325659,
67 };
68 #endif /* WL_DRM_FORMAT_ENUM */
69
70 struct wl_drm;
71
72 struct wl_drm_buffer {
73 struct wl_resource *resource;
74 struct wl_drm *drm;
75 int32_t width, height;
76 uint32_t format;
77 const void *driver_format;
78 int32_t offset[3];
79 int32_t stride[3];
80 void *driver_buffer;
81 };
82
83 struct wayland_drm_callbacks {
84 int (*authenticate)(void *user_data, uint32_t id);
85
86 void (*reference_buffer)(void *user_data, uint32_t name, int fd,
87 struct wl_drm_buffer *buffer);
88
89 void (*release_buffer)(void *user_data, struct wl_drm_buffer *buffer);
90 };
91
92 enum { WAYLAND_DRM_PRIME = 0x01 };
93
94 struct wl_drm_buffer *
95 wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource);
96
97 struct wl_drm *
98 wayland_drm_init(struct wl_display *display, char *device_name,
99 struct wayland_drm_callbacks *callbacks, void *user_data,
100 uint32_t flags);
101
102 void
103 wayland_drm_uninit(struct wl_drm *drm);
104
105 uint32_t
106 wayland_drm_buffer_get_format(struct wl_drm_buffer *buffer);
107
108 void *
109 wayland_drm_buffer_get_buffer(struct wl_drm_buffer *buffer);
110
111 #endif