Commit 5a541bd5 authored by Keith Packard's avatar Keith Packard

modesetting: [v2] Don't re-enable the cursor when loading the image

Hidden cursors also have their image updated; re-enabling the cursor
each time the image is set will cause it to re-appear.

 * Unifies the code that was in  drmmode_load_cursor_argb and
  drm_mode_show_cursor and moves it to a new drmmode_set_cursor

 * Add a new boolean, 'cursor_up', to the per-crtc
   private data to track whether the cursor should be displayed.

 * Call drmmode_set_cursor from drm_mode_show_cursor and, if
   the cursor should be displayed, from drm_mode_load_cursor_argb.

v2: Call drmModeSetCursor2 when loading a new cursor image if the
    cursor should be displayed.
Signed-off-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <michel.daenzer@amd.com>
parent 0f5fdaf6
......@@ -394,25 +394,32 @@ drmmode_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
}
static void
drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
drmmode_set_cursor(xf86CrtcPtr crtc)
{
modesettingPtr ms = modesettingPTR(crtc->scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
int i;
uint32_t *ptr;
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;
/* cursor should be mapped already */
ptr = (uint32_t *) (drmmode_crtc->cursor_bo->ptr);
if (use_set_cursor2) {
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
CursorPtr cursor = xf86_config->cursor;
for (i = 0; i < ms->cursor_width * ms->cursor_height; i++)
ptr[i] = image[i]; // cpu_to_le32(image[i]);
ret =
drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
handle, ms->cursor_width, ms->cursor_height,
cursor->bits->xhot, cursor->bits->yhot);
if (ret == -EINVAL)
use_set_cursor2 = FALSE;
else
return;
}
ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
ms->cursor_width, ms->cursor_height);
ret =
drmModeSetCursor(drmmode_crtc->drmmode->fd,
drmmode_crtc->mode_crtc->crtc_id, handle,
ms->cursor_width, ms->cursor_height);
if (ret) {
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
......@@ -424,45 +431,43 @@ drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
}
static void
drmmode_hide_cursor(xf86CrtcPtr crtc)
drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
{
modesettingPtr ms = modesettingPTR(crtc->scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
int i;
uint32_t *ptr;
drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
ms->cursor_width, ms->cursor_height);
/* cursor should be mapped already */
ptr = (uint32_t *) (drmmode_crtc->cursor_bo->ptr);
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)
drmmode_set_cursor(crtc);
}
static void
drmmode_show_cursor(xf86CrtcPtr crtc)
drmmode_hide_cursor(xf86CrtcPtr crtc)
{
modesettingPtr ms = modesettingPTR(crtc->scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
uint32_t handle = drmmode_crtc->cursor_bo->handle;
static Bool use_set_cursor2 = TRUE;
if (use_set_cursor2) {
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
CursorPtr cursor = xf86_config->cursor;
int ret;
ret =
drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
handle, ms->cursor_width, ms->cursor_height,
cursor->bits->xhot, cursor->bits->yhot);
if (ret == -EINVAL)
use_set_cursor2 = FALSE;
else
return;
}
drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
drmmode_crtc->cursor_up = FALSE;
drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
ms->cursor_width, ms->cursor_height);
}
static void
drmmode_show_cursor(xf86CrtcPtr crtc)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_crtc->cursor_up = TRUE;
drmmode_set_cursor(crtc);
}
static void
drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t * red, uint16_t * green,
uint16_t * blue, int size)
......
......@@ -87,6 +87,7 @@ typedef struct {
drmModeCrtcPtr mode_crtc;
uint32_t vblank_pipe;
struct dumb_bo *cursor_bo;
Bool cursor_up;
unsigned rotate_fb_id;
uint16_t lut_r[256], lut_g[256], lut_b[256];
DamagePtr slave_damage;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment