mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
backend/drm: handle custom modes in connect_drm_connector()
On startup, some connectors might be already lit up with a custom mode. We weren't correctly populating the current output state in this case.
This commit is contained in:
parent
08c74f36a9
commit
ca1f9f86e6
1 changed files with 19 additions and 8 deletions
|
|
@ -1614,6 +1614,7 @@ static bool connect_drm_connector(struct wlr_drm_connector *wlr_conn,
|
|||
|
||||
wlr_log(WLR_INFO, "Detected modes:");
|
||||
|
||||
bool found_current_mode = false;
|
||||
for (int i = 0; i < drm_conn->count_modes; ++i) {
|
||||
if (drm_conn->modes[i].flags & DRM_MODE_FLAG_INTERLACE) {
|
||||
continue;
|
||||
|
|
@ -1632,14 +1633,7 @@ static bool connect_drm_connector(struct wlr_drm_connector *wlr_conn,
|
|||
if (current_modeinfo != NULL && memcmp(&mode->drm_mode,
|
||||
current_modeinfo, sizeof(*current_modeinfo)) == 0) {
|
||||
wlr_output_state_set_mode(&state, &mode->wlr_mode);
|
||||
|
||||
uint64_t mode_id = 0;
|
||||
get_drm_prop(drm->fd, wlr_conn->crtc->id,
|
||||
wlr_conn->crtc->props.mode_id, &mode_id);
|
||||
|
||||
wlr_conn->crtc->own_mode_id = false;
|
||||
wlr_conn->crtc->mode_id = mode_id;
|
||||
wlr_conn->refresh = calculate_refresh_rate(current_modeinfo);
|
||||
found_current_mode = true;
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, " %"PRId32"x%"PRId32" @ %.3f Hz %s",
|
||||
|
|
@ -1650,6 +1644,23 @@ static bool connect_drm_connector(struct wlr_drm_connector *wlr_conn,
|
|||
wl_list_insert(modes.prev, &mode->wlr_mode.link);
|
||||
}
|
||||
|
||||
if (current_modeinfo != NULL) {
|
||||
int32_t refresh = calculate_refresh_rate(current_modeinfo);
|
||||
|
||||
if (!found_current_mode) {
|
||||
wlr_output_state_set_custom_mode(&state,
|
||||
current_modeinfo->hdisplay, current_modeinfo->vdisplay, refresh);
|
||||
}
|
||||
|
||||
uint64_t mode_id = 0;
|
||||
get_drm_prop(drm->fd, wlr_conn->crtc->id,
|
||||
wlr_conn->crtc->props.mode_id, &mode_id);
|
||||
|
||||
wlr_conn->crtc->own_mode_id = false;
|
||||
wlr_conn->crtc->mode_id = mode_id;
|
||||
wlr_conn->refresh = refresh;
|
||||
}
|
||||
|
||||
free(current_modeinfo);
|
||||
|
||||
wlr_output_init(output, &drm->backend, &output_impl, drm->session->event_loop, &state);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue