modesetting: Fall back to SW cursor for OOB dims

Signed-off-by: John Studnicka <contact@zentec.dev>
This commit is contained in:
John Studnicka
2026-01-25 03:31:38 -07:00
committed by Enrico Weigelt
parent fa5db91243
commit 23dfcba633
2 changed files with 19 additions and 6 deletions

View File

@@ -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;

View File

@@ -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;