summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2016-09-28 18:17:53 +0900
committerMichel Dänzer <michel@daenzer.net>2016-10-05 17:31:57 +0900
commitd42773eb45baff5933730e26878a0b45fcf07b65 (patch)
treea3adc1df05d3a8e12344daa9dc714cf2513e2dd3
parentbdee9f4dd4f21015e7696e06c4b485ab2b3a16dc (diff)
Rotate and reflect cursor hotspot position for drmModeSetCursor2
We were always passing the hotspot position in the X screen coordinate space, but drmModeSetCursor2 needs it in the CRTC coordinate space. The wrong hotspot position would cause the kernel driver to adjust the HW cursor position incorrectly when the hotspot position changed. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--src/drmmode_display.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 31aa1db..fb41975 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1008,13 +1008,43 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc)
if (use_set_cursor2) {
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
CursorPtr cursor = xf86_config->cursor;
+ int xhot = cursor->bits->xhot;
+ int yhot = cursor->bits->yhot;
int ret;
+ if (crtc->rotation != RR_Rotate_0 &&
+ crtc->rotation != (RR_Rotate_180 | RR_Reflect_X |
+ RR_Reflect_Y)) {
+ int t;
+
+ /* Reflect & rotate hotspot position */
+ if (crtc->rotation & RR_Reflect_X)
+ xhot = info->cursor_w - xhot - 1;
+ if (crtc->rotation & RR_Reflect_Y)
+ yhot = info->cursor_h - yhot - 1;
+
+ switch (crtc->rotation & 0xf) {
+ case RR_Rotate_90:
+ t = xhot;
+ xhot = yhot;
+ yhot = info->cursor_w - t - 1;
+ break;
+ case RR_Rotate_180:
+ xhot = info->cursor_w - xhot - 1;
+ yhot = info->cursor_h - yhot - 1;
+ break;
+ case RR_Rotate_270:
+ t = xhot;
+ xhot = info->cursor_h - yhot - 1;
+ yhot = t;
+ }
+ }
+
ret = drmModeSetCursor2(pAMDGPUEnt->fd,
drmmode_crtc->mode_crtc->crtc_id,
bo_handle,
info->cursor_w, info->cursor_h,
- cursor->bits->xhot, cursor->bits->yhot);
+ xhot, yhot);
if (ret == -EINVAL)
use_set_cursor2 = FALSE;
else