From e7455f48a37cff8d15bdd3ca12daadb81bfc2423 Mon Sep 17 00:00:00 2001 From: notbabaisyou Date: Thu, 14 Aug 2025 13:52:52 +0200 Subject: [PATCH] hw/modesetting: Add drmmode_get_cursor_limit. Used in upcoming commit. --- .../video/modesetting/drmmode_display.c | 34 +++++++++++++++++++ .../video/modesetting/drmmode_display.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.c b/hw/xfree86/drivers/video/modesetting/drmmode_display.c index 139b9529f7..10de202901 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.c @@ -4598,6 +4598,40 @@ drmmode_crtc_set_vrr(xf86CrtcPtr crtc, Bool enabled) drmmode_crtc->vrr_enabled = enabled; } +Bool drmmode_get_cursor_limit(ScrnInfoPtr pScrn, drmmode_cursor_dim_ptr cursor_lim) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int max_width = 0, max_height = 0, i; + + if (!cursor_lim) + return FALSE; + + for (i = 0; i < xf86_config->num_crtc; i++) { + xf86CrtcPtr crtc = xf86_config->crtc[i]; + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + drmmode_cursor_rec cursor = drmmode_crtc->cursor; + + /* Very ugly. */ + drmmode_cursor_dim_rec largest = cursor.dimensions[cursor.num_dimensions - 1]; + + int width = largest.width; + int height = largest.height; + + /** + * TODO: We should only let sizes that all CRTCs support. + */ + if (width > max_width && height > max_height) + { + max_width = width; + max_height = height; + } + } + + cursor_lim->width = max_width; + cursor_lim->height = max_height; + return TRUE; +} + /* * We hook the screen's cursor-sprite (swcursor) functions to see if a swcursor * is active. When a swcursor is active we disable page-flipping. diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.h b/hw/xfree86/drivers/video/modesetting/drmmode_display.h index d470e2d417..27948246d4 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.h +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.h @@ -355,4 +355,6 @@ Bool drmmode_crtc_get_fb_id(xf86CrtcPtr crtc, uint32_t *fb_id, int *x, int *y); void drmmode_set_dpms(ScrnInfoPtr scrn, int PowerManagementMode, int flags); void drmmode_crtc_set_vrr(xf86CrtcPtr crtc, Bool enabled); +Bool drmmode_get_cursor_limit(ScrnInfoPtr pScrn, drmmode_cursor_dim_ptr cursor_lim); + #endif