From 6c984ac9a737304ab5e26de90c76a79d970b6e33 Mon Sep 17 00:00:00 2001 From: Hans De Goede Date: Wed, 31 Aug 2016 16:11:11 +0200 Subject: [PATCH] modesetting: Do not use function local static variables The modesetting driver may be driving 2 screens (slave and master gpu), which may have different behavior wrt hardware cursor support. So stop using static variables and instead store the hw-cursor support related data in a per screen struct. While at it actually make it per crtc data as in theory different crtc's could have different hw-cursor support. Signed-off-by: Hans de Goede Reviewed-by: Keith Packard --- hw/xfree86/drivers/modesetting/drmmode_display.c | 10 ++++------ hw/xfree86/drivers/modesetting/drmmode_display.h | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 1dad66ae3..dd8cc712d 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -756,10 +756,9 @@ drmmode_set_cursor(xf86CrtcPtr crtc) drmmode_ptr drmmode = drmmode_crtc->drmmode; uint32_t handle = drmmode_crtc->cursor_bo->handle; modesettingPtr ms = modesettingPTR(crtc->scrn); - static Bool use_set_cursor2 = TRUE; int ret; - if (use_set_cursor2) { + if (!drmmode_crtc->set_cursor2_failed) { CursorPtr cursor = xf86CurrentCursor(crtc->scrn->pScreen); ret = @@ -769,7 +768,7 @@ drmmode_set_cursor(xf86CrtcPtr crtc) if (!ret) return TRUE; - use_set_cursor2 = FALSE; + drmmode_crtc->set_cursor2_failed = TRUE; } ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle, @@ -803,7 +802,6 @@ drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image) drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; int i; uint32_t *ptr; - static Bool first_time = TRUE; /* cursor should be mapped already */ ptr = (uint32_t *) (drmmode_crtc->cursor_bo->ptr); @@ -811,11 +809,11 @@ drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image) for (i = 0; i < ms->cursor_width * ms->cursor_height; i++) ptr[i] = image[i]; // cpu_to_le32(image[i]); - if (drmmode_crtc->cursor_up || first_time) { + if (drmmode_crtc->cursor_up || !drmmode_crtc->first_cursor_load_done) { Bool ret = drmmode_set_cursor(crtc); if (!drmmode_crtc->cursor_up) drmmode_hide_cursor(crtc); - first_time = FALSE; + drmmode_crtc->first_cursor_load_done = TRUE; return ret; } return TRUE; diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h index 5499c16df..6d05ec4a0 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.h +++ b/hw/xfree86/drivers/modesetting/drmmode_display.h @@ -89,6 +89,8 @@ typedef struct { int dpms_mode; struct dumb_bo *cursor_bo; Bool cursor_up; + Bool set_cursor2_failed; + Bool first_cursor_load_done; uint16_t lut_r[256], lut_g[256], lut_b[256]; drmmode_bo rotate_bo;