<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>grep for TSTD below...</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> xorg-driver-ati <xorg-driver-ati-bounces@lists.x.org> on behalf of Michel Dänzer <michel@daenzer.net><br>
<b>Sent:</b> Wednesday, June 8, 2016 04:45<br>
<b>To:</b> xorg-driver-ati@lists.x.org<br>
<b>Cc:</b> Yu, Qiang<br>
<b>Subject:</b> [PATCH xf86-video-amdgpu 3/6] Add amdgpu_pixmap_get_tiling_info</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">From: Michel Dänzer <michel.daenzer@amd.com><br>
<br>
Retrieves the tiling information about a pixmap BO from the kernel<br>
driver.<br>
<br>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com><br>
---<br>
src/amdgpu_bo_helper.c | 33 ++++++++++++++++++++++++++++++++-<br>
src/amdgpu_bo_helper.h | 2 ++<br>
src/amdgpu_pixmap.h | 2 ++<br>
3 files changed, 36 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c<br>
index a566920..783347b 100644<br>
--- a/src/amdgpu_bo_helper.c<br>
+++ b/src/amdgpu_bo_helper.c<br>
@@ -131,6 +131,35 @@ Bool amdgpu_bo_get_handle(struct amdgpu_buffer *bo, uint32_t *handle)<br>
handle) == 0;<br>
}<br>
<br>
+static void amdgpu_pixmap_do_get_tiling_info(PixmapPtr pixmap)<br>
+{<br>
+ struct amdgpu_pixmap *priv = amdgpu_get_pixmap_private(pixmap);<br>
+ ScreenPtr screen = pixmap->drawable.pScreen;<br>
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);<br>
+ AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);<br>
+ struct drm_amdgpu_gem_metadata gem_metadata;<br>
+<br>
+ gem_metadata.handle = priv->handle;<br>
+ gem_metadata.op = AMDGPU_GEM_METADATA_OP_GET_METADATA;<br>
+<br>
+ if (drmCommandWriteRead(pAMDGPUEnt->fd, DRM_AMDGPU_GEM_METADATA,<br>
+ &gem_metadata, sizeof(gem_metadata)) == 0)<br>
+ priv->tiling_info = gem_metadata.data.tiling_info;<br>
+}<br>
+<br>
+uint64_t amdgpu_pixmap_get_tiling_info(PixmapPtr pixmap)<br>
+{<br>
+ struct amdgpu_pixmap *priv = amdgpu_get_pixmap_private(pixmap);<br>
+ uint32_t handle;<br>
+<br>
+ if (!priv || !priv->handle_valid) {<br>
+ amdgpu_pixmap_get_handle(pixmap, &handle);<br>
+ priv = amdgpu_get_pixmap_private(pixmap);</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">TSTD: If this fails won't you just end up with a NULL pointer?</div>
<div class="PlainText"><br>
+ }<br>
+<br>
+ return priv->tiling_info;<br>
+}<br>
+<br>
Bool amdgpu_pixmap_get_handle(PixmapPtr pixmap, uint32_t *handle)<br>
{<br>
#ifdef USE_GLAMOR<br>
@@ -162,13 +191,15 @@ Bool amdgpu_pixmap_get_handle(PixmapPtr pixmap, uint32_t *handle)<br>
r = drmPrimeFDToHandle(pAMDGPUEnt->fd, fd, &priv->handle);<br>
close(fd);<br>
if (r == 0)<br>
- goto success;<br>
+ goto get_tiling_info;<br>
}<br>
#endif<br>
<br>
if (!priv->bo || !amdgpu_bo_get_handle(priv->bo, &priv->handle))<br>
return FALSE;<br>
<br>
+ get_tiling_info:<br>
+ amdgpu_pixmap_do_get_tiling_info(pixmap);<br>
success:<br>
priv->handle_valid = TRUE;<br>
*handle = priv->handle;<br>
diff --git a/src/amdgpu_bo_helper.h b/src/amdgpu_bo_helper.h<br>
index 3e81fca..efbdcda 100644<br>
--- a/src/amdgpu_bo_helper.h<br>
+++ b/src/amdgpu_bo_helper.h<br>
@@ -31,6 +31,8 @@ extern struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width<br>
<br>
extern Bool amdgpu_bo_get_handle(struct amdgpu_buffer *bo, uint32_t *handle);<br>
<br>
+extern uint64_t amdgpu_pixmap_get_tiling_info(PixmapPtr pixmap);<br>
+<br>
extern Bool amdgpu_pixmap_get_handle(PixmapPtr pixmap, uint32_t *handle);<br>
<br>
extern int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo);<br>
diff --git a/src/amdgpu_pixmap.h b/src/amdgpu_pixmap.h<br>
index 1fba90e..ecdd74d 100644<br>
--- a/src/amdgpu_pixmap.h<br>
+++ b/src/amdgpu_pixmap.h<br>
@@ -32,6 +32,8 @@ struct amdgpu_pixmap {<br>
uint_fast32_t gpu_read;<br>
uint_fast32_t gpu_write;<br>
<br>
+ uint64_t tiling_info;<br>
+<br>
struct amdgpu_buffer *bo;<br>
<br>
/* GEM handle for pixmaps shared via DRI2/3 */<br>
-- <br>
2.8.1<br>
<br>
_______________________________________________<br>
xorg-driver-ati mailing list<br>
xorg-driver-ati@lists.x.org<br>
<a href="https://lists.x.org/mailman/listinfo/xorg-driver-ati" id="LPlnk230970">https://lists.x.org/mailman/listinfo/xorg-driver-ati</a><br>
</div>
</span></font></div>
</div>
</body>
</html>