[Mesa-dev] [PATCH 1/1] radeonsi: Use libdrm to get chipset name for radeon

Samuel Li Samuel.Li at amd.com
Tue Jul 4 21:35:56 UTC 2017


Change-Id: I98d17f4af07c30f1739b43db1a6e1616a58332ef
Signed-off-by: Samuel Li <Samuel.Li at amd.com>
---
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 2a6ce2c..10d53d2 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -45,6 +45,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <radeon_surface.h>
+#include <radeon_asic_id.h>
 
 static struct util_hash_table *fd_tab = NULL;
 static mtx_t fd_tab_mutex = _MTX_INITIALIZER_NP;
@@ -557,6 +558,7 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws)
     mtx_destroy(&ws->bo_handles_mutex);
     mtx_destroy(&ws->bo_va_mutex);
     mtx_destroy(&ws->bo_fence_lock);
+    radeon_asic_id_deinitialize();
 
     if (ws->fd >= 0)
         close(ws->fd);
@@ -734,6 +736,19 @@ static int handle_compare(void *key1, void *key2)
     return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
 }
 
+static const char* radeon_get_chip_name(struct radeon_winsys *ws)
+{
+    int r;
+    drmDevicePtr dev;
+    r = drmGetDevice2(((struct radeon_drm_winsys *)ws)->fd, DRM_DEVICE_GET_PCI_REVISION, &dev);
+    if (r) {
+        fprintf(stderr, "radeon: drmGetDevice2 failed.\n");
+        return NULL;
+    }
+
+    return radeon_get_marketing_name(dev->deviceinfo.pci->device_id, dev->deviceinfo.pci->revision_id);
+}
+
 PUBLIC struct radeon_winsys *
 radeon_drm_winsys_create(int fd, unsigned flags,
 			 radeon_screen_create_t screen_create)
@@ -803,10 +818,12 @@ radeon_drm_winsys_create(int fd, unsigned flags,
     ws->base.cs_request_feature = radeon_cs_request_feature;
     ws->base.query_value = radeon_query_value;
     ws->base.read_registers = radeon_read_registers;
+    ws->base.get_chip_name = radeon_get_chip_name;
 
     radeon_drm_bo_init_functions(ws);
     radeon_drm_cs_init_functions(ws);
     radeon_surface_init_functions(ws);
+    radeon_asic_id_initialize();
 
     (void) mtx_init(&ws->hyperz_owner_mutex, mtx_plain);
     (void) mtx_init(&ws->cmask_owner_mutex, mtx_plain);
-- 
2.7.4



More information about the mesa-dev mailing list