[Mesa-dev] [PATCH 1/2] loader: Add support for USB devices

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


From: Thierry Reding <treding at nvidia.com>

Allow USB devices to be used as output slaves for PRIME. Note that this
currently doesn't work on the X.Org server's built-in modesetting driver
because it requires glamor in order to expose the necessary capabilities
through RandR.

It should be possible to use this in order to accelerate Wayland clients
on the GPU, though it's questionable how useful that is without having a
compositor that gets accelerated.

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

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 449ff54d1377..d2f7165c1011 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -112,6 +112,8 @@ static char *drm_construct_id_path_tag(drmDevicePtr device)
 {
 /* Length of "pci-xxxx_xx_xx_x\0" */
 #define PCI_ID_PATH_TAG_LENGTH 17
+/* Length of "usb-xxx_xxx\0" */
+#define USB_ID_PATH_TAG_LENGTH 12
    char *tag = NULL;
 
    if (device->bustype == DRM_BUS_PCI) {
@@ -122,6 +124,13 @@ static char *drm_construct_id_path_tag(drmDevicePtr device)
         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);
+   } else if (device->bustype == DRM_BUS_USB) {
+      tag = calloc(USB_ID_PATH_TAG_LENGTH, sizeof(char));
+      if (!tag)
+         return NULL;
+
+      snprintf(tag, USB_ID_PATH_TAG_LENGTH, "usb-%03u_%03u",
+               device->businfo.usb->bus, device->businfo.pci->dev);
    }
    return tag;
 }
-- 
2.11.0



More information about the mesa-dev mailing list