mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 14:45:58 +01:00
backend/drm: de-allocate unused CRTCs
They can be re-used by another output after a subsequent hotplug.
This commit is contained in:
parent
0086dbed09
commit
1fcecd68df
1 changed files with 15 additions and 11 deletions
|
@ -783,28 +783,32 @@ void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wlr_drm_connector *connectors[num_outputs];
|
||||||
|
i = 0;
|
||||||
|
wl_list_for_each(conn, &drm->outputs, link) {
|
||||||
|
connectors[i] = conn;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
||||||
if (crtc_res[i] == UNMATCHED) {
|
if (crtc_res[i] == UNMATCHED) {
|
||||||
|
// De-allocate CRTCs we don't use anymore
|
||||||
|
if (crtc[i] != UNMATCHED) {
|
||||||
|
dealloc_crtc(connectors[crtc[i]]);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crtc_res[i] != crtc[i]) {
|
if (crtc_res[i] != crtc[i]) {
|
||||||
changed_outputs[crtc_res[i]] = true;
|
changed_outputs[crtc_res[i]] = true;
|
||||||
|
|
||||||
struct wlr_drm_connector *c;
|
struct wlr_drm_connector *conn = connectors[crtc_res[i]];
|
||||||
size_t pos = 0;
|
|
||||||
wl_list_for_each(c, &drm->outputs, link) {
|
|
||||||
if (pos == crtc_res[i]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
dealloc_crtc(c);
|
dealloc_crtc(conn);
|
||||||
c->crtc = &drm->crtcs[i];
|
conn->crtc = &drm->crtcs[i];
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "Assigning CRTC %zu to output %d -> %d '%s'",
|
wlr_log(WLR_DEBUG, "Assigning CRTC %zu to output %d -> %d '%s'",
|
||||||
i, crtc[i], crtc_res[i], c->output.name);
|
i, crtc[i], crtc_res[i], conn->output.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue