mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 08:32:30 +00:00
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.
This commit is contained in:
parent
7f6d646e0a
commit
8b18352318
@ -1215,15 +1215,23 @@ static drmModeModeInfo *connector_get_current_mode(struct wlr_drm_connector *wlr
|
|||||||
return mode;
|
return mode;
|
||||||
} else {
|
} else {
|
||||||
// Fallback to the legacy API
|
// 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;
|
return NULL;
|
||||||
}
|
}
|
||||||
drmModeModeInfo *mode = malloc(sizeof(*mode));
|
drmModeModeInfo *mode = malloc(sizeof(*mode));
|
||||||
if (mode == NULL) {
|
if (mode == NULL) {
|
||||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||||
|
drmModeFreeCrtc(drm_crtc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*mode = wlr_conn->crtc->legacy_crtc->mode;
|
*mode = drm_crtc->mode;
|
||||||
|
drmModeFreeCrtc(drm_crtc);
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user