[PATCH 1/2] Add radeon_get_pixmap_tiling_flags helper

Michel Dänzer michel at daenzer.net
Wed Apr 1 18:36:47 PDT 2015


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

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/radeon_bo_helper.c | 33 +++++++++++++++++++++++++++++++++
 src/radeon_bo_helper.h |  3 +++
 2 files changed, 36 insertions(+)

diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c
index adf6599..ebbb192 100644
--- a/src/radeon_bo_helper.c
+++ b/src/radeon_bo_helper.c
@@ -229,8 +229,16 @@ Bool radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle)
 	r = drmPrimeFDToHandle(info->dri2.drm_fd, fd, &priv->handle);
 	close(fd);
 	if (r == 0) {
+	    struct drm_radeon_gem_set_tiling args = { .handle = priv->handle };
+
 	    priv->handle_valid = TRUE;
 	    *handle = priv->handle;
+
+	    if (drmCommandWriteRead(info->dri2.drm_fd,
+				    DRM_RADEON_GEM_GET_TILING, &args,
+				    sizeof(args)) == 0)
+		priv->tiling_flags = args.tiling_flags;
+
 	    return TRUE;
 	}
     }
@@ -239,6 +247,31 @@ Bool radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle)
     return FALSE;
 }
 
+uint32_t radeon_get_pixmap_tiling_flags(PixmapPtr pPix)
+{
+#ifdef USE_GLAMOR
+    RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(pPix->drawable.pScreen));
+
+    if (info->use_glamor) {
+	struct radeon_pixmap *priv = radeon_get_pixmap_private(pPix);
+
+	if (!priv || (!priv->bo && !priv->handle_valid)) {
+	    uint32_t handle;
+
+	    radeon_get_pixmap_handle(pPix, &handle);
+	    priv = radeon_get_pixmap_private(pPix);
+	}
+
+	return priv ? priv->tiling_flags : 0;
+    } else
+#endif
+    {
+	struct radeon_exa_pixmap_priv *driver_priv;
+	driver_priv = exaGetPixmapDriverPrivate(pPix);
+	return driver_priv ? driver_priv->tiling_flags : 0;
+    }
+}
+
 #ifdef RADEON_PIXMAP_SHARING
 
 Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p)
diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h
index 89ad4be..d4a4ee0 100644
--- a/src/radeon_bo_helper.h
+++ b/src/radeon_bo_helper.h
@@ -31,6 +31,9 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth,
 extern Bool
 radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle);
 
+extern uint32_t
+radeon_get_pixmap_tiling_flags(PixmapPtr pPix);
+
 extern Bool
 radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p);
 
-- 
2.1.4



More information about the xorg-driver-ati mailing list