From c9d6b18eef1099a033b89b834b0e2822e1218a4a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 7 May 2020 16:17:18 +0200 Subject: [PATCH] backend/drm: remove wlr_drm_interface.crtc_move_cursor Instead, make the legacy backend call drmModeMoveCursor on page-flip. --- backend/drm/atomic.c | 7 ------- backend/drm/backend.c | 2 -- backend/drm/drm.c | 17 ++--------------- backend/drm/legacy.c | 14 ++++++++------ include/backend/drm/iface.h | 3 --- 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index d6149539..11c273e2 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -193,12 +193,6 @@ static bool atomic_crtc_set_cursor(struct wlr_drm_backend *drm, return true; } -static bool atomic_crtc_move_cursor(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc, int x, int y) { - /* Cursor updates happen when we pageflip */ - return true; -} - static bool atomic_crtc_set_gamma(struct wlr_drm_backend *drm, struct wlr_drm_crtc *crtc, size_t size, uint16_t *r, uint16_t *g, uint16_t *b) { @@ -258,7 +252,6 @@ const struct wlr_drm_interface atomic_iface = { .conn_enable = atomic_conn_enable, .crtc_pageflip = atomic_crtc_pageflip, .crtc_set_cursor = atomic_crtc_set_cursor, - .crtc_move_cursor = atomic_crtc_move_cursor, .crtc_set_gamma = atomic_crtc_set_gamma, .crtc_get_gamma_size = atomic_crtc_get_gamma_size, }; diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 7aeaa01e..c07736cf 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -112,8 +112,6 @@ static void session_signal(struct wl_listener *listener, void *data) { } drm->iface->crtc_set_cursor(drm, conn->crtc, bo); - drm->iface->crtc_move_cursor(drm, conn->crtc, conn->cursor_x, - conn->cursor_y); if (conn->crtc->gamma_table != NULL) { size_t size = conn->crtc->gamma_table_size; diff --git a/backend/drm/drm.c b/backend/drm/drm.c index f06b0600..578b966f 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -953,11 +953,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output, plane->cursor_hotspot_x = hotspot.x; plane->cursor_hotspot_y = hotspot.y; - if (!drm->iface->crtc_move_cursor(drm, conn->crtc, conn->cursor_x, - conn->cursor_y)) { - return false; - } - wlr_output_update_needs_frame(output); } @@ -1033,7 +1028,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output, static bool drm_connector_move_cursor(struct wlr_output *output, int x, int y) { struct wlr_drm_connector *conn = get_drm_connector_from_output(output); - struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend); if (!conn->crtc) { return false; } @@ -1056,15 +1050,8 @@ static bool drm_connector_move_cursor(struct wlr_output *output, conn->cursor_x = box.x; conn->cursor_y = box.y; - if (!drm->session->active) { - return true; // will be committed when session is resumed - } - - bool ok = drm->iface->crtc_move_cursor(drm, conn->crtc, box.x, box.y); - if (ok) { - wlr_output_update_needs_frame(output); - } - return ok; + wlr_output_update_needs_frame(output); + return true; } static void drm_connector_destroy(struct wlr_output *output) { diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index be5ec4a0..da9b636f 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -9,6 +9,8 @@ static bool legacy_crtc_pageflip(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, drmModeModeInfo *mode) { struct wlr_drm_crtc *crtc = conn->crtc; + struct wlr_drm_plane *cursor = crtc->cursor; + struct wlr_drm_fb *fb = plane_get_next_fb(crtc->primary); struct gbm_bo *bo = drm_fb_acquire(fb, drm, &crtc->primary->mgpu_surf); if (!bo) { @@ -28,6 +30,12 @@ static bool legacy_crtc_pageflip(struct wlr_drm_backend *drm, } } + if (cursor != NULL && cursor->cursor_enabled && 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; + } + if (drmModePageFlip(drm->fd, crtc->id, fb_id, DRM_MODE_PAGE_FLIP_EVENT, drm)) { wlr_log_errno(WLR_ERROR, "%s: Failed to page flip", conn->output.name); return false; @@ -75,11 +83,6 @@ bool legacy_crtc_set_cursor(struct wlr_drm_backend *drm, return true; } -bool legacy_crtc_move_cursor(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc, int x, int y) { - return !drmModeMoveCursor(drm->fd, crtc->id, x, y); -} - static bool legacy_crtc_set_gamma(struct wlr_drm_backend *drm, struct wlr_drm_crtc *crtc, size_t size, uint16_t *r, uint16_t *g, uint16_t *b) { @@ -95,7 +98,6 @@ const struct wlr_drm_interface legacy_iface = { .conn_enable = legacy_conn_enable, .crtc_pageflip = legacy_crtc_pageflip, .crtc_set_cursor = legacy_crtc_set_cursor, - .crtc_move_cursor = legacy_crtc_move_cursor, .crtc_set_gamma = legacy_crtc_set_gamma, .crtc_get_gamma_size = legacy_crtc_get_gamma_size, }; diff --git a/include/backend/drm/iface.h b/include/backend/drm/iface.h index d8268347..acaf4730 100644 --- a/include/backend/drm/iface.h +++ b/include/backend/drm/iface.h @@ -22,9 +22,6 @@ struct wlr_drm_interface { // 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); - // Move the cursor on crtc - bool (*crtc_move_cursor)(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc, int x, int y); // Set the gamma lut on crtc bool (*crtc_set_gamma)(struct wlr_drm_backend *drm, struct wlr_drm_crtc *crtc, size_t size,