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).
master
Simon Ser 3 years ago committed by Simon Zeni
parent a362d21d6b
commit 017555651b

@ -168,7 +168,7 @@ error:
static bool atomic_crtc_commit(struct wlr_drm_backend *drm, static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
struct wlr_drm_connector *conn, const struct wlr_output_state *state, 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_output *output = &conn->output;
struct wlr_drm_crtc *crtc = conn->crtc; 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; vrr_enabled = state->adaptive_sync_enabled;
} }
if (test_only) {
flags |= DRM_MODE_ATOMIC_TEST_ONLY;
}
if (modeset) { if (modeset) {
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
} else if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { } else if (!test_only) {
flags |= DRM_MODE_ATOMIC_NONBLOCK; 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); bool ok = atomic_commit(&atom, conn, flags);
atomic_finish(&atom); 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->mode_id, mode_id);
commit_blob(drm, &crtc->gamma_lut, gamma_lut); commit_blob(drm, &crtc->gamma_lut, gamma_lut);

@ -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, 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_backend *drm = conn->backend;
struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_crtc *crtc = conn->crtc;
bool ok = drm->iface->crtc_commit(drm, conn, state, flags); bool ok = drm->iface->crtc_commit(drm, conn, state, flags, test_only);
if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { if (ok && !test_only) {
drm_plane_set_committed(crtc->primary); drm_plane_set_committed(crtc->primary);
if (crtc->cursor != NULL) { if (crtc->cursor != NULL) {
drm_plane_set_committed(crtc->cursor); 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(drm_connector_state_active(conn, state));
assert(plane_get_next_fb(crtc->primary)); 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; return false;
} }
@ -475,7 +478,7 @@ static bool drm_connector_test(struct wlr_output *output) {
if (!drm_connector_set_pending_fb(conn, &output->pending)) { if (!drm_connector_set_pending_fb(conn, &output->pending)) {
return false; 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; return false;
} }
} }
@ -559,7 +562,7 @@ bool drm_connector_commit_state(struct wlr_drm_connector *conn,
WLR_OUTPUT_STATE_GAMMA_LUT)) { WLR_OUTPUT_STATE_GAMMA_LUT)) {
assert(conn->crtc != NULL); assert(conn->crtc != NULL);
// TODO: maybe request a page-flip event here? // 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; return false;
} }
} }
@ -677,7 +680,7 @@ static bool drm_connector_test_renderer(struct wlr_drm_connector *conn,
goto out; goto out;
} }
ok = drm_crtc_commit(conn, state, DRM_MODE_ATOMIC_TEST_ONLY); ok = drm_crtc_commit(conn, state, 0, true);
out: out:
drm_fb_move(&plane->pending_fb, &prev_fb); 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 (wlr_mode == NULL) {
if (conn->crtc != NULL) { if (conn->crtc != NULL) {
if (!drm_crtc_commit(conn, state, 0)) { if (!drm_crtc_commit(conn, state, 0, false)) {
return false; return false;
} }
realloc_crtcs(drm); realloc_crtcs(drm);
@ -1128,7 +1131,7 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {
.committed = WLR_OUTPUT_STATE_ENABLED, .committed = WLR_OUTPUT_STATE_ENABLED,
.enabled = false, .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 // On GPU unplug, disabling the CRTC can fail with EPERM
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to disable CRTC %"PRIu32, wlr_drm_conn_log(conn, WLR_ERROR, "Failed to disable CRTC %"PRIu32,
conn->crtc->id); conn->crtc->id);

@ -10,7 +10,11 @@
static bool legacy_crtc_commit(struct wlr_drm_backend *drm, static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
struct wlr_drm_connector *conn, const struct wlr_output_state *state, 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_output *output = &conn->output;
struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_crtc *crtc = conn->crtc;
struct wlr_drm_plane *cursor = crtc->cursor; struct wlr_drm_plane *cursor = crtc->cursor;

@ -16,7 +16,7 @@ struct wlr_drm_interface {
// Commit al pending changes on a CRTC. // Commit al pending changes on a CRTC.
bool (*crtc_commit)(struct wlr_drm_backend *drm, bool (*crtc_commit)(struct wlr_drm_backend *drm,
struct wlr_drm_connector *conn, const struct wlr_output_state *state, struct wlr_drm_connector *conn, const struct wlr_output_state *state,
uint32_t flags); uint32_t flags, bool test_only);
}; };
extern const struct wlr_drm_interface atomic_iface; extern const struct wlr_drm_interface atomic_iface;

Loading…
Cancel
Save