diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2018-11-23 18:22:25 +0100 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2018-12-13 12:39:16 +0100 |
commit | b344e1559e936046ef02c777fc4f6bcefa3830bc (patch) | |
tree | e1453bbb8c2c3beb8f024b1e77a00cdfd9bdb847 | |
parent | e95044e45350870fa7e237860e89ade91ac03550 (diff) |
Use drmIoctl in drmmode_show_cursor
This should be functionally equivalent to what drmModeSetCursor(2) do
behind the scenes, but allows for new tricks in following changes.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | src/drmmode_display.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 2e9e623..022f107 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1711,14 +1711,21 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc) AMDGPUInfoPtr info = AMDGPUPTR(pScrn); AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn); drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; - uint32_t bo_handle; static Bool use_set_cursor2 = TRUE; + struct drm_mode_cursor2 arg; - if (!amdgpu_bo_get_handle(drmmode_crtc->cursor_buffer, &bo_handle)) { + memset(&arg, 0, sizeof(arg)); + + if (!amdgpu_bo_get_handle(drmmode_crtc->cursor_buffer, &arg.handle)) { ErrorF("failed to get BO handle for cursor\n"); return; } + arg.flags = DRM_MODE_CURSOR_BO; + arg.crtc_id = drmmode_crtc->mode_crtc->crtc_id; + arg.width = info->cursor_w; + arg.height = info->cursor_h; + if (use_set_cursor2) { xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); CursorPtr cursor = xf86_config->cursor; @@ -1754,19 +1761,17 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc) } } - ret = drmModeSetCursor2(pAMDGPUEnt->fd, - drmmode_crtc->mode_crtc->crtc_id, - bo_handle, - info->cursor_w, info->cursor_h, - xhot, yhot); + arg.hot_x = xhot; + arg.hot_y = yhot; + + ret = drmIoctl(pAMDGPUEnt->fd, DRM_IOCTL_MODE_CURSOR2, &arg); if (ret == -EINVAL) use_set_cursor2 = FALSE; else return; } - drmModeSetCursor(pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, bo_handle, - info->cursor_w, info->cursor_h); + drmIoctl(pAMDGPUEnt->fd, DRM_IOCTL_MODE_CURSOR, &arg); } /* Xorg expects a non-NULL return value from drmmode_crtc_shadow_allocate, and |