From 23dfcba633f19762e1e75aef737a5b891c59f77b Mon Sep 17 00:00:00 2001 From: John Studnicka Date: Sun, 25 Jan 2026 03:31:38 -0700 Subject: [PATCH] modesetting: Fall back to SW cursor for OOB dims Signed-off-by: John Studnicka --- .../video/modesetting/drmmode_display.c | 24 ++++++++++++++----- .../video/modesetting/drmmode_display.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.c b/hw/xfree86/drivers/video/modesetting/drmmode_display.c index b97e0df9c..ac285d09a 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.c @@ -2001,7 +2001,6 @@ drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image) drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; modesettingPtr ms = modesettingPTR(crtc->scrn); CursorPtr cursor = xf86CurrentCursor(crtc->scrn->pScreen); - int i; if (drmmode_crtc->cursor_up) { /* we probe the cursor so late, because we want to make sure that @@ -2013,9 +2012,10 @@ drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image) drmmode_cursor_rec drmmode_cursor = drmmode_crtc->cursor; /* Find the most compatiable size. */ - for (i = 0; i < drmmode_cursor.num_dimensions; i++) + int idx; + for (idx = 0; idx < drmmode_cursor.num_dimensions; idx++) { - drmmode_cursor_dim_rec dimensions = drmmode_cursor.dimensions[i]; + drmmode_cursor_dim_rec dimensions = drmmode_cursor.dimensions[idx]; if (dimensions.width >= cursor->bits->width && dimensions.height >= cursor->bits->height) { @@ -2023,11 +2023,23 @@ drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image) } } - const int cursor_pitch = drmmode_cursor_get_pitch(drmmode_crtc, i); + if (idx >= drmmode_cursor.num_dimensions) { + /* No compatible hardware cursor size; fall back to software cursor. */ + if (!drmmode_crtc->cursor_dim_fallback_warned) { + xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING, + "No compatible hardware cursor size for %dx%d; " + "falling back to software cursor\n", + cursor->bits->width, cursor->bits->height); + drmmode_crtc->cursor_dim_fallback_warned = TRUE; + } + return FALSE; + } + + const int cursor_pitch = drmmode_cursor_get_pitch(drmmode_crtc, idx); /* Get the resolution of the cursor. */ - int cursor_width = drmmode_cursor.dimensions[i].width; - int cursor_height = drmmode_cursor.dimensions[i].height; + int cursor_width = drmmode_cursor.dimensions[idx].width; + int cursor_height = drmmode_cursor.dimensions[idx].height; /* Get the size of the cursor image buffer */ int image_width = ms->cursor_image_width; diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.h b/hw/xfree86/drivers/video/modesetting/drmmode_display.h index 2d12012e9..4e0907871 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.h +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.h @@ -257,6 +257,7 @@ typedef struct { int old_pitch; Bool cursor_probed; + Bool cursor_dim_fallback_warned; int* cursor_pitches; } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;