diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2023-08-28 18:50:21 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-09-07 01:56:32 +0000 |
commit | 9be72ec4ca5b70ad34d073622b1bd4b008d2397a (patch) | |
tree | 921ddd0e503e22459c8bbc111bd89558778306c2 /backend/drm/drm.c | |
parent | e315068b9848d7fc920eb21340a076bb6587c1ff (diff) |
backend/drm: Compute custom mode correctly
Diffstat (limited to 'backend/drm/drm.c')
-rw-r--r-- | backend/drm/drm.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 9f9a105b..18e9a64e 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -453,25 +453,31 @@ static void drm_connector_state_init(struct wlr_drm_connector_state *state, base->enabled : conn->output.enabled, }; + struct wlr_output_mode *mode = conn->output.current_mode; + int32_t width = conn->output.width; + int32_t height = conn->output.height; + int32_t refresh = conn->output.refresh; + if (base->committed & WLR_OUTPUT_STATE_MODE) { switch (base->mode_type) { case WLR_OUTPUT_STATE_MODE_FIXED:; - struct wlr_drm_mode *mode = - wl_container_of(base->mode, mode, wlr_mode); - state->mode = mode->drm_mode; + mode = base->mode; break; case WLR_OUTPUT_STATE_MODE_CUSTOM: - generate_cvt_mode(&state->mode, base->custom_mode.width, - base->custom_mode.height, - (float)base->custom_mode.refresh / 1000); - state->mode.type = DRM_MODE_TYPE_USERDEF; + mode = NULL; + width = base->custom_mode.width; + height = base->custom_mode.height; + refresh = base->custom_mode.refresh; break; } - } else if (state->active) { - struct wlr_drm_mode *mode = - wl_container_of(conn->output.current_mode, mode, wlr_mode); - assert(mode != NULL); - state->mode = mode->drm_mode; + } + + if (mode) { + struct wlr_drm_mode *drm_mode = wl_container_of(mode, drm_mode, wlr_mode); + state->mode = drm_mode->drm_mode; + } else { + generate_cvt_mode(&state->mode, width, height, (float)refresh / 1000); + state->mode.type = DRM_MODE_TYPE_USERDEF; } if (conn->crtc != NULL) { |