aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-04-06 19:30:57 +0200
committerKenny Levinsen <kl@kl.wtf>2021-06-13 10:57:17 +0200
commitb180d3482f5d198b95c3ded70eb549325b8cb73c (patch)
treebdbd8b892ad31559d362ecf5120ed30663282400
parent63f891e393ca5256ad5b6847291d88c098321ed6 (diff)
backend/drm: introduce drm_connector_alloc_crtc
This function allocates a CRTC for a connector if necessary.
-rw-r--r--backend/drm/drm.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 578944d2..7c28d319 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -727,6 +727,19 @@ static void attempt_enable_needs_modeset(struct wlr_drm_backend *drm) {
}
}
+static bool drm_connector_alloc_crtc(struct wlr_drm_connector *conn) {
+ if (conn->crtc != NULL) {
+ return true;
+ }
+
+ bool prev_desired_enabled = conn->desired_enabled;
+ conn->desired_enabled = true;
+ realloc_crtcs(conn->backend);
+ conn->desired_enabled = prev_desired_enabled;
+
+ return conn->crtc != NULL;
+}
+
static bool drm_connector_set_mode(struct wlr_drm_connector *conn,
const struct wlr_output_state *state) {
struct wlr_drm_backend *drm = conn->backend;
@@ -763,11 +776,7 @@ static bool drm_connector_set_mode(struct wlr_drm_connector *conn,
return false;
}
- if (conn->crtc == NULL) {
- // Maybe we can steal a CRTC from a disabled output
- realloc_crtcs(drm);
- }
- if (conn->crtc == NULL) {
+ if (!drm_connector_alloc_crtc(conn)) {
wlr_drm_conn_log(conn, WLR_ERROR,
"Cannot perform modeset: no CRTC for this connector");
return false;