From 3f821b291eaeb53e9e48aaa645324fdb85aae3c5 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Sat, 29 Nov 2025 16:25:51 +0200 Subject: [PATCH] modesetting: get more values from the fallback cursor probe The space needed to store these extra values is at worst a few dozen bytes. In exchange for these, larger cursors glyphs can use a more optimal cursor size. Signed-off-by: stefan11111 --- .../drivers/video/modesetting/drmmode_display.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.c b/hw/xfree86/drivers/video/modesetting/drmmode_display.c index 3591c2192..d340b9818 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.c @@ -4794,7 +4794,7 @@ static void drmmode_probe_cursor_size(xf86CrtcPtr crtc) * this doesn't happen, there shouldn't be any issues. */ - int num_dimensions = 1; + int num_dimensions = !(max_width == max_height); if (min_width > min_height) { for(int j = min_height; j <= min_width; j *= 2) { num_dimensions++; @@ -4806,6 +4806,10 @@ static void drmmode_probe_cursor_size(xf86CrtcPtr crtc) } + for (int j = MAX(min_width, min_height) * 2; j <= MIN(max_width, max_height); j *= 2) { + num_dimensions++; + } + void *tmp = realloc(drmmode_cursor->dimensions, num_dimensions * sizeof(drmmode_cursor_dim_rec)); if (!tmp) { xf86DrvMsgVerb(crtc->scrn->scrnIndex, X_INFO, MS_LOGLEVEL_DEBUG, @@ -4817,15 +4821,15 @@ static void drmmode_probe_cursor_size(xf86CrtcPtr crtc) drmmode_cursor->dimensions = tmp; drmmode_cursor->num_dimensions = num_dimensions; + int idx = 0; + if (min_width > min_height) { - int idx = 0; for(int j = min_height; j <= min_width; j *= 2) { drmmode_cursor->dimensions[idx].width = min_width; drmmode_cursor->dimensions[idx].height = j; idx++; } } else { - int idx = 0; for(int j = min_width; j <= min_height; j *= 2) { drmmode_cursor->dimensions[idx].width = j; drmmode_cursor->dimensions[idx].height = min_height; @@ -4833,6 +4837,12 @@ static void drmmode_probe_cursor_size(xf86CrtcPtr crtc) } } + for (int j = MAX(min_width, min_height) * 2; j <= MIN(max_width, max_height); j *= 2) { + drmmode_cursor->dimensions[idx].width = j; + drmmode_cursor->dimensions[idx].height = j; + idx++; + } + /* maximum size */ drmmode_cursor->dimensions[num_dimensions - 1].width = max_width; drmmode_cursor->dimensions[num_dimensions - 1].height = max_height;