From d5162b44931c28d5b44db57a373b395c8232069b Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Mon, 22 Sep 2025 14:37:14 +0300 Subject: [PATCH] modesetting: Handle cursor images and buffers smaller than 64x64 correctly Signed-off-by: stefan11111 --- hw/xfree86/drivers/video/modesetting/driver.c | 18 ++++++++++++++++-- .../video/modesetting/drmmode_display.c | 7 +++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/drivers/video/modesetting/driver.c b/hw/xfree86/drivers/video/modesetting/driver.c index d944be8aa..497ee15a2 100644 --- a/hw/xfree86/drivers/video/modesetting/driver.c +++ b/hw/xfree86/drivers/video/modesetting/driver.c @@ -1965,11 +1965,25 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) return FALSE; /* Need to extend HWcursor support to handle mask interleave */ - if (!ms->drmmode.sw_cursor) + if (!ms->drmmode.sw_cursor) { + /* XXX Is there any spec that says we should interleave the cursor bits? XXX */ + int interleave; + if (cursor_dim.width >= 64) + interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64; + else if (cursor_dim.width >= 32) + interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32; + else if (cursor_dim.width >= 16) + interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16; + else if (cursor_dim.width >= 8) + interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8; + else + interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; + xf86_cursors_init(pScreen, cursor_dim.width, cursor_dim.height, - HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 | + interleave | HARDWARE_CURSOR_UPDATE_UNHIDDEN | HARDWARE_CURSOR_ARGB); + } /* Must force it before EnterVT, so we are in control of VT and * later memory should be bound when allocating, e.g rotate_mem */ diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.c b/hw/xfree86/drivers/video/modesetting/drmmode_display.c index 3c063d459..de688c6b2 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.c @@ -4679,8 +4679,8 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) xf86CrtcPtr crtc = xf86_config->crtc[i]; drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; drmmode_cursor_rec cursor = drmmode_crtc->cursor; - - /* If we don't have any dimensions then + + /* If we don't have any dimensions then * something has gone terribly wrong. */ assert(cursor.num_dimensions); @@ -4829,8 +4829,7 @@ Bool drmmode_get_largest_cursor(ScrnInfoPtr pScrn, drmmode_cursor_dim_ptr cursor { xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - /* We need the cursor image to be at least 64x64 */ - int max_width = 64, max_height = 64; + int max_width = 0, max_height = 0; if (!cursor_lim) return FALSE;