[Mesa-dev] [PATCH 2/2] loader: Add support for platform and host1x busses

Thierry Reding thierry.reding at gmail.com
Fri Dec 23 19:55:03 UTC 2016


From: Thierry Reding <treding at nvidia.com>

ARM SoCs usually have their DRM/KMS devices on the platform bus, so add
support for this bus in order to allow use of the DRI_PRIME environment
variable with those devices.

While at it, also support the host1x bus, which is effectively the same
but uses an additional layer in the bus hierarchy.

Note that it isn't enough to support the bus that has the rendering GPU
because the loader code will also try to construct an ID path tag for a
scanout-only device if it is the default that is being opened.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 src/loader/loader.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index d2f7165c1011..514fe5991613 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -131,6 +131,40 @@ static char *drm_construct_id_path_tag(drmDevicePtr device)
 
       snprintf(tag, USB_ID_PATH_TAG_LENGTH, "usb-%03u_%03u",
                device->businfo.usb->bus, device->businfo.pci->dev);
+   } else if (device->bustype == DRM_BUS_PLATFORM) {
+      size_t length = 10; /* platform- + \0 */
+      char *name;
+
+      name = strrchr(device->businfo.platform->fullname, '/');
+      if (!name)
+         name = device->businfo.platform->fullname;
+      else
+         name++;
+
+      length += strlen(name);
+
+      tag = calloc(length, sizeof(char));
+      if (!tag)
+         return NULL;
+
+      snprintf(tag, length, "platform-%s", name);
+   } else if (device->bustype == DRM_BUS_HOST1X) {
+      size_t length = 8; /* host1x- + \0 */
+      char *name;
+
+      name = strrchr(device->businfo.host1x->fullname, '/');
+      if (!name)
+         name = device->businfo.host1x->fullname;
+      else
+         name++;
+
+      length += strlen(name);
+
+      tag = calloc(length, sizeof(char));
+      if (!tag)
+         return NULL;
+
+      snprintf(tag, length, "host1x-%s", name);
    }
    return tag;
 }
-- 
2.11.0



More information about the mesa-dev mailing list