backend/drm: introduce wlr_drm_lease

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3183
This commit is contained in:
Simon Ser 2021-11-03 14:03:59 +01:00 committed by Simon Zeni
parent a37f538ca0
commit 86f5ecf468
5 changed files with 80 additions and 56 deletions

View file

@ -36,7 +36,7 @@ struct wlr_drm_plane {
struct wlr_drm_crtc {
uint32_t id;
uint32_t lessee_id;
struct wlr_drm_lease *lease;
// Atomic modesetting only
uint32_t mode_id;
@ -118,7 +118,7 @@ struct wlr_drm_connector {
enum wlr_drm_connector_status status;
bool desired_enabled;
uint32_t id;
uint32_t lessee_id;
struct wlr_drm_lease *lease;
struct wlr_drm_crtc *crtc;
uint32_t possible_crtcs;
@ -157,6 +157,7 @@ bool drm_connector_is_cursor_visible(struct wlr_drm_connector *conn);
bool drm_connector_supports_vrr(struct wlr_drm_connector *conn);
size_t drm_crtc_get_gamma_lut_size(struct wlr_drm_backend *drm,
struct wlr_drm_crtc *crtc);
void drm_lease_destroy(struct wlr_drm_lease *lease);
struct wlr_drm_fb *plane_get_next_fb(struct wlr_drm_plane *plane);

View file

@ -14,6 +14,20 @@
#include <wlr/backend/session.h>
#include <wlr/types/wlr_output.h>
struct wlr_drm_backend;
struct wlr_drm_lease {
int fd;
uint32_t lessee_id;
struct wlr_drm_backend *backend;
struct {
struct wl_signal destroy;
} events;
void *data;
};
/**
* Creates a DRM backend using the specified GPU file descriptor (typically from
* a device node in /dev/dri).
@ -41,18 +55,20 @@ uint32_t wlr_drm_connector_get_id(struct wlr_output *output);
int wlr_drm_backend_get_non_master_fd(struct wlr_backend *backend);
/**
* Leases a given output to the caller. The output must be from the associated
* DRM backend.
* Returns a valid opened DRM FD or -1 on error.
* Leases the given outputs to the caller. The outputs must be from the
* associated DRM backend.
*
* Returns NULL on error.
*/
int wlr_drm_create_lease(struct wlr_output **outputs, size_t n_outputs,
uint32_t *lessee_id);
struct wlr_drm_lease *wlr_drm_create_lease(struct wlr_output **outputs,
size_t n_outputs, int *lease_fd);
/**
* Terminates a given lease. The output will be owned again by the backend
* Terminates and destroys a given lease.
*
* The outputs will be owned again by the backend.
*/
bool wlr_drm_backend_terminate_lease(struct wlr_backend *backend,
uint32_t lessee_id);
void wlr_drm_lease_terminate(struct wlr_drm_lease *lease);
/**
* Add mode to the list of available modes

View file

@ -81,14 +81,13 @@ struct wlr_drm_lease_request_v1 {
struct wlr_drm_lease_v1 {
struct wl_resource *resource;
struct wlr_drm_lease *drm_lease;
struct wlr_drm_lease_device_v1 *device;
struct wlr_drm_lease_connector_v1 **connectors;
size_t n_connectors;
uint32_t lessee_id;
struct wl_list link; // wlr_drm_lease_device_v1::leases
void *data;