mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-18 06:47:31 -04:00
backend/drm: use a single commit to restore state after VT switch
This commit is contained in:
parent
0ae9329f04
commit
0a60d5816c
1 changed files with 40 additions and 9 deletions
|
|
@ -1792,11 +1792,9 @@ void scan_drm_leases(struct wlr_drm_backend *drm) {
|
||||||
|
|
||||||
static void build_current_connector_state(struct wlr_output_state *state,
|
static void build_current_connector_state(struct wlr_output_state *state,
|
||||||
struct wlr_drm_connector *conn) {
|
struct wlr_drm_connector *conn) {
|
||||||
bool enabled = conn->status != DRM_MODE_DISCONNECTED && conn->output.enabled;
|
|
||||||
|
|
||||||
wlr_output_state_init(state);
|
wlr_output_state_init(state);
|
||||||
wlr_output_state_set_enabled(state, enabled);
|
wlr_output_state_set_enabled(state, conn->output.enabled);
|
||||||
if (!enabled) {
|
if (!conn->output.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1830,6 +1828,12 @@ static bool skip_reset_for_restore(struct wlr_drm_backend *drm) {
|
||||||
if (crtc != NULL && conn->crtc != crtc) {
|
if (crtc != NULL && conn->crtc != crtc) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!conn->output.enabled && crtc != NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (conn->output.enabled && conn->status == DRM_MODE_DISCONNECTED) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < drm->num_planes; i++) {
|
for (size_t i = 0; i < drm->num_planes; i++) {
|
||||||
|
|
@ -1881,15 +1885,42 @@ void restore_drm_device(struct wlr_drm_backend *drm) {
|
||||||
wlr_log(WLR_ERROR, "Failed to reset state after VT switch");
|
wlr_log(WLR_ERROR, "Failed to reset state after VT switch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t states_cap = wl_list_length(&drm->connectors);
|
||||||
|
struct wlr_output_state *output_states = calloc(states_cap, sizeof(output_states[0]));
|
||||||
|
struct wlr_drm_connector_state *conn_states = calloc(states_cap, sizeof(conn_states[0]));
|
||||||
|
if (output_states == NULL || conn_states == NULL) {
|
||||||
|
goto out_states;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t states_len = 0;
|
||||||
struct wlr_drm_connector *conn;
|
struct wlr_drm_connector *conn;
|
||||||
wl_list_for_each(conn, &drm->connectors, link) {
|
wl_list_for_each(conn, &drm->connectors, link) {
|
||||||
struct wlr_output_state state;
|
if (conn->status == DRM_MODE_DISCONNECTED || !conn->output.enabled) {
|
||||||
build_current_connector_state(&state, conn);
|
continue; // already disabled above
|
||||||
if (!drm_connector_commit_state(conn, &state)) {
|
|
||||||
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to restore state after VT switch");
|
|
||||||
}
|
}
|
||||||
wlr_output_state_finish(&state);
|
|
||||||
|
build_current_connector_state(&output_states[states_len], conn);
|
||||||
|
drm_connector_state_init(&conn_states[states_len], conn, &output_states[states_len]);
|
||||||
|
states_len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wlr_drm_device_state dev_state = {
|
||||||
|
.modeset = true,
|
||||||
|
.connectors = conn_states,
|
||||||
|
.connectors_len = states_len,
|
||||||
|
};
|
||||||
|
if (!drm_commit(drm, &dev_state, DRM_MODE_PAGE_FLIP_EVENT, false)) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to restore state after VT switch");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < states_len; i++) {
|
||||||
|
drm_connector_state_finish(&conn_states[i]);
|
||||||
|
wlr_output_state_finish(&output_states[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
out_states:
|
||||||
|
free(output_states);
|
||||||
|
free(conn_states);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mhz_to_nsec(int mhz) {
|
static int mhz_to_nsec(int mhz) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue