Index: devil/devil/utils/usb_hubs.py |
diff --git a/devil/devil/utils/usb_hubs.py b/devil/devil/utils/usb_hubs.py |
index a37cb3b47b56ea004f80e4e296634b4cab86fad6..5a65c5aa3693db53ff4013bea0b7ab663635d462 100644 |
--- a/devil/devil/utils/usb_hubs.py |
+++ b/devil/devil/utils/usb_hubs.py |
@@ -7,6 +7,11 @@ PLUGABLE_7PORT_LAYOUT = {1:7, |
3:5, |
4:{1:4, 2:3, 3:2, 4:1}} |
+PLUGABLE_7PORT_USB3_LAYOUT = {1:{1:1, 2:2, 3:3, 4:4}, |
+ 2:5, |
+ 3:6, |
+ 4:7} |
+ |
class HubType(object): |
def __init__(self, id_func, port_mapping): |
"""Defines a type of hub. |
@@ -89,10 +94,47 @@ def _is_plugable_7port_hub(node): |
return False |
return '1a40:0101' in node.PortToDevice(4).desc |
+# Plugable 7-Port USB-3 Hubs show up twice in the USB devices list; they have |
+# two different "branches", one which has USB2 devices and one which has |
+# USB3 devices. The "part2" is the "USB-2" branch of the hub, the |
+# "part3" is the "USB-3" branch of the hub. |
+ |
+def _is_plugable_7port_usb3_part2_hub(node): |
+ """Check if a node is the "USB2 branch" of |
+ a Plugable 7-Port USB-3 Hub (Model USB3-HUB7BC) |
+ The topology of this device is a 4-port hub, |
+ with another 4-port hub connected on port 1. |
+ """ |
+ if '2109:2811' not in node.desc: |
+ return False |
+ if not node.HasPort(1): |
+ return False |
+ return '2109:2811' in node.PortToDevice(1).desc |
+ |
+def _is_plugable_7port_usb3_part3_hub(node): |
+ """Check if a node is the "USB3 branch" of |
+ a Plugable 7-Port USB-3 Hub (Model USB3-HUB7BC) |
+ The topology of this device is a 4-port hub, |
+ with another 4-port hub connected on port 1. |
+ """ |
+ if '2109:8110' not in node.desc: |
+ return False |
+ if not node.HasPort(1): |
+ return False |
+ return '2109:8110' in node.PortToDevice(1).desc |
+ |
PLUGABLE_7PORT = HubType(_is_plugable_7port_hub, PLUGABLE_7PORT_LAYOUT) |
+PLUGABLE_7PORT_USB3_PART2 = HubType(_is_plugable_7port_usb3_part2_hub, |
+ PLUGABLE_7PORT_USB3_LAYOUT) |
+PLUGABLE_7PORT_USB3_PART3 = HubType(_is_plugable_7port_usb3_part3_hub, |
+ PLUGABLE_7PORT_USB3_LAYOUT) |
def GetHubType(type_name): |
if type_name == 'plugable_7port': |
return PLUGABLE_7PORT |
+ if type_name == 'plugable_7port_usb3_part2': |
+ return PLUGABLE_7PORT_USB3_PART2 |
+ if type_name == 'plugable_7port_usb3_part3': |
+ return PLUGABLE_7PORT_USB3_PART3 |
else: |
raise ValueError('Invalid hub type') |