backend/drm: ensure CRTC is set up in drm_connector_state_init()

In [1] we discovered a bug where wlr_drm_connector_state.primary_fb
would not be set up correctly because drm_connector_alloc_crtc() was
called after drm_connector_state_init(). This is tricky to discover,
so instead assert() that we have a usable CRTC by the time
drm_connector_state_init() is called.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4569
master
Simon Ser 9 months ago committed by Alexander Orzechowski
parent ba89b90a9c
commit c3743364e2

@ -544,16 +544,20 @@ static void drm_connector_state_init(struct wlr_drm_connector_state *state,
state->mode.type = DRM_MODE_TYPE_USERDEF; state->mode.type = DRM_MODE_TYPE_USERDEF;
} }
if (conn->crtc != NULL) { if (output_pending_enabled(&conn->output, base)) {
// The CRTC must be set up before this function is called
assert(conn->crtc != NULL);
struct wlr_drm_plane *primary = conn->crtc->primary; struct wlr_drm_plane *primary = conn->crtc->primary;
if (primary->queued_fb != NULL) { if (primary->queued_fb != NULL) {
state->primary_fb = drm_fb_lock(primary->queued_fb); state->primary_fb = drm_fb_lock(primary->queued_fb);
} else if (primary->current_fb != NULL) { } else if (primary->current_fb != NULL) {
state->primary_fb = drm_fb_lock(primary->current_fb); state->primary_fb = drm_fb_lock(primary->current_fb);
} }
}
if (conn->crtc != NULL && conn->cursor_enabled) { if (conn->cursor_enabled) {
struct wlr_drm_plane *cursor = conn->crtc->cursor; struct wlr_drm_plane *cursor = conn->crtc->cursor;
assert(cursor != NULL);
if (conn->cursor_pending_fb != NULL) { if (conn->cursor_pending_fb != NULL) {
state->cursor_fb = drm_fb_lock(conn->cursor_pending_fb); state->cursor_fb = drm_fb_lock(conn->cursor_pending_fb);
} else if (cursor->queued_fb != NULL) { } else if (cursor->queued_fb != NULL) {
@ -562,6 +566,7 @@ static void drm_connector_state_init(struct wlr_drm_connector_state *state,
state->cursor_fb = drm_fb_lock(cursor->current_fb); state->cursor_fb = drm_fb_lock(cursor->current_fb);
} }
} }
}
} }
static void drm_connector_state_finish(struct wlr_drm_connector_state *state) { static void drm_connector_state_finish(struct wlr_drm_connector_state *state) {

Loading…
Cancel
Save