aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-04-06 17:14:17 +0200
committerKenny Levinsen <kl@kl.wtf>2021-04-29 19:51:57 +0200
commitdfea0ff31dbf74f4d310df8eb55a57a51878e1fc (patch)
treece503b3393a17db49f8c1deed0bcbbc40ff8cc31 /backend
parent485ecc11a6d31c1a2ba3724dd61ce34f77e7436f (diff)
backend/drm: remove wlr_drm_crtc_state.active
Replace it with drm_connector_state_active, which figures out whether the connector is active depending on the wlr_output_state to be applied.
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/atomic.c20
-rw-r--r--backend/drm/drm.c14
-rw-r--r--backend/drm/legacy.c9
3 files changed, 24 insertions, 19 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c
index ac586bb5..df94410b 100644
--- a/backend/drm/atomic.c
+++ b/backend/drm/atomic.c
@@ -55,13 +55,14 @@ 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) {
+ struct wlr_drm_connector *conn, const struct wlr_output_state *state,
+ uint32_t *blob_id) {
+ if (!drm_connector_state_active(conn, state)) {
*blob_id = 0;
return true;
}
- if (drmModeCreatePropertyBlob(drm->fd, &crtc->pending.mode->drm_mode,
+ if (drmModeCreatePropertyBlob(drm->fd, &conn->crtc->pending.mode->drm_mode,
sizeof(drmModeModeInfo), blob_id)) {
wlr_log_errno(WLR_ERROR, "Unable to create mode property blob");
return false;
@@ -170,10 +171,11 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
struct wlr_drm_crtc *crtc = conn->crtc;
bool modeset = drm_connector_state_is_modeset(state);
+ bool active = drm_connector_state_active(conn, state);
uint32_t mode_id = crtc->mode_id;
if (modeset) {
- if (!create_mode_blob(drm, crtc, &mode_id)) {
+ if (!create_mode_blob(drm, conn, state, &mode_id)) {
return false;
}
}
@@ -213,16 +215,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 (modeset && crtc->pending.active &&
- conn->props.link_status != 0) {
+ atomic_add(&atom, conn->id, conn->props.crtc_id, active ? crtc->id : 0);
+ if (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 (active) {
if (crtc->props.gamma_lut != 0) {
atomic_add(&atom, crtc->id, crtc->props.gamma_lut, gamma_lut);
}
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 08a55857..0d4cc9b7 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -363,7 +363,7 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn,
return false;
}
- assert(crtc->pending.active);
+ assert(drm_connector_state_active(conn, state));
assert(plane_get_next_fb(crtc->primary));
if (!drm_crtc_commit(conn, state, DRM_MODE_PAGE_FLIP_EVENT)) {
return false;
@@ -680,7 +680,6 @@ static bool drm_connector_init_renderer(struct wlr_drm_connector *conn,
}
struct wlr_drm_plane *plane = crtc->primary;
- crtc->pending.active = true;
crtc->pending.mode = mode;
int width = mode->wlr_mode.width;
@@ -703,7 +702,6 @@ static bool drm_connector_init_renderer(struct wlr_drm_connector *conn,
"retrying without modifiers");
modifiers = false;
- crtc->pending.active = true;
crtc->pending.mode = mode;
if (!drm_plane_init_surface(plane, drm, width, height, format,
@@ -752,7 +750,6 @@ bool drm_connector_set_mode(struct wlr_drm_connector *conn,
if (wlr_mode == NULL) {
if (conn->crtc != NULL) {
- conn->crtc->pending.active = false;
if (!drm_crtc_commit(conn, state, 0)) {
return false;
}
@@ -1042,6 +1039,14 @@ bool drm_connector_state_is_modeset(const struct wlr_output_state *state) {
(WLR_OUTPUT_STATE_ENABLED | WLR_OUTPUT_STATE_MODE);
}
+bool drm_connector_state_active(struct wlr_drm_connector *conn,
+ const struct wlr_output_state *state) {
+ if (state->committed & WLR_OUTPUT_STATE_ENABLED) {
+ return state->enabled;
+ }
+ return conn->output.enabled;
+}
+
static const int32_t subpixel_map[] = {
[DRM_MODE_SUBPIXEL_UNKNOWN] = WL_OUTPUT_SUBPIXEL_UNKNOWN,
[DRM_MODE_SUBPIXEL_HORIZONTAL_RGB] = WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB,
@@ -1060,7 +1065,6 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {
wlr_drm_conn_log(conn, WLR_DEBUG, "De-allocating CRTC %zu",
conn->crtc - drm->crtcs);
- conn->crtc->pending.active = false;
struct wlr_output_state state = {
.committed = WLR_OUTPUT_STATE_ENABLED,
.enabled = false,
diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c
index 2f573899..dad45253 100644
--- a/backend/drm/legacy.c
+++ b/backend/drm/legacy.c
@@ -15,8 +15,10 @@ 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 active = drm_connector_state_active(conn, state);
+
uint32_t fb_id = 0;
- if (crtc->pending.active) {
+ if (active) {
struct wlr_drm_fb *fb = plane_get_next_fb(crtc->primary);
if (fb == NULL) {
wlr_log(WLR_ERROR, "%s: failed to acquire primary FB",
@@ -30,14 +32,13 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
uint32_t *conns = NULL;
size_t conns_len = 0;
drmModeModeInfo *mode = NULL;
- if (crtc->pending.active) {
+ if (active) {
conns = &conn->id;
conns_len = 1;
mode = &crtc->pending.mode->drm_mode;
}
- uint32_t dpms = crtc->pending.active ?
- DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF;
+ uint32_t dpms = active ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF;
if (drmModeConnectorSetProperty(drm->fd, conn->id, conn->props.dpms,
dpms) != 0) {
wlr_drm_conn_log_errno(conn, WLR_ERROR,