backend/drm: Compute custom mode correctly

This commit is contained in:
Alexander Orzechowski 2023-08-28 18:50:21 -04:00 committed by Simon Ser
parent e315068b98
commit 9be72ec4ca

View File

@ -453,25 +453,31 @@ static void drm_connector_state_init(struct wlr_drm_connector_state *state,
base->enabled : conn->output.enabled, 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) { if (base->committed & WLR_OUTPUT_STATE_MODE) {
switch (base->mode_type) { switch (base->mode_type) {
case WLR_OUTPUT_STATE_MODE_FIXED:; case WLR_OUTPUT_STATE_MODE_FIXED:;
struct wlr_drm_mode *mode = mode = base->mode;
wl_container_of(base->mode, mode, wlr_mode);
state->mode = mode->drm_mode;
break; break;
case WLR_OUTPUT_STATE_MODE_CUSTOM: case WLR_OUTPUT_STATE_MODE_CUSTOM:
generate_cvt_mode(&state->mode, base->custom_mode.width, mode = NULL;
base->custom_mode.height, width = base->custom_mode.width;
(float)base->custom_mode.refresh / 1000); height = base->custom_mode.height;
state->mode.type = DRM_MODE_TYPE_USERDEF; refresh = base->custom_mode.refresh;
break; break;
} }
} else if (state->active) { }
struct wlr_drm_mode *mode =
wl_container_of(conn->output.current_mode, mode, wlr_mode); if (mode) {
assert(mode != NULL); struct wlr_drm_mode *drm_mode = wl_container_of(mode, drm_mode, wlr_mode);
state->mode = mode->drm_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) { if (conn->crtc != NULL) {