Coverage for linuxpy/usb/raw.py: 0%
507 statements
« prev ^ index » next coverage.py v7.6.8, created at 2025-05-27 13:54 +0200
« prev ^ index » next coverage.py v7.6.8, created at 2025-05-27 13:54 +0200
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
429usbdevfs_hub_portinfo._fields_ = [("nports", cchar), ("port", cchar * 127)]
432class usbdevfs_disconnect_claim(Struct):
433 pass
436usbdevfs_disconnect_claim._fields_ = [("interface", cuint), ("flags", cuint), ("driver", cchar * 256)]
439class usbdevfs_streams(Struct):
440 pass
443usbdevfs_streams._fields_ = [("num_streams", cuint), ("num_eps", cuint), ("eps", POINTER(cchar))]
446class usb_ctrlrequest(Struct):
447 _pack_ = True
450usb_ctrlrequest._fields_ = [("bRequestType", u8), ("bRequest", u8), ("wValue", u16), ("wIndex", u16), ("wLength", u16)]
453class usb_descriptor_header(Struct):
454 _pack_ = True
457usb_descriptor_header._fields_ = [("bLength", u8), ("bDescriptorType", u8)]
460class usb_device_descriptor(Struct):
461 _pack_ = True
464usb_device_descriptor._fields_ = [
465 ("bLength", u8),
466 ("bDescriptorType", u8),
467 ("bcdUSB", u16),
468 ("bDeviceClass", u8),
469 ("bDeviceSubClass", u8),
470 ("bDeviceProtocol", u8),
471 ("bMaxPacketSize0", u8),
472 ("idVendor", u16),
473 ("idProduct", u16),
474 ("bcdDevice", u16),
475 ("iManufacturer", u8),
476 ("iProduct", u8),
477 ("iSerialNumber", u8),
478 ("bNumConfigurations", u8),
479]
482class usb_config_descriptor(Struct):
483 _pack_ = True
486usb_config_descriptor._fields_ = [
487 ("bLength", u8),
488 ("bDescriptorType", u8),
489 ("wTotalLength", u16),
490 ("bNumInterfaces", u8),
491 ("bConfigurationValue", u8),
492 ("iConfiguration", u8),
493 ("bmAttributes", u8),
494 ("bMaxPower", u8),
495]
498class usb_string_descriptor(Struct):
499 _pack_ = True
501 class M1(Union):
502 class M1(Struct):
503 class M1(Struct):
504 _pack_ = True
506 M1._fields_ = []
508 M1._fields_ = [("__empty_wData", M1.M1), ("wData", POINTER(u16))]
510 _anonymous_ = ("m1",)
512 M1._fields_ = [("legacy_padding", u16), ("m1", M1.M1)]
514 _anonymous_ = ("m1",)
517usb_string_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("m1", usb_string_descriptor.M1)]
520class usb_interface_descriptor(Struct):
521 _pack_ = True
524usb_interface_descriptor._fields_ = [
525 ("bLength", u8),
526 ("bDescriptorType", u8),
527 ("bInterfaceNumber", u8),
528 ("bAlternateSetting", u8),
529 ("bNumEndpoints", u8),
530 ("bInterfaceClass", u8),
531 ("bInterfaceSubClass", u8),
532 ("bInterfaceProtocol", u8),
533 ("iInterface", u8),
534]
537class usb_endpoint_descriptor(Struct):
538 _pack_ = True
541usb_endpoint_descriptor._fields_ = [
542 ("bLength", u8),
543 ("bDescriptorType", u8),
544 ("bEndpointAddress", u8),
545 ("bmAttributes", u8),
546 ("wMaxPacketSize", u16),
547 ("bInterval", u8),
548 ("bRefresh", u8),
549 ("bSynchAddress", u8),
550]
553class usb_ssp_isoc_ep_comp_descriptor(Struct):
554 _pack_ = True
557usb_ssp_isoc_ep_comp_descriptor._fields_ = [
558 ("bLength", u8),
559 ("bDescriptorType", u8),
560 ("wReseved", u16),
561 ("dwBytesPerInterval", cuint),
562]
565class usb_ss_ep_comp_descriptor(Struct):
566 _pack_ = True
569usb_ss_ep_comp_descriptor._fields_ = [
570 ("bLength", u8),
571 ("bDescriptorType", u8),
572 ("bMaxBurst", u8),
573 ("bmAttributes", u8),
574 ("wBytesPerInterval", u16),
575]
578class usb_qualifier_descriptor(Struct):
579 _pack_ = True
582usb_qualifier_descriptor._fields_ = [
583 ("bLength", u8),
584 ("bDescriptorType", u8),
585 ("bcdUSB", u16),
586 ("bDeviceClass", u8),
587 ("bDeviceSubClass", u8),
588 ("bDeviceProtocol", u8),
589 ("bMaxPacketSize0", u8),
590 ("bNumConfigurations", u8),
591 ("bRESERVED", u8),
592]
595class usb_otg_descriptor(Struct):
596 _pack_ = True
599usb_otg_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bmAttributes", u8)]
602class usb_otg20_descriptor(Struct):
603 _pack_ = True
606usb_otg20_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bmAttributes", u8), ("bcdOTG", u16)]
609class usb_debug_descriptor(Struct):
610 _pack_ = True
613usb_debug_descriptor._fields_ = [
614 ("bLength", u8),
615 ("bDescriptorType", u8),
616 ("bDebugInEndpoint", u8),
617 ("bDebugOutEndpoint", u8),
618]
621class usb_interface_assoc_descriptor(Struct):
622 _pack_ = True
625usb_interface_assoc_descriptor._fields_ = [
626 ("bLength", u8),
627 ("bDescriptorType", u8),
628 ("bFirstInterface", u8),
629 ("bInterfaceCount", u8),
630 ("bFunctionClass", u8),
631 ("bFunctionSubClass", u8),
632 ("bFunctionProtocol", u8),
633 ("iFunction", u8),
634]
637class usb_security_descriptor(Struct):
638 _pack_ = True
641usb_security_descriptor._fields_ = [
642 ("bLength", u8),
643 ("bDescriptorType", u8),
644 ("wTotalLength", u16),
645 ("bNumEncryptionTypes", u8),
646]
649class usb_key_descriptor(Struct):
650 _pack_ = True
653usb_key_descriptor._fields_ = [
654 ("bLength", u8),
655 ("bDescriptorType", u8),
656 ("tTKID", cchar * 3),
657 ("bReserved", u8),
658 ("bKeyData", POINTER(cchar)),
659]
662class usb_encryption_descriptor(Struct):
663 _pack_ = True
666usb_encryption_descriptor._fields_ = [
667 ("bLength", u8),
668 ("bDescriptorType", u8),
669 ("bEncryptionType", u8),
670 ("bEncryptionValue", u8),
671 ("bAuthKeyIndex", u8),
672]
675class usb_bos_descriptor(Struct):
676 _pack_ = True
679usb_bos_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("wTotalLength", u16), ("bNumDeviceCaps", u8)]
682class usb_dev_cap_header(Struct):
683 _pack_ = True
686usb_dev_cap_header._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bDevCapabilityType", u8)]
689class usb_wireless_cap_descriptor(Struct):
690 _pack_ = True
693usb_wireless_cap_descriptor._fields_ = [
694 ("bLength", u8),
695 ("bDescriptorType", u8),
696 ("bDevCapabilityType", u8),
697 ("bmAttributes", u8),
698 ("wPHYRates", u16),
699 ("bmTFITXPowerInfo", u8),
700 ("bmFFITXPowerInfo", u8),
701 ("bmBandGroup", u16),
702 ("bReserved", u8),
703]
706class usb_ext_cap_descriptor(Struct):
707 _pack_ = True
710usb_ext_cap_descriptor._fields_ = [
711 ("bLength", u8),
712 ("bDescriptorType", u8),
713 ("bDevCapabilityType", u8),
714 ("bmAttributes", cuint),
715]
718class usb_ss_cap_descriptor(Struct):
719 _pack_ = True
722usb_ss_cap_descriptor._fields_ = [
723 ("bLength", u8),
724 ("bDescriptorType", u8),
725 ("bDevCapabilityType", u8),
726 ("bmAttributes", u8),
727 ("wSpeedSupported", u16),
728 ("bFunctionalitySupport", u8),
729 ("bU1devExitLat", u8),
730 ("bU2DevExitLat", u16),
731]
734class usb_ss_container_id_descriptor(Struct):
735 _pack_ = True
738usb_ss_container_id_descriptor._fields_ = [
739 ("bLength", u8),
740 ("bDescriptorType", u8),
741 ("bDevCapabilityType", u8),
742 ("bReserved", u8),
743 ("ContainerID", cchar * 16),
744]
747class usb_plat_dev_cap_descriptor(Struct):
748 _pack_ = True
751usb_plat_dev_cap_descriptor._fields_ = [
752 ("bLength", u8),
753 ("bDescriptorType", u8),
754 ("bDevCapabilityType", u8),
755 ("bReserved", u8),
756 ("UUID", cchar * 16),
757 ("CapabilityData", POINTER(cchar)),
758]
761class usb_ssp_cap_descriptor(Struct):
762 _pack_ = True
764 class M1(Union):
765 class M1(Struct):
766 class M1(Struct):
767 _pack_ = True
769 M1._fields_ = []
771 M1._fields_ = [("__empty_bmSublinkSpeedAttr", M1.M1), ("bmSublinkSpeedAttr", POINTER(cuint))]
773 _anonymous_ = ("m1",)
775 M1._fields_ = [("legacy_padding", cuint), ("m1", M1.M1)]
777 _anonymous_ = ("m1",)
780usb_ssp_cap_descriptor._fields_ = [
781 ("bLength", u8),
782 ("bDescriptorType", u8),
783 ("bDevCapabilityType", u8),
784 ("bReserved", u8),
785 ("bmAttributes", cuint),
786 ("wFunctionalitySupport", u16),
787 ("wReserved", u16),
788 ("m1", usb_ssp_cap_descriptor.M1),
789]
792class usb_pd_cap_descriptor(Struct):
793 _pack_ = True
796usb_pd_cap_descriptor._fields_ = [
797 ("bLength", u8),
798 ("bDescriptorType", u8),
799 ("bDevCapabilityType", u8),
800 ("bReserved", u8),
801 ("bmAttributes", cuint),
802 ("bmProviderPorts", u16),
803 ("bmConsumerPorts", u16),
804 ("bcdBCVersion", u16),
805 ("bcdPDVersion", u16),
806 ("bcdUSBTypeCVersion", u16),
807]
810class usb_pd_cap_battery_info_descriptor(Struct):
811 _pack_ = True
814usb_pd_cap_battery_info_descriptor._fields_ = [
815 ("bLength", u8),
816 ("bDescriptorType", u8),
817 ("bDevCapabilityType", u8),
818 ("iBattery", u8),
819 ("iSerial", u8),
820 ("iManufacturer", u8),
821 ("bBatteryId", u8),
822 ("bReserved", u8),
823 ("dwChargedThreshold", cuint),
824 ("dwWeakThreshold", cuint),
825 ("dwBatteryDesignCapacity", cuint),
826 ("dwBatteryLastFullchargeCapacity", cuint),
827]
830class usb_pd_cap_consumer_port_descriptor(Struct):
831 _pack_ = True
834usb_pd_cap_consumer_port_descriptor._fields_ = [
835 ("bLength", u8),
836 ("bDescriptorType", u8),
837 ("bDevCapabilityType", u8),
838 ("bReserved", u8),
839 ("bmCapabilities", u8),
840 ("wMinVoltage", u16),
841 ("wMaxVoltage", u16),
842 ("wReserved", u16),
843 ("dwMaxOperatingPower", cuint),
844 ("dwMaxPeakPower", cuint),
845 ("dwMaxPeakPowerTime", cuint),
846]
849class usb_pd_cap_provider_port_descriptor(Struct):
850 _pack_ = True
853usb_pd_cap_provider_port_descriptor._fields_ = [
854 ("bLength", u8),
855 ("bDescriptorType", u8),
856 ("bDevCapabilityType", u8),
857 ("bReserved1", u8),
858 ("bmCapabilities", u8),
859 ("bNumOfPDObjects", u8),
860 ("bReserved2", u8),
861 ("wPowerDataObject", POINTER(cuint)),
862]
865class usb_ptm_cap_descriptor(Struct):
866 _pack_ = True
869usb_ptm_cap_descriptor._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bDevCapabilityType", u8)]
872class usb_wireless_ep_comp_descriptor(Struct):
873 _pack_ = True
876usb_wireless_ep_comp_descriptor._fields_ = [
877 ("bLength", u8),
878 ("bDescriptorType", u8),
879 ("bMaxBurst", u8),
880 ("bMaxSequence", u8),
881 ("wMaxStreamDelay", u16),
882 ("wOverTheAirPacketSize", u16),
883 ("bOverTheAirInterval", u8),
884 ("bmCompAttributes", u8),
885]
888class usb_handshake(Struct):
889 _pack_ = True
892usb_handshake._fields_ = [
893 ("bMessageNumber", u8),
894 ("bStatus", u8),
895 ("tTKID", cchar * 3),
896 ("bReserved", u8),
897 ("CDID", cchar * 16),
898 ("nonce", cchar * 16),
899 ("MIC", cchar * 8),
900]
903class usb_connection_context(Struct):
904 _pack_ = True
907usb_connection_context._fields_ = [("CHID", cchar * 16), ("CDID", cchar * 16), ("CK", cchar * 16)]
910class usb_set_sel_req(Struct):
911 _pack_ = True
914usb_set_sel_req._fields_ = [("u1_sel", u8), ("u1_pel", u8), ("u2_sel", u16), ("u2_pel", u16)]
917class usb_port_status(Struct):
918 _pack_ = True
921usb_port_status._fields_ = [("wPortStatus", u16), ("wPortChange", u16), ("dwExtPortStatus", cuint)]
924class usb_hub_status(Struct):
925 _pack_ = True
928usb_hub_status._fields_ = [("wHubStatus", u16), ("wHubChange", u16)]
931class usb_hub_descriptor(Struct):
932 _pack_ = True
934 class M1(Union):
935 _pack_ = True
937 class M1(Struct):
938 _pack_ = True
940 M1._fields_ = [("DeviceRemovable", cchar * 4), ("PortPwrCtrlMask", cchar * 4)]
942 class M2(Struct):
943 _pack_ = True
945 M2._fields_ = [("bHubHdrDecLat", u8), ("wHubDelay", u16), ("DeviceRemovable", u16)]
947 M1._fields_ = [("hs", M1.M1), ("ss", M1.M2)]
950usb_hub_descriptor._fields_ = [
951 ("bDescLength", u8),
952 ("bDescriptorType", u8),
953 ("bNbrPorts", u8),
954 ("wHubCharacteristics", u16),
955 ("bPwrOn2PwrGood", u8),
956 ("bHubContrCurrent", u8),
957 ("u", usb_hub_descriptor.M1),
958]
961class uvc_descriptor_header(Struct):
962 _pack_ = True
965uvc_descriptor_header._fields_ = [("bLength", u8), ("bDescriptorType", u8), ("bDescriptorSubType", u8)]
968class uvc_header_descriptor(Struct):
969 _pack_ = True
972uvc_header_descriptor._fields_ = [
973 ("bLength", u8),
974 ("bDescriptorType", u8),
975 ("bDescriptorSubType", u8),
976 ("bcdUVC", u16),
977 ("wTotalLength", u16),
978 ("dwClockFrequency", cuint),
979 ("bInCollection", u8),
980 ("baInterfaceNr", POINTER(cchar)),
981]
984class uvc_input_terminal_descriptor(Struct):
985 _pack_ = True
988uvc_input_terminal_descriptor._fields_ = [
989 ("bLength", u8),
990 ("bDescriptorType", u8),
991 ("bDescriptorSubType", u8),
992 ("bTerminalID", u8),
993 ("wTerminalType", u16),
994 ("bAssocTerminal", u8),
995 ("iTerminal", u8),
996]
999class uvc_output_terminal_descriptor(Struct):
1000 _pack_ = True
1003uvc_output_terminal_descriptor._fields_ = [
1004 ("bLength", u8),
1005 ("bDescriptorType", u8),
1006 ("bDescriptorSubType", u8),
1007 ("bTerminalID", u8),
1008 ("wTerminalType", u16),
1009 ("bAssocTerminal", u8),
1010 ("bSourceID", u8),
1011 ("iTerminal", u8),
1012]
1015class uvc_camera_terminal_descriptor(Struct):
1016 _pack_ = True
1019uvc_camera_terminal_descriptor._fields_ = [
1020 ("bLength", u8),
1021 ("bDescriptorType", u8),
1022 ("bDescriptorSubType", u8),
1023 ("bTerminalID", u8),
1024 ("wTerminalType", u16),
1025 ("bAssocTerminal", u8),
1026 ("iTerminal", u8),
1027 ("wObjectiveFocalLengthMin", u16),
1028 ("wObjectiveFocalLengthMax", u16),
1029 ("wOcularFocalLength", u16),
1030 ("bControlSize", u8),
1031 ("bmControls", cchar * 3),
1032]
1035class uvc_selector_unit_descriptor(Struct):
1036 _pack_ = True
1039uvc_selector_unit_descriptor._fields_ = [
1040 ("bLength", u8),
1041 ("bDescriptorType", u8),
1042 ("bDescriptorSubType", u8),
1043 ("bUnitID", u8),
1044 ("bNrInPins", u8),
1045 ("baSourceID", cchar * 0),
1046 ("iSelector", u8),
1047]
1050class uvc_processing_unit_descriptor(Struct):
1051 _pack_ = True
1054uvc_processing_unit_descriptor._fields_ = [
1055 ("bLength", u8),
1056 ("bDescriptorType", u8),
1057 ("bDescriptorSubType", u8),
1058 ("bUnitID", u8),
1059 ("bSourceID", u8),
1060 ("wMaxMultiplier", u16),
1061 ("bControlSize", u8),
1062 ("bmControls", cchar * 2),
1063 ("iProcessing", u8),
1064 ("bmVideoStandards", u8),
1065]
1068class uvc_extension_unit_descriptor(Struct):
1069 _pack_ = True
1072uvc_extension_unit_descriptor._fields_ = [
1073 ("bLength", u8),
1074 ("bDescriptorType", u8),
1075 ("bDescriptorSubType", u8),
1076 ("bUnitID", u8),
1077 ("guidExtensionCode", cchar * 16),
1078 ("bNumControls", u8),
1079 ("bNrInPins", u8),
1080 ("baSourceID", cchar * 0),
1081 ("bControlSize", u8),
1082 ("bmControls", cchar * 0),
1083 ("iExtension", u8),
1084]
1087class uvc_control_endpoint_descriptor(Struct):
1088 _pack_ = True
1091uvc_control_endpoint_descriptor._fields_ = [
1092 ("bLength", u8),
1093 ("bDescriptorType", u8),
1094 ("bDescriptorSubType", u8),
1095 ("wMaxTransferSize", u16),
1096]
1099class uvc_input_header_descriptor(Struct):
1100 _pack_ = True
1103uvc_input_header_descriptor._fields_ = [
1104 ("bLength", u8),
1105 ("bDescriptorType", u8),
1106 ("bDescriptorSubType", u8),
1107 ("bNumFormats", u8),
1108 ("wTotalLength", u16),
1109 ("bEndpointAddress", u8),
1110 ("bmInfo", u8),
1111 ("bTerminalLink", u8),
1112 ("bStillCaptureMethod", u8),
1113 ("bTriggerSupport", u8),
1114 ("bTriggerUsage", u8),
1115 ("bControlSize", u8),
1116 ("bmaControls", POINTER(cchar)),
1117]
1120class uvc_output_header_descriptor(Struct):
1121 _pack_ = True
1124uvc_output_header_descriptor._fields_ = [
1125 ("bLength", u8),
1126 ("bDescriptorType", u8),
1127 ("bDescriptorSubType", u8),
1128 ("bNumFormats", u8),
1129 ("wTotalLength", u16),
1130 ("bEndpointAddress", u8),
1131 ("bTerminalLink", u8),
1132 ("bControlSize", u8),
1133 ("bmaControls", POINTER(cchar)),
1134]
1137class uvc_color_matching_descriptor(Struct):
1138 _pack_ = True
1141uvc_color_matching_descriptor._fields_ = [
1142 ("bLength", u8),
1143 ("bDescriptorType", u8),
1144 ("bDescriptorSubType", u8),
1145 ("bColorPrimaries", u8),
1146 ("bTransferCharacteristics", u8),
1147 ("bMatrixCoefficients", u8),
1148]
1151class uvc_streaming_control(Struct):
1152 _pack_ = True
1155uvc_streaming_control._fields_ = [
1156 ("bmHint", u16),
1157 ("bFormatIndex", u8),
1158 ("bFrameIndex", u8),
1159 ("dwFrameInterval", cuint),
1160 ("wKeyFrameRate", u16),
1161 ("wPFrameRate", u16),
1162 ("wCompQuality", u16),
1163 ("wCompWindowSize", u16),
1164 ("wDelay", u16),
1165 ("dwMaxVideoFrameSize", cuint),
1166 ("dwMaxPayloadTransferSize", cuint),
1167 ("dwClockFrequency", cuint),
1168 ("bmFramingInfo", u8),
1169 ("bPreferedVersion", u8),
1170 ("bMinVersion", u8),
1171 ("bMaxVersion", u8),
1172]
1175class uvc_format_uncompressed(Struct):
1176 _pack_ = True
1179uvc_format_uncompressed._fields_ = [
1180 ("bLength", u8),
1181 ("bDescriptorType", u8),
1182 ("bDescriptorSubType", u8),
1183 ("bFormatIndex", u8),
1184 ("bNumFrameDescriptors", u8),
1185 ("guidFormat", cchar * 16),
1186 ("bBitsPerPixel", u8),
1187 ("bDefaultFrameIndex", u8),
1188 ("bAspectRatioX", u8),
1189 ("bAspectRatioY", u8),
1190 ("bmInterlaceFlags", u8),
1191 ("bCopyProtect", u8),
1192]
1195class uvc_frame_uncompressed(Struct):
1196 _pack_ = True
1199uvc_frame_uncompressed._fields_ = [
1200 ("bLength", u8),
1201 ("bDescriptorType", u8),
1202 ("bDescriptorSubType", u8),
1203 ("bFrameIndex", u8),
1204 ("bmCapabilities", u8),
1205 ("wWidth", u16),
1206 ("wHeight", u16),
1207 ("dwMinBitRate", cuint),
1208 ("dwMaxBitRate", cuint),
1209 ("dwMaxVideoFrameBufferSize", cuint),
1210 ("dwDefaultFrameInterval", cuint),
1211 ("bFrameIntervalType", u8),
1212 ("dwFrameInterval", POINTER(cuint)),
1213]
1216class uvc_format_mjpeg(Struct):
1217 _pack_ = True
1220uvc_format_mjpeg._fields_ = [
1221 ("bLength", u8),
1222 ("bDescriptorType", u8),
1223 ("bDescriptorSubType", u8),
1224 ("bFormatIndex", u8),
1225 ("bNumFrameDescriptors", u8),
1226 ("bmFlags", u8),
1227 ("bDefaultFrameIndex", u8),
1228 ("bAspectRatioX", u8),
1229 ("bAspectRatioY", u8),
1230 ("bmInterlaceFlags", u8),
1231 ("bCopyProtect", u8),
1232]
1235class uvc_frame_mjpeg(Struct):
1236 _pack_ = True
1239uvc_frame_mjpeg._fields_ = [
1240 ("bLength", u8),
1241 ("bDescriptorType", u8),
1242 ("bDescriptorSubType", u8),
1243 ("bFrameIndex", u8),
1244 ("bmCapabilities", u8),
1245 ("wWidth", u16),
1246 ("wHeight", u16),
1247 ("dwMinBitRate", cuint),
1248 ("dwMaxBitRate", cuint),
1249 ("dwMaxVideoFrameBufferSize", cuint),
1250 ("dwDefaultFrameInterval", cuint),
1251 ("bFrameIntervalType", u8),
1252 ("dwFrameInterval", POINTER(cuint)),
1253]
1256# Extra structs not found on header files
1259class usb_hid_descriptor(Struct):
1260 _fields_ = [
1261 ("bLength", u8),
1262 ("bDescriptorType", u8),
1263 ("bcdHID", u16),
1264 ("bCountryCode", u8),
1265 ("bNumDescriptors", u8),
1266 ("bClassDescriptorType", u8),
1267 ("wClassDescriptorLength", u16),
1268 ]
1271class IOC(enum.IntEnum):
1272 CONTROL = _IOWR("U", 0, usbdevfs_ctrltransfer)
1273 BULK = _IOWR("U", 2, usbdevfs_bulktransfer)
1274 RESETEP = _IOR("U", 3, cuint)
1275 SETINTERFACE = _IOR("U", 4, usbdevfs_setinterface)
1276 SETCONFIGURATION = _IOR("U", 5, cuint)
1277 GETDRIVER = _IOW("U", 8, usbdevfs_getdriver)
1278 SUBMITURB = _IOR("U", 10, usbdevfs_urb)
1279 DISCARDURB = _IO("U", 11)
1280 REAPURB = _IOW("U", 12, cvoidp)
1281 REAPURBNDELAY = _IOW("U", 13, cvoidp)
1282 DISCSIGNAL = _IOR("U", 14, usbdevfs_disconnectsignal)
1283 CLAIMINTERFACE = _IOR("U", 15, cuint)
1284 RELEASEINTERFACE = _IOR("U", 16, cuint)
1285 CONNECTINFO = _IOW("U", 17, usbdevfs_connectinfo)
1286 IOCTL = _IOWR("U", 18, usbdevfs_ioctl)
1287 HUB_PORTINFO = _IOR("U", 19, usbdevfs_hub_portinfo)
1288 RESET = _IO("U", 20)
1289 CLEAR_HALT = _IOR("U", 21, cuint)
1290 DISCONNECT = _IO("U", 22)
1291 CONNECT = _IO("U", 23)
1292 CLAIM_PORT = _IOR("U", 24, cuint)
1293 RELEASE_PORT = _IOR("U", 25, cuint)
1294 GET_CAPABILITIES = _IOR("U", 26, u32)
1295 DISCONNECT_CLAIM = _IOR("U", 27, usbdevfs_disconnect_claim)
1296 ALLOC_STREAMS = _IOR("U", 28, usbdevfs_streams)
1297 FREE_STREAMS = _IOR("U", 29, usbdevfs_streams)
1298 DROP_PRIVILEGES = _IOW("U", 30, u32)
1299 GET_SPEED = _IO("U", 31)
1300 FORBID_SUSPEND = _IO("U", 33)
1301 ALLOW_SUSPEND = _IO("U", 34)
1302 WAIT_FOR_RESUME = _IO("U", 35)