From bedc890935945162e4892b4c0f66888388f781e6 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Tue, 18 Jun 2024 11:33:02 +0200 Subject: [PATCH] backend/drm: Use cached vrr support flag We do not expect the connector support to change throughout the lifetime of the link on this connector, so use the value we initially probed. --- backend/drm/atomic.c | 2 +- backend/drm/drm.c | 30 +++--------------------------- backend/drm/legacy.c | 2 +- include/backend/drm/drm.h | 1 - 4 files changed, 5 insertions(+), 30 deletions(-) diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index 9defa7c6..18e33dcf 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -276,7 +276,7 @@ bool drm_atomic_connector_prepare(struct wlr_drm_connector_state *state, bool mo output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED; bool vrr_enabled = prev_vrr_enabled; if ((state->base->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED)) { - if (state->base->adaptive_sync_enabled && !drm_connector_supports_vrr(conn)) { + if (state->base->adaptive_sync_enabled && !output->adaptive_sync_supported) { return false; } vrr_enabled = state->base->adaptive_sync_enabled; diff --git a/backend/drm/drm.c b/backend/drm/drm.c index dff02e87..f506edb2 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -721,32 +721,6 @@ static bool drm_connector_set_pending_layer_fbs(struct wlr_drm_connector *conn, static bool drm_connector_alloc_crtc(struct wlr_drm_connector *conn); -bool drm_connector_supports_vrr(struct wlr_drm_connector *conn) { - struct wlr_drm_backend *drm = conn->backend; - - struct wlr_drm_crtc *crtc = conn->crtc; - if (!crtc) { - return false; - } - - uint64_t vrr_capable; - if (conn->props.vrr_capable == 0 || - !get_drm_prop(drm->fd, conn->id, conn->props.vrr_capable, - &vrr_capable) || !vrr_capable) { - wlr_drm_conn_log(conn, WLR_DEBUG, "Failed to enable adaptive sync: " - "connector doesn't support VRR"); - return false; - } - - if (crtc->props.vrr_enabled == 0) { - wlr_drm_conn_log(conn, WLR_DEBUG, "Failed to enable adaptive sync: " - "CRTC %"PRIu32" doesn't support VRR", crtc->id); - return false; - } - - return true; -} - static bool drm_connector_prepare(struct wlr_drm_connector_state *conn_state, bool test_only) { const struct wlr_output_state *state = conn_state->base; struct wlr_drm_connector *conn = conn_state->connector; @@ -770,7 +744,9 @@ static bool drm_connector_prepare(struct wlr_drm_connector_state *conn_state, bo if ((state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) && state->adaptive_sync_enabled && - !drm_connector_supports_vrr(conn)) { + !output->adaptive_sync_supported) { + wlr_drm_conn_log(conn, WLR_DEBUG, + "Can't enable adaptive sync: connector doesn't support VRR"); return false; } diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index afa7f8fb..0c591f4d 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -110,7 +110,7 @@ static bool legacy_crtc_commit(const struct wlr_drm_connector_state *state, } if (state->base->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) { - if (state->base->adaptive_sync_enabled && !drm_connector_supports_vrr(conn)) { + if (state->base->adaptive_sync_enabled && !output->adaptive_sync_supported) { return false; } if (crtc->props.vrr_enabled != 0 && diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 8a56a5fc..0b1e429b 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -212,7 +212,6 @@ void restore_drm_device(struct wlr_drm_backend *drm); int handle_drm_event(int fd, uint32_t mask, void *data); void destroy_drm_connector(struct wlr_drm_connector *conn); bool drm_connector_is_cursor_visible(struct wlr_drm_connector *conn); -bool drm_connector_supports_vrr(struct wlr_drm_connector *conn); size_t drm_crtc_get_gamma_lut_size(struct wlr_drm_backend *drm, struct wlr_drm_crtc *crtc); void drm_lease_destroy(struct wlr_drm_lease *lease);