aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-07-08 15:56:01 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-07-09 15:31:19 -0400
commit017555651b01a2e4fbdda9d59b29c847094d57b7 (patch)
treebf823ca3013b373ad87f7f41608a474ada174e2e /backend/drm
parenta362d21d6b2191ce0101657629ae01841189cae5 (diff)
backend/drm: add test_only arg to wlr_drm_interface.crtc_commit
Right now callers of drm_crtc_commit need to check whether the interface is legacy or atomic before passing the TEST_ONLY flag. Additionally, the fallbacks for legacy are in-place in the common code. Add a test_only arg to the crtc_commit hook. This way, there's no risk to pass atomic-only flags to the legacy function (add an assert to ensure this) and all of the legacy-specific logic can be put back into legacy.c (done in next commit).
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/atomic.c9
-rw-r--r--backend/drm/drm.c21
-rw-r--r--backend/drm/legacy.c6
3 files changed, 23 insertions, 13 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c
index c7b630d6..23f9d60f 100644
--- a/backend/drm/atomic.c
+++ b/backend/drm/atomic.c
@@ -168,7 +168,7 @@ error:
static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
struct wlr_drm_connector *conn, const struct wlr_output_state *state,
- uint32_t flags) {
+ uint32_t flags, bool test_only) {
struct wlr_output *output = &conn->output;
struct wlr_drm_crtc *crtc = conn->crtc;
@@ -209,9 +209,12 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
vrr_enabled = state->adaptive_sync_enabled;
}
+ if (test_only) {
+ flags |= DRM_MODE_ATOMIC_TEST_ONLY;
+ }
if (modeset) {
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
- } else if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
+ } else if (!test_only) {
flags |= DRM_MODE_ATOMIC_NONBLOCK;
}
@@ -250,7 +253,7 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
bool ok = atomic_commit(&atom, conn, flags);
atomic_finish(&atom);
- if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
+ if (ok && !test_only) {
commit_blob(drm, &crtc->mode_id, mode_id);
commit_blob(drm, &crtc->gamma_lut, gamma_lut);
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index fb498a5d..403e5d7c 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -345,11 +345,14 @@ static void drm_plane_set_committed(struct wlr_drm_plane *plane) {
}
static bool drm_crtc_commit(struct wlr_drm_connector *conn,
- const struct wlr_output_state *state, uint32_t flags) {
+ const struct wlr_output_state *state, uint32_t flags, bool test_only) {
+ // Disallow atomic-only flags
+ assert((flags & ~DRM_MODE_PAGE_FLIP_FLAGS) == 0);
+
struct wlr_drm_backend *drm = conn->backend;
struct wlr_drm_crtc *crtc = conn->crtc;
- bool ok = drm->iface->crtc_commit(drm, conn, state, flags);
- if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
+ bool ok = drm->iface->crtc_commit(drm, conn, state, flags, test_only);
+ if (ok && !test_only) {
drm_plane_set_committed(crtc->primary);
if (crtc->cursor != NULL) {
drm_plane_set_committed(crtc->cursor);
@@ -383,7 +386,7 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn,
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)) {
+ if (!drm_crtc_commit(conn, state, DRM_MODE_PAGE_FLIP_EVENT, false)) {
return false;
}
@@ -475,7 +478,7 @@ static bool drm_connector_test(struct wlr_output *output) {
if (!drm_connector_set_pending_fb(conn, &output->pending)) {
return false;
}
- if (!drm_crtc_commit(conn, &output->pending, DRM_MODE_ATOMIC_TEST_ONLY)) {
+ if (!drm_crtc_commit(conn, &output->pending, 0, true)) {
return false;
}
}
@@ -559,7 +562,7 @@ bool drm_connector_commit_state(struct wlr_drm_connector *conn,
WLR_OUTPUT_STATE_GAMMA_LUT)) {
assert(conn->crtc != NULL);
// TODO: maybe request a page-flip event here?
- if (!drm_crtc_commit(conn, &state, 0)) {
+ if (!drm_crtc_commit(conn, &state, 0, false)) {
return false;
}
}
@@ -677,7 +680,7 @@ static bool drm_connector_test_renderer(struct wlr_drm_connector *conn,
goto out;
}
- ok = drm_crtc_commit(conn, state, DRM_MODE_ATOMIC_TEST_ONLY);
+ ok = drm_crtc_commit(conn, state, 0, true);
out:
drm_fb_move(&plane->pending_fb, &prev_fb);
@@ -783,7 +786,7 @@ static bool drm_connector_set_mode(struct wlr_drm_connector *conn,
if (wlr_mode == NULL) {
if (conn->crtc != NULL) {
- if (!drm_crtc_commit(conn, state, 0)) {
+ if (!drm_crtc_commit(conn, state, 0, false)) {
return false;
}
realloc_crtcs(drm);
@@ -1128,7 +1131,7 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {
.committed = WLR_OUTPUT_STATE_ENABLED,
.enabled = false,
};
- if (!drm_crtc_commit(conn, &state, 0)) {
+ if (!drm_crtc_commit(conn, &state, 0, false)) {
// On GPU unplug, disabling the CRTC can fail with EPERM
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to disable CRTC %"PRIu32,
conn->crtc->id);
diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c
index 43436165..ca23bb1c 100644
--- a/backend/drm/legacy.c
+++ b/backend/drm/legacy.c
@@ -10,7 +10,11 @@
static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
struct wlr_drm_connector *conn, const struct wlr_output_state *state,
- uint32_t flags) {
+ uint32_t flags, bool test_only) {
+ if (test_only) {
+ return true;
+ }
+
struct wlr_output *output = &conn->output;
struct wlr_drm_crtc *crtc = conn->crtc;
struct wlr_drm_plane *cursor = crtc->cursor;