diff options
-rw-r--r-- | backend/drm/atomic.c | 9 | ||||
-rw-r--r-- | backend/drm/drm.c | 21 | ||||
-rw-r--r-- | backend/drm/legacy.c | 6 | ||||
-rw-r--r-- | include/backend/drm/iface.h | 2 |
4 files changed, 24 insertions, 14 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index c7b630d6..23f9d60f 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -168,7 +168,7 @@ error: static bool atomic_crtc_commit(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, const struct wlr_output_state *state, - uint32_t flags) { + uint32_t flags, bool test_only) { struct wlr_output *output = &conn->output; struct wlr_drm_crtc *crtc = conn->crtc; @@ -209,9 +209,12 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, vrr_enabled = state->adaptive_sync_enabled; } + if (test_only) { + flags |= DRM_MODE_ATOMIC_TEST_ONLY; + } if (modeset) { flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; - } else if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { + } else if (!test_only) { flags |= DRM_MODE_ATOMIC_NONBLOCK; } @@ -250,7 +253,7 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, bool ok = atomic_commit(&atom, conn, flags); atomic_finish(&atom); - if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { + if (ok && !test_only) { commit_blob(drm, &crtc->mode_id, mode_id); commit_blob(drm, &crtc->gamma_lut, gamma_lut); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index fb498a5d..403e5d7c 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -345,11 +345,14 @@ static void drm_plane_set_committed(struct wlr_drm_plane *plane) { } static bool drm_crtc_commit(struct wlr_drm_connector *conn, - const struct wlr_output_state *state, uint32_t flags) { + const struct wlr_output_state *state, uint32_t flags, bool test_only) { + // Disallow atomic-only flags + assert((flags & ~DRM_MODE_PAGE_FLIP_FLAGS) == 0); + struct wlr_drm_backend *drm = conn->backend; struct wlr_drm_crtc *crtc = conn->crtc; - bool ok = drm->iface->crtc_commit(drm, conn, state, flags); - if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { + bool ok = drm->iface->crtc_commit(drm, conn, state, flags, test_only); + if (ok && !test_only) { drm_plane_set_committed(crtc->primary); if (crtc->cursor != NULL) { drm_plane_set_committed(crtc->cursor); @@ -383,7 +386,7 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn, assert(drm_connector_state_active(conn, state)); assert(plane_get_next_fb(crtc->primary)); - if (!drm_crtc_commit(conn, state, DRM_MODE_PAGE_FLIP_EVENT)) { + if (!drm_crtc_commit(conn, state, DRM_MODE_PAGE_FLIP_EVENT, false)) { return false; } @@ -475,7 +478,7 @@ static bool drm_connector_test(struct wlr_output *output) { if (!drm_connector_set_pending_fb(conn, &output->pending)) { return false; } - if (!drm_crtc_commit(conn, &output->pending, DRM_MODE_ATOMIC_TEST_ONLY)) { + if (!drm_crtc_commit(conn, &output->pending, 0, true)) { return false; } } @@ -559,7 +562,7 @@ bool drm_connector_commit_state(struct wlr_drm_connector *conn, WLR_OUTPUT_STATE_GAMMA_LUT)) { assert(conn->crtc != NULL); // TODO: maybe request a page-flip event here? - if (!drm_crtc_commit(conn, &state, 0)) { + if (!drm_crtc_commit(conn, &state, 0, false)) { return false; } } @@ -677,7 +680,7 @@ static bool drm_connector_test_renderer(struct wlr_drm_connector *conn, goto out; } - ok = drm_crtc_commit(conn, state, DRM_MODE_ATOMIC_TEST_ONLY); + ok = drm_crtc_commit(conn, state, 0, true); out: drm_fb_move(&plane->pending_fb, &prev_fb); @@ -783,7 +786,7 @@ static bool drm_connector_set_mode(struct wlr_drm_connector *conn, if (wlr_mode == NULL) { if (conn->crtc != NULL) { - if (!drm_crtc_commit(conn, state, 0)) { + if (!drm_crtc_commit(conn, state, 0, false)) { return false; } realloc_crtcs(drm); @@ -1128,7 +1131,7 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) { .committed = WLR_OUTPUT_STATE_ENABLED, .enabled = false, }; - if (!drm_crtc_commit(conn, &state, 0)) { + if (!drm_crtc_commit(conn, &state, 0, false)) { // On GPU unplug, disabling the CRTC can fail with EPERM wlr_drm_conn_log(conn, WLR_ERROR, "Failed to disable CRTC %"PRIu32, conn->crtc->id); diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index 43436165..ca23bb1c 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -10,7 +10,11 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, const struct wlr_output_state *state, - uint32_t flags) { + uint32_t flags, bool test_only) { + if (test_only) { + return true; + } + struct wlr_output *output = &conn->output; struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_plane *cursor = crtc->cursor; diff --git a/include/backend/drm/iface.h b/include/backend/drm/iface.h index 98bae974..f7107973 100644 --- a/include/backend/drm/iface.h +++ b/include/backend/drm/iface.h @@ -16,7 +16,7 @@ struct wlr_drm_interface { // Commit al pending changes on a CRTC. bool (*crtc_commit)(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, const struct wlr_output_state *state, - uint32_t flags); + uint32_t flags, bool test_only); }; extern const struct wlr_drm_interface atomic_iface; |