xf86-video-amdgpu: Branch 'master' - 4 commits

Michel Dänzer daenzer at kemper.freedesktop.org
Sat Feb 27 06:28:01 UTC 2016


 src/amdgpu_bo_helper.c |   44 ++++++++++++++++++++
 src/amdgpu_bo_helper.h |    2 
 src/amdgpu_dri2.c      |  103 ++++++++++++++++++++++---------------------------
 src/amdgpu_dri3.c      |   10 ++++
 src/amdgpu_pixmap.h    |    5 ++
 src/amdgpu_present.c   |   18 +-------
 src/drmmode_display.c  |   30 ++++----------
 src/drmmode_display.h  |    2 
 8 files changed, 122 insertions(+), 92 deletions(-)

New commits:
commit 5ec1797a2858d693d18d21326e2307d71555e1db
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Feb 24 17:33:49 2016 +0900

    DRI2: Use amdgpu_pixmap_get_handle
    
    Now we can share pixmaps with no struct amdgpu_buffer via DRI2.
    
    Fixes VDPAU video playback freezing when using an OpenGL compositor with
    DRI3 enabled and mpv VAAPI hardware decoding with OpenGL output.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89755
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93804
    
    (ported from radeon commit f8b0f23e9f4af9f9097ee5e72d53b45173163c41)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index 18eb876..bcb5dae 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -45,6 +45,7 @@
 
 #include <gbm.h>
 
+#include "amdgpu_bo_helper.h"
 #include "amdgpu_version.h"
 
 #include "amdgpu_list.h"
@@ -86,6 +87,25 @@ DevPrivateKey dri2_window_private_key = &dri2_window_private_key_index;
 	((struct dri2_window_priv*) \
 	 dixLookupPrivate(&(window)->devPrivates, dri2_window_private_key))
 
+/* Get GEM flink name for a pixmap */
+static Bool
+amdgpu_get_flink_name(AMDGPUEntPtr pAMDGPUEnt, PixmapPtr pixmap, uint32_t *name)
+{
+	struct amdgpu_buffer *bo = amdgpu_get_pixmap_bo(pixmap);
+	struct drm_gem_flink flink;
+
+	if (bo && !(bo->flags & AMDGPU_BO_FLAGS_GBM) &&
+	    amdgpu_bo_export(bo->bo.amdgpu,
+			     amdgpu_bo_handle_type_gem_flink_name,
+			     name) == 0)
+		return TRUE;
+
+	if (!amdgpu_pixmap_get_handle(pixmap, &flink.handle) ||
+	    ioctl(pAMDGPUEnt->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0)
+		return FALSE;
+	*name = flink.name;
+	return TRUE;
+}
 
 static PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
 {
@@ -150,11 +170,11 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
 			   unsigned int attachment, unsigned int format)
 {
 	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 	BufferPtr buffers;
 	struct dri2_buffer_priv *privates;
 	PixmapPtr pixmap;
-	struct amdgpu_buffer *bo = NULL;
 	unsigned front_width;
 	unsigned aligned_width = drawable->width;
 	unsigned height = drawable->height;
@@ -185,10 +205,12 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
 	pixmap = NULL;
 
 	if (attachment == DRI2BufferFrontLeft) {
+		uint32_t handle;
+
 		pixmap = get_drawable_pixmap(drawable);
 		if (pScreen != pixmap->drawable.pScreen)
 			pixmap = NULL;
-		else if (info->use_glamor && !amdgpu_get_pixmap_bo(pixmap)) {
+		else if (info->use_glamor && !amdgpu_pixmap_get_handle(pixmap, &handle)) {
 			is_glamor_pixmap = TRUE;
 			aligned_width = pixmap->drawable.width;
 			height = pixmap->drawable.height;
@@ -213,29 +235,11 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
 		goto error;
 
 	if (pixmap) {
-		struct drm_gem_flink flink;
-		union gbm_bo_handle bo_handle;
-
 		if (is_glamor_pixmap)
 			pixmap = fixup_glamor(drawable, pixmap);
-		bo = amdgpu_get_pixmap_bo(pixmap);
-		if (!bo) {
-			goto error;
-		}
-
-		if (bo->flags & AMDGPU_BO_FLAGS_GBM) {
-			AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 
-			bo_handle = gbm_bo_get_handle(bo->bo.gbm);
-			flink.handle = bo_handle.u32;
-			if (ioctl(pAMDGPUEnt->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0)
-				goto error;
-			buffers->name = flink.name;
-		} else {
-			amdgpu_bo_export(bo->bo.amdgpu,
-				amdgpu_bo_handle_type_gem_flink_name,
-				&buffers->name);
-		}
+		if (!amdgpu_get_flink_name(pAMDGPUEnt, pixmap, &buffers->name))
+			goto error;
 	}
 
 	privates = calloc(1, sizeof(struct dri2_buffer_priv));
@@ -633,31 +637,17 @@ static Bool update_front(DrawablePtr draw, DRI2BufferPtr front)
 	ScreenPtr screen = draw->pScreen;
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
-	PixmapPtr pixmap;
+	PixmapPtr pixmap = get_drawable_pixmap(draw);
 	struct dri2_buffer_priv *priv = front->driverPrivate;
-	struct amdgpu_buffer *bo = NULL;
-	union gbm_bo_handle bo_handle;
-	struct drm_gem_flink flink;
 
-	pixmap = get_drawable_pixmap(draw);
-	pixmap->refcnt++;
+	if (!amdgpu_get_flink_name(pAMDGPUEnt, pixmap, &front->name))
+		return FALSE;
 
-	bo = amdgpu_get_pixmap_bo(pixmap);
-	if (bo->flags & AMDGPU_BO_FLAGS_GBM) {
-		bo_handle = gbm_bo_get_handle(bo->bo.gbm);
-		flink.handle = bo_handle.u32;
-		if (ioctl(pAMDGPUEnt->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0)
-			return FALSE;
-		front->name = flink.name;
-	} else {
-		amdgpu_bo_export(bo->bo.amdgpu,
-			amdgpu_bo_handle_type_gem_flink_name,
-			&front->name);
-	}
 	(*draw->pScreen->DestroyPixmap) (priv->pixmap);
 	front->pitch = pixmap->devKind;
 	front->cpp = pixmap->drawable.bitsPerPixel / 8;
 	priv->pixmap = pixmap;
+	pixmap->refcnt++;
 
 	return TRUE;
 }
diff --git a/src/amdgpu_pixmap.h b/src/amdgpu_pixmap.h
index 6fd5ef1..6d16628 100644
--- a/src/amdgpu_pixmap.h
+++ b/src/amdgpu_pixmap.h
@@ -34,7 +34,7 @@ struct amdgpu_pixmap {
 
 	struct amdgpu_buffer *bo;
 
-	/* GEM handle for pixmaps shared via DRI3 */
+	/* GEM handle for pixmaps shared via DRI2/3 */
 	Bool handle_valid;
 	uint32_t handle;
 };
commit df60c635e1e632233de9dd4b01d63c2b963003f8
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Feb 24 17:06:43 2016 +0900

    glamor: Avoid generating GEM flink names for BOs shared via DRI3 (v2)
    
    We can't create our own struct amdgpu_buffer representation in this case
    because destroying that would make the GEM handle inaccessible to glamor
    as well. So just get the handle directly via dma-buf.
    
    (ported from radeon commit 391900a670addec39515f924265bfa9f8bfa9ec0,
     extended to cache BO handles in the private for non-DRI3 pixmaps as
     well)
    
    v2: Swap whole pixmap privates instead of just BOs in
        amdgpu_dri2_exchange_buffers to avoid invalidating cached BO handles
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c
index ad56197..01b0d87 100644
--- a/src/amdgpu_bo_helper.c
+++ b/src/amdgpu_bo_helper.c
@@ -133,12 +133,46 @@ Bool amdgpu_bo_get_handle(struct amdgpu_buffer *bo, uint32_t *handle)
 
 Bool amdgpu_pixmap_get_handle(PixmapPtr pixmap, uint32_t *handle)
 {
-	struct amdgpu_buffer *bo = amdgpu_get_pixmap_bo(pixmap);
+#ifdef USE_GLAMOR
+	ScreenPtr screen = pixmap->drawable.pScreen;
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+#endif
+	struct amdgpu_pixmap *priv = amdgpu_get_pixmap_private(pixmap);
+
+	if (!priv) {
+		priv = calloc(1, sizeof(*priv));
+		amdgpu_set_pixmap_private(pixmap, priv);
+	}
 
-	if (!bo)
+	if (priv->handle_valid)
+		goto success;
+	
+#ifdef USE_GLAMOR
+	if (info->use_glamor) {
+		AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
+		CARD16 stride;
+		CARD32 size;
+		int fd, r;
+
+		fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size);
+		if (fd < 0)
+			return FALSE;
+
+		r = drmPrimeFDToHandle(pAMDGPUEnt->fd, fd, &priv->handle);
+		close(fd);
+		if (r == 0)
+			goto success;
+	}
+#endif
+
+	if (!priv->bo || !amdgpu_bo_get_handle(priv->bo, &priv->handle))
 		return FALSE;
 
-	return amdgpu_bo_get_handle(bo, handle);
+ success:
+	priv->handle_valid = TRUE;
+	*handle = priv->handle;
+	return TRUE;
 }
 
 int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo)
diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index d974cb8..18eb876 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -719,8 +719,8 @@ amdgpu_dri2_exchange_buffers(DrawablePtr draw, DRI2BufferPtr front,
 {
 	struct dri2_buffer_priv *front_priv = front->driverPrivate;
 	struct dri2_buffer_priv *back_priv = back->driverPrivate;
-	struct amdgpu_buffer *front_bo = NULL;
-	struct amdgpu_buffer *back_bo = NULL;
+	struct amdgpu_pixmap *front_pix;
+	struct amdgpu_pixmap *back_pix;
 	ScreenPtr screen;
 	AMDGPUInfoPtr info;
 	RegionRec region;
@@ -737,20 +737,23 @@ amdgpu_dri2_exchange_buffers(DrawablePtr draw, DRI2BufferPtr front,
 	front->name = back->name;
 	back->name = tmp;
 
-	/* Swap pixmap bos */
-	front_bo = amdgpu_get_pixmap_bo(front_priv->pixmap);
-	back_bo = amdgpu_get_pixmap_bo(back_priv->pixmap);
-	amdgpu_set_pixmap_bo(front_priv->pixmap, back_bo);
-	amdgpu_set_pixmap_bo(back_priv->pixmap, front_bo);
+	/* Swap pixmap privates */
+	front_pix = amdgpu_get_pixmap_private(front_priv->pixmap);
+	back_pix = amdgpu_get_pixmap_private(back_priv->pixmap);
+	amdgpu_set_pixmap_private(front_priv->pixmap, back_pix);
+	amdgpu_set_pixmap_private(back_priv->pixmap, front_pix);
 
 	/* Do we need to update the Screen? */
 	screen = draw->pScreen;
 	info = AMDGPUPTR(xf86ScreenToScrn(screen));
-	if (front_bo == info->front_buffer) {
-		amdgpu_bo_ref(back_bo);
+	if (front_pix->bo == info->front_buffer) {
+		struct amdgpu_pixmap *screen_priv =
+			amdgpu_get_pixmap_private(screen->GetScreenPixmap(screen));
+
+		amdgpu_bo_ref(back_pix->bo);
 		amdgpu_bo_unref(&info->front_buffer);
-		info->front_buffer = back_bo;
-		amdgpu_set_pixmap_bo(screen->GetScreenPixmap(screen), back_bo);
+		info->front_buffer = back_pix->bo;
+		*screen_priv = *back_pix;
 	}
 
 	amdgpu_glamor_exchange_buffers(front_priv->pixmap, back_priv->pixmap);
diff --git a/src/amdgpu_dri3.c b/src/amdgpu_dri3.c
index c4b40d0..65d4899 100644
--- a/src/amdgpu_dri3.c
+++ b/src/amdgpu_dri3.c
@@ -125,6 +125,16 @@ static PixmapPtr amdgpu_dri3_pixmap_from_fd(ScreenPtr screen,
 {
 	PixmapPtr pixmap;
 
+#ifdef USE_GLAMOR
+	/* Avoid generating a GEM flink name if possible */
+	if (AMDGPUPTR(xf86ScreenToScrn(screen))->use_glamor) {
+		pixmap = glamor_pixmap_from_fd(screen, fd, width, height,
+					       stride, depth, bpp);
+		if (pixmap)
+			return pixmap;
+	}
+#endif
+
 	if (depth < 8)
 		return NULL;
 
diff --git a/src/amdgpu_pixmap.h b/src/amdgpu_pixmap.h
index 7e0e449..6fd5ef1 100644
--- a/src/amdgpu_pixmap.h
+++ b/src/amdgpu_pixmap.h
@@ -33,6 +33,10 @@ struct amdgpu_pixmap {
 	uint_fast32_t gpu_write;
 
 	struct amdgpu_buffer *bo;
+
+	/* GEM handle for pixmaps shared via DRI3 */
+	Bool handle_valid;
+	uint32_t handle;
 };
 
 #if HAS_DEVPRIVATEKEYREC
@@ -70,6 +74,7 @@ static inline void amdgpu_set_pixmap_bo(PixmapPtr pPix, struct amdgpu_buffer *bo
 
 		if (priv->bo) {
 			amdgpu_bo_unref(&priv->bo);
+			priv->handle_valid = FALSE;
 		}
 
 		if (!bo) {
commit e463b849f3e9d7b69e64a65619a22e00e78d297b
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Feb 23 18:10:29 2016 +0900

    Make amdgpu_do_pageflip take a pixmap instead of a BO
    
    (inspired by radeon commit 7b4fc4a677d252d01c2bf80d162bc35814059eaa)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index 230e8ba..d974cb8 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -595,7 +595,6 @@ amdgpu_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client,
 {
 	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
 	struct dri2_buffer_priv *back_priv;
-	struct amdgpu_buffer *bo = NULL;
 	DRI2FrameEventPtr flip_info;
 	/* Main crtc for this drawable shall finally deliver pageflip event. */
 	xf86CrtcPtr crtc = amdgpu_dri2_drawable_crtc(draw, FALSE);
@@ -618,10 +617,9 @@ amdgpu_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client,
 
 	/* Page flip the full screen buffer */
 	back_priv = back->driverPrivate;
-	bo = amdgpu_get_pixmap_bo(back_priv->pixmap);
-
-	if (amdgpu_do_pageflip(scrn, client, bo, AMDGPU_DRM_QUEUE_ID_DEFAULT,
-			       flip_info, ref_crtc_hw_id,
+	if (amdgpu_do_pageflip(scrn, client, back_priv->pixmap,
+			       AMDGPU_DRM_QUEUE_ID_DEFAULT, flip_info,
+			       ref_crtc_hw_id,
 			       amdgpu_dri2_flip_event_handler,
 			       amdgpu_dri2_flip_event_abort)) {
 		info->drmmode.dri2_flipping = TRUE;
diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index 07d7ef7..73ebb4c 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -294,16 +294,11 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
 	struct amdgpu_present_vblank_event *event;
 	xf86CrtcPtr xf86_crtc = crtc->devPrivate;
 	int crtc_id = xf86_crtc ? drmmode_get_crtc_id(xf86_crtc) : -1;
-	struct amdgpu_buffer *bo;
 	Bool ret;
 
 	if (!amdgpu_present_check_flip(crtc, screen->root, pixmap, sync_flip))
 		return FALSE;
 
-	bo = amdgpu_get_pixmap_bo(pixmap);
-	if (!bo)
-		return FALSE;
-
 	event = calloc(1, sizeof(struct amdgpu_present_vblank_event));
 	if (!event)
 		return FALSE;
@@ -311,8 +306,8 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
 	event->event_id = event_id;
 	event->crtc = xf86_crtc;
 
-	ret = amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, bo,
-				 event_id, event, crtc_id,
+	ret = amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
+				 pixmap, event_id, event, crtc_id,
 				 amdgpu_present_flip_event,
 				 amdgpu_present_flip_abort);
 	if (!ret)
@@ -334,18 +329,11 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 	struct amdgpu_present_vblank_event *event;
 	PixmapPtr pixmap = screen->GetScreenPixmap(screen);
-	struct amdgpu_buffer *bo;
 	int i;
 
 	if (!amdgpu_present_check_flip(NULL, screen->root, pixmap, TRUE))
 		goto modeset;
 
-	bo = amdgpu_get_pixmap_bo(pixmap);
-	if (!bo) {
-		ErrorF("%s: amdgpu_get_pixmap_bo failed, display might freeze\n", __func__);
-		goto modeset;
-	}
-
 	event = calloc(1, sizeof(struct amdgpu_present_vblank_event));
 	if (!event) {
 		ErrorF("%s: calloc failed, display might freeze\n", __func__);
@@ -354,7 +342,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
 
 	event->event_id = event_id;
 
-	if (amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, bo,
+	if (amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, pixmap,
 			       event_id, event, -1, amdgpu_present_flip_event,
 			       amdgpu_present_flip_abort))
 		return;
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 896b9d2..658eb90 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2307,7 +2307,7 @@ void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 }
 
 Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
-			struct amdgpu_buffer *new_front, uint64_t id, void *data,
+			PixmapPtr new_front, uint64_t id, void *data,
 			int ref_crtc_hw_id, amdgpu_drm_handler_proc handler,
 			amdgpu_drm_abort_proc abort)
 {
@@ -2315,27 +2315,16 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 	drmmode_crtc_private_ptr drmmode_crtc = config->crtc[0]->driver_private;
 	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-	unsigned int pitch;
 	int i;
-	int height;
 	drmmode_flipdata_ptr flipdata = NULL;
 	drmmode_flipevtcarrier_ptr flipcarrier = NULL;
 	struct amdgpu_drm_queue_entry *drm_queue = NULL;
-	union gbm_bo_handle bo_handle;
-	uint32_t handle;
+	uint32_t new_front_handle;
 
-	if (new_front->flags & AMDGPU_BO_FLAGS_GBM) {
-		pitch = gbm_bo_get_stride(new_front->bo.gbm);
-		height = gbm_bo_get_height(new_front->bo.gbm);
-		bo_handle = gbm_bo_get_handle(new_front->bo.gbm);
-		handle = bo_handle.u32;
-	} else {
-		pitch = scrn->displayWidth;
-		height = scrn->virtualY;
-		if (amdgpu_bo_export(new_front->bo.amdgpu,
-				amdgpu_bo_handle_type_kms,
-				&handle))
-			goto error;
+	if (!amdgpu_pixmap_get_handle(new_front, &new_front_handle)) {
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "flip queue: data alloc failed.\n");
+		return FALSE;
 	}
 
 	flipdata = calloc(1, sizeof(drmmode_flipdata_rec));
@@ -2349,9 +2338,10 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 	 * Create a new handle for the back buffer
 	 */
 	flipdata->old_fb_id = drmmode->fb_id;
-	if (drmModeAddFB(pAMDGPUEnt->fd, scrn->virtualX, height,
-			 scrn->depth, scrn->bitsPerPixel, pitch,
-			 handle, &drmmode->fb_id))
+	if (drmModeAddFB(pAMDGPUEnt->fd, new_front->drawable.width,
+			 new_front->drawable.height, scrn->depth,
+			 scrn->bitsPerPixel, new_front->devKind,
+			 new_front_handle, &drmmode->fb_id))
 		goto error;
 
 	/*
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index f1e6dc3..92b7457 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -144,7 +144,7 @@ extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 extern int drmmode_get_crtc_id(xf86CrtcPtr crtc);
 extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe);
 Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
-			struct amdgpu_buffer *new_front, uint64_t id, void *data,
+			PixmapPtr new_front, uint64_t id, void *data,
 			int ref_crtc_hw_id, amdgpu_drm_handler_proc handler,
 			amdgpu_drm_abort_proc abort);
 int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
commit 1ee341f9d909f3b7ba2984fc912dabdb98c34b19
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Feb 23 18:42:19 2016 +0900

    Add amdgpu_pixmap_get_handle helper
    
    (inspired by radeon commits dfad91fffb5bd013785223b42d78886df839eacf
     and ccbda955ebae1d457d35293833f12791e0f9fb0b)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c
index 65f1ac6..ad56197 100644
--- a/src/amdgpu_bo_helper.c
+++ b/src/amdgpu_bo_helper.c
@@ -131,6 +131,16 @@ Bool amdgpu_bo_get_handle(struct amdgpu_buffer *bo, uint32_t *handle)
 				handle) == 0;
 }
 
+Bool amdgpu_pixmap_get_handle(PixmapPtr pixmap, uint32_t *handle)
+{
+	struct amdgpu_buffer *bo = amdgpu_get_pixmap_bo(pixmap);
+
+	if (!bo)
+		return FALSE;
+
+	return amdgpu_bo_get_handle(bo, handle);
+}
+
 int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo)
 {
 	int ret = 0;
diff --git a/src/amdgpu_bo_helper.h b/src/amdgpu_bo_helper.h
index 4dae200..10e2db7 100644
--- a/src/amdgpu_bo_helper.h
+++ b/src/amdgpu_bo_helper.h
@@ -31,6 +31,8 @@ extern struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width
 
 extern Bool amdgpu_bo_get_handle(struct amdgpu_buffer *bo, uint32_t *handle);
 
+extern Bool amdgpu_pixmap_get_handle(PixmapPtr pixmap, uint32_t *handle);
+
 extern int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo);
 
 extern void amdgpu_bo_unmap(struct amdgpu_buffer *bo);


More information about the xorg-commit mailing list