Skip to contentSkip to conversation

Consolidate amdgpu_scanout_flip_abort/handler helpers

PATCH In review Michel Dänzer 2 participants 4 messages Aug 18, 2017 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Consolidate amdgpu_scanout_flip_abort/handler helpers

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

While at it, make them use crtc->driver_private.

(Ported from radeon commit 36ce7920136c0d723c9397a84e7dd5926a9c7943)

---
 src/amdgpu_kms.c | 85 ++++++++++++++++++++++++--------------------------------
 1 file changed, 36 insertions(+), 49 deletions(-)
src/amdgpu_kms.c +36 -49
index b0f1a3d94..f665a01cd 100644
@@ -420,6 +420,38 @@ amdgpu_sync_scanout_pixmaps(xf86CrtcPtr xf86_crtc, RegionPtr new_region,
 	RegionUninit(&remaining);
 }
 
+static void
+amdgpu_scanout_flip_abort(xf86CrtcPtr crtc, void *event_data)
+{
+	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(crtc->scrn);
+	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+	drmmode_crtc->scanout_update_pending = FALSE;
+	drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->flip_pending,
+			     NULL);
+}
+
+static void
+amdgpu_scanout_flip_handler(xf86CrtcPtr crtc, uint32_t msc, uint64_t usec,
+			    void *event_data)
+{
+	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(crtc->scrn);
+	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+	drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->fb,
+			     drmmode_crtc->flip_pending);
+	amdgpu_scanout_flip_abort(crtc, event_data);
+
+#ifdef HAVE_PRESENT_H
+	if (drmmode_crtc->present_vblank_event_id) {
+		present_event_notify(drmmode_crtc->present_vblank_event_id,
+				     drmmode_crtc->present_vblank_usec,
+				     drmmode_crtc->present_vblank_msc);
+		drmmode_crtc->present_vblank_event_id = 0;
+	}
+#endif
+}
+
 #ifdef AMDGPU_PIXMAP_SHARING
 
 static RegionPtr
@@ -664,38 +696,6 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
 	drmmode_crtc->scanout_update_pending = TRUE;
 }
 
-static void
-amdgpu_prime_scanout_flip_abort(xf86CrtcPtr crtc, void *event_data)
-{
-	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(crtc->scrn);
-	drmmode_crtc_private_ptr drmmode_crtc = event_data;
-
-	drmmode_crtc->scanout_update_pending = FALSE;
-	drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->flip_pending,
-			     NULL);
-}
-
-static void
-amdgpu_prime_scanout_flip_handler(xf86CrtcPtr crtc, uint32_t msc, uint64_t usec,
-				  void *event_data)
-{
-	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(crtc->scrn);
-	drmmode_crtc_private_ptr drmmode_crtc = event_data;
-
-	drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->fb,
-			     drmmode_crtc->flip_pending);
-	amdgpu_prime_scanout_flip_abort(crtc, event_data);
-
-#ifdef HAVE_PRESENT_H
-	if (drmmode_crtc->present_vblank_event_id) {
-		present_event_notify(drmmode_crtc->present_vblank_event_id,
-				     drmmode_crtc->present_vblank_usec,
-				     drmmode_crtc->present_vblank_msc);
-		drmmode_crtc->present_vblank_event_id = 0;
-	}
-#endif
-}
-
 static void
 amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)
 {
@@ -723,9 +723,9 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)
 	drm_queue_seq = amdgpu_drm_queue_alloc(crtc,
 					       AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
 					       AMDGPU_DRM_QUEUE_ID_DEFAULT,
-					       drmmode_crtc,
-					       amdgpu_prime_scanout_flip_handler,
-					       amdgpu_prime_scanout_flip_abort);
+					       NULL,
+					       amdgpu_scanout_flip_handler,
+					       amdgpu_scanout_flip_abort);
 	if (drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "Allocating DRM event queue entry failed for PRIME flip.\n");
@@ -975,19 +975,6 @@ amdgpu_scanout_update(xf86CrtcPtr xf86_crtc)
 	drmmode_crtc->scanout_update_pending = TRUE;
 }
 
-static void
-amdgpu_scanout_flip_abort(xf86CrtcPtr crtc, void *event_data)
-{
-	amdgpu_prime_scanout_flip_abort(crtc, event_data);
-}
-
-static void
-amdgpu_scanout_flip_handler(xf86CrtcPtr crtc, uint32_t msc, uint64_t usec,
-			    void *event_data)
-{
-	amdgpu_prime_scanout_flip_handler(crtc, msc, usec, event_data);
-}
-
 static void
 amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 					xf86CrtcPtr xf86_crtc)
@@ -1014,7 +1001,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 	drm_queue_seq = amdgpu_drm_queue_alloc(xf86_crtc,
 					       AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
 					       AMDGPU_DRM_QUEUE_ID_DEFAULT,
-					       drmmode_crtc,
+					       NULL,
 					       amdgpu_scanout_flip_handler,
 					       amdgpu_scanout_flip_abort);
 	if (drm_queue_seq == AMDGPU_DRM_QUEUE_ERROR) {
Signature · 6 lines
2.14.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): 20170818085503.3908-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

PATCH 2/3 Use xorg_list_append for the DRM event list

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

We were adding entries at the start of the list, i.e. the list was ordered from most recently added to least recently added. However, the corresponding DRM events are generally expected to arrive in the same order as they are queued, which means that amdgpu_drm_queue_alloc would generally have to traverse the whole list to find the entry corresponding to an arrived event. Fix this by adding entries at the end of the list.

(Ported from radeon commit 3e24770b1b472fc15df56d06f5f04778c9db63dd)

---
 src/amdgpu_drm_queue.c | 2 +-
 src/amdgpu_list.h      | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
src/amdgpu_drm_queue.c +1 -1
index e8810fdf0..eb3ca633d 100644
@@ -105,7 +105,7 @@ amdgpu_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
 	e->handler = handler;
 	e->abort = abort;
 
-	xorg_list_add(&e->list, &amdgpu_drm_queue);
+	xorg_list_append(&e->list, &amdgpu_drm_queue);
 
 	return e->seq;
 }
src/amdgpu_list.h +7 -0
index a2b1d3cc4..eb28835e3 100644
@@ -35,6 +35,13 @@
 #define xorg_list_del			list_del
 #define xorg_list_for_each_entry	list_for_each_entry
 #define xorg_list_for_each_entry_safe	list_for_each_entry_safe
+
+static inline void
+xorg_list_append(struct list *entry, struct list *head)
+{
+	__list_add(entry, head->prev, head);
+}
+
 #endif
 
 #endif /* _AMDGPU_LIST_H_ */
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 3/3 Make amdgpu_scanout_do_update take a PixmapPtr instead of a DrawablePtr

In reply to a message not in the archive

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

All callers were already passing in a pixmap.

This allows simplifying the rotated scanout case slightly.

(Ported from radeon commit d822a0f47070374ad0c1a97b559bae27724dc52a)

---
 src/amdgpu_drv.h      |  2 +-
 src/amdgpu_kms.c      | 13 ++++++-------
 src/drmmode_display.c |  6 +++---
 3 files changed, 10 insertions(+), 11 deletions(-)
src/amdgpu_drv.h +1 -1
index 13237470a..75c2a2653 100644
@@ -341,7 +341,7 @@ Bool amdgpu_dri3_screen_init(ScreenPtr screen);
 
 /* amdgpu_kms.c */
 Bool amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
-			       DrawablePtr src_draw, BoxPtr extents);
+			      PixmapPtr src_pix, BoxPtr extents);
 void AMDGPUWindowExposures_oneshot(WindowPtr pWin, RegionPtr pRegion
 #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,16,99,901,0)
 				   , RegionPtr pBSRegion
src/amdgpu_kms.c +6 -7
index f665a01cd..e0b735819 100644
@@ -806,7 +806,7 @@ amdgpu_dirty_update(ScrnInfoPtr scrn)
 
 Bool
 amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
-			 DrawablePtr src_draw, BoxPtr extents)
+			 PixmapPtr src_pix, BoxPtr extents)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
 	RegionRec region = { .extents = *extents, .data = NULL };
@@ -834,10 +834,9 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
 		PictFormatPtr format = PictureWindowFormat(pScreen->root);
 		int error;
 		PicturePtr src, dst;
-		XID include_inferiors = IncludeInferiors;
 
-		src = CreatePicture(None, src_draw, format, CPSubwindowMode,
-				    &include_inferiors, serverClient, &error);
+		src = CreatePicture(None, &src_pix->drawable, format, 0L, NULL,
+				    serverClient, &error);
 		if (!src) {
 			ErrorF("Failed to create source picture for transformed scanout "
 			       "update\n");
@@ -880,7 +879,7 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
 		GCPtr gc = GetScratchGC(pDraw->depth, pScreen);
 
 		ValidateGC(pDraw, gc);
-		(*gc->ops->CopyArea)(src_draw, pDraw, gc,
+		(*gc->ops->CopyArea)(&src_pix->drawable, pDraw, gc,
 				     xf86_crtc->x + extents->x1, xf86_crtc->y + extents->y1,
 				     extents->x2 - extents->x1, extents->y2 - extents->y1,
 				     extents->x1, extents->y1);
@@ -912,7 +911,7 @@ amdgpu_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec,
 	    !drmmode_crtc->flip_pending &&
 	    drmmode_crtc->dpms_mode == DPMSModeOn) {
 		if (amdgpu_scanout_do_update(crtc, drmmode_crtc->scanout_id,
-					     &screen->GetWindowPixmap(screen->root)->drawable,
+					     screen->GetWindowPixmap(screen->root),
 					     &region->extents))
 			RegionEmpty(region);
 	}
@@ -993,7 +992,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 
 	scanout_id = drmmode_crtc->scanout_id ^ 1;
 	if (!amdgpu_scanout_do_update(xf86_crtc, scanout_id,
-				      &pScreen->GetWindowPixmap(pScreen->root)->drawable,
+				      pScreen->GetWindowPixmap(pScreen->root),
 				      &region->extents))
 		return;
 	RegionEmpty(region);
src/drmmode_display.c +3 -3
index edd955ece..ad3325be6 100644
@@ -779,7 +779,7 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 		*x = *y = 0;
 
 		amdgpu_scanout_do_update(crtc, scanout_id,
-					 &screen->GetWindowPixmap(screen->root)->drawable,
+					 screen->GetWindowPixmap(screen->root),
 					 box);
 		amdgpu_glamor_finish(scrn);
 	}
@@ -2850,8 +2850,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 				goto error;
 			}
 
-			amdgpu_scanout_do_update(crtc, scanout_id,
-						 &new_front->drawable, &extents);
+			amdgpu_scanout_do_update(crtc, scanout_id, new_front,
+						 &extents);
 
 			drmmode_crtc_wait_pending_event(drmmode_crtc, pAMDGPUEnt->fd,
 							drmmode_crtc->scanout_update_pending);
Signature · 6 lines
2.14.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): 20170818085503.3908-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by Alex Deucher
#5 lore raw

RE: [PATCH xf86-video-amdgpu 3/3] Make amdgpu_scanout_do_update take a PixmapPtr instead of a DrawablePtr

Quoted 10 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Friday, August 18, 2017 4:55 AM
To: [email protected]
Subject: [PATCH xf86-video-amdgpu 3/3] Make amdgpu_scanout_do_update take a PixmapPtr instead of a DrawablePtr

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

Quoted 7 lines

All callers were already passing in a pixmap.

This allows simplifying the rotated scanout case slightly.

(Ported from radeon commit d822a0f47070374ad0c1a97b559bae27724dc52a)

Series is:

Quoted 121 lines
---
 src/amdgpu_drv.h      |  2 +-
 src/amdgpu_kms.c      | 13 ++++++-------
 src/drmmode_display.c |  6 +++---
 3 files changed, 10 insertions(+), 11 deletions(-)
src/amdgpu_drv.h +1 -1
index 13237470a..75c2a2653 100644
@@ -341,7 +341,7 @@ Bool amdgpu_dri3_screen_init(ScreenPtr screen);
 
 /* amdgpu_kms.c */
 Bool amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
-			       DrawablePtr src_draw, BoxPtr extents);
+			      PixmapPtr src_pix, BoxPtr extents);
 void AMDGPUWindowExposures_oneshot(WindowPtr pWin, RegionPtr

pRegion
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,16,99,901,0)

src/amdgpu_drv.h +0 -0
 				   , RegionPtr pBSRegion
src/amdgpu_kms.c +1 -1
index f665a01cd..e0b735819 100644
@@ -806,7 +806,7 @@ amdgpu_dirty_update(ScrnInfoPtr scrn)
 
 Bool
 amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
-			 DrawablePtr src_draw, BoxPtr extents)
+			 PixmapPtr src_pix, BoxPtr extents)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc-
 >driver_private;
src/amdgpu_kms.c +1 -3
 	RegionRec region = { .extents = *extents, .data = NULL };
@@ -834,10 +834,9 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc,
 int scanout_id,
 		PictFormatPtr format = PictureWindowFormat(pScreen-
 >root);
 		int error;
 		PicturePtr src, dst;
-		XID include_inferiors = IncludeInferiors;
 
-		src = CreatePicture(None, src_draw, format,
 CPSubwindowMode,
-				    &include_inferiors, serverClient, &error);
+		src = CreatePicture(None, &src_pix->drawable, format, 0L,

NULL,

src/amdgpu_kms.c +1 -0
+				    serverClient, &error);
 		if (!src) {
 			ErrorF("Failed to create source picture for

transformed scanout "

src/amdgpu_kms.c +1 -1
 			       "update\n");
@@ -880,7 +879,7 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc,
 int scanout_id,
 		GCPtr gc = GetScratchGC(pDraw->depth, pScreen);
 
 		ValidateGC(pDraw, gc);
-		(*gc->ops->CopyArea)(src_draw, pDraw, gc,
+		(*gc->ops->CopyArea)(&src_pix->drawable, pDraw, gc,
 				     xf86_crtc->x + extents->x1, xf86_crtc->y +
 extents->y1,

extents->x2 - extents->x1, extents->y2 -
extents->y1,

src/amdgpu_kms.c +1 -1
 				     extents->x1, extents->y1);
@@ -912,7 +911,7 @@ amdgpu_scanout_update_handler(xf86CrtcPtr crtc,
 uint32_t frame, uint64_t usec,
 	    !drmmode_crtc->flip_pending &&
 	    drmmode_crtc->dpms_mode == DPMSModeOn) {
 		if (amdgpu_scanout_do_update(crtc, drmmode_crtc-
 >scanout_id,
-					     &screen-
 >GetWindowPixmap(screen->root)->drawable,
+					     screen-
Quoted 1 line

GetWindowPixmap(screen->root),

src/amdgpu_kms.c +1 -1
 					     &region->extents))
 			RegionEmpty(region);
 	}
@@ -993,7 +992,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen,
 AMDGPUInfoPtr info,
 
 	scanout_id = drmmode_crtc->scanout_id ^ 1;
 	if (!amdgpu_scanout_do_update(xf86_crtc, scanout_id,
-				      &pScreen->GetWindowPixmap(pScreen-
 >root)->drawable,
+				      pScreen->GetWindowPixmap(pScreen-
 >root),
src/amdgpu_kms.c +0 -0
 				      &region->extents))
 		return;
 	RegionEmpty(region);
src/drmmode_display.c +1 -1
index edd955ece..ad3325be6 100644
@@ -779,7 +779,7 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc,
 DisplayModePtr mode,
 		*x = *y = 0;
 
 		amdgpu_scanout_do_update(crtc, scanout_id,
-					 &screen-
 >GetWindowPixmap(screen->root)->drawable,
+					 screen->GetWindowPixmap(screen-
 >root),
src/drmmode_display.c +2 -2
 					 box);
 		amdgpu_glamor_finish(scrn);
 	}
@@ -2850,8 +2850,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn,
 ClientPtr client,
 				goto error;
 			}
 
-			amdgpu_scanout_do_update(crtc, scanout_id,
-						 &new_front->drawable,
 &extents);
+			amdgpu_scanout_do_update(crtc, scanout_id,
 new_front,
+						 &extents);

drmmode_crtc_wait_pending_event(drmmode_crtc, pAMDGPUEnt-

Quoted 1 line

fd,

drmmode_crtc-

Quoted 8 lines
Quoted 1 line

scanout_update_pending);

--
2.14.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