2018-07-13 14:40:56 +02:00
|
|
|
/*
|
|
|
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
|
|
|
* future consistency of this API.
|
|
|
|
*/
|
|
|
|
#ifndef WLR_USE_UNSTABLE
|
|
|
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
|
|
|
#endif
|
|
|
|
|
2018-02-23 18:45:16 +01:00
|
|
|
#ifndef WLR_TYPES_WLR_LINUX_DMABUF_H
|
|
|
|
#define WLR_TYPES_WLR_LINUX_DMABUF_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2018-11-13 12:35:08 +01:00
|
|
|
#include <sys/stat.h>
|
2021-02-16 20:00:52 +01:00
|
|
|
#include <wayland-server-core.h>
|
2021-04-12 14:09:27 +02:00
|
|
|
#include <wlr/types/wlr_buffer.h>
|
2018-05-29 23:38:00 +02:00
|
|
|
#include <wlr/render/dmabuf.h>
|
2022-11-30 13:24:46 +01:00
|
|
|
#include <wlr/render/drm_format_set.h>
|
2018-02-23 18:45:16 +01:00
|
|
|
|
2021-06-07 18:20:45 +02:00
|
|
|
struct wlr_surface;
|
|
|
|
|
2018-07-19 22:50:00 +02:00
|
|
|
struct wlr_dmabuf_v1_buffer {
|
2021-04-12 14:09:27 +02:00
|
|
|
struct wlr_buffer base;
|
|
|
|
|
|
|
|
struct wl_resource *resource; // can be NULL if the client destroyed it
|
2018-05-29 23:38:00 +02:00
|
|
|
struct wlr_dmabuf_attributes attributes;
|
2021-04-12 14:09:27 +02:00
|
|
|
|
2021-11-22 10:32:55 +01:00
|
|
|
// private state
|
|
|
|
|
2021-04-12 14:09:27 +02:00
|
|
|
struct wl_listener release;
|
2018-02-23 18:45:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the given resource was created via the linux-dmabuf
|
|
|
|
* buffer protocol, false otherwise
|
|
|
|
*/
|
2018-07-19 22:50:00 +02:00
|
|
|
bool wlr_dmabuf_v1_resource_is_buffer(struct wl_resource *buffer_resource);
|
2018-02-23 18:45:16 +01:00
|
|
|
|
|
|
|
/**
|
2022-05-24 18:46:59 +02:00
|
|
|
* Returns the struct wlr_dmabuf_buffer if the given resource was created
|
|
|
|
* via the linux-dmabuf buffer protocol.
|
2018-02-23 18:45:16 +01:00
|
|
|
*/
|
2018-07-19 22:50:00 +02:00
|
|
|
struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_buffer_resource(
|
2018-02-23 18:45:16 +01:00
|
|
|
struct wl_resource *buffer_resource);
|
|
|
|
|
2018-11-13 12:35:08 +01:00
|
|
|
struct wlr_linux_dmabuf_feedback_v1 {
|
|
|
|
dev_t main_device;
|
2022-12-09 17:58:40 +01:00
|
|
|
struct wl_array tranches; // struct wlr_linux_dmabuf_feedback_v1_tranche
|
2018-11-13 12:35:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_linux_dmabuf_feedback_v1_tranche {
|
|
|
|
dev_t target_device;
|
|
|
|
uint32_t flags; // bitfield of enum zwp_linux_dmabuf_feedback_v1_tranche_flags
|
2022-12-09 17:58:40 +01:00
|
|
|
struct wlr_drm_format_set formats;
|
2018-11-13 12:35:08 +01:00
|
|
|
};
|
|
|
|
|
2018-02-23 18:45:16 +01:00
|
|
|
/* the protocol interface */
|
2018-07-19 22:50:00 +02:00
|
|
|
struct wlr_linux_dmabuf_v1 {
|
2018-07-08 20:21:31 +02:00
|
|
|
struct wl_global *global;
|
2018-04-30 23:20:39 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
|
|
|
|
2021-11-22 10:32:55 +01:00
|
|
|
// private state
|
|
|
|
|
2018-11-13 12:35:08 +01:00
|
|
|
struct wlr_linux_dmabuf_feedback_v1_compiled *default_feedback;
|
2022-11-30 13:24:46 +01:00
|
|
|
struct wlr_drm_format_set default_formats; // for legacy clients
|
2021-06-07 18:20:45 +02:00
|
|
|
struct wl_list surfaces; // wlr_linux_dmabuf_v1_surface.link
|
2018-11-13 12:35:08 +01:00
|
|
|
|
2022-11-30 13:00:09 +01:00
|
|
|
int main_device_fd; // to sanity check FDs sent by clients
|
|
|
|
|
2018-04-30 23:20:39 +02:00
|
|
|
struct wl_listener display_destroy;
|
2018-02-23 18:45:16 +01:00
|
|
|
};
|
|
|
|
|
2022-11-30 13:28:52 +01:00
|
|
|
/**
|
|
|
|
* Create the linux-dmabuf-unstable-v1 global.
|
|
|
|
*
|
|
|
|
* Compositors using struct wlr_renderer should use
|
|
|
|
* wlr_linux_dmabuf_v1_create_with_renderer() instead.
|
|
|
|
*/
|
|
|
|
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *display,
|
|
|
|
uint32_t version, const struct wlr_linux_dmabuf_feedback_v1 *default_feedback);
|
|
|
|
|
2018-02-23 18:45:16 +01:00
|
|
|
/**
|
2022-11-24 10:04:15 +01:00
|
|
|
* Create the linux-dmabuf-unstable-v1 global.
|
|
|
|
*
|
|
|
|
* The default DMA-BUF feedback is initialized from the struct wlr_renderer.
|
2018-02-23 18:45:16 +01:00
|
|
|
*/
|
2022-11-24 10:04:15 +01:00
|
|
|
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create_with_renderer(struct wl_display *display,
|
2022-11-24 10:07:19 +01:00
|
|
|
uint32_t version, struct wlr_renderer *renderer);
|
2018-02-23 18:45:16 +01:00
|
|
|
|
2021-06-07 18:20:45 +02:00
|
|
|
/**
|
|
|
|
* Set a surface's DMA-BUF feedback.
|
|
|
|
*
|
|
|
|
* Passing a NULL feedback resets it to the default feedback.
|
|
|
|
*/
|
|
|
|
bool wlr_linux_dmabuf_v1_set_surface_feedback(
|
|
|
|
struct wlr_linux_dmabuf_v1 *linux_dmabuf, struct wlr_surface *surface,
|
|
|
|
const struct wlr_linux_dmabuf_feedback_v1 *feedback);
|
|
|
|
|
2022-12-09 18:06:26 +01:00
|
|
|
/**
|
|
|
|
* Append a tranche at the end of the DMA-BUF feedback list.
|
|
|
|
*
|
|
|
|
* Tranches must be added with decreasing priority.
|
|
|
|
*/
|
|
|
|
struct wlr_linux_dmabuf_feedback_v1_tranche *wlr_linux_dmabuf_feedback_add_tranche(
|
|
|
|
struct wlr_linux_dmabuf_feedback_v1 *feedback);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release resources allocated by a DMA-BUF feedback object.
|
|
|
|
*/
|
|
|
|
void wlr_linux_dmabuf_feedback_v1_finish(struct wlr_linux_dmabuf_feedback_v1 *feedback);
|
|
|
|
|
2022-12-09 18:30:16 +01:00
|
|
|
struct wlr_linux_dmabuf_feedback_v1_init_options {
|
|
|
|
// Main renderer used by the compositor
|
|
|
|
struct wlr_renderer *main_renderer;
|
|
|
|
// Output on which direct scan-out is possible on the primary plane, or NULL
|
|
|
|
struct wlr_output *scanout_primary_output;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize a DMA-BUF feedback object with the provided options.
|
|
|
|
*
|
|
|
|
* The caller is responsible for calling wlr_linux_dmabuf_feedback_v1_finish() after use.
|
|
|
|
*/
|
|
|
|
bool wlr_linux_dmabuf_feedback_v1_init_with_options(struct wlr_linux_dmabuf_feedback_v1 *feedback,
|
|
|
|
const struct wlr_linux_dmabuf_feedback_v1_init_options *options);
|
|
|
|
|
2018-02-23 18:45:16 +01:00
|
|
|
#endif
|