• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef WAYLAND_DRM_H
2 #define WAYLAND_DRM_H
3 
4 #include <wayland-server.h>
5 
6 struct wl_display;
7 struct wl_resource;
8 struct wl_drm_buffer;
9 
10 struct wayland_drm_callbacks {
11 	int (*authenticate)(void *user_data, uint32_t id);
12 
13 	void (*reference_buffer)(void *user_data, uint32_t name, int fd,
14                                  struct wl_drm_buffer *buffer);
15 
16 	void (*release_buffer)(void *user_data, struct wl_drm_buffer *buffer);
17 };
18 
19 
20 struct wl_drm {
21 	struct wl_display *display;
22 	struct wl_global *wl_drm_global;
23 
24 	void *user_data;
25 	char *device_name;
26 	uint32_t flags;
27 
28 	struct wayland_drm_callbacks callbacks;
29 
30 	struct wl_buffer_interface buffer_interface;
31 };
32 
33 struct wl_drm_buffer {
34 	struct wl_resource *resource;
35 	struct wl_drm *drm;
36 	int32_t width, height;
37 	uint32_t format;
38         const void *driver_format;
39         int32_t offset[3];
40         int32_t stride[3];
41 	void *driver_buffer;
42 };
43 
44 enum { WAYLAND_DRM_PRIME = 0x01 };
45 
46 static inline struct wl_drm_buffer *
wayland_drm_buffer_get(struct wl_drm * drm,struct wl_resource * resource)47 wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
48 {
49 	if (resource == NULL)
50 		return NULL;
51 
52 	if (wl_resource_instance_of(resource, &wl_buffer_interface,
53 	                            &drm->buffer_interface))
54 		return wl_resource_get_user_data(resource);
55 	else
56 		return NULL;
57 }
58 
59 struct wl_drm *
60 wayland_drm_init(struct wl_display *display, char *device_name,
61 		 const struct wayland_drm_callbacks *callbacks, void *user_data,
62                  uint32_t flags);
63 
64 void
65 wayland_drm_uninit(struct wl_drm *drm);
66 
67 #endif
68