All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH xf86-video-amdgpu] Rotate and reflect cursor hotspot position for drmModeSetCursor2
@ 2016-10-05  8:49 Michel Dänzer
       [not found] ` <20161005084922.1637-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Michel Dänzer @ 2016-10-05  8:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

From: Michel Dänzer <michel.daenzer@amd.com>

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.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/drmmode_display.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

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
-- 
2.9.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH xf86-video-amdgpu] Rotate and reflect cursor hotspot position for drmModeSetCursor2
       [not found] ` <20161005084922.1637-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-10-05 13:27   ` Deucher, Alexander
  0 siblings, 0 replies; 2+ messages in thread
From: Deucher, Alexander @ 2016-10-05 13:27 UTC (permalink / raw)
  To: 'Michel Dänzer', amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf
> Of Michel Dänzer
> Sent: Wednesday, October 05, 2016 4:49 AM
> To: amd-gfx@lists.freedesktop.org
> Subject: [PATCH xf86-video-amdgpu] Rotate and reflect cursor hotspot
> position for drmModeSetCursor2
> 
> From: Michel Dänzer <michel.daenzer@amd.com>
> 
> 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.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

Good catch!

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  src/drmmode_display.c | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 
> 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
> --
> 2.9.3
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-05 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-05  8:49 [PATCH xf86-video-amdgpu] Rotate and reflect cursor hotspot position for drmModeSetCursor2 Michel Dänzer
     [not found] ` <20161005084922.1637-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-10-05 13:27   ` Deucher, Alexander

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.