From da63d11d341e9e1bc3c0dcb040e2cc5d82a3959e Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 7 May 2020 21:28:42 +0200 Subject: [PATCH] backend/drm: remove crtc_set_cursor from interface --- backend/drm/atomic.c | 10 ------- backend/drm/backend.c | 13 -------- backend/drm/drm.c | 15 +--------- backend/drm/legacy.c | 59 ++++++++++++++++++------------------- include/backend/drm/iface.h | 3 -- 5 files changed, 30 insertions(+), 70 deletions(-) diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index 0b258cfb..d4f033f0 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -237,15 +237,6 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, return false; } - if (crtc->active && crtc->cursor) { - drm_fb_move(&crtc->cursor->queued_fb, &crtc->cursor->pending_fb); - } - return true; -} - -static bool atomic_crtc_set_cursor(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc, struct gbm_bo *bo) { - /* Cursor updates happen when we pageflip */ return true; } @@ -267,6 +258,5 @@ static size_t atomic_crtc_get_gamma_size(struct wlr_drm_backend *drm, const struct wlr_drm_interface atomic_iface = { .crtc_commit = atomic_crtc_commit, - .crtc_set_cursor = atomic_crtc_set_cursor, .crtc_get_gamma_size = atomic_crtc_get_gamma_size, }; diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 4eabb0ec..6f9370f3 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -100,19 +100,6 @@ static void session_signal(struct wl_listener *listener, void *data) { } else { enable_drm_connector(&conn->output, false); } - - if (!conn->crtc) { - continue; - } - - struct wlr_drm_plane *plane = conn->crtc->cursor; - struct gbm_bo *bo = NULL; - if (plane->cursor_enabled) { - bo = drm_fb_acquire(&plane->current_fb, drm, - &plane->mgpu_surf); - } - - drm->iface->crtc_set_cursor(drm, conn->crtc, bo); } } else { wlr_log(WLR_INFO, "DRM fd paused"); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index ed01459b..60df4348 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -360,6 +360,7 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn) { conn->pageflip_pending = true; drm_fb_move(&crtc->primary->queued_fb, &crtc->primary->pending_fb); + drm_fb_move(&crtc->cursor->queued_fb, &crtc->cursor->pending_fb); wlr_output_update_enabled(&conn->output, true); return true; } @@ -1013,17 +1014,7 @@ static bool drm_connector_set_cursor(struct wlr_output *output, plane->cursor_enabled = true; } - if (!drm->session->active) { - return true; // will be committed when session is resumed - } - - struct gbm_bo *bo = NULL; - if (plane->cursor_enabled) { - bo = drm_fb_acquire(&plane->pending_fb, drm, &plane->mgpu_surf); - - wlr_log(WLR_DEBUG, "SET_CURSOR %p %p", plane->pending_fb.bo, bo); - /* Workaround for nouveau buffers created with GBM_BO_USER_LINEAR are * placed in NOUVEAU_GEM_DOMAIN_GART. When the bo is attached to the * cursor plane it is moved to NOUVEAU_GEM_DOMAIN_VRAM. However, this @@ -1035,10 +1026,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output, glFinish(); } - if (!drm->iface->crtc_set_cursor(drm, crtc, bo)) { - return false; - } - wlr_output_update_needs_frame(output); return true; } diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index ecf67092..09e7df16 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -56,10 +56,36 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm, } } - if (cursor != NULL && cursor->cursor_enabled && drmModeMoveCursor(drm->fd, + if (cursor != NULL && cursor->cursor_enabled) { + struct wlr_drm_fb *cursor_fb = plane_get_next_fb(cursor); + struct gbm_bo *cursor_bo = + drm_fb_acquire(cursor_fb, drm, &cursor->mgpu_surf); + if (!cursor_bo) { + wlr_log_errno(WLR_DEBUG, "%s: failed to acquire cursor FB", + conn->output.name); + return false; + } + + if (drmModeSetCursor(drm->fd, crtc->id, + gbm_bo_get_handle(cursor_bo).u32, + cursor->surf.width, cursor->surf.height)) { + wlr_log_errno(WLR_DEBUG, "%s: failed to set hardware cursor", + conn->output.name); + return false; + } + + if (drmModeMoveCursor(drm->fd, crtc->id, conn->cursor_x, conn->cursor_y) != 0) { - wlr_log_errno(WLR_ERROR, "%s: failed to move cursor", conn->output.name); - return false; + wlr_log_errno(WLR_ERROR, "%s: failed to move cursor", + conn->output.name); + return false; + } + } else { + if (drmModeSetCursor(drm->fd, crtc->id, 0, 0, 0)) { + wlr_log_errno(WLR_DEBUG, "%s: failed to unset hardware cursor", + conn->output.name); + return false; + } } if (flags & DRM_MODE_PAGE_FLIP_EVENT) { @@ -73,32 +99,6 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm, return true; } -bool legacy_crtc_set_cursor(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc, struct gbm_bo *bo) { - if (!crtc || !crtc->cursor) { - return true; - } - - if (!bo) { - if (drmModeSetCursor(drm->fd, crtc->id, 0, 0, 0)) { - wlr_log_errno(WLR_DEBUG, "Failed to clear hardware cursor"); - return false; - } - return true; - } - - struct wlr_drm_plane *plane = crtc->cursor; - - if (drmModeSetCursor(drm->fd, crtc->id, gbm_bo_get_handle(bo).u32, - plane->surf.width, plane->surf.height)) { - wlr_log_errno(WLR_DEBUG, "Failed to set hardware cursor"); - return false; - } - - drm_fb_move(&crtc->cursor->queued_fb, &crtc->cursor->pending_fb); - return true; -} - bool drm_legacy_crtc_set_gamma(struct wlr_drm_backend *drm, struct wlr_drm_crtc *crtc) { uint32_t size = crtc->gamma_table_size; @@ -124,6 +124,5 @@ static size_t legacy_crtc_get_gamma_size(struct wlr_drm_backend *drm, const struct wlr_drm_interface legacy_iface = { .crtc_commit = legacy_crtc_commit, - .crtc_set_cursor = legacy_crtc_set_cursor, .crtc_get_gamma_size = legacy_crtc_get_gamma_size, }; diff --git a/include/backend/drm/iface.h b/include/backend/drm/iface.h index e9bf8040..6393579c 100644 --- a/include/backend/drm/iface.h +++ b/include/backend/drm/iface.h @@ -16,9 +16,6 @@ struct wlr_drm_interface { // Commit al pending changes on a CRTC. bool (*crtc_commit)(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, uint32_t flags); - // Enable the cursor buffer on crtc. Set bo to NULL to disable - bool (*crtc_set_cursor)(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc, struct gbm_bo *bo); // Get the gamma lut size of a crtc size_t (*crtc_get_gamma_size)(struct wlr_drm_backend *drm, struct wlr_drm_crtc *crtc);