backend/drm: fill scratch wlr_output_state for set_mode
Populate the wlr_output_state when setting a mode. This will allow drm_connector_set_mode to stop relying on ephemeral fields in wlr_drm_crtc. Also drm_connector_set_mode will be able to apply both a new buffer and a new mode atomically.
This commit is contained in:
parent
1a9701cd7c
commit
c9c2d7539c
|
@ -118,12 +118,17 @@ static void handle_session_active(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
struct wlr_drm_connector *conn;
|
struct wlr_drm_connector *conn;
|
||||||
wl_list_for_each(conn, &drm->outputs, link) {
|
wl_list_for_each(conn, &drm->outputs, link) {
|
||||||
struct wlr_output_state state = {0};
|
struct wlr_output_mode *mode = NULL;
|
||||||
if (conn->output.enabled && conn->output.current_mode != NULL) {
|
if (conn->output.enabled && conn->output.current_mode != NULL) {
|
||||||
drm_connector_set_mode(conn, &state, conn->output.current_mode);
|
mode = conn->output.current_mode;
|
||||||
} else {
|
|
||||||
drm_connector_set_mode(conn, &state, NULL);
|
|
||||||
}
|
}
|
||||||
|
struct wlr_output_state state = {
|
||||||
|
.committed = WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_ENABLED,
|
||||||
|
.enabled = mode != NULL,
|
||||||
|
.mode_type = WLR_OUTPUT_STATE_MODE_FIXED,
|
||||||
|
.mode = mode,
|
||||||
|
};
|
||||||
|
drm_connector_set_mode(conn, &state, mode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wlr_log(WLR_INFO, "DRM fd paused");
|
wlr_log(WLR_INFO, "DRM fd paused");
|
||||||
|
|
|
@ -735,7 +735,12 @@ static void attempt_enable_needs_modeset(struct wlr_drm_backend *drm) {
|
||||||
conn->desired_enabled) {
|
conn->desired_enabled) {
|
||||||
wlr_drm_conn_log(conn, WLR_DEBUG,
|
wlr_drm_conn_log(conn, WLR_DEBUG,
|
||||||
"Output has a desired mode and a CRTC, attempting a modeset");
|
"Output has a desired mode and a CRTC, attempting a modeset");
|
||||||
struct wlr_output_state state = {0};
|
struct wlr_output_state state = {
|
||||||
|
.committed = WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_ENABLED,
|
||||||
|
.enabled = true,
|
||||||
|
.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, conn->desired_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1056,7 +1061,10 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {
|
||||||
|
|
||||||
conn->crtc->pending_modeset = true;
|
conn->crtc->pending_modeset = true;
|
||||||
conn->crtc->pending.active = false;
|
conn->crtc->pending.active = false;
|
||||||
struct wlr_output_state state = {0};
|
struct wlr_output_state state = {
|
||||||
|
.committed = WLR_OUTPUT_STATE_ENABLED,
|
||||||
|
.enabled = false,
|
||||||
|
};
|
||||||
if (!drm_crtc_commit(conn, &state, 0)) {
|
if (!drm_crtc_commit(conn, &state, 0)) {
|
||||||
// On GPU unplug, disabling the CRTC can fail with EPERM
|
// On GPU unplug, disabling the CRTC can fail with EPERM
|
||||||
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to disable CRTC %"PRIu32,
|
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to disable CRTC %"PRIu32,
|
||||||
|
@ -1185,7 +1193,10 @@ static void realloc_crtcs(struct wlr_drm_backend *drm) {
|
||||||
|
|
||||||
struct wlr_drm_mode *mode =
|
struct wlr_drm_mode *mode =
|
||||||
(struct wlr_drm_mode *)conn->output.current_mode;
|
(struct wlr_drm_mode *)conn->output.current_mode;
|
||||||
struct wlr_output_state state = {0};
|
struct wlr_output_state state = {
|
||||||
|
.committed = WLR_OUTPUT_STATE_ENABLED,
|
||||||
|
.enabled = true,
|
||||||
|
};
|
||||||
if (!drm_connector_init_renderer(conn, &state, mode)) {
|
if (!drm_connector_init_renderer(conn, &state, mode)) {
|
||||||
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to initialize renderer");
|
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to initialize renderer");
|
||||||
wlr_output_update_enabled(&conn->output, false);
|
wlr_output_update_enabled(&conn->output, false);
|
||||||
|
|
Loading…
Reference in New Issue