mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
backend/drm: don't unset mode/CRTC when disabling output
Closes: https://github.com/swaywm/wlroots/issues/2203
This commit is contained in:
parent
dcae6f1431
commit
bfd7625813
4 changed files with 36 additions and 37 deletions
|
|
@ -56,7 +56,7 @@ static void atomic_add(struct atomic *atom, uint32_t id, uint32_t prop, uint64_t
|
|||
|
||||
static bool create_mode_blob(struct wlr_drm_backend *drm,
|
||||
struct wlr_drm_crtc *crtc, uint32_t *blob_id) {
|
||||
if (!crtc->pending.active) {
|
||||
if (crtc->pending.mode == NULL) {
|
||||
*blob_id = 0;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -170,6 +170,11 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
|
|||
struct wlr_output *output = &conn->output;
|
||||
struct wlr_drm_crtc *crtc = conn->crtc;
|
||||
|
||||
uint32_t active = output->enabled;
|
||||
if (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
|
||||
active = output->pending.enabled;
|
||||
}
|
||||
|
||||
uint32_t mode_id = crtc->mode_id;
|
||||
if (crtc->pending_modeset) {
|
||||
if (!create_mode_blob(drm, crtc, &mode_id)) {
|
||||
|
|
@ -213,15 +218,14 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
|
|||
struct atomic atom;
|
||||
atomic_begin(&atom);
|
||||
atomic_add(&atom, conn->id, conn->props.crtc_id,
|
||||
crtc->pending.active ? crtc->id : 0);
|
||||
if (crtc->pending_modeset && crtc->pending.active &&
|
||||
conn->props.link_status != 0) {
|
||||
mode_id != 0 ? crtc->id : 0);
|
||||
if (crtc->pending_modeset && active && conn->props.link_status != 0) {
|
||||
atomic_add(&atom, conn->id, conn->props.link_status,
|
||||
DRM_MODE_LINK_STATUS_GOOD);
|
||||
}
|
||||
atomic_add(&atom, crtc->id, crtc->props.mode_id, mode_id);
|
||||
atomic_add(&atom, crtc->id, crtc->props.active, crtc->pending.active);
|
||||
if (crtc->pending.active) {
|
||||
atomic_add(&atom, crtc->id, crtc->props.active, active);
|
||||
if (mode_id != 0) {
|
||||
if (crtc->props.gamma_lut != 0) {
|
||||
atomic_add(&atom, crtc->id, crtc->props.gamma_lut, gamma_lut);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,7 +366,6 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn) {
|
|||
return false;
|
||||
}
|
||||
|
||||
assert(crtc->pending.active);
|
||||
assert(plane_get_next_fb(crtc->primary)->type != WLR_DRM_FB_TYPE_NONE);
|
||||
if (!drm_crtc_commit(conn, DRM_MODE_PAGE_FLIP_EVENT)) {
|
||||
return false;
|
||||
|
|
@ -547,22 +546,13 @@ static bool drm_connector_commit(struct wlr_output *output) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (output->pending.committed &
|
||||
(WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_ENABLED)) {
|
||||
struct wlr_output_mode *wlr_mode = output->current_mode;
|
||||
if (output->pending.committed & WLR_OUTPUT_STATE_MODE) {
|
||||
assert((output->pending.committed & WLR_OUTPUT_STATE_ENABLED) ?
|
||||
output->pending.enabled : output->enabled);
|
||||
|
||||
bool enable = (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) ?
|
||||
output->pending.enabled : output->enabled;
|
||||
if (!enable) {
|
||||
wlr_mode = NULL;
|
||||
}
|
||||
|
||||
if (output->pending.committed & WLR_OUTPUT_STATE_MODE) {
|
||||
assert(enable);
|
||||
wlr_mode = drm_connector_get_pending_mode(conn);
|
||||
if (wlr_mode == NULL) {
|
||||
return false;
|
||||
}
|
||||
struct wlr_output_mode *wlr_mode = drm_connector_get_pending_mode(conn);
|
||||
if (wlr_mode == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!drm_connector_set_mode(conn, wlr_mode)) {
|
||||
|
|
@ -574,7 +564,8 @@ static bool drm_connector_commit(struct wlr_output *output) {
|
|||
return false;
|
||||
}
|
||||
} else if (output->pending.committed &
|
||||
(WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED |
|
||||
(WLR_OUTPUT_STATE_ENABLE |
|
||||
WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED |
|
||||
WLR_OUTPUT_STATE_GAMMA_LUT)) {
|
||||
assert(conn->crtc != NULL);
|
||||
// TODO: maybe request a page-flip event here?
|
||||
|
|
@ -694,7 +685,6 @@ static bool drm_connector_init_renderer(struct wlr_drm_connector *conn,
|
|||
struct wlr_drm_plane *plane = crtc->primary;
|
||||
|
||||
crtc->pending_modeset = true;
|
||||
crtc->pending.active = true;
|
||||
crtc->pending.mode = mode;
|
||||
|
||||
int width = mode->wlr_mode.width;
|
||||
|
|
@ -725,7 +715,6 @@ static bool drm_connector_init_renderer(struct wlr_drm_connector *conn,
|
|||
modifiers = false;
|
||||
|
||||
crtc->pending_modeset = true;
|
||||
crtc->pending.active = true;
|
||||
crtc->pending.mode = mode;
|
||||
|
||||
if (!drm_plane_init_surface(plane, drm, width, height, format,
|
||||
|
|
@ -773,7 +762,7 @@ bool drm_connector_set_mode(struct wlr_drm_connector *conn,
|
|||
if (wlr_mode == NULL) {
|
||||
if (conn->crtc != NULL) {
|
||||
conn->crtc->pending_modeset = true;
|
||||
conn->crtc->pending.active = false;
|
||||
conn->crtc->pending.mode = NULL;
|
||||
if (!drm_crtc_commit(conn, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,24 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
|
|||
struct wlr_drm_crtc *crtc = conn->crtc;
|
||||
struct wlr_drm_plane *cursor = crtc->cursor;
|
||||
|
||||
bool enabled = output->enabled;
|
||||
if (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
|
||||
enabled = output->pending.enabled;
|
||||
}
|
||||
|
||||
if (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
|
||||
uint32_t dpms = output->pending.enabled ?
|
||||
DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF;
|
||||
if (drmModeConnectorSetProperty(drm->fd, conn->id, conn->props.dpms,
|
||||
dpms) != 0) {
|
||||
wlr_log_errno(WLR_ERROR, "%s: failed to set DPMS property",
|
||||
conn->output.name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t fb_id = 0;
|
||||
if (crtc->pending.active) {
|
||||
if (enabled) {
|
||||
struct wlr_drm_fb *fb = plane_get_next_fb(crtc->primary);
|
||||
struct gbm_bo *bo = drm_fb_acquire(fb, drm, &crtc->primary->mgpu_surf);
|
||||
if (!bo) {
|
||||
|
|
@ -38,15 +54,6 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
|
|||
mode = &crtc->pending.mode->drm_mode;
|
||||
}
|
||||
|
||||
uint32_t dpms = crtc->pending.active ?
|
||||
DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF;
|
||||
if (drmModeConnectorSetProperty(drm->fd, conn->id, conn->props.dpms,
|
||||
dpms) != 0) {
|
||||
wlr_log_errno(WLR_ERROR, "%s: failed to set DPMS property",
|
||||
conn->output.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (drmModeSetCrtc(drm->fd, crtc->id, fb_id, 0, 0,
|
||||
conns, conns_len, mode)) {
|
||||
wlr_log_errno(WLR_ERROR, "%s: failed to set CRTC",
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ struct wlr_drm_plane {
|
|||
};
|
||||
|
||||
struct wlr_drm_crtc_state {
|
||||
bool active;
|
||||
struct wlr_drm_mode *mode;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue