diff options
author | Simon Ser <contact@emersion.fr> | 2021-04-06 17:06:37 +0200 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2021-04-29 19:51:57 +0200 |
commit | 485ecc11a6d31c1a2ba3724dd61ce34f77e7436f (patch) | |
tree | 6da8c9ede14785a3d8abffc9e5a3329af133f53b /backend | |
parent | c9c2d7539c69c8bf349a5b633ab61ce2d7c20e8a (diff) |
backend/drm: remove wlr_drm_crtc.pending_modeset
Replace it with a new drm_connector_state_is_modeset function that
decides whether a modeset is necessary directly from the
wlr_output_state which is going to be applied.
Diffstat (limited to 'backend')
-rw-r--r-- | backend/drm/atomic.c | 8 | ||||
-rw-r--r-- | backend/drm/drm.c | 12 | ||||
-rw-r--r-- | backend/drm/legacy.c | 2 |
3 files changed, 12 insertions, 10 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index 4a33d358..ac586bb5 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -169,8 +169,10 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, struct wlr_output *output = &conn->output; struct wlr_drm_crtc *crtc = conn->crtc; + bool modeset = drm_connector_state_is_modeset(state); + uint32_t mode_id = crtc->mode_id; - if (crtc->pending_modeset) { + if (modeset) { if (!create_mode_blob(drm, crtc, &mode_id)) { return false; } @@ -203,7 +205,7 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, vrr_enabled = state->adaptive_sync_enabled; } - if (crtc->pending_modeset) { + if (modeset) { flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; } else if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { flags |= DRM_MODE_ATOMIC_NONBLOCK; @@ -213,7 +215,7 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, atomic_begin(&atom); atomic_add(&atom, conn->id, conn->props.crtc_id, crtc->pending.active ? crtc->id : 0); - if (crtc->pending_modeset && crtc->pending.active && + if (modeset && crtc->pending.active && conn->props.link_status != 0) { atomic_add(&atom, conn->id, conn->props.link_status, DRM_MODE_LINK_STATUS_GOOD); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index e2a78de8..08a55857 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -345,7 +345,6 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn, drm_fb_clear(&crtc->cursor->pending_fb); } } - crtc->pending_modeset = false; return ok; } @@ -358,7 +357,7 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn, // page-flip, either a blocking modeset. When performing a blocking modeset // we'll wait for all queued page-flips to complete, so we don't need this // safeguard. - if (conn->pending_page_flip_crtc && !crtc->pending_modeset) { + if (conn->pending_page_flip_crtc && !drm_connector_state_is_modeset(state)) { wlr_drm_conn_log(conn, WLR_ERROR, "Failed to page-flip output: " "a page-flip is already pending"); return false; @@ -681,7 +680,6 @@ static bool drm_connector_init_renderer(struct wlr_drm_connector *conn, } struct wlr_drm_plane *plane = crtc->primary; - crtc->pending_modeset = true; crtc->pending.active = true; crtc->pending.mode = mode; @@ -705,7 +703,6 @@ static bool drm_connector_init_renderer(struct wlr_drm_connector *conn, "retrying without modifiers"); modifiers = false; - crtc->pending_modeset = true; crtc->pending.active = true; crtc->pending.mode = mode; @@ -755,7 +752,6 @@ bool drm_connector_set_mode(struct wlr_drm_connector *conn, if (wlr_mode == NULL) { if (conn->crtc != NULL) { - conn->crtc->pending_modeset = true; conn->crtc->pending.active = false; if (!drm_crtc_commit(conn, state, 0)) { return false; @@ -1041,6 +1037,11 @@ uint32_t wlr_drm_connector_get_id(struct wlr_output *output) { return conn->id; } +bool drm_connector_state_is_modeset(const struct wlr_output_state *state) { + return state->committed & + (WLR_OUTPUT_STATE_ENABLED | WLR_OUTPUT_STATE_MODE); +} + static const int32_t subpixel_map[] = { [DRM_MODE_SUBPIXEL_UNKNOWN] = WL_OUTPUT_SUBPIXEL_UNKNOWN, [DRM_MODE_SUBPIXEL_HORIZONTAL_RGB] = WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB, @@ -1059,7 +1060,6 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) { wlr_drm_conn_log(conn, WLR_DEBUG, "De-allocating CRTC %zu", conn->crtc - drm->crtcs); - conn->crtc->pending_modeset = true; conn->crtc->pending.active = false; struct wlr_output_state state = { .committed = WLR_OUTPUT_STATE_ENABLED, diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index 61b92558..2f573899 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -26,7 +26,7 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm, fb_id = fb->id; } - if (crtc->pending_modeset) { + if (drm_connector_state_is_modeset(state)) { uint32_t *conns = NULL; size_t conns_len = 0; drmModeModeInfo *mode = NULL; |