• 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 	bool (*is_format_supported)(void *user_data, uint32_t format);
19 };
20 
21 
22 struct wl_drm {
23 	struct wl_display *display;
24 	struct wl_global *wl_drm_global;
25 
26 	void *user_data;
27 	char *device_name;
28 	uint32_t flags;
29 
30 	struct wayland_drm_callbacks callbacks;
31 
32 	struct wl_buffer_interface buffer_interface;
33 };
34 
35 struct wl_drm_buffer {
36 	struct wl_resource *resource;
37 	struct wl_drm *drm;
38 	int32_t width, height;
39 	uint32_t format;
40         const void *driver_format;
41         int32_t offset[3];
42         int32_t stride[3];
43 	void *driver_buffer;
44 };
45 
46 enum { WAYLAND_DRM_PRIME = 0x01 };
47 
48 static inline struct wl_drm_buffer *
wayland_drm_buffer_get(struct wl_drm * drm,struct wl_resource * resource)49 wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
50 {
51 	if (resource == NULL)
52 		return NULL;
53 
54 	if (wl_resource_instance_of(resource, &wl_buffer_interface,
55 	                            &drm->buffer_interface))
56 		return wl_resource_get_user_data(resource);
57 	else
58 		return NULL;
59 }
60 
61 struct wl_drm *
62 wayland_drm_init(struct wl_display *display, char *device_name,
63 		 const struct wayland_drm_callbacks *callbacks, void *user_data,
64                  uint32_t flags);
65 
66 void
67 wayland_drm_uninit(struct wl_drm *drm);
68 
69 #endif
70