From 8f90d7f8f51f5d501e3f70ebdab8abfdbfa007b9 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 6 Apr 2021 16:32:01 +0200 Subject: [PATCH] backend/drm: take wlr_output_state as arg in crtc_commit Stop assuming that the state to be applied is in output->pending in crtc_commit. This will allow us to remove ephemeral fields in wlr_drm_crtc, which are used scratch fields to stash temporary per-commit data. --- backend/drm/atomic.c | 17 +++++++++-------- backend/drm/drm.c | 2 +- backend/drm/legacy.c | 15 ++++++++------- include/backend/drm/iface.h | 3 ++- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index 4cfd5566..4a33d358 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -164,7 +164,8 @@ error: } static bool atomic_crtc_commit(struct wlr_drm_backend *drm, - struct wlr_drm_connector *conn, uint32_t flags) { + struct wlr_drm_connector *conn, const struct wlr_output_state *state, + uint32_t flags) { struct wlr_output *output = &conn->output; struct wlr_drm_crtc *crtc = conn->crtc; @@ -176,19 +177,19 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, } uint32_t gamma_lut = crtc->gamma_lut; - if (output->pending.committed & WLR_OUTPUT_STATE_GAMMA_LUT) { + if (state->committed & WLR_OUTPUT_STATE_GAMMA_LUT) { // Fallback to legacy gamma interface when gamma properties are not // available (can happen on older Intel GPUs that support gamma but not // degamma). if (crtc->props.gamma_lut == 0) { if (!drm_legacy_crtc_set_gamma(drm, crtc, - output->pending.gamma_lut_size, - output->pending.gamma_lut)) { + state->gamma_lut_size, + state->gamma_lut)) { return false; } } else { - if (!create_gamma_lut_blob(drm, output->pending.gamma_lut_size, - output->pending.gamma_lut, &gamma_lut)) { + if (!create_gamma_lut_blob(drm, state->gamma_lut_size, + state->gamma_lut, &gamma_lut)) { return false; } } @@ -197,9 +198,9 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, bool prev_vrr_enabled = output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED; bool vrr_enabled = prev_vrr_enabled; - if ((output->pending.committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) && + if ((state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) && drm_connector_supports_vrr(conn)) { - vrr_enabled = output->pending.adaptive_sync_enabled; + vrr_enabled = state->adaptive_sync_enabled; } if (crtc->pending_modeset) { diff --git a/backend/drm/drm.c b/backend/drm/drm.c index e2b4bb3e..df31752d 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -330,7 +330,7 @@ static void drm_plane_set_committed(struct wlr_drm_plane *plane) { static bool drm_crtc_commit(struct wlr_drm_connector *conn, uint32_t flags) { struct wlr_drm_backend *drm = conn->backend; struct wlr_drm_crtc *crtc = conn->crtc; - bool ok = drm->iface->crtc_commit(drm, conn, flags); + bool ok = drm->iface->crtc_commit(drm, conn, &conn->output.pending, flags); if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { memcpy(&crtc->current, &crtc->pending, sizeof(struct wlr_drm_crtc_state)); drm_plane_set_committed(crtc->primary); diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index da2e0d9f..61b92558 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -9,7 +9,8 @@ #include "backend/drm/util.h" static bool legacy_crtc_commit(struct wlr_drm_backend *drm, - struct wlr_drm_connector *conn, uint32_t flags) { + struct wlr_drm_connector *conn, const struct wlr_output_state *state, + uint32_t flags) { struct wlr_output *output = &conn->output; struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_plane *cursor = crtc->cursor; @@ -51,27 +52,27 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm, } } - if (output->pending.committed & WLR_OUTPUT_STATE_GAMMA_LUT) { + if (state->committed & WLR_OUTPUT_STATE_GAMMA_LUT) { if (!drm_legacy_crtc_set_gamma(drm, crtc, - output->pending.gamma_lut_size, output->pending.gamma_lut)) { + state->gamma_lut_size, state->gamma_lut)) { return false; } } - if ((output->pending.committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) && + if ((state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) && drm_connector_supports_vrr(conn)) { if (drmModeObjectSetProperty(drm->fd, crtc->id, DRM_MODE_OBJECT_CRTC, crtc->props.vrr_enabled, - output->pending.adaptive_sync_enabled) != 0) { + state->adaptive_sync_enabled) != 0) { wlr_drm_conn_log_errno(conn, WLR_ERROR, "drmModeObjectSetProperty(VRR_ENABLED) failed"); return false; } - output->adaptive_sync_status = output->pending.adaptive_sync_enabled ? + output->adaptive_sync_status = state->adaptive_sync_enabled ? WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED : WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED; wlr_drm_conn_log(conn, WLR_DEBUG, "VRR %s", - output->pending.adaptive_sync_enabled ? "enabled" : "disabled"); + state->adaptive_sync_enabled ? "enabled" : "disabled"); } if (cursor != NULL && drm_connector_is_cursor_visible(conn)) { diff --git a/include/backend/drm/iface.h b/include/backend/drm/iface.h index ae84bafe..98bae974 100644 --- a/include/backend/drm/iface.h +++ b/include/backend/drm/iface.h @@ -15,7 +15,8 @@ struct wlr_drm_crtc; struct wlr_drm_interface { // Commit al pending changes on a CRTC. bool (*crtc_commit)(struct wlr_drm_backend *drm, - struct wlr_drm_connector *conn, uint32_t flags); + struct wlr_drm_connector *conn, const struct wlr_output_state *state, + uint32_t flags); }; extern const struct wlr_drm_interface atomic_iface;