Coverage for linuxpy/usb/raw.py: 100%
567 statements
« prev ^ index » next coverage.py v7.10.4, created at 2026-02-19 15:11 +0100
« prev ^ index » next coverage.py v7.10.4, created at 2026-02-19 15:11 +0100
1#
2# This file is part of the linuxpy project
3#
4# Copyright (c) 2023 Tiago Coutinho
5# Distributed under the GPLv3 license. See LICENSE for more info.
7# This file has been generated by linuxpy.codegen.usbfs
8# Date: 2024-09-09 08:39:27.157457
9# System: Linux
10# Release: 6.10.6-amd64
11# Version: #1 SMP PREEMPT_DYNAMIC Debian 6.10.6-1 (2024-08-19)
13import enum
15from linuxpy.ctypes import (
16 POINTER,
17 Struct,
18 Union,
19 cchar,
20 cint,
21 cuint,
22 cvoidp,
23 u8,
24 u16,
25 u32,
26)
27from linuxpy.ioctl import IO as _IO, IOR as _IOR, IOW as _IOW, IOWR as _IOWR
30class URBType(enum.IntEnum):
31 ISO = 0x0
32 INTERRUPT = 0x1
33 CONTROL = 0x2
34 BULK = 0x3
37class URB(enum.IntFlag):
38 SHORT_NOT_OK = 0x1
39 ISO_ASAP = 0x2
40 BULK_CONTINUATION = 0x4
41 NO_FSBR = 0x20 # Not used
42 ZERO_PACKET = 0x40
43 NO_INTERRUPT = 0x80
46class Capability(enum.IntFlag):
47 ZERO_PACKET = 0x1
48 BULK_CONTINUATION = 0x2
49 NO_PACKET_SIZE_LIM = 0x4
50 BULK_SCATTER_GATHER = 0x8
51 REAP_AFTER_DISCONNECT = 0x10
52 MMAP = 0x20
53 DROP_PRIVILEGES = 0x40
54 CONNINFO_EX = 0x80
55 SUSPEND = 0x100
58class DisconnectClaim(enum.IntFlag):
59 IF_DRIVER = 0x1
60 EXCEPT_DRIVER = 0x2
63class Direction(enum.IntEnum):
64 OUT = 0 # to device
65 IN = 0x80 # to host
68class RequestType(enum.IntEnum):
69 MASK = 0x03 << 5
70 STANDARD = 0x00 << 5
71 CLASS = 0x01 << 5
72 VENDOR = 0x02 << 5
73 RESERVED = 0x03 << 5
74 _USB_TYPE_C_BRIDGE = 0x12
77class Recipient(enum.IntEnum):
78 MASK = 0x1F
79 DEVICE = 0x0
80 INTERFACE = 0x1
81 ENDPOINT = 0x2
82 OTHER = 0x3
83 PORT = 0x4
84 RPIPE = 0x5
87class Request(enum.IntEnum):
88 GET_STATUS = 0x0
89 CLEAR_FEATURE = 0x1
90 SET_FEATURE = 0x3
91 SET_ADDRESS = 0x5
92 GET_DESCRIPTOR = 0x6
93 SET_DESCRIPTOR = 0x7
94 GET_CONFIGURATION = 0x8
95 SET_CONFIGURATION = 0x9
96 GET_INTERFACE = 0xA
97 SET_INTERFACE = 0xB
98 SYNCH_FRAME = 0xC
99 SET_SEL = 0x30
100 SET_ISOCH_DELAY = 0x31
101 SET_ENCRYPTION = 0x0D # Wireless USB
102 GET_ENCRYPTION = 0xE
103 RPIPE_ABORT = 0xE
104 SET_HANDSHAKE = 0xF
105 RPIPE_RESET = 0xF
106 GET_HANDSHAKE = 0x10
107 SET_CONNECTION = 0x11
108 SET_SECURITY_DATA = 0x12
109 GET_SECURITY_DATA = 0x13
110 SET_WUSB_DATA = 0x14
111 LOOPBACK_DATA_WRITE = 0x15
112 LOOPBACK_DATA_READ = 0x16
113 SET_INTERFACE_DS = 0x17
114 GET_PARTNER_PDO = 0x14
115 GET_BATTERY_STATUS = 0x15
116 SET_PDO = 0x16
117 GET_VDM = 0x17
118 SEND_VDM = 0x18
121class Device(enum.IntEnum):
122 SELF_POWERED = 0 # (read only)
123 REMOTE_WAKEUP = 1 # dev may initiate wakeup
124 TEST_MODE = 2 # (wired high speed only)
125 BATTERY = 2 # (wireless)
126 B_HNP_ENABLE = 3 # (otg) dev may initiate HNP
127 WUSB_DEVICE = 3 # (wireless)
128 A_HNP_SUPPORT = 4 # (otg) RH port supports HNP
129 A_ALT_HNP_SUPPORT = 5 # (otg) other RH port does
130 DEBUG_MODE = 6 # (special devices only)
131 U1_ENABLE = 48 # dev may initiate U1 transition
132 U2_ENABLE = 49 # dev may initiate U2 transition
133 LTM_ENABLE = 50 # dev may send LTM
134 BATTERY_WAKE_MASK = 0x28
135 OS_IS_PD_AWARE = 0x29
136 POLICY_MODE = 0x2A
137 CHARGING_POLICY = 0x36
140class Class(enum.IntEnum):
141 PER_INTERFACE = 0 # for DeviceClass
142 AUDIO = 0x1
143 COMM = 0x2
144 HID = 0x3
145 PHYSICAL = 0x5
146 STILL_IMAGE = 0x6
147 PRINTER = 0x7
148 MASS_STORAGE = 0x8
149 HUB = 0x9
150 CDC_DATA = 0xA
151 CSCID = 0x0B # chip+ smart card
152 CONTENT_SEC = 0x0D # content security
153 VIDEO = 0xE
154 WIRELESS_CONTROLLER = 0xE0
155 PERSONAL_HEALTHCARE = 0xF
156 AUDIO_VIDEO = 0x10
157 BILLBOARD = 0x11
158 MISC = 0xEF
159 APP_SPEC = 0xFE
160 VENDOR_SPEC = 0xFF
163class Test(enum.IntEnum):
164 J = 0x1
165 K = 0x2
166 SE0_NAK = 0x3
167 PACKET = 0x4
168 FORCE_ENABLE = 0x5
171class StatusType(enum.IntEnum):
172 STANDARD = 0x0
173 PTM = 0x1
176class EndpointTransferType(enum.IntEnum):
177 CONTROL = 0x0
178 ISOC = 0x1
179 BULK = 0x2
180 INT = 0x3
183class VideoSubClass(enum.IntEnum):
184 UNDEFINED = 0x0
185 VIDEOCONTROL = 0x1
186 VIDEOSTREAMING = 0x2
187 VIDEO_INTERFACE_COLLECTION = 0x3
190class VideoProtocol(enum.IntEnum):
191 UNDEFINED = 0x0
192 _15 = 0x1
195class VideoControl(enum.IntEnum):
196 DESCRIPTOR_UNDEFINED = 0x0
197 HEADER = 0x1
198 INPUT_TERMINAL = 0x2
199 OUTPUT_TERMINAL = 0x3
200 SELECTOR_UNIT = 0x4
201 PROCESSING_UNIT = 0x5
202 EXTENSION_UNIT = 0x6
203 CONTROL_UNDEFINED = 0x0
204 VIDEO_POWER_MODE_CONTROL = 0x1
205 REQUEST_ERROR_CODE_CONTROL = 0x2
208class VideoStreaming(enum.IntEnum):
209 UNDEFINED = 0x0
210 INPUT_HEADER = 0x1
211 OUTPUT_HEADER = 0x2
212 STILL_IMAGE_FRAME = 0x3
213 FORMAT_UNCOMPRESSED = 0x4
214 FRAME_UNCOMPRESSED = 0x5
215 FORMAT_MJPEG = 0x6
216 FRAME_MJPEG = 0x7
217 FORMAT_MPEG2TS = 0xA
218 FORMAT_DV = 0xC
219 COLORFORMAT = 0xD
220 FORMAT_FRAME_BASED = 0x10
221 FRAME_FRAME_BASED = 0x11
222 FORMAT_STREAM_BASED = 0x12
223 CONTROL_UNDEFINED = 0x0
224 PROBE_CONTROL = 0x1
225 COMMIT_CONTROL = 0x2
226 STILL_PROBE_CONTROL = 0x3
227 STILL_COMMIT_CONTROL = 0x4
228 STILL_IMAGE_TRIGGER_CONTROL = 0x5
229 STREAM_ERROR_CODE_CONTROL = 0x6
230 GENERATE_KEY_FRAME_CONTROL = 0x7
231 UPDATE_FRAME_SEGMENT_CONTROL = 0x8
232 SYNC_DELAY_CONTROL = 0x9
235class VideoEndPoint(enum.IntEnum):
236 UNDEFINED = 0x0
237 GENERAL = 0x1
238 ENDPOINT = 0x2
239 INTERRUPT = 0x3
242class UsbipDeviceStatus(enum.IntEnum):
243 SDEV_ST_AVAILABLE = 1
244 SDEV_ST_USED = 2
245 SDEV_ST_ERROR = 3
246 VDEV_ST_NULL = 4
247 VDEV_ST_NOTASSIGNED = 5
248 VDEV_ST_USED = 6
249 VDEV_ST_ERROR = 7
252class UsbDeviceSpeed(enum.IntEnum):
253 UNKNOWN = 0
254 LOW = 1
255 FULL = 2
256 HIGH = 3
257 WIRELESS = 4
258 SUPER = 5
259 SUPER_PLUS = 6
262class UsbDeviceState(enum.IntEnum):
263 NOTATTACHED = 0
264 ATTACHED = 1
265 POWERED = 2
266 RECONNECTING = 3
267 UNAUTHENTICATED = 4
268 DEFAULT = 5
269 ADDRESS = 6
270 CONFIGURED = 7
271 SUSPENDED = 8
274class Usb3LinkState(enum.IntEnum):
275 _0 = 0
276 _1 = 1
277 _2 = 2
278 _3 = 3
281class HubLedMode(enum.IntEnum):
282 AUTO = 0
283 CYCLE = 1
284 GREEN_BLINK = 2
285 GREEN_BLINK_OFF = 3
286 AMBER_BLINK = 4
287 AMBER_BLINK_OFF = 5
288 ALT_BLINK = 6
289 ALT_BLINK_OFF = 7
292class UvcColorPrimariesValues(enum.IntEnum):
293 UNSPECIFIED = 0
294 BT_709_SRGB = 1
295 BT_470_2_M = 2
296 BT_470_2_B_G = 3
297 SMPTE_170M = 4
298 SMPTE_240M = 5
301class UvcTransferCharacteristicsValues(enum.IntEnum):
302 UNSPECIFIED = 0
303 BT_709 = 1
304 BT_470_2_M = 2
305 BT_470_2_B_G = 3
306 SMPTE_170M = 4
307 SMPTE_240M = 5
308 LINEAR = 6
309 SRGB = 7
312class UvcMatrixCoefficients(enum.IntEnum):
313 UNSPECIFIED = 0
314 BT_709 = 1
315 FCC = 2
316 BT_470_2_B_G = 3
317 SMPTE_170M = 4
318 SMPTE_240M = 5
321class usbdevfs_ctrltransfer(Struct):
322 pass
325usbdevfs_ctrltransfer._fields_ = [
326 ("bRequestType", u8),
327 ("bRequest", u8),
328 ("wValue", u16),
329 ("wIndex", u16),
330 ("wLength", u16),
331 ("timeout", cuint),
332 ("data", POINTER(None)),
333]
336class usbdevfs_bulktransfer(Struct):
337 pass
340usbdevfs_bulktransfer._fields_ = [("ep", cuint), ("len", cuint), ("timeout", cuint), ("data", POINTER(None))]
343class usbdevfs_setinterface(Struct):
344 pass
347usbdevfs_setinterface._fields_ = [("interface", cuint), ("altsetting", cuint)]
350class usbdevfs_disconnectsignal(Struct):
351 pass
354usbdevfs_disconnectsignal._fields_ = [("signr", cuint), ("context", POINTER(None))]
357class usbdevfs_getdriver(Struct):
358 pass
361usbdevfs_getdriver._fields_ = [("interface", cuint), ("driver", cchar * 256)]
364class usbdevfs_connectinfo(Struct):
365 pass
368usbdevfs_connectinfo._fields_ = [("devnum", cuint), ("slow", u8)]
371class usbdevfs_conninfo_ex(Struct):
372 pass
375usbdevfs_conninfo_ex._fields_ = [
376 ("size", cuint),
377 ("busnum", cuint),
378 ("devnum", cuint),
379 ("speed", cuint),
380 ("num_ports", u8),
381 ("ports", cchar * 7),
382]
385class usbdevfs_iso_packet_desc(Struct):
386 pass
389usbdevfs_iso_packet_desc._fields_ = [("length", cuint), ("actual_length", cuint), ("status", cuint)]
392class usbdevfs_urb(Struct):
393 class M1(Union):
394 pass
396 M1._fields_ = [("number_of_packets", cint), ("stream_id", cuint)]
398 _anonymous_ = ("m1",)
401usbdevfs_urb._fields_ = [
402 ("type", u8),
403 ("endpoint", u8),
404 ("status", cint),
405 ("flags", cuint),
406 ("buffer", POINTER(None)),
407 ("buffer_length", cint),
408 ("actual_length", cint),
409 ("start_frame", cint),
410 ("m1", usbdevfs_urb.M1),
411 ("error_count", cint),
412 ("signr", cuint),
413 ("usercontext", POINTER(None)),
414 ("iso_frame_desc", POINTER(usbdevfs_iso_packet_desc)),
415]
418class usbdevfs_ioctl(Struct):
419 pass
422usbdevfs_ioctl._fields_ = [("ifno", cint), ("ioctl_code", cint), ("data", POINTER(None))]
425class usbdevfs_hub_portinfo(Struct):
426 _pack_ = True
427 _layout_ = "ms"
430usbdevfs_hub_portinfo._fields_ = [("nports", cchar), ("port", cchar * 127)]
433class usbdevfs_disconnect_claim(Struct):
434 pass
437usbdevfs_disconnect_claim._fields_ = [("interface", cuint), ("flags", cuint), ("driver", cchar * 256)]
440class usbdevfs_streams(Struct):
441 pass
444usbdevfs_streams._fields_ = [("num_streams", cuint), ("num_eps", cuint), ("eps", POINTER(cchar))]
447class usb_ctrlrequest(Struct):
448 _pack_ = True
449 _layout_ = "ms"
452usb_ctrlrequest._fields_ = [("bRequestType", u8), ("bRequest", u8), ("wValue", u16), ("wIndex", u16), ("wLength", u16)]
455class usb_descriptor_header(Struct):
456 _pack_ = True
457 _layout_ = "ms"
460usb_descriptor_header._fields_ = [("bLength", u8), ("bDescriptorType", u8)]
463class usb_device_descriptor(Struct):
464 _pack_ = True
465 _layout_ = "ms"
468usb_device_descriptor._fields_ = [
469 ("bLength", u8),
470 ("bDescriptorType", u8),
471 ("bcdUSB", u16),
472 ("bDeviceClass", u8),
473 ("bDeviceSubClass", u8),
474 ("bDeviceProtocol", u8),
475 ("bMaxPacketSize0", u8),
476 ("idVendor", u16),
477 ("idProduct", u16),
478 ("bcdDevice", u16),
479 ("iManufacturer", u8),
480 ("iProduct", u8),
481 ("iSerialNumber", u8),
482 ("bNumConfigurations", u8),
483]
486class usb_config_descriptor(Struct):
487 _pack_ = True
488 _layout_ = "ms"
491usb_config_descriptor._fields_ = [
492 ("bLength", u8),
493 ("bDescriptorType", u8),
494 ("wTotalLength", u16),
495 ("bNumInterfaces", u8),
496 ("bConfigurationValue", u8),
497 ("iConfiguration", u8),
498 ("bmAttributes", u8),
499 ("bMaxPower", u8),
500]
503class usb_string_descriptor(Struct):
504 _pack_ = True
505 _layout_ = "ms"
507 class M1(Union):
508 class M1(Struct):
509 class M1(Struct):
510 _pack_ = True
511 _layout_ = "ms"
513 M1._fields_ = []
515 M1._fields_ = [("__empty_wData", M1.M1), ("wData", POINTER(u16))]
517 _anonymous_ = ("m1",)
519 M1._fields_ = [("legacy_padding", u16), ("m1", M1.M1)]
521 _anonymous_ = ("m1",)
524usb_string_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("m1", usb_string_descriptor.M1)]
527class usb_interface_descriptor(Struct):
528 _pack_ = True
529 _layout_ = "ms"
532usb_interface_descriptor._fields_ = [
533 ("bLength", u8),
534 ("bDescriptorType", u8),
535 ("bInterfaceNumber", u8),
536 ("bAlternateSetting", u8),
537 ("bNumEndpoints", u8),
538 ("bInterfaceClass", u8),
539 ("bInterfaceSubClass", u8),
540 ("bInterfaceProtocol", u8),
541 ("iInterface", u8),
542]
545class usb_endpoint_descriptor(Struct):
546 _pack_ = True
547 _layout_ = "ms"
550usb_endpoint_descriptor._fields_ = [
551 ("bLength", u8),
552 ("bDescriptorType", u8),
553 ("bEndpointAddress", u8),
554 ("bmAttributes", u8),
555 ("wMaxPacketSize", u16),
556 ("bInterval", u8),
557 ("bRefresh", u8),
558 ("bSynchAddress", u8),
559]
562class usb_ssp_isoc_ep_comp_descriptor(Struct):
563 _pack_ = True
564 _layout_ = "ms"
567usb_ssp_isoc_ep_comp_descriptor._fields_ = [
568 ("bLength", u8),
569 ("bDescriptorType", u8),
570 ("wReseved", u16),
571 ("dwBytesPerInterval", cuint),
572]
575class usb_ss_ep_comp_descriptor(Struct):
576 _pack_ = True
577 _layout_ = "ms"
580usb_ss_ep_comp_descriptor._fields_ = [
581 ("bLength", u8),
582 ("bDescriptorType", u8),
583 ("bMaxBurst", u8),
584 ("bmAttributes", u8),
585 ("wBytesPerInterval", u16),
586]
589class usb_qualifier_descriptor(Struct):
590 _pack_ = True
591 _layout_ = "ms"
594usb_qualifier_descriptor._fields_ = [
595 ("bLength", u8),
596 ("bDescriptorType", u8),
597 ("bcdUSB", u16),
598 ("bDeviceClass", u8),
599 ("bDeviceSubClass", u8),
600 ("bDeviceProtocol", u8),
601 ("bMaxPacketSize0", u8),
602 ("bNumConfigurations", u8),
603 ("bRESERVED", u8),
604]
607class usb_otg_descriptor(Struct):
608 _pack_ = True
609 _layout_ = "ms"
612usb_otg_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bmAttributes", u8)]
615class usb_otg20_descriptor(Struct):
616 _pack_ = True
617 _layout_ = "ms"
620usb_otg20_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bmAttributes", u8), ("bcdOTG", u16)]
623class usb_debug_descriptor(Struct):
624 _pack_ = True
625 _layout_ = "ms"
628usb_debug_descriptor._fields_ = [
629 ("bLength", u8),
630 ("bDescriptorType", u8),
631 ("bDebugInEndpoint", u8),
632 ("bDebugOutEndpoint", u8),
633]
636class usb_interface_assoc_descriptor(Struct):
637 _pack_ = True
638 _layout_ = "ms"
641usb_interface_assoc_descriptor._fields_ = [
642 ("bLength", u8),
643 ("bDescriptorType", u8),
644 ("bFirstInterface", u8),
645 ("bInterfaceCount", u8),
646 ("bFunctionClass", u8),
647 ("bFunctionSubClass", u8),
648 ("bFunctionProtocol", u8),
649 ("iFunction", u8),
650]
653class usb_security_descriptor(Struct):
654 _pack_ = True
655 _layout_ = "ms"
658usb_security_descriptor._fields_ = [
659 ("bLength", u8),
660 ("bDescriptorType", u8),
661 ("wTotalLength", u16),
662 ("bNumEncryptionTypes", u8),
663]
666class usb_key_descriptor(Struct):
667 _pack_ = True
668 _layout_ = "ms"
671usb_key_descriptor._fields_ = [
672 ("bLength", u8),
673 ("bDescriptorType", u8),
674 ("tTKID", cchar * 3),
675 ("bReserved", u8),
676 ("bKeyData", POINTER(cchar)),
677]
680class usb_encryption_descriptor(Struct):
681 _pack_ = True
682 _layout_ = "ms"
685usb_encryption_descriptor._fields_ = [
686 ("bLength", u8),
687 ("bDescriptorType", u8),
688 ("bEncryptionType", u8),
689 ("bEncryptionValue", u8),
690 ("bAuthKeyIndex", u8),
691]
694class usb_bos_descriptor(Struct):
695 _pack_ = True
696 _layout_ = "ms"
699usb_bos_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("wTotalLength", u16), ("bNumDeviceCaps", u8)]
702class usb_dev_cap_header(Struct):
703 _pack_ = True
704 _layout_ = "ms"
707usb_dev_cap_header._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bDevCapabilityType", u8)]
710class usb_wireless_cap_descriptor(Struct):
711 _pack_ = True
712 _layout_ = "ms"
715usb_wireless_cap_descriptor._fields_ = [
716 ("bLength", u8),
717 ("bDescriptorType", u8),
718 ("bDevCapabilityType", u8),
719 ("bmAttributes", u8),
720 ("wPHYRates", u16),
721 ("bmTFITXPowerInfo", u8),
722 ("bmFFITXPowerInfo", u8),
723 ("bmBandGroup", u16),
724 ("bReserved", u8),
725]
728class usb_ext_cap_descriptor(Struct):
729 _pack_ = True
730 _layout_ = "ms"
733usb_ext_cap_descriptor._fields_ = [
734 ("bLength", u8),
735 ("bDescriptorType", u8),
736 ("bDevCapabilityType", u8),
737 ("bmAttributes", cuint),
738]
741class usb_ss_cap_descriptor(Struct):
742 _pack_ = True
743 _layout_ = "ms"
746usb_ss_cap_descriptor._fields_ = [
747 ("bLength", u8),
748 ("bDescriptorType", u8),
749 ("bDevCapabilityType", u8),
750 ("bmAttributes", u8),
751 ("wSpeedSupported", u16),
752 ("bFunctionalitySupport", u8),
753 ("bU1devExitLat", u8),
754 ("bU2DevExitLat", u16),
755]
758class usb_ss_container_id_descriptor(Struct):
759 _pack_ = True
760 _layout_ = "ms"
763usb_ss_container_id_descriptor._fields_ = [
764 ("bLength", u8),
765 ("bDescriptorType", u8),
766 ("bDevCapabilityType", u8),
767 ("bReserved", u8),
768 ("ContainerID", cchar * 16),
769]
772class usb_plat_dev_cap_descriptor(Struct):
773 _pack_ = True
774 _layout_ = "ms"
777usb_plat_dev_cap_descriptor._fields_ = [
778 ("bLength", u8),
779 ("bDescriptorType", u8),
780 ("bDevCapabilityType", u8),
781 ("bReserved", u8),
782 ("UUID", cchar * 16),
783 ("CapabilityData", POINTER(cchar)),
784]
787class usb_ssp_cap_descriptor(Struct):
788 _pack_ = True
789 _layout_ = "ms"
791 class M1(Union):
792 class M1(Struct):
793 class M1(Struct):
794 _pack_ = True
795 _layout_ = "ms"
797 M1._fields_ = []
799 M1._fields_ = [("__empty_bmSublinkSpeedAttr", M1.M1), ("bmSublinkSpeedAttr", POINTER(cuint))]
801 _anonymous_ = ("m1",)
803 M1._fields_ = [("legacy_padding", cuint), ("m1", M1.M1)]
805 _anonymous_ = ("m1",)
808usb_ssp_cap_descriptor._fields_ = [
809 ("bLength", u8),
810 ("bDescriptorType", u8),
811 ("bDevCapabilityType", u8),
812 ("bReserved", u8),
813 ("bmAttributes", cuint),
814 ("wFunctionalitySupport", u16),
815 ("wReserved", u16),
816 ("m1", usb_ssp_cap_descriptor.M1),
817]
820class usb_pd_cap_descriptor(Struct):
821 _pack_ = True
822 _layout_ = "ms"
825usb_pd_cap_descriptor._fields_ = [
826 ("bLength", u8),
827 ("bDescriptorType", u8),
828 ("bDevCapabilityType", u8),
829 ("bReserved", u8),
830 ("bmAttributes", cuint),
831 ("bmProviderPorts", u16),
832 ("bmConsumerPorts", u16),
833 ("bcdBCVersion", u16),
834 ("bcdPDVersion", u16),
835 ("bcdUSBTypeCVersion", u16),
836]
839class usb_pd_cap_battery_info_descriptor(Struct):
840 _pack_ = True
841 _layout_ = "ms"
844usb_pd_cap_battery_info_descriptor._fields_ = [
845 ("bLength", u8),
846 ("bDescriptorType", u8),
847 ("bDevCapabilityType", u8),
848 ("iBattery", u8),
849 ("iSerial", u8),
850 ("iManufacturer", u8),
851 ("bBatteryId", u8),
852 ("bReserved", u8),
853 ("dwChargedThreshold", cuint),
854 ("dwWeakThreshold", cuint),
855 ("dwBatteryDesignCapacity", cuint),
856 ("dwBatteryLastFullchargeCapacity", cuint),
857]
860class usb_pd_cap_consumer_port_descriptor(Struct):
861 _pack_ = True
862 _layout_ = "ms"
865usb_pd_cap_consumer_port_descriptor._fields_ = [
866 ("bLength", u8),
867 ("bDescriptorType", u8),
868 ("bDevCapabilityType", u8),
869 ("bReserved", u8),
870 ("bmCapabilities", u8),
871 ("wMinVoltage", u16),
872 ("wMaxVoltage", u16),
873 ("wReserved", u16),
874 ("dwMaxOperatingPower", cuint),
875 ("dwMaxPeakPower", cuint),
876 ("dwMaxPeakPowerTime", cuint),
877]
880class usb_pd_cap_provider_port_descriptor(Struct):
881 _pack_ = True
882 _layout_ = "ms"
885usb_pd_cap_provider_port_descriptor._fields_ = [
886 ("bLength", u8),
887 ("bDescriptorType", u8),
888 ("bDevCapabilityType", u8),
889 ("bReserved1", u8),
890 ("bmCapabilities", u8),
891 ("bNumOfPDObjects", u8),
892 ("bReserved2", u8),
893 ("wPowerDataObject", POINTER(cuint)),
894]
897class usb_ptm_cap_descriptor(Struct):
898 _pack_ = True
899 _layout_ = "ms"
902usb_ptm_cap_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bDevCapabilityType", u8)]
905class usb_wireless_ep_comp_descriptor(Struct):
906 _pack_ = True
907 _layout_ = "ms"
910usb_wireless_ep_comp_descriptor._fields_ = [
911 ("bLength", u8),
912 ("bDescriptorType", u8),
913 ("bMaxBurst", u8),
914 ("bMaxSequence", u8),
915 ("wMaxStreamDelay", u16),
916 ("wOverTheAirPacketSize", u16),
917 ("bOverTheAirInterval", u8),
918 ("bmCompAttributes", u8),
919]
922class usb_handshake(Struct):
923 _pack_ = True
924 _layout_ = "ms"
927usb_handshake._fields_ = [
928 ("bMessageNumber", u8),
929 ("bStatus", u8),
930 ("tTKID", cchar * 3),
931 ("bReserved", u8),
932 ("CDID", cchar * 16),
933 ("nonce", cchar * 16),
934 ("MIC", cchar * 8),
935]
938class usb_connection_context(Struct):
939 _pack_ = True
940 _layout_ = "ms"
943usb_connection_context._fields_ = [("CHID", cchar * 16), ("CDID", cchar * 16), ("CK", cchar * 16)]
946class usb_set_sel_req(Struct):
947 _pack_ = True
948 _layout_ = "ms"
951usb_set_sel_req._fields_ = [("u1_sel", u8), ("u1_pel", u8), ("u2_sel", u16), ("u2_pel", u16)]
954class usb_port_status(Struct):
955 _pack_ = True
956 _layout_ = "ms"
959usb_port_status._fields_ = [("wPortStatus", u16), ("wPortChange", u16), ("dwExtPortStatus", cuint)]
962class usb_hub_status(Struct):
963 _pack_ = True
964 _layout_ = "ms"
967usb_hub_status._fields_ = [("wHubStatus", u16), ("wHubChange", u16)]
970class usb_hub_descriptor(Struct):
971 _pack_ = True
972 _layout_ = "ms"
974 class M1(Union):
975 _pack_ = True
976 _layout_ = "ms"
978 class M1(Struct):
979 _pack_ = True
980 _layout_ = "ms"
982 M1._fields_ = [("DeviceRemovable", cchar * 4), ("PortPwrCtrlMask", cchar * 4)]
984 class M2(Struct):
985 _pack_ = True
986 _layout_ = "ms"
988 M2._fields_ = [("bHubHdrDecLat", u8), ("wHubDelay", u16), ("DeviceRemovable", u16)]
990 M1._fields_ = [("hs", M1.M1), ("ss", M1.M2)]
993usb_hub_descriptor._fields_ = [
994 ("bDescLength", u8),
995 ("bDescriptorType", u8),
996 ("bNbrPorts", u8),
997 ("wHubCharacteristics", u16),
998 ("bPwrOn2PwrGood", u8),
999 ("bHubContrCurrent", u8),
1000 ("u", usb_hub_descriptor.M1),
1001]
1004class uvc_descriptor_header(Struct):
1005 _pack_ = True
1006 _layout_ = "ms"
1009uvc_descriptor_header._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bDescriptorSubType", u8)]
1012class uvc_header_descriptor(Struct):
1013 _pack_ = True
1014 _layout_ = "ms"
1017uvc_header_descriptor._fields_ = [
1018 ("bLength", u8),
1019 ("bDescriptorType", u8),
1020 ("bDescriptorSubType", u8),
1021 ("bcdUVC", u16),
1022 ("wTotalLength", u16),
1023 ("dwClockFrequency", cuint),
1024 ("bInCollection", u8),
1025 ("baInterfaceNr", POINTER(cchar)),
1026]
1029class uvc_input_terminal_descriptor(Struct):
1030 _pack_ = True
1031 _layout_ = "ms"
1034uvc_input_terminal_descriptor._fields_ = [
1035 ("bLength", u8),
1036 ("bDescriptorType", u8),
1037 ("bDescriptorSubType", u8),
1038 ("bTerminalID", u8),
1039 ("wTerminalType", u16),
1040 ("bAssocTerminal", u8),
1041 ("iTerminal", u8),
1042]
1045class uvc_output_terminal_descriptor(Struct):
1046 _pack_ = True
1047 _layout_ = "ms"
1050uvc_output_terminal_descriptor._fields_ = [
1051 ("bLength", u8),
1052 ("bDescriptorType", u8),
1053 ("bDescriptorSubType", u8),
1054 ("bTerminalID", u8),
1055 ("wTerminalType", u16),
1056 ("bAssocTerminal", u8),
1057 ("bSourceID", u8),
1058 ("iTerminal", u8),
1059]
1062class uvc_camera_terminal_descriptor(Struct):
1063 _pack_ = True
1064 _layout_ = "ms"
1067uvc_camera_terminal_descriptor._fields_ = [
1068 ("bLength", u8),
1069 ("bDescriptorType", u8),
1070 ("bDescriptorSubType", u8),
1071 ("bTerminalID", u8),
1072 ("wTerminalType", u16),
1073 ("bAssocTerminal", u8),
1074 ("iTerminal", u8),
1075 ("wObjectiveFocalLengthMin", u16),
1076 ("wObjectiveFocalLengthMax", u16),
1077 ("wOcularFocalLength", u16),
1078 ("bControlSize", u8),
1079 ("bmControls", cchar * 3),
1080]
1083class uvc_selector_unit_descriptor(Struct):
1084 _pack_ = True
1085 _layout_ = "ms"
1088uvc_selector_unit_descriptor._fields_ = [
1089 ("bLength", u8),
1090 ("bDescriptorType", u8),
1091 ("bDescriptorSubType", u8),
1092 ("bUnitID", u8),
1093 ("bNrInPins", u8),
1094 ("baSourceID", cchar * 0),
1095 ("iSelector", u8),
1096]
1099class uvc_processing_unit_descriptor(Struct):
1100 _pack_ = True
1101 _layout_ = "ms"
1104uvc_processing_unit_descriptor._fields_ = [
1105 ("bLength", u8),
1106 ("bDescriptorType", u8),
1107 ("bDescriptorSubType", u8),
1108 ("bUnitID", u8),
1109 ("bSourceID", u8),
1110 ("wMaxMultiplier", u16),
1111 ("bControlSize", u8),
1112 ("bmControls", cchar * 2),
1113 ("iProcessing", u8),
1114 ("bmVideoStandards", u8),
1115]
1118class uvc_extension_unit_descriptor(Struct):
1119 _pack_ = True
1120 _layout_ = "ms"
1123uvc_extension_unit_descriptor._fields_ = [
1124 ("bLength", u8),
1125 ("bDescriptorType", u8),
1126 ("bDescriptorSubType", u8),
1127 ("bUnitID", u8),
1128 ("guidExtensionCode", cchar * 16),
1129 ("bNumControls", u8),
1130 ("bNrInPins", u8),
1131 ("baSourceID", cchar * 0),
1132 ("bControlSize", u8),
1133 ("bmControls", cchar * 0),
1134 ("iExtension", u8),
1135]
1138class uvc_control_endpoint_descriptor(Struct):
1139 _pack_ = True
1140 _layout_ = "ms"
1143uvc_control_endpoint_descriptor._fields_ = [
1144 ("bLength", u8),
1145 ("bDescriptorType", u8),
1146 ("bDescriptorSubType", u8),
1147 ("wMaxTransferSize", u16),
1148]
1151class uvc_input_header_descriptor(Struct):
1152 _pack_ = True
1153 _layout_ = "ms"
1156uvc_input_header_descriptor._fields_ = [
1157 ("bLength", u8),
1158 ("bDescriptorType", u8),
1159 ("bDescriptorSubType", u8),
1160 ("bNumFormats", u8),
1161 ("wTotalLength", u16),
1162 ("bEndpointAddress", u8),
1163 ("bmInfo", u8),
1164 ("bTerminalLink", u8),
1165 ("bStillCaptureMethod", u8),
1166 ("bTriggerSupport", u8),
1167 ("bTriggerUsage", u8),
1168 ("bControlSize", u8),
1169 ("bmaControls", POINTER(cchar)),
1170]
1173class uvc_output_header_descriptor(Struct):
1174 _pack_ = True
1175 _layout_ = "ms"
1178uvc_output_header_descriptor._fields_ = [
1179 ("bLength", u8),
1180 ("bDescriptorType", u8),
1181 ("bDescriptorSubType", u8),
1182 ("bNumFormats", u8),
1183 ("wTotalLength", u16),
1184 ("bEndpointAddress", u8),
1185 ("bTerminalLink", u8),
1186 ("bControlSize", u8),
1187 ("bmaControls", POINTER(cchar)),
1188]
1191class uvc_color_matching_descriptor(Struct):
1192 _pack_ = True
1193 _layout_ = "ms"
1196uvc_color_matching_descriptor._fields_ = [
1197 ("bLength", u8),
1198 ("bDescriptorType", u8),
1199 ("bDescriptorSubType", u8),
1200 ("bColorPrimaries", u8),
1201 ("bTransferCharacteristics", u8),
1202 ("bMatrixCoefficients", u8),
1203]
1206class uvc_streaming_control(Struct):
1207 _pack_ = True
1208 _layout_ = "ms"
1211uvc_streaming_control._fields_ = [
1212 ("bmHint", u16),
1213 ("bFormatIndex", u8),
1214 ("bFrameIndex", u8),
1215 ("dwFrameInterval", cuint),
1216 ("wKeyFrameRate", u16),
1217 ("wPFrameRate", u16),
1218 ("wCompQuality", u16),
1219 ("wCompWindowSize", u16),
1220 ("wDelay", u16),
1221 ("dwMaxVideoFrameSize", cuint),
1222 ("dwMaxPayloadTransferSize", cuint),
1223 ("dwClockFrequency", cuint),
1224 ("bmFramingInfo", u8),
1225 ("bPreferedVersion", u8),
1226 ("bMinVersion", u8),
1227 ("bMaxVersion", u8),
1228]
1231class uvc_format_uncompressed(Struct):
1232 _pack_ = True
1233 _layout_ = "ms"
1236uvc_format_uncompressed._fields_ = [
1237 ("bLength", u8),
1238 ("bDescriptorType", u8),
1239 ("bDescriptorSubType", u8),
1240 ("bFormatIndex", u8),
1241 ("bNumFrameDescriptors", u8),
1242 ("guidFormat", cchar * 16),
1243 ("bBitsPerPixel", u8),
1244 ("bDefaultFrameIndex", u8),
1245 ("bAspectRatioX", u8),
1246 ("bAspectRatioY", u8),
1247 ("bmInterlaceFlags", u8),
1248 ("bCopyProtect", u8),
1249]
1252class uvc_frame_uncompressed(Struct):
1253 _pack_ = True
1254 _layout_ = "ms"
1257uvc_frame_uncompressed._fields_ = [
1258 ("bLength", u8),
1259 ("bDescriptorType", u8),
1260 ("bDescriptorSubType", u8),
1261 ("bFrameIndex", u8),
1262 ("bmCapabilities", u8),
1263 ("wWidth", u16),
1264 ("wHeight", u16),
1265 ("dwMinBitRate", cuint),
1266 ("dwMaxBitRate", cuint),
1267 ("dwMaxVideoFrameBufferSize", cuint),
1268 ("dwDefaultFrameInterval", cuint),
1269 ("bFrameIntervalType", u8),
1270 ("dwFrameInterval", POINTER(cuint)),
1271]
1274class uvc_format_mjpeg(Struct):
1275 _pack_ = True
1276 _layout_ = "ms"
1279uvc_format_mjpeg._fields_ = [
1280 ("bLength", u8),
1281 ("bDescriptorType", u8),
1282 ("bDescriptorSubType", u8),
1283 ("bFormatIndex", u8),
1284 ("bNumFrameDescriptors", u8),
1285 ("bmFlags", u8),
1286 ("bDefaultFrameIndex", u8),
1287 ("bAspectRatioX", u8),
1288 ("bAspectRatioY", u8),
1289 ("bmInterlaceFlags", u8),
1290 ("bCopyProtect", u8),
1291]
1294class uvc_frame_mjpeg(Struct):
1295 _pack_ = True
1296 _layout_ = "ms"
1299uvc_frame_mjpeg._fields_ = [
1300 ("bLength", u8),
1301 ("bDescriptorType", u8),
1302 ("bDescriptorSubType", u8),
1303 ("bFrameIndex", u8),
1304 ("bmCapabilities", u8),
1305 ("wWidth", u16),
1306 ("wHeight", u16),
1307 ("dwMinBitRate", cuint),
1308 ("dwMaxBitRate", cuint),
1309 ("dwMaxVideoFrameBufferSize", cuint),
1310 ("dwDefaultFrameInterval", cuint),
1311 ("bFrameIntervalType", u8),
1312 ("dwFrameInterval", POINTER(cuint)),
1313]
1316# Extra structs not found on header files
1319class usb_hid_descriptor(Struct):
1320 _fields_ = [
1321 ("bLength", u8),
1322 ("bDescriptorType", u8),
1323 ("bcdHID", u16),
1324 ("bCountryCode", u8),
1325 ("bNumDescriptors", u8),
1326 ("bClassDescriptorType", u8),
1327 ("wClassDescriptorLength", u16),
1328 ]
1331class IOC(enum.IntEnum):
1332 CONTROL = _IOWR("U", 0, usbdevfs_ctrltransfer)
1333 BULK = _IOWR("U", 2, usbdevfs_bulktransfer)
1334 RESETEP = _IOR("U", 3, cuint)
1335 SETINTERFACE = _IOR("U", 4, usbdevfs_setinterface)
1336 SETCONFIGURATION = _IOR("U", 5, cuint)
1337 GETDRIVER = _IOW("U", 8, usbdevfs_getdriver)
1338 SUBMITURB = _IOR("U", 10, usbdevfs_urb)
1339 DISCARDURB = _IO("U", 11)
1340 REAPURB = _IOW("U", 12, cvoidp)
1341 REAPURBNDELAY = _IOW("U", 13, cvoidp)
1342 DISCSIGNAL = _IOR("U", 14, usbdevfs_disconnectsignal)
1343 CLAIMINTERFACE = _IOR("U", 15, cuint)
1344 RELEASEINTERFACE = _IOR("U", 16, cuint)
1345 CONNECTINFO = _IOW("U", 17, usbdevfs_connectinfo)
1346 IOCTL = _IOWR("U", 18, usbdevfs_ioctl)
1347 HUB_PORTINFO = _IOR("U", 19, usbdevfs_hub_portinfo)
1348 RESET = _IO("U", 20)
1349 CLEAR_HALT = _IOR("U", 21, cuint)
1350 DISCONNECT = _IO("U", 22)
1351 CONNECT = _IO("U", 23)
1352 CLAIM_PORT = _IOR("U", 24, cuint)
1353 RELEASE_PORT = _IOR("U", 25, cuint)
1354 GET_CAPABILITIES = _IOR("U", 26, u32)
1355 DISCONNECT_CLAIM = _IOR("U", 27, usbdevfs_disconnect_claim)
1356 ALLOC_STREAMS = _IOR("U", 28, usbdevfs_streams)
1357 FREE_STREAMS = _IOR("U", 29, usbdevfs_streams)
1358 DROP_PRIVILEGES = _IOW("U", 30, u32)
1359 GET_SPEED = _IO("U", 31)
1360 FORBID_SUSPEND = _IO("U", 33)
1361 ALLOW_SUSPEND = _IO("U", 34)
1362 WAIT_FOR_RESUME = _IO("U", 35)