usb_constants.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. """USB constant definitions.
  5. """
  6. class DescriptorType(object):
  7. """Descriptor Types.
  8. See Universal Serial Bus Specification Revision 2.0 Table 9-5.
  9. """
  10. DEVICE = 1
  11. CONFIGURATION = 2
  12. STRING = 3
  13. INTERFACE = 4
  14. ENDPOINT = 5
  15. QUALIFIER = 6
  16. OTHER_SPEED_CONFIGURATION = 7
  17. BOS = 15
  18. DEVICE_CAPABILITY = 16
  19. class CapabilityType(object):
  20. """Device capability types.
  21. See Universal Serial Bus 3.1 Specification, Revision 1.0 Table 9-14.
  22. """
  23. WIRELESS_USB = 0x01
  24. USB_20_EXTENSION = 0x02
  25. SUPERSPEED_USB = 0x03
  26. CONTAINER_ID = 0x04
  27. PLATFORM = 0x05
  28. POWER_DELIVERY_CAPABILITY = 0x06
  29. BATTERY_INFO_CAPABILITY = 0x07
  30. PD_CONSUMER_PORT_CAPABILITY = 0x08
  31. PD_PROVIDER_PORT_CAPABILITY = 0x09
  32. SUPERSPEED_PLUS = 0x0A
  33. PRECISION_TIME_MEASUREMENT = 0x0B
  34. WIRELESS_USB_EXT = 0x0C
  35. class DeviceClass(object):
  36. """Class code.
  37. See http://www.usb.org/developers/defined_class.
  38. """
  39. PER_INTERFACE = 0
  40. AUDIO = 1
  41. COMM = 2
  42. HID = 3
  43. PHYSICAL = 5
  44. STILL_IMAGE = 6
  45. PRINTER = 7
  46. MASS_STORAGE = 8
  47. HUB = 9
  48. CDC_DATA = 10
  49. CSCID = 11
  50. CONTENT_SEC = 13
  51. VIDEO = 14
  52. VENDOR = 0xFF
  53. class DeviceSubClass(object):
  54. """Subclass code.
  55. See http://www.usb.org/developers/defined_class.
  56. """
  57. PER_INTERFACE = 0
  58. VENDOR = 0xFF
  59. class DeviceProtocol(object):
  60. """Protocol code.
  61. See http://www.usb.org/developers/defined_class.
  62. """
  63. PER_INTERFACE = 0
  64. VENDOR = 0xFF
  65. class InterfaceClass(object):
  66. """Class code.
  67. See http://www.usb.org/developers/defined_class.
  68. """
  69. VENDOR = 0xFF
  70. class InterfaceSubClass(object):
  71. """Subclass code.
  72. See http://www.usb.org/developers/defined_class.
  73. """
  74. VENDOR = 0xFF
  75. class InterfaceProtocol(object):
  76. """Protocol code.
  77. See http://www.usb.org/developers/defined_class.
  78. """
  79. VENDOR = 0xFF
  80. class TransferType(object):
  81. """Transfer Type.
  82. See http://www.usb.org/developers/defined_class.
  83. """
  84. MASK = 3
  85. CONTROL = 0
  86. ISOCHRONOUS = 1
  87. BULK = 2
  88. INTERRUPT = 3
  89. class Dir(object):
  90. """Data transfer direction.
  91. See Universal Serial Bus Specification Revision 2.0 Table 9-2.
  92. """
  93. OUT = 0
  94. IN = 0x80
  95. class Type(object):
  96. """Request Type.
  97. See Universal Serial Bus Specification Revision 2.0 Table 9-2.
  98. """
  99. MASK = 0x60
  100. STANDARD = 0x00
  101. CLASS = 0x20
  102. VENDOR = 0x40
  103. RESERVED = 0x60
  104. class Recipient(object):
  105. """Request Recipient.
  106. See Universal Serial Bus Specification Revision 2.0 Table 9-2.
  107. """
  108. MASK = 0x1f
  109. DEVICE = 0
  110. INTERFACE = 1
  111. ENDPOINT = 2
  112. OTHER = 3
  113. class Request(object):
  114. """Standard Request Codes.
  115. See Universal Serial Bus Specification Revision 2.0 Table 9-4.
  116. """
  117. GET_STATUS = 0x00
  118. CLEAR_FEATURE = 0x01
  119. SET_FEATURE = 0x03
  120. SET_ADDRESS = 0x05
  121. GET_DESCRIPTOR = 0x06
  122. SET_DESCRIPTOR = 0x07
  123. GET_CONFIGURATION = 0x08
  124. SET_CONFIGURATION = 0x09
  125. GET_INTERFACE = 0x0A
  126. SET_INTERFACE = 0x0B
  127. SYNCH_FRAME = 0x0C
  128. SET_SEL = 0x30
  129. SET_ISOCH_DELAY = 0x31
  130. class Speed(object):
  131. UNKNOWN = 0
  132. LOW = 1
  133. FULL = 2
  134. HIGH = 3
  135. WIRELESS = 4
  136. SUPER = 5
  137. class VendorID(object):
  138. GOOGLE = 0x18D1
  139. class ProductID(object):
  140. GOOGLE_TEST_GADGET = 0x58F0
  141. GOOGLE_KEYBOARD_GADGET = 0x58F1
  142. GOOGLE_MOUSE_GADGET = 0x58F2
  143. GOOGLE_HID_ECHO_GADGET = 0x58F3
  144. GOOGLE_ECHO_GADGET = 0x58F4
  145. GOOGLE_COMPOSITE_ECHO_GADGET = 0x58F5