aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-12-15 19:26:20 +0100
committerSimon Ser <contact@emersion.fr>2022-12-15 19:26:20 +0100
commit8b18352318056a034257150fa29e49d117492173 (patch)
treeb175bac9a99b0bba9368dc2f8da69791b5626f91
parent7f6d646e0aa78bd796c6a106b77951b4be61935a (diff)
backend/drm: fetch fresh legacy CRTC in connector_get_current_mode()
connect_drm_connector() may be called long after create_drm_connector(). During that time the DRM mode might have changed. Avoid working with stale information.
-rw-r--r--backend/drm/drm.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index ce1aca09..a869e935 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -1215,15 +1215,23 @@ static drmModeModeInfo *connector_get_current_mode(struct wlr_drm_connector *wlr
return mode;
} else {
// Fallback to the legacy API
- if (!wlr_conn->crtc->legacy_crtc->mode_valid) {
+ drmModeCrtc *drm_crtc = drmModeGetCrtc(drm->fd, wlr_conn->crtc->id);
+ if (drm_crtc == NULL) {
+ wlr_log_errno(WLR_ERROR, "drmModeGetCrtc failed");
+ return NULL;
+ }
+ if (!drm_crtc->mode_valid) {
+ drmModeFreeCrtc(drm_crtc);
return NULL;
}
drmModeModeInfo *mode = malloc(sizeof(*mode));
if (mode == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed");
+ drmModeFreeCrtc(drm_crtc);
return NULL;
}
- *mode = wlr_conn->crtc->legacy_crtc->mode;
+ *mode = drm_crtc->mode;
+ drmModeFreeCrtc(drm_crtc);
return mode;
}
}