Rotate and reflect cursor hotspot position for drmModeSetCursor2
PATCH 1/1 Rotate and reflect cursor hotspot position for drmModeSetCursor2
From: Michel Dänzer <[email protected]>
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.
(Ported from amdgpu commit d42773eb45baff5933730e26878a0b45fcf07b65)
--- src/drmmode_display.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
src/drmmode_display.c +31 -1
@@ -1047,12 +1047,42 @@ 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 (drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle, info->cursor_w, info->cursor_h, - cursor->bits->xhot, cursor->bits->yhot); + xhot, yhot);if (ret == -EINVAL ) use_set_cursor2 = FALSE;else
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20161006095812.26716-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 10 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Thursday, October 06, 2016 5:58 AM
To: [email protected]
Subject: [PATCH xf86-video-ati] Rotate and reflect cursor hotspot position for drmModeSetCursor2From: Michel Dänzer <[email protected]>
Quoted 8 lines
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.
(Ported from amdgpu commit
d42773eb45baff5933730e26878a0b45fcf07b65)Signed-off-by Michel Dänzer <[email protected]>
Quoted 57 lines
--- src/drmmode_display.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)src/drmmode_display.c +31
-1@@ -1047,12 +1047,42 @@ 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 (drmmode->fd, drmmode_crtc- >mode_crtc->crtc_id, handle, info->cursor_w, info->cursor_h, - cursor->bits->xhot, cursor->bits->yhot); + xhot, yhot);if (ret == -EINVAL )src/drmmode_display.c +0
-1use_set_cursor2 = FALSE; else --2.9.3
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx