13464ebd5Sriastradh#ifndef WAYLAND_DRM_H 23464ebd5Sriastradh#define WAYLAND_DRM_H 33464ebd5Sriastradh 43464ebd5Sriastradh#include <wayland-server.h> 53464ebd5Sriastradh 601e04c3fSmrgstruct wl_display; 701e04c3fSmrgstruct wl_resource; 801e04c3fSmrgstruct wl_drm_buffer; 901e04c3fSmrg 1001e04c3fSmrgstruct wayland_drm_callbacks { 1101e04c3fSmrg int (*authenticate)(void *user_data, uint32_t id); 1201e04c3fSmrg 1301e04c3fSmrg void (*reference_buffer)(void *user_data, uint32_t name, int fd, 1401e04c3fSmrg struct wl_drm_buffer *buffer); 1501e04c3fSmrg 1601e04c3fSmrg void (*release_buffer)(void *user_data, struct wl_drm_buffer *buffer); 1701e04c3fSmrg 1801e04c3fSmrg bool (*is_format_supported)(void *user_data, uint32_t format); 19af69d88dSmrg}; 20af69d88dSmrg 2101e04c3fSmrg 2201e04c3fSmrgstruct wl_drm { 2301e04c3fSmrg struct wl_display *display; 2401e04c3fSmrg struct wl_global *wl_drm_global; 2501e04c3fSmrg 2601e04c3fSmrg void *user_data; 2701e04c3fSmrg char *device_name; 2801e04c3fSmrg uint32_t flags; 2901e04c3fSmrg 3001e04c3fSmrg struct wayland_drm_callbacks callbacks; 3101e04c3fSmrg 3201e04c3fSmrg struct wl_buffer_interface buffer_interface; 3301e04c3fSmrg}; 343464ebd5Sriastradh 35af69d88dSmrgstruct wl_drm_buffer { 36af69d88dSmrg struct wl_resource *resource; 37af69d88dSmrg struct wl_drm *drm; 38af69d88dSmrg int32_t width, height; 39af69d88dSmrg uint32_t format; 40af69d88dSmrg const void *driver_format; 41af69d88dSmrg int32_t offset[3]; 42af69d88dSmrg int32_t stride[3]; 43af69d88dSmrg void *driver_buffer; 44af69d88dSmrg}; 45af69d88dSmrg 46af69d88dSmrgenum { WAYLAND_DRM_PRIME = 0x01 }; 47af69d88dSmrg 4801e04c3fSmrgstatic inline struct wl_drm_buffer * 4901e04c3fSmrgwayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource) 5001e04c3fSmrg{ 5101e04c3fSmrg if (resource == NULL) 5201e04c3fSmrg return NULL; 5301e04c3fSmrg 5401e04c3fSmrg if (wl_resource_instance_of(resource, &wl_buffer_interface, 5501e04c3fSmrg &drm->buffer_interface)) 5601e04c3fSmrg return wl_resource_get_user_data(resource); 5701e04c3fSmrg else 5801e04c3fSmrg return NULL; 5901e04c3fSmrg} 60af69d88dSmrg 613464ebd5Sriastradhstruct wl_drm * 623464ebd5Sriastradhwayland_drm_init(struct wl_display *display, char *device_name, 6301e04c3fSmrg const struct wayland_drm_callbacks *callbacks, void *user_data, 64af69d88dSmrg uint32_t flags); 653464ebd5Sriastradh 663464ebd5Sriastradhvoid 673464ebd5Sriastradhwayland_drm_uninit(struct wl_drm *drm); 683464ebd5Sriastradh 693464ebd5Sriastradh#endif 70