backend/drm: introduce pending and current CRTC state

Previously, we only had the pending state (crtc->pending, crtc->mode and
crtc->active). This causes issues when a commit fails: the pending state
is left as-is, and the next commit may read stale data from it.

This will also cause issues when implementing test-only commits: we need
to rollback the pending CRTC state after a test-only commit.

Introduce separate pending and current CRTC states. Properly update the
current state after a commit.
This commit is contained in:
Simon Ser 2020-05-18 14:27:42 +02:00 committed by Drew DeVault
parent d6cc718472
commit 15d8f1806e
4 changed files with 37 additions and 26 deletions

View file

@ -15,7 +15,7 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
struct wlr_drm_plane *cursor = crtc->cursor;
uint32_t fb_id = 0;
if (crtc->active) {
if (crtc->pending.active) {
struct wlr_drm_fb *fb = plane_get_next_fb(crtc->primary);
struct gbm_bo *bo = drm_fb_acquire(fb, drm, &crtc->primary->mgpu_surf);
if (!bo) {
@ -28,18 +28,20 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
}
}
if (crtc->pending & WLR_DRM_CRTC_MODE) {
if (crtc->pending_modeset) {
uint32_t *conns = NULL;
size_t conns_len = 0;
drmModeModeInfo *mode = NULL;
if (crtc->active) {
if (crtc->pending.mode != NULL) {
conns = &conn->id;
conns_len = 1;
mode = &crtc->mode;
mode = &crtc->pending.mode->drm_mode;
}
uint32_t dpms = crtc->pending.active ?
DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF;
if (drmModeConnectorSetProperty(drm->fd, conn->id, conn->props.dpms,
crtc->active ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF) != 0) {
dpms) != 0) {
wlr_log_errno(WLR_ERROR, "%s: failed to set DPMS property",
conn->output.name);
return false;