aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/backend.c2
-rw-r--r--backend/drm/drm.c46
-rw-r--r--include/backend/drm/drm.h2
3 files changed, 20 insertions, 30 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 5ec709a5..c494898e 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -128,7 +128,7 @@ static void handle_session_active(struct wl_listener *listener, void *data) {
.mode_type = WLR_OUTPUT_STATE_MODE_FIXED,
.mode = mode,
};
- drm_connector_set_mode(conn, &state, mode);
+ drm_connector_set_mode(conn, &state);
}
} else {
wlr_log(WLR_INFO, "DRM fd paused");
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 18e17c29..e71debd8 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -427,21 +427,6 @@ static bool drm_connector_test(struct wlr_output *output) {
return true;
}
-static struct wlr_output_mode *drm_connector_get_pending_mode(
- struct wlr_drm_connector *conn) {
- struct wlr_output *output = &conn->output;
-
- switch (output->pending.mode_type) {
- case WLR_OUTPUT_STATE_MODE_FIXED:
- return output->pending.mode;
- case WLR_OUTPUT_STATE_MODE_CUSTOM:;
- drmModeModeInfo mode = {0};
- drm_connector_state_mode(conn, &output->pending, &mode);
- return wlr_drm_connector_add_mode(output, &mode);
- }
- abort();
-}
-
static bool drm_connector_commit_buffer(struct wlr_output *output) {
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
struct wlr_drm_backend *drm = conn->backend;
@@ -517,23 +502,21 @@ static bool drm_connector_commit(struct wlr_output *output) {
if (output->pending.committed &
(WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_ENABLED)) {
- struct wlr_output_mode *wlr_mode = output->current_mode;
+ struct wlr_output_state state = output->pending;
- bool enable = (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) ?
- output->pending.enabled : output->enabled;
- if (!enable) {
- wlr_mode = NULL;
- }
+ if ((state.committed & WLR_OUTPUT_STATE_MODE) &&
+ state.mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM) {
+ drmModeModeInfo mode = {0};
+ drm_connector_state_mode(conn, &output->pending, &mode);
- if (output->pending.committed & WLR_OUTPUT_STATE_MODE) {
- assert(enable);
- wlr_mode = drm_connector_get_pending_mode(conn);
- if (wlr_mode == NULL) {
+ state.mode_type = WLR_OUTPUT_STATE_MODE_FIXED;
+ state.mode = wlr_drm_connector_add_mode(output, &mode);
+ if (state.mode == NULL) {
return false;
}
}
- if (!drm_connector_set_mode(conn, &output->pending, wlr_mode)) {
+ if (!drm_connector_set_mode(conn, &state)) {
return false;
}
} else if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
@@ -730,15 +713,22 @@ static void attempt_enable_needs_modeset(struct wlr_drm_backend *drm) {
.mode_type = WLR_OUTPUT_STATE_MODE_FIXED,
.mode = conn->desired_mode,
};
- drm_connector_set_mode(conn, &state, conn->desired_mode);
+ drm_connector_set_mode(conn, &state);
}
}
}
bool drm_connector_set_mode(struct wlr_drm_connector *conn,
- const struct wlr_output_state *state, struct wlr_output_mode *wlr_mode) {
+ const struct wlr_output_state *state) {
struct wlr_drm_backend *drm = conn->backend;
+ struct wlr_output_mode *wlr_mode = NULL;
+ if (drm_connector_state_active(conn, state)) {
+ assert(state->committed & WLR_OUTPUT_STATE_MODE);
+ assert(state->mode_type == WLR_OUTPUT_STATE_MODE_FIXED);
+ wlr_mode = state->mode;
+ }
+
conn->desired_enabled = wlr_mode != NULL;
conn->desired_mode = wlr_mode;
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index 4715cbf7..6201a328 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -144,7 +144,7 @@ void scan_drm_connectors(struct wlr_drm_backend *state);
int handle_drm_event(int fd, uint32_t mask, void *data);
void destroy_drm_connector(struct wlr_drm_connector *conn);
bool drm_connector_set_mode(struct wlr_drm_connector *conn,
- const struct wlr_output_state *state, struct wlr_output_mode *mode);
+ const struct wlr_output_state *state);
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,