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 <keithp@keithp.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
			
			
This commit is contained in:
		
							parent
							
								
									0f5fdaf600
								
							
						
					
					
						commit
						5a541bd5e7
					
				| 
						 | 
				
			
			@ -394,60 +394,18 @@ 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;
 | 
			
		||||
    uint32_t handle = drmmode_crtc->cursor_bo->handle;
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    /* 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]);
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
 | 
			
		||||
        cursor_info->MaxWidth = cursor_info->MaxHeight = 0;
 | 
			
		||||
        drmmode_crtc->drmmode->sw_cursor = TRUE;
 | 
			
		||||
        /* fallback to swcursor */
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
    drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
 | 
			
		||||
                     ms->cursor_width, ms->cursor_height);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
drmmode_show_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;
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    static Bool use_set_cursor2 = TRUE;
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    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,
 | 
			
		||||
| 
						 | 
				
			
			@ -459,10 +417,57 @@ drmmode_show_cursor(xf86CrtcPtr crtc)
 | 
			
		|||
            return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
 | 
			
		||||
    ret = drmModeSetCursor(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;
 | 
			
		||||
 | 
			
		||||
        cursor_info->MaxWidth = cursor_info->MaxHeight = 0;
 | 
			
		||||
        drmmode_crtc->drmmode->sw_cursor = TRUE;
 | 
			
		||||
        /* fallback to swcursor */
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 | 
			
		||||
    int i;
 | 
			
		||||
    uint32_t *ptr;
 | 
			
		||||
 | 
			
		||||
    /* 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_hide_cursor(xf86CrtcPtr crtc)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 | 
			
		||||
    drmmode_ptr drmmode = drmmode_crtc->drmmode;
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue