mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-05-01 06:47:01 -04:00
backend/drm: extract post-commit logic into functions
It's more readable, and we'll soon call this from a loop for multi-connector commits.
This commit is contained in:
parent
11e5f4f528
commit
7f6c3b34f0
1 changed files with 43 additions and 31 deletions
|
|
@ -453,24 +453,11 @@ static struct wlr_drm_page_flip *drm_page_flip_create(struct wlr_drm_connector *
|
|||
return page_flip;
|
||||
}
|
||||
|
||||
static bool drm_crtc_commit(struct wlr_drm_connector *conn,
|
||||
const struct wlr_drm_connector_state *state,
|
||||
uint32_t flags, bool test_only) {
|
||||
// Disallow atomic-only flags
|
||||
assert((flags & ~DRM_MODE_PAGE_FLIP_FLAGS) == 0);
|
||||
|
||||
struct wlr_drm_page_flip *page_flip = NULL;
|
||||
if (flags & DRM_MODE_PAGE_FLIP_EVENT) {
|
||||
page_flip = drm_page_flip_create(conn);
|
||||
if (page_flip == NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
struct wlr_drm_backend *drm = conn->backend;
|
||||
static void drm_connector_apply_commit(const struct wlr_drm_connector_state *state,
|
||||
struct wlr_drm_page_flip *page_flip) {
|
||||
struct wlr_drm_connector *conn = state->connector;
|
||||
struct wlr_drm_crtc *crtc = conn->crtc;
|
||||
bool ok = drm->iface->crtc_commit(conn, state, page_flip, flags, test_only);
|
||||
if (ok && !test_only) {
|
||||
|
||||
drm_fb_clear(&crtc->primary->queued_fb);
|
||||
if (state->primary_fb != NULL) {
|
||||
crtc->primary->queued_fb = drm_fb_lock(state->primary_fb);
|
||||
|
|
@ -489,7 +476,11 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn,
|
|||
if (state->base->committed & WLR_OUTPUT_STATE_MODE) {
|
||||
conn->refresh = calculate_refresh_rate(&state->mode);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
static void drm_connector_rollback_commit(const struct wlr_drm_connector_state *state) {
|
||||
struct wlr_drm_crtc *crtc = state->connector->crtc;
|
||||
|
||||
// The set_cursor() hook is a bit special: it's not really synchronized
|
||||
// to commit() or test(). Once set_cursor() returns true, the new
|
||||
// cursor is effectively committed. So don't roll it back here, or we
|
||||
|
|
@ -501,7 +492,28 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn,
|
|||
wl_list_for_each(layer, &crtc->layers, link) {
|
||||
drm_fb_clear(&layer->pending_fb);
|
||||
}
|
||||
}
|
||||
|
||||
static bool drm_crtc_commit(struct wlr_drm_connector *conn,
|
||||
const struct wlr_drm_connector_state *state,
|
||||
uint32_t flags, bool test_only) {
|
||||
// Disallow atomic-only flags
|
||||
assert((flags & ~DRM_MODE_PAGE_FLIP_FLAGS) == 0);
|
||||
|
||||
struct wlr_drm_page_flip *page_flip = NULL;
|
||||
if (flags & DRM_MODE_PAGE_FLIP_EVENT) {
|
||||
page_flip = drm_page_flip_create(conn);
|
||||
if (page_flip == NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
struct wlr_drm_backend *drm = conn->backend;
|
||||
bool ok = drm->iface->crtc_commit(conn, state, page_flip, flags, test_only);
|
||||
if (ok && !test_only) {
|
||||
drm_connector_apply_commit(state, page_flip);
|
||||
} else {
|
||||
drm_connector_rollback_commit(state);
|
||||
drm_page_flip_destroy(page_flip);
|
||||
}
|
||||
return ok;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue