ac: add radeon_info::name
[mesa.git] / src / loader / loader.c
index 913b3dcac032b3c9cd0ab068874627913f2b45bc..fda49521aae4056214d54e9366acccc818cb64b9 100644 (file)
@@ -110,17 +110,43 @@ static char *loader_get_dri_config_device_id(void)
 
 static char *drm_construct_id_path_tag(drmDevicePtr device)
 {
-#define PCI_ID_PATH_TAG_LENGTH sizeof("pci-xxxx_xx_xx_x")
    char *tag = NULL;
 
    if (device->bustype == DRM_BUS_PCI) {
-        tag = calloc(PCI_ID_PATH_TAG_LENGTH, sizeof(char));
-        if (tag == NULL)
-            return NULL;
+      if (asprintf(&tag, "pci-%04x_%02x_%02x_%1u",
+                   device->businfo.pci->domain,
+                   device->businfo.pci->bus,
+                   device->businfo.pci->dev,
+                   device->businfo.pci->func) < 0) {
+         return NULL;
+      }
+   } else if (device->bustype == DRM_BUS_PLATFORM ||
+              device->bustype == DRM_BUS_HOST1X) {
+      char *fullname, *name, *address;
+
+      if (device->bustype == DRM_BUS_PLATFORM)
+         fullname = device->businfo.platform->fullname;
+      else
+         fullname = device->businfo.host1x->fullname;
+
+      name = strrchr(fullname, '/');
+      if (!name)
+         name = strdup(fullname);
+      else
+         name = strdup(name + 1);
+
+      address = strchr(name, '@');
+      if (address) {
+         *address++ = '\0';
+
+         if (asprintf(&tag, "platform-%s_%s", address, name) < 0)
+            tag = NULL;
+      } else {
+         if (asprintf(&tag, "platform-%s", name) < 0)
+            tag = NULL;
+      }
 
-        snprintf(tag, PCI_ID_PATH_TAG_LENGTH, "pci-%04x_%02x_%02x_%1u",
-                 device->businfo.pci->domain, device->businfo.pci->bus,
-                 device->businfo.pci->dev, device->businfo.pci->func);
+      free(name);
    }
    return tag;
 }
@@ -382,8 +408,8 @@ loader_get_extensions_name(const char *driver_name)
 
    const size_t len = strlen(name);
    for (size_t i = 0; i < len; i++) {
-          if (name[i] == '-')
-                  name[i] = '_';
+      if (name[i] == '-')
+         name[i] = '_';
    }
 
    return name;