Skip to contentSkip to conversation

Move cursor related ScreenInit calls into AMDGPUCursorInit_KMS

PATCH In review Michel Dänzer 2 participants 4 messages Dec 22, 2017 – Dec 23, 2017 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Move cursor related ScreenInit calls into AMDGPUCursorInit_KMS

From: Michel Dänzer <[email protected]>

And bail if xf86_cursors_init fails.

---
 src/amdgpu_kms.c | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)
src/amdgpu_kms.c +25 -19
index c15711224..58531bf33 100644
@@ -1523,12 +1523,29 @@ static Bool AMDGPUCursorInit_KMS(ScreenPtr pScreen)
 	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 
-	return xf86_cursors_init(pScreen, info->cursor_w, info->cursor_h,
-				 (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
-				  HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
-				  HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
-				  HARDWARE_CURSOR_UPDATE_UNHIDDEN |
-				  HARDWARE_CURSOR_ARGB));
+	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, AMDGPU_LOGLEVEL_DEBUG,
+		       "Initializing Cursor\n");
+
+	/* Set Silken Mouse */
+	xf86SetSilkenMouse(pScreen);
+
+	/* Cursor setup */
+	miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+	if (xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE))
+		return TRUE;
+
+	if (!xf86_cursors_init(pScreen, info->cursor_w, info->cursor_h,
+			       HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+			       HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+			       HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
+			       HARDWARE_CURSOR_UPDATE_UNHIDDEN |
+			       HARDWARE_CURSOR_ARGB)) {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "xf86_cursors_init failed\n");
+		return FALSE;
+	}
+
+	return TRUE;
 }
 
 void AMDGPUBlank(ScrnInfoPtr pScrn)
@@ -1858,19 +1875,8 @@ Bool AMDGPUScreenInit_KMS(ScreenPtr pScreen, int argc, char **argv)
 		       "Initializing DPMS\n");
 	xf86DPMSInit(pScreen, xf86DPMSSet, 0);
 
-	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, AMDGPU_LOGLEVEL_DEBUG,
-		       "Initializing Cursor\n");
-
-	/* Set Silken Mouse */
-	xf86SetSilkenMouse(pScreen);
-
-	/* Cursor setup */
-	miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
-
-	if (!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) {
-		if (AMDGPUCursorInit_KMS(pScreen)) {
-		}
-	}
+	if (!AMDGPUCursorInit_KMS(pScreen))
+		return FALSE;
 
 	/* DGA setup */
 #ifdef XFreeXDGA
Signature · 6 lines
2.15.1

_______________________________________________
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): 20171222173944.23221-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

PATCH 2/2 Keep track of how many SW cursors are visible on each screen

From: Michel Dänzer <[email protected]>

And use this to determine when we cannot use page flipping for DRI clients. We previously did this based on whether the HW cursor cannot be used on at least one CRTC, which had at least two issues:

* Even while the HW cursor cannot be used, no SW cursor may actually be visible (e.g. because all cursors are disabled), in which case we can use page flipping for DRI clients anyway
* Even while the HW cursor can be used, there may be SW cursors visible from non-core pointer devices, in which case we cannot use page flipping for DRI clients anyway

---
 src/amdgpu_dri2.c     |  2 +-
 src/amdgpu_drv.h      | 13 +++++++++++++
 src/amdgpu_kms.c      | 28 +++++++++++++++++++++++++++
 src/amdgpu_present.c  |  2 +-
 src/drmmode_display.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/drmmode_display.h |  4 ++++
 6 files changed, 99 insertions(+), 2 deletions(-)
src/amdgpu_dri2.c +1 -1
index a8ccd22ba..4ffa34676 100644
@@ -603,7 +603,7 @@ can_flip(xf86CrtcPtr crtc, DrawablePtr draw,
 
 	if (draw->type != DRAWABLE_WINDOW ||
 	    !info->allowPageFlip ||
-	    info->hwcursor_disabled ||
+	    info->sprites_visible > 0 ||
 	    info->drmmode.present_flipping ||
 	    !pScrn->vtSema ||
 	    !DRI2CanFlip(draw))
src/amdgpu_drv.h +13 -0
index 055c3c3e9..72975d597 100644
@@ -234,6 +234,13 @@ struct amdgpu_client_priv {
 	uint_fast32_t needs_flush;
 };
 
+struct amdgpu_device_priv {
+	CursorPtr cursor;
+	Bool sprite_visible;
+};
+
+extern DevScreenPrivateKeyRec amdgpu_device_private_key;
+
 typedef struct {
 	EntityInfoPtr pEnt;
 	struct pci_device *PciInfo;
@@ -274,6 +281,12 @@ typedef struct {
 	CreateScreenResourcesProcPtr CreateScreenResources;
 	CreateWindowProcPtr CreateWindow;
 	WindowExposuresProcPtr WindowExposures;
+	void (*SetCursor) (DeviceIntPtr pDev, ScreenPtr pScreen,
+			   CursorPtr pCursor, int x, int y);
+	void (*MoveCursor) (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
+
+	/* Number of SW cursor currently visible on this screen */
+	int sprites_visible;
 
 	Bool IsSecondary;
 
src/amdgpu_kms.c +28 -0
index 58531bf33..49044f514 100644
@@ -37,6 +37,7 @@
 #include "amdgpu_glamor.h"
 #include "amdgpu_probe.h"
 #include "micmap.h"
+#include "mipointrst.h"
 
 #include "amdgpu_version.h"
 #include "shadow.h"
@@ -62,6 +63,7 @@
 #include <gbm.h>
 
 static DevScreenPrivateKeyRec amdgpu_client_private_key;
+DevScreenPrivateKeyRec amdgpu_device_private_key;
 
 static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen);
 
@@ -1532,6 +1534,23 @@ static Bool AMDGPUCursorInit_KMS(ScreenPtr pScreen)
 	/* Cursor setup */
 	miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
 
+	if (info->allowPageFlip) {
+		miPointerScreenPtr PointPriv =
+			dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+		if (!dixRegisterScreenPrivateKey(&amdgpu_device_private_key, pScreen,
+						 PRIVATE_DEVICE,
+						 sizeof(struct amdgpu_device_priv))) {
+			xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "dixRegisterScreenPrivateKey failed\n");
+			return FALSE;
+		}
+
+		info->SetCursor = PointPriv->spriteFuncs->SetCursor;
+		info->MoveCursor = PointPriv->spriteFuncs->MoveCursor;
+		PointPriv->spriteFuncs->SetCursor = drmmode_sprite_set_cursor;
+		PointPriv->spriteFuncs->MoveCursor = drmmode_sprite_move_cursor;
+	}
+
 	if (xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE))
 		return TRUE;
 
@@ -1701,6 +1720,15 @@ static Bool AMDGPUCloseScreen_KMS(ScreenPtr pScreen)
 	amdgpu_glamor_fini(pScreen);
 	pScrn->vtSema = FALSE;
 	xf86ClearPrimInitDone(info->pEnt->index);
+
+	if (info->allowPageFlip) {
+		miPointerScreenPtr PointPriv =
+			dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+		PointPriv->spriteFuncs->SetCursor = info->SetCursor;
+		PointPriv->spriteFuncs->MoveCursor = info->MoveCursor;
+	}
+
 	pScreen->BlockHandler = info->BlockHandler;
 	pScreen->CloseScreen = info->CloseScreen;
 	return pScreen->CloseScreen(pScreen);
src/amdgpu_present.c +1 -1
index cef93c068..4e74bfac9 100644
@@ -273,7 +273,7 @@ amdgpu_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap,
 	if (!info->allowPageFlip)
 		return FALSE;
 
-	if (info->hwcursor_disabled)
+	if (info->sprites_visible > 0)
 		return FALSE;
 
 	if (info->drmmode.dri2_flipping)
src/drmmode_display.c +52 -0

64 lines not on this page · raw message

src/drmmode_display.h +4 -0
index 03134f0c9..4e6f70776 100644
@@ -198,6 +198,10 @@ extern int drmmode_page_flip_target_relative(AMDGPUEntPtr pAMDGPUEnt,
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
 extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+extern void drmmode_sprite_set_cursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+				      CursorPtr pCursor, int x, int y);
+extern void drmmode_sprite_move_cursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x,
+				       int y);
 extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id,
 			       struct amdgpu_buffer *bo);
 void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
Signature · 6 lines
2.15.1

_______________________________________________
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): 20171222173944.23221-2-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#4 lore raw

Re: [PATCH xf86-video-amdgpu 2/2] Keep track of how many SW cursors are visible on each screen

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Michel Dänzer <[email protected]>
Sent: Friday, December 22, 2017 12:39:44 PM
To: [email protected]
Subject: [PATCH xf86-video-amdgpu 2/2] Keep track of how many SW cursors are visible on each screen

From: Michel Dänzer <[email protected]>

And use this to determine when we cannot use page flipping for DRI clients. We previously did this based on whether the HW cursor cannot be used on at least one CRTC, which had at least two issues:

* Even while the HW cursor cannot be used, no SW cursor may actually be visible (e.g. because all cursors are disabled), in which case we can use page flipping for DRI clients anyway
* Even while the HW cursor can be used, there may be SW cursors visible from non-core pointer devices, in which case we cannot use page flipping for DRI clients anyway

---
 src/amdgpu_dri2.c     |  2 +-
 src/amdgpu_drv.h      | 13 +++++++++++++
 src/amdgpu_kms.c      | 28 +++++++++++++++++++++++++++
 src/amdgpu_present.c  |  2 +-
 src/drmmode_display.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/drmmode_display.h |  4 ++++
 6 files changed, 99 insertions(+), 2 deletions(-)
src/amdgpu_dri2.c +1 -1
index a8ccd22ba..4ffa34676 100644
@@ -603,7 +603,7 @@ can_flip(xf86CrtcPtr crtc, DrawablePtr draw,
 
         if (draw->type != DRAWABLE_WINDOW ||
             !info->allowPageFlip ||
-           info->hwcursor_disabled ||
+           info->sprites_visible > 0 ||
             info->drmmode.present_flipping ||
             !pScrn->vtSema ||
             !DRI2CanFlip(draw))
src/amdgpu_drv.h +13 -0
index 055c3c3e9..72975d597 100644
@@ -234,6 +234,13 @@ struct amdgpu_client_priv {
         uint_fast32_t needs_flush;
 };
 
+struct amdgpu_device_priv {
+       CursorPtr cursor;
+       Bool sprite_visible;
+};
+
+extern DevScreenPrivateKeyRec amdgpu_device_private_key;
+
 typedef struct {
         EntityInfoPtr pEnt;
         struct pci_device *PciInfo;
@@ -274,6 +281,12 @@ typedef struct {
         CreateScreenResourcesProcPtr CreateScreenResources;
         CreateWindowProcPtr CreateWindow;
         WindowExposuresProcPtr WindowExposures;
+       void (*SetCursor) (DeviceIntPtr pDev, ScreenPtr pScreen,
+                          CursorPtr pCursor, int x, int y);
+       void (*MoveCursor) (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
+
+       /* Number of SW cursor currently visible on this screen */
+       int sprites_visible;
 
         Bool IsSecondary;
 
src/amdgpu_kms.c +28 -0
index 58531bf33..49044f514 100644
@@ -37,6 +37,7 @@
 #include "amdgpu_glamor.h"
 #include "amdgpu_probe.h"
 #include "micmap.h"
+#include "mipointrst.h"
 
 #include "amdgpu_version.h"
 #include "shadow.h"
@@ -62,6 +63,7 @@
 #include <gbm.h>
 
 static DevScreenPrivateKeyRec amdgpu_client_private_key;
+DevScreenPrivateKeyRec amdgpu_device_private_key;
 
 static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen);
 
@@ -1532,6 +1534,23 @@ static Bool AMDGPUCursorInit_KMS(ScreenPtr pScreen)
         /* Cursor setup */
         miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
 
+       if (info->allowPageFlip) {
+               miPointerScreenPtr PointPriv =
+                       dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+               if (!dixRegisterScreenPrivateKey(&amdgpu_device_private_key, pScreen,
+                                                PRIVATE_DEVICE,
+                                                sizeof(struct amdgpu_device_priv))) {
+                       xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "dixRegisterScreenPrivateKey failed\n");
+                       return FALSE;
+               }
+
+               info->SetCursor = PointPriv->spriteFuncs->SetCursor;
+               info->MoveCursor = PointPriv->spriteFuncs->MoveCursor;
+               PointPriv->spriteFuncs->SetCursor = drmmode_sprite_set_cursor;
+               PointPriv->spriteFuncs->MoveCursor = drmmode_sprite_move_cursor;
+       }
+
         if (xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE))
                 return TRUE;
 
@@ -1701,6 +1720,15 @@ static Bool AMDGPUCloseScreen_KMS(ScreenPtr pScreen)
         amdgpu_glamor_fini(pScreen);
         pScrn->vtSema = FALSE;
         xf86ClearPrimInitDone(info->pEnt->index);
+
+       if (info->allowPageFlip) {
+               miPointerScreenPtr PointPriv =
+                       dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+               PointPriv->spriteFuncs->SetCursor = info->SetCursor;
+               PointPriv->spriteFuncs->MoveCursor = info->MoveCursor;
+       }
+
         pScreen->BlockHandler = info->BlockHandler;
         pScreen->CloseScreen = info->CloseScreen;
         return pScreen->CloseScreen(pScreen);
src/amdgpu_present.c +1 -1
index cef93c068..4e74bfac9 100644
@@ -273,7 +273,7 @@ amdgpu_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap,
         if (!info->allowPageFlip)
                 return FALSE;
 
-       if (info->hwcursor_disabled)
+       if (info->sprites_visible > 0)
                 return FALSE;
 
         if (info->drmmode.dri2_flipping)
src/drmmode_display.c +52 -0

64 lines not on this page · raw message

src/drmmode_display.h +4 -0
index 03134f0c9..4e6f70776 100644
@@ -198,6 +198,10 @@ extern int drmmode_page_flip_target_relative(AMDGPUEntPtr pAMDGPUEnt,
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
 extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+extern void drmmode_sprite_set_cursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+                                     CursorPtr pCursor, int x, int y);
+extern void drmmode_sprite_move_cursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x,
+                                      int y);
 extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id,
                                struct amdgpu_buffer *bo);
 void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);

--
2.15.1

_______________________________________________
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

Reviewed-by
#5 lore raw
In reply to a message not in the archive

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Michel Dänzer <[email protected]>
Sent: Friday, December 22, 2017 12:39:43 PM
To: [email protected]
Subject: [PATCH xf86-video-amdgpu 1/2] Move cursor related ScreenInit calls into AMDGPUCursorInit_KMS

From: Michel Dänzer <[email protected]>

And bail if xf86_cursors_init fails.

---
 src/amdgpu_kms.c | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)
src/amdgpu_kms.c +25 -19
index c15711224..58531bf33 100644
@@ -1523,12 +1523,29 @@ static Bool AMDGPUCursorInit_KMS(ScreenPtr pScreen)
         ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
         AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 
-       return xf86_cursors_init(pScreen, info->cursor_w, info->cursor_h,
-                                (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
-                                 HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
-                                 HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
-                                 HARDWARE_CURSOR_UPDATE_UNHIDDEN |
-                                 HARDWARE_CURSOR_ARGB));
+       xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, AMDGPU_LOGLEVEL_DEBUG,
+                      "Initializing Cursor\n");
+
+       /* Set Silken Mouse */
+       xf86SetSilkenMouse(pScreen);
+
+       /* Cursor setup */
+       miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+       if (xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE))
+               return TRUE;
+
+       if (!xf86_cursors_init(pScreen, info->cursor_w, info->cursor_h,
+                              HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+                              HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+                              HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
+                              HARDWARE_CURSOR_UPDATE_UNHIDDEN |
+                              HARDWARE_CURSOR_ARGB)) {
+               xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "xf86_cursors_init failed\n");
+               return FALSE;
+       }
+
+       return TRUE;
 }
 
 void AMDGPUBlank(ScrnInfoPtr pScrn)
@@ -1858,19 +1875,8 @@ Bool AMDGPUScreenInit_KMS(ScreenPtr pScreen, int argc, char **argv)
                        "Initializing DPMS\n");
         xf86DPMSInit(pScreen, xf86DPMSSet, 0);
 
-       xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, AMDGPU_LOGLEVEL_DEBUG,
-                      "Initializing Cursor\n");
-
-       /* Set Silken Mouse */
-       xf86SetSilkenMouse(pScreen);
-
-       /* Cursor setup */
-       miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
-
-       if (!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) {
-               if (AMDGPUCursorInit_KMS(pScreen)) {
-               }
-       }
+       if (!AMDGPUCursorInit_KMS(pScreen))
+               return FALSE;
 
         /* DGA setup */
 #ifdef XFreeXDGA

--
2.15.1

_______________________________________________
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