aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/drm.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-08-18 19:17:33 +0200
committerSimon Ser <contact@emersion.fr>2023-02-20 18:38:57 +0100
commit9d43e7e4d67d4076c8b20ee2715eadec86a83e73 (patch)
tree1c75d2e0719d5a48ac97d5d1fb80c28f84ee66a1 /backend/drm/drm.c
parentb4e9487312a8b5b80c56ddfdd5751c12882cd3a9 (diff)
backend/drm: add libliftoff interface
Diffstat (limited to 'backend/drm/drm.c')
-rw-r--r--backend/drm/drm.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index f342249f..bfbe6cbd 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -30,6 +30,11 @@
#include "render/swapchain.h"
#include "render/wlr_renderer.h"
#include "util/env.h"
+#include "config.h"
+
+#if HAVE_LIBLIFTOFF
+#include <libliftoff.h>
+#endif
// Output state which needs a KMS commit to be applied
static const uint32_t COMMIT_OUTPUT_STATE =
@@ -76,7 +81,20 @@ bool check_drm_features(struct wlr_drm_backend *drm) {
return false;
}
- if (env_parse_bool("WLR_DRM_NO_ATOMIC")) {
+ if (env_parse_bool("WLR_DRM_FORCE_LIBLIFTOFF")) {
+#if HAVE_LIBLIFTOFF
+ wlr_log(WLR_INFO,
+ "WLR_DRM_FORCE_LIBLIFTOFF set, forcing libliftoff interface");
+ if (drmSetClientCap(drm->fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0) {
+ wlr_log_errno(WLR_ERROR, "drmSetClientCap(ATOMIC) failed");
+ return false;
+ }
+ drm->iface = &liftoff_iface;
+#else
+ wlr_log(WLR_ERROR, "libliftoff interface not available");
+ return false;
+#endif
+ } else if (env_parse_bool("WLR_DRM_NO_ATOMIC")) {
wlr_log(WLR_DEBUG,
"WLR_DRM_NO_ATOMIC set, forcing legacy DRM interface");
drm->iface = &legacy_iface;
@@ -121,6 +139,7 @@ static bool init_plane(struct wlr_drm_backend *drm,
p->type = type;
p->id = drm_plane->plane_id;
p->props = props;
+ p->initial_crtc_id = drm_plane->crtc_id;
for (size_t i = 0; i < drm_plane->count_formats; ++i) {
// Force a LINEAR layout for the cursor if the driver doesn't support
@@ -263,6 +282,10 @@ bool init_drm_resources(struct wlr_drm_backend *drm) {
goto error_crtcs;
}
+ if (drm->iface->init != NULL && !drm->iface->init(drm)) {
+ goto error_crtcs;
+ }
+
drmModeFreeResources(res);
return true;
@@ -279,6 +302,10 @@ void finish_drm_resources(struct wlr_drm_backend *drm) {
return;
}
+ if (drm->iface->finish != NULL) {
+ drm->iface->finish(drm);
+ }
+
for (size_t i = 0; i < drm->num_crtcs; ++i) {
struct wlr_drm_crtc *crtc = &drm->crtcs[i];
@@ -295,6 +322,9 @@ void finish_drm_resources(struct wlr_drm_backend *drm) {
for (size_t i = 0; i < drm->num_planes; ++i) {
struct wlr_drm_plane *plane = &drm->planes[i];
wlr_drm_format_set_finish(&plane->formats);
+#if HAVE_LIBLIFTOFF
+ liftoff_plane_destroy(plane->liftoff);
+#endif
}
free(drm->planes);