libusb: libusb.h Source File

| libusb 1.0.27 A cross-platform user library to access USB devices

libusb.h
1/*
2 * Public libusb header file
3 * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
4 * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
5 * Copyright © 2012 Pete Batard <pete@akeo.ie>
6 * Copyright © 2012-2023 Nathan Hjelm <hjelmn@cs.unm.edu>
7 * Copyright © 2014-2020 Chris Dickens <christopher.a.dickens@gmail.com>
8 * For more information, please visit: https://libusb.info
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#ifndef LIBUSB_H
26#define LIBUSB_H
27
28#if defined(_MSC_VER)
29#pragma warning(push)
30/* Disable: warning C4200: nonstandard extension used : zero-sized array in struct/union */
31#pragma warning(disable:4200)
32/* on MS environments, the inline keyword is available in C++ only */
33#if !defined(__cplusplus)
34#define inline __inline
35#endif
36/* ssize_t is also not available */
37#ifndef _SSIZE_T_DEFINED
38#define _SSIZE_T_DEFINED
39#include <basetsd.h>
40typedef SSIZE_T ssize_t;
41#endif /* _SSIZE_T_DEFINED */
42#endif /* _MSC_VER */
43
44#include <limits.h>
45#include <stdint.h>
46#include <sys/types.h>
47#if !defined(_MSC_VER)
48#include <sys/time.h>
49#endif
50#include <time.h>
51
52#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
53#define LIBUSB_FLEXIBLE_ARRAY /* [] - valid C99 code */
54#else
55#define LIBUSB_FLEXIBLE_ARRAY 0 /* [0] - non-standard, but usually working code */
56#endif /* __STDC_VERSION__ */
57
58/* 'interface' might be defined as a macro on Windows, so we need to
59 * undefine it so as not to break the current libusb API, because
60 * libusb_config_descriptor has an 'interface' member
61 * As this can be problematic if you include windows.h after libusb.h
62 * in your sources, we force windows.h to be included first. */
63#if defined(_WIN32) || defined(__CYGWIN__)
64#include <windows.h>
65#if defined(interface)
66#undef interface
67#endif
68#if !defined(__CYGWIN__)
69#include <winsock.h>
70#endif
71#endif /* _WIN32 || __CYGWIN__ */
72
73#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
74#define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated ("Use " #f " instead")))
75#elif defined(__GNUC__) && (__GNUC__ >= 3)
76#define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated))
77#elif defined(_MSC_VER)
78#define LIBUSB_DEPRECATED_FOR(f) __declspec(deprecated("Use " #f " instead"))
79#else
80#define LIBUSB_DEPRECATED_FOR(f)
81#endif /* __GNUC__ */
82
83#if defined(__GNUC__)
84#define LIBUSB_PACKED __attribute__ ((packed))
85#else
86#define LIBUSB_PACKED
87#endif /* __GNUC__ */
88
114/* LIBUSB_CALL must be defined on both definition and declaration of libusb
115 * functions. You'd think that declaration would be enough, but cygwin will
116 * complain about conflicting types unless both are marked this way.
117 * The placement of this macro is important too; it must appear after the
118 * return type, before the function name. See internal documentation for
119 * API_EXPORTED.
120 */
121#if defined(_WIN32) || defined(__CYGWIN__)
122#define LIBUSB_CALL WINAPI
123#define LIBUSB_CALLV WINAPIV
124#else
125#define LIBUSB_CALL
126#define LIBUSB_CALLV
127#endif /* _WIN32 || __CYGWIN__ */
128
171#define LIBUSB_API_VERSION 0x0100010A
172
179#define LIBUSBX_API_VERSION LIBUSB_API_VERSION
180
181#if defined(__cplusplus)
182extern "C" {
183#endif
184
193 static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
194{
195 union {
196 uint8_t b8[2];
197 uint16_t b16;
198 } _tmp;
199 _tmp.b8[1] = (uint8_t) (x >> 8);
200 _tmp.b8[0] = (uint8_t) (x & 0xff);
201 return _tmp.b16;
202}
203
212#define libusb_le16_to_cpu libusb_cpu_to_le16
213
214/* standard USB stuff */
215
218 enum libusb_class_code {
223 LIBUSB_CLASS_PER_INTERFACE = 0x00,
224
226 LIBUSB_CLASS_AUDIO = 0x01,
227
229 LIBUSB_CLASS_COMM = 0x02,
230
232 LIBUSB_CLASS_HID = 0x03,
233
235 LIBUSB_CLASS_PHYSICAL = 0x05,
236
238 LIBUSB_CLASS_IMAGE = 0x06,
239 LIBUSB_CLASS_PTP = 0x06, /* legacy name from libusb-0.1 usb.h */
240
242 LIBUSB_CLASS_PRINTER = 0x07,
243
245 LIBUSB_CLASS_MASS_STORAGE = 0x08,
246
248 LIBUSB_CLASS_HUB = 0x09,
249
251 LIBUSB_CLASS_DATA = 0x0a,
252
254 LIBUSB_CLASS_SMART_CARD = 0x0b,
255
257 LIBUSB_CLASS_CONTENT_SECURITY = 0x0d,
258
260 LIBUSB_CLASS_VIDEO = 0x0e,
261
263 LIBUSB_CLASS_PERSONAL_HEALTHCARE = 0x0f,
264
266 LIBUSB_CLASS_DIAGNOSTIC_DEVICE = 0xdc,
267
269 LIBUSB_CLASS_WIRELESS = 0xe0,
270
272 LIBUSB_CLASS_MISCELLANEOUS = 0xef,
273
275 LIBUSB_CLASS_APPLICATION = 0xfe,
276
278 LIBUSB_CLASS_VENDOR_SPEC = 0xff
279};
280
283 enum libusb_descriptor_type {
285 LIBUSB_DT_DEVICE = 0x01,
286
288 LIBUSB_DT_CONFIG = 0x02,
289
291 LIBUSB_DT_STRING = 0x03,
292
294 LIBUSB_DT_INTERFACE = 0x04,
295
297 LIBUSB_DT_ENDPOINT = 0x05,
298
301 LIBUSB_DT_INTERFACE_ASSOCIATION = 0x0b,
302
304 LIBUSB_DT_BOS = 0x0f,
305
307 LIBUSB_DT_DEVICE_CAPABILITY = 0x10,
308
310 LIBUSB_DT_HID = 0x21,
311
313 LIBUSB_DT_REPORT = 0x22,
314
316 LIBUSB_DT_PHYSICAL = 0x23,
317
319 LIBUSB_DT_HUB = 0x29,
320
322 LIBUSB_DT_SUPERSPEED_HUB = 0x2a,
323
325 LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30
326};
327
328/* Descriptor sizes per descriptor type */
329#define LIBUSB_DT_DEVICE_SIZE 18
330#define LIBUSB_DT_CONFIG_SIZE 9
331#define LIBUSB_DT_INTERFACE_SIZE 9
332#define LIBUSB_DT_ENDPOINT_SIZE 7
333#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
334#define LIBUSB_DT_HUB_NONVAR_SIZE 7
335#define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6
336#define LIBUSB_DT_BOS_SIZE 5
337#define LIBUSB_DT_DEVICE_CAPABILITY_SIZE 3
338
339/* BOS descriptor sizes */
340#define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7
341#define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10
342#define LIBUSB_BT_CONTAINER_ID_SIZE 20
343#define LIBUSB_BT_PLATFORM_DESCRIPTOR_MIN_SIZE 20
344
345/* We unwrap the BOS => define its max size */
346#define LIBUSB_DT_BOS_MAX_SIZE \
347 (LIBUSB_DT_BOS_SIZE + \
348 LIBUSB_BT_USB_2_0_EXTENSION_SIZE + \
349 LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE + \
350 LIBUSB_BT_CONTAINER_ID_SIZE)
351
352#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
353#define LIBUSB_ENDPOINT_DIR_MASK 0x80
354
359 enum libusb_endpoint_direction {
361 LIBUSB_ENDPOINT_OUT = 0x00,
362
364 LIBUSB_ENDPOINT_IN = 0x80
365};
366
367#define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
368
373 enum libusb_endpoint_transfer_type {
375 LIBUSB_ENDPOINT_TRANSFER_TYPE_CONTROL = 0x0,
376
378 LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS = 0x1,
379
381 LIBUSB_ENDPOINT_TRANSFER_TYPE_BULK = 0x2,
382
384 LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT = 0x3
385};
386
389 enum libusb_standard_request {
391 LIBUSB_REQUEST_GET_STATUS = 0x00,
392
394 LIBUSB_REQUEST_CLEAR_FEATURE = 0x01,
395
396 /* 0x02 is reserved */
397
399 LIBUSB_REQUEST_SET_FEATURE = 0x03,
400
401 /* 0x04 is reserved */
402
404 LIBUSB_REQUEST_SET_ADDRESS = 0x05,
405
407 LIBUSB_REQUEST_GET_DESCRIPTOR = 0x06,
408
410 LIBUSB_REQUEST_SET_DESCRIPTOR = 0x07,
411
413 LIBUSB_REQUEST_GET_CONFIGURATION = 0x08,
414
416 LIBUSB_REQUEST_SET_CONFIGURATION = 0x09,
417
419 LIBUSB_REQUEST_GET_INTERFACE = 0x0a,
420
422 LIBUSB_REQUEST_SET_INTERFACE = 0x0b,
423
425 LIBUSB_REQUEST_SYNCH_FRAME = 0x0c,
426
428 LIBUSB_REQUEST_SET_SEL = 0x30,
429
432 LIBUSB_SET_ISOCH_DELAY = 0x31
433};
434
439 enum libusb_request_type {
441 LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5),
442
444 LIBUSB_REQUEST_TYPE_CLASS = (0x01 << 5),
445
447 LIBUSB_REQUEST_TYPE_VENDOR = (0x02 << 5),
448
450 LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5)
451};
452
457 enum libusb_request_recipient {
459 LIBUSB_RECIPIENT_DEVICE = 0x00,
460
462 LIBUSB_RECIPIENT_INTERFACE = 0x01,
463
465 LIBUSB_RECIPIENT_ENDPOINT = 0x02,
466
468 LIBUSB_RECIPIENT_OTHER = 0x03
469};
470
471#define LIBUSB_ISO_SYNC_TYPE_MASK 0x0c
472
478 enum libusb_iso_sync_type {
480 LIBUSB_ISO_SYNC_TYPE_NONE = 0x0,
481
483 LIBUSB_ISO_SYNC_TYPE_ASYNC = 0x1,
484
486 LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 0x2,
487
489 LIBUSB_ISO_SYNC_TYPE_SYNC = 0x3
490};
491
492#define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
493
499 enum libusb_iso_usage_type {
501 LIBUSB_ISO_USAGE_TYPE_DATA = 0x0,
502
504 LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 0x1,
505
507 LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 0x2
508};
509
514 enum libusb_supported_speed {
516 LIBUSB_LOW_SPEED_OPERATION = (1 << 0),
517
519 LIBUSB_FULL_SPEED_OPERATION = (1 << 1),
520
522 LIBUSB_HIGH_SPEED_OPERATION = (1 << 2),
523
525 LIBUSB_SUPER_SPEED_OPERATION = (1 << 3)
526};
527
533 enum libusb_usb_2_0_extension_attributes {
535 LIBUSB_BM_LPM_SUPPORT = (1 << 1)
536};
537
543 enum libusb_ss_usb_device_capability_attributes {
545 LIBUSB_BM_LTM_SUPPORT = (1 << 1)
546};
547
551 enum libusb_bos_type {
553 LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 0x01,
554
556 LIBUSB_BT_USB_2_0_EXTENSION = 0x02,
557
559 LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 0x03,
560
562 LIBUSB_BT_CONTAINER_ID = 0x04,
563
565 LIBUSB_BT_PLATFORM_DESCRIPTOR = 0x05
566};
567
573 struct libusb_device_descriptor {
575 uint8_t bLength;
576
580 uint8_t bDescriptorType;
581
584 uint16_t bcdUSB;
585
587 uint8_t bDeviceClass;
588
591 uint8_t bDeviceSubClass;
592
595 uint8_t bDeviceProtocol;
596
598 uint8_t bMaxPacketSize0;
599
601 uint16_t idVendor;
602
604 uint16_t idProduct;
605
607 uint16_t bcdDevice;
608
610 uint8_t iManufacturer;
611
613 uint8_t iProduct;
614
616 uint8_t iSerialNumber;
617
619 uint8_t bNumConfigurations;
620};
621
627 struct libusb_endpoint_descriptor {
629 uint8_t bLength;
630
634 uint8_t bDescriptorType;
635
639 uint8_t bEndpointAddress;
640
647 uint8_t bmAttributes;
648
650 uint16_t wMaxPacketSize;
651
653 uint8_t bInterval;
654
657 uint8_t bRefresh;
658
660 uint8_t bSynchAddress;
661
664 const unsigned char *extra;
665
667 int extra_length;
668};
669
675 struct libusb_interface_association_descriptor {
677 uint8_t bLength;
678
682 uint8_t bDescriptorType;
683
686 uint8_t bFirstInterface;
687
690 uint8_t bInterfaceCount;
691
697 uint8_t bFunctionClass;
698
703 uint8_t bFunctionSubClass;
704
709 uint8_t bFunctionProtocol;
710
712 uint8_t iFunction;
713};
714
719 struct libusb_interface_association_descriptor_array {
723 const struct libusb_interface_association_descriptor *iad;
724
726 int length;
727};
728
734 struct libusb_interface_descriptor {
736 uint8_t bLength;
737
741 uint8_t bDescriptorType;
742
744 uint8_t bInterfaceNumber;
745
747 uint8_t bAlternateSetting;
748
751 uint8_t bNumEndpoints;
752
754 uint8_t bInterfaceClass;
755
758 uint8_t bInterfaceSubClass;
759
762 uint8_t bInterfaceProtocol;
763
765 uint8_t iInterface;
766
769 const struct libusb_endpoint_descriptor *endpoint;
770
773 const unsigned char *extra;
774
776 int extra_length;
777};
778
782 struct libusb_interface {
785 const struct libusb_interface_descriptor *altsetting;
786
789 int num_altsetting;
790};
791
797 struct libusb_config_descriptor {
799 uint8_t bLength;
800
804 uint8_t bDescriptorType;
805
807 uint16_t wTotalLength;
808
810 uint8_t bNumInterfaces;
811
813 uint8_t bConfigurationValue;
814
816 uint8_t iConfiguration;
817
819 uint8_t bmAttributes;
820
825 uint8_t MaxPower;
826
829 const struct libusb_interface *interface;
830
833 const unsigned char *extra;
834
836 int extra_length;
837};
838
845 struct libusb_ss_endpoint_companion_descriptor {
847 uint8_t bLength;
848
852 uint8_t bDescriptorType;
853
856 uint8_t bMaxBurst;
857
862 uint8_t bmAttributes;
863
866 uint16_t wBytesPerInterval;
867};
868
874 struct libusb_bos_dev_capability_descriptor {
876 uint8_t bLength;
877
881 uint8_t bDescriptorType;
882
884 uint8_t bDevCapabilityType;
885
887 uint8_t dev_capability_data[LIBUSB_FLEXIBLE_ARRAY];
888};
889
895 struct libusb_bos_descriptor {
897 uint8_t bLength;
898
902 uint8_t bDescriptorType;
903
905 uint16_t wTotalLength;
906
909 uint8_t bNumDeviceCaps;
910
912 struct libusb_bos_dev_capability_descriptor *dev_capability[LIBUSB_FLEXIBLE_ARRAY];
913};
914
920 struct libusb_usb_2_0_extension_descriptor {
922 uint8_t bLength;
923
927 uint8_t bDescriptorType;
928
932 uint8_t bDevCapabilityType;
933
938 uint32_t bmAttributes;
939};
940
946 struct libusb_ss_usb_device_capability_descriptor {
948 uint8_t bLength;
949
953 uint8_t bDescriptorType;
954
958 uint8_t bDevCapabilityType;
959
964 uint8_t bmAttributes;
965
968 uint16_t wSpeedSupported;
969
974 uint8_t bFunctionalitySupport;
975
977 uint8_t bU1DevExitLat;
978
980 uint16_t bU2DevExitLat;
981};
982
988 struct libusb_container_id_descriptor {
990 uint8_t bLength;
991
995 uint8_t bDescriptorType;
996
1000 uint8_t bDevCapabilityType;
1001
1003 uint8_t bReserved;
1004
1006 uint8_t ContainerID[16];
1007};
1008
1013 struct libusb_platform_descriptor {
1015 uint8_t bLength;
1016
1020 uint8_t bDescriptorType;
1021
1025 uint8_t bDevCapabilityType;
1026
1028 uint8_t bReserved;
1029
1031 uint8_t PlatformCapabilityUUID[16];
1032
1034 uint8_t CapabilityData[LIBUSB_FLEXIBLE_ARRAY];
1035};
1036
1039#if defined(_MSC_VER) || defined(__WATCOMC__)
1040#pragma pack(push, 1)
1041#endif
1042 struct libusb_control_setup {
1048 uint8_t bmRequestType;
1049
1055 uint8_t bRequest;
1056
1058 uint16_t wValue;
1059
1062 uint16_t wIndex;
1063
1065 uint16_t wLength;
1066} LIBUSB_PACKED;
1067#if defined(_MSC_VER) || defined(__WATCOMC__)
1068#pragma pack(pop)
1069#endif
1070
1071#define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
1072
1073/* libusb */
1074
1075struct libusb_context;
1076struct libusb_device;
1077struct libusb_device_handle;
1078
1082 struct libusb_version {
1084 const uint16_t major;
1085
1087 const uint16_t minor;
1088
1090 const uint16_t micro;
1091
1093 const uint16_t nano;
1094
1096 const char *rc;
1097
1099 const char *describe;
1100};
1101
1120 typedef struct libusb_context libusb_context;
1121
1137 typedef struct libusb_device libusb_device;
1138
1139
1148 typedef struct libusb_device_handle libusb_device_handle;
1149
1153 enum libusb_speed {
1155 LIBUSB_SPEED_UNKNOWN = 0,
1156
1158 LIBUSB_SPEED_LOW = 1,
1159
1161 LIBUSB_SPEED_FULL = 2,
1162
1164 LIBUSB_SPEED_HIGH = 3,
1165
1167 LIBUSB_SPEED_SUPER = 4,
1168
1170 LIBUSB_SPEED_SUPER_PLUS = 5
1171};
1172
1180 enum libusb_error {
1182 LIBUSB_SUCCESS = 0,
1183
1185 LIBUSB_ERROR_IO = -1,
1186
1188 LIBUSB_ERROR_INVALID_PARAM = -2,
1189
1191 LIBUSB_ERROR_ACCESS = -3,
1192
1194 LIBUSB_ERROR_NO_DEVICE = -4,
1195
1197 LIBUSB_ERROR_NOT_FOUND = -5,
1198
1200 LIBUSB_ERROR_BUSY = -6,
1201
1203 LIBUSB_ERROR_TIMEOUT = -7,
1204
1206 LIBUSB_ERROR_OVERFLOW = -8,
1207
1209 LIBUSB_ERROR_PIPE = -9,
1210
1212 LIBUSB_ERROR_INTERRUPTED = -10,
1213
1215 LIBUSB_ERROR_NO_MEM = -11,
1216
1218 LIBUSB_ERROR_NOT_SUPPORTED = -12,
1219
1220 /* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
1221 message strings in strerror.c when adding new error codes here. */
1222
1224 LIBUSB_ERROR_OTHER = -99
1225};
1226
1227/* Total number of error codes in enum libusb_error */
1228#define LIBUSB_ERROR_COUNT 14
1229
1232 enum libusb_transfer_type {
1234 LIBUSB_TRANSFER_TYPE_CONTROL = 0U,
1235
1237 LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1U,
1238
1240 LIBUSB_TRANSFER_TYPE_BULK = 2U,
1241
1243 LIBUSB_TRANSFER_TYPE_INTERRUPT = 3U,
1244
1246 LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4U
1247};
1248
1251 enum libusb_transfer_status {
1254 LIBUSB_TRANSFER_COMPLETED,
1255
1257 LIBUSB_TRANSFER_ERROR,
1258
1260 LIBUSB_TRANSFER_TIMED_OUT,
1261
1263 LIBUSB_TRANSFER_CANCELLED,
1264
1267 LIBUSB_TRANSFER_STALL,
1268
1270 LIBUSB_TRANSFER_NO_DEVICE,
1271
1273 LIBUSB_TRANSFER_OVERFLOW
1274
1275 /* NB! Remember to update libusb_error_name()
1276 when adding new status codes here. */
1277};
1278
1281 enum libusb_transfer_flags {
1283 LIBUSB_TRANSFER_SHORT_NOT_OK = (1U << 0),
1284
1289 LIBUSB_TRANSFER_FREE_BUFFER = (1U << 1),
1290
1295 LIBUSB_TRANSFER_FREE_TRANSFER = (1U << 2),
1296
1321 LIBUSB_TRANSFER_ADD_ZERO_PACKET = (1U << 3)
1322};
1323
1326 struct libusb_iso_packet_descriptor {
1328 unsigned int length;
1329
1331 unsigned int actual_length;
1332
1334 enum libusb_transfer_status status;
1335};
1336
1337struct libusb_transfer;
1338
1348 typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
1349
1356 struct libusb_transfer {
1358 libusb_device_handle *dev_handle;
1359
1361 uint8_t flags;
1362
1364 unsigned char endpoint;
1365
1367 unsigned char type;
1368
1371 unsigned int timeout;
1372
1380 enum libusb_transfer_status status;
1381
1383 int length;
1384
1388 int actual_length;
1389
1392 libusb_transfer_cb_fn callback;
1393
1404 void *user_data;
1405
1407 unsigned char *buffer;
1408
1411 int num_iso_packets;
1412
1414 struct libusb_iso_packet_descriptor iso_packet_desc[LIBUSB_FLEXIBLE_ARRAY];
1415};
1416
1422 enum libusb_capability {
1424 LIBUSB_CAP_HAS_CAPABILITY = 0x0000U,
1425
1427 LIBUSB_CAP_HAS_HOTPLUG = 0x0001U,
1428
1433 LIBUSB_CAP_HAS_HID_ACCESS = 0x0100U,
1434
1437 LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101U
1438};
1439
1443 enum libusb_log_level {
1445 LIBUSB_LOG_LEVEL_NONE = 0,
1446
1448 LIBUSB_LOG_LEVEL_ERROR = 1,
1449
1451 LIBUSB_LOG_LEVEL_WARNING = 2,
1452
1454 LIBUSB_LOG_LEVEL_INFO = 3,
1455
1457 LIBUSB_LOG_LEVEL_DEBUG = 4
1458};
1459
1467 enum libusb_log_cb_mode {
1469 LIBUSB_LOG_CB_GLOBAL = (1 << 0),
1470
1472 LIBUSB_LOG_CB_CONTEXT = (1 << 1)
1473};
1474
1478 enum libusb_option {
1501 LIBUSB_OPTION_LOG_LEVEL = 0,
1502
1510 LIBUSB_OPTION_USE_USBDK = 1,
1511
1530 LIBUSB_OPTION_NO_DEVICE_DISCOVERY = 2,
1531
1532#define LIBUSB_OPTION_WEAK_AUTHORITY LIBUSB_OPTION_NO_DEVICE_DISCOVERY
1533
1543 LIBUSB_OPTION_LOG_CB = 3,
1544
1545 LIBUSB_OPTION_MAX = 4
1546};
1547
1559 typedef void (LIBUSB_CALL *libusb_log_cb)(libusb_context *ctx,
1560 enum libusb_log_level level, const char *str);
1561
1566 struct libusb_init_option {
1568 enum libusb_option option;
1570 union {
1571 int ival;
1572 libusb_log_cb log_cbval;
1573 } value;
1574};
1575
1576int LIBUSB_CALL libusb_init(libusb_context **ctx);
1577int LIBUSB_CALL libusb_init_context(libusb_context **ctx, const struct libusb_init_option options[], int num_options);
1578void LIBUSB_CALL libusb_exit(libusb_context *ctx);
1579void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
1580/* may be deprecated in the future in favor of lubusb_init_context()+libusb_set_option() */
1581void LIBUSB_CALL libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode);
1582const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
1583int LIBUSB_CALL libusb_has_capability(uint32_t capability);
1584const char * LIBUSB_CALL libusb_error_name(int errcode);
1585int LIBUSB_CALL libusb_setlocale(const char *locale);
1586const char * LIBUSB_CALL libusb_strerror(int errcode);
1587
1588ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
1589 libusb_device ***list);
1590void LIBUSB_CALL libusb_free_device_list(libusb_device **list,
1591 int unref_devices);
1592 libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev);
1593void LIBUSB_CALL libusb_unref_device(libusb_device *dev);
1594
1595int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev,
1596 int *config);
1597int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev,
1598 struct libusb_device_descriptor *desc);
1599int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev,
1600 struct libusb_config_descriptor **config);
1601int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev,
1602 uint8_t config_index, struct libusb_config_descriptor **config);
1603int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev,
1604 uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
1605void LIBUSB_CALL libusb_free_config_descriptor(
1606 struct libusb_config_descriptor *config);
1607int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor(
1608 libusb_context *ctx,
1609 const struct libusb_endpoint_descriptor *endpoint,
1610 struct libusb_ss_endpoint_companion_descriptor **ep_comp);
1611void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor(
1612 struct libusb_ss_endpoint_companion_descriptor *ep_comp);
1613int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
1614 struct libusb_bos_descriptor **bos);
1615void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
1616int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor(
1617 libusb_context *ctx,
1618 struct libusb_bos_dev_capability_descriptor *dev_cap,
1619 struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
1620void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor(
1621 struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
1622int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor(
1623 libusb_context *ctx,
1624 struct libusb_bos_dev_capability_descriptor *dev_cap,
1625 struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
1626void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor(
1627 struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
1628int LIBUSB_CALL libusb_get_container_id_descriptor(libusb_context *ctx,
1629 struct libusb_bos_dev_capability_descriptor *dev_cap,
1630 struct libusb_container_id_descriptor **container_id);
1631void LIBUSB_CALL libusb_free_container_id_descriptor(
1632 struct libusb_container_id_descriptor *container_id);
1633int LIBUSB_CALL libusb_get_platform_descriptor(libusb_context *ctx,
1634 struct libusb_bos_dev_capability_descriptor *dev_cap,
1635 struct libusb_platform_descriptor **platform_descriptor);
1636void LIBUSB_CALL libusb_free_platform_descriptor(
1637 struct libusb_platform_descriptor *platform_descriptor);
1638uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
1639uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
1640int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len);
1641LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
1642int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *path, uint8_t path_length);
1643 libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev);
1644uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
1645int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
1646int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
1647 unsigned char endpoint);
1648int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
1649 unsigned char endpoint);
1650int LIBUSB_CALL libusb_get_max_alt_packet_size(libusb_device *dev,
1651 int interface_number, int alternate_setting, unsigned char endpoint);
1652
1653int LIBUSB_CALL libusb_get_interface_association_descriptors(libusb_device *dev,
1654 uint8_t config_index, struct libusb_interface_association_descriptor_array **iad_array);
1655int LIBUSB_CALL libusb_get_active_interface_association_descriptors(libusb_device *dev,
1656 struct libusb_interface_association_descriptor_array **iad_array);
1657void LIBUSB_CALL libusb_free_interface_association_descriptors(
1658 struct libusb_interface_association_descriptor_array *iad_array);
1659
1660int LIBUSB_CALL libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle);
1661int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **dev_handle);
1662void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle);
1663 libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle);
1664
1665int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev_handle,
1666 int configuration);
1667int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev_handle,
1668 int interface_number);
1669int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev_handle,
1670 int interface_number);
1671
1672 libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
1673 libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
1674
1675int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev_handle,
1676 int interface_number, int alternate_setting);
1677int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev_handle,
1678 unsigned char endpoint);
1679int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev_handle);
1680
1681int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev_handle,
1682 uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
1683int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev_handle,
1684 unsigned char *endpoints, int num_endpoints);
1685
1686unsigned char * LIBUSB_CALL libusb_dev_mem_alloc(libusb_device_handle *dev_handle,
1687 size_t length);
1688int LIBUSB_CALL libusb_dev_mem_free(libusb_device_handle *dev_handle,
1689 unsigned char *buffer, size_t length);
1690
1691int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev_handle,
1692 int interface_number);
1693int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev_handle,
1694 int interface_number);
1695int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev_handle,
1696 int interface_number);
1697int LIBUSB_CALL libusb_set_auto_detach_kernel_driver(
1698 libusb_device_handle *dev_handle, int enable);
1699
1700/* async I/O */
1701
1714 static inline unsigned char *libusb_control_transfer_get_data(
1715 struct libusb_transfer *transfer)
1716{
1717 return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
1718}
1719
1732 static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
1733 struct libusb_transfer *transfer)
1734{
1735 return (struct libusb_control_setup *)(void *)transfer->buffer;
1736}
1737
1761 static inline void libusb_fill_control_setup(unsigned char *buffer,
1762 uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
1763 uint16_t wLength)
1764{
1765 struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *)buffer;
1766 setup->bmRequestType = bmRequestType;
1767 setup->bRequest = bRequest;
1768 setup->wValue = libusb_cpu_to_le16(wValue);
1769 setup->wIndex = libusb_cpu_to_le16(wIndex);
1770 setup->wLength = libusb_cpu_to_le16(wLength);
1771}
1772
1773struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
1774int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
1775int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
1776void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
1777void LIBUSB_CALL libusb_transfer_set_stream_id(
1778 struct libusb_transfer *transfer, uint32_t stream_id);
1779uint32_t LIBUSB_CALL libusb_transfer_get_stream_id(
1780 struct libusb_transfer *transfer);
1781
1810 static inline void libusb_fill_control_transfer(
1811 struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1812 unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
1813 unsigned int timeout)
1814{
1815 struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *)buffer;
1816 transfer->dev_handle = dev_handle;
1817 transfer->endpoint = 0;
1818 transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
1819 transfer->timeout = timeout;
1820 transfer->buffer = buffer;
1821 if (setup)
1822 transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE
1823 + libusb_le16_to_cpu(setup->wLength));
1824 transfer->user_data = user_data;
1825 transfer->callback = callback;
1826}
1827
1841 static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
1842 libusb_device_handle *dev_handle, unsigned char endpoint,
1843 unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
1844 void *user_data, unsigned int timeout)
1845{
1846 transfer->dev_handle = dev_handle;
1847 transfer->endpoint = endpoint;
1848 transfer->type = LIBUSB_TRANSFER_TYPE_BULK;
1849 transfer->timeout = timeout;
1850 transfer->buffer = buffer;
1851 transfer->length = length;
1852 transfer->user_data = user_data;
1853 transfer->callback = callback;
1854}
1855
1872 static inline void libusb_fill_bulk_stream_transfer(
1873 struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1874 unsigned char endpoint, uint32_t stream_id,
1875 unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
1876 void *user_data, unsigned int timeout)
1877{
1878 libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
1879 length, callback, user_data, timeout);
1880 transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
1881 libusb_transfer_set_stream_id(transfer, stream_id);
1882}
1883
1897 static inline void libusb_fill_interrupt_transfer(
1898 struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1899 unsigned char endpoint, unsigned char *buffer, int length,
1900 libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
1901{
1902 transfer->dev_handle = dev_handle;
1903 transfer->endpoint = endpoint;
1904 transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT;
1905 transfer->timeout = timeout;
1906 transfer->buffer = buffer;
1907 transfer->length = length;
1908 transfer->user_data = user_data;
1909 transfer->callback = callback;
1910}
1911
1926 static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer,
1927 libusb_device_handle *dev_handle, unsigned char endpoint,
1928 unsigned char *buffer, int length, int num_iso_packets,
1929 libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
1930{
1931 transfer->dev_handle = dev_handle;
1932 transfer->endpoint = endpoint;
1933 transfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS;
1934 transfer->timeout = timeout;
1935 transfer->buffer = buffer;
1936 transfer->length = length;
1937 transfer->num_iso_packets = num_iso_packets;
1938 transfer->user_data = user_data;
1939 transfer->callback = callback;
1940}
1941
1950 static inline void libusb_set_iso_packet_lengths(
1951 struct libusb_transfer *transfer, unsigned int length)
1952{
1953 int i;
1954
1955 for (i = 0; i < transfer->num_iso_packets; i++)
1956 transfer->iso_packet_desc[i].length = length;
1957}
1958
1975 static inline unsigned char *libusb_get_iso_packet_buffer(
1976 struct libusb_transfer *transfer, unsigned int packet)
1977{
1978 int i;
1979 size_t offset = 0;
1980 int _packet;
1981
1982 /* oops..slight bug in the API. packet is an unsigned int, but we use
1983 * signed integers almost everywhere else. range-check and convert to
1984 * signed to avoid compiler warnings. FIXME for libusb-2. */
1985 if (packet > INT_MAX)
1986 return NULL;
1987 _packet = (int) packet;
1988
1989 if (_packet >= transfer->num_iso_packets)
1990 return NULL;
1991
1992 for (i = 0; i < _packet; i++)
1993 offset += transfer->iso_packet_desc[i].length;
1994
1995 return transfer->buffer + offset;
1996}
1997
2017 static inline unsigned char *libusb_get_iso_packet_buffer_simple(
2018 struct libusb_transfer *transfer, unsigned int packet)
2019{
2020 int _packet;
2021
2022 /* oops..slight bug in the API. packet is an unsigned int, but we use
2023 * signed integers almost everywhere else. range-check and convert to
2024 * signed to avoid compiler warnings. FIXME for libusb-2. */
2025 if (packet > INT_MAX)
2026 return NULL;
2027 _packet = (int) packet;
2028
2029 if (_packet >= transfer->num_iso_packets)
2030 return NULL;
2031
2032 return transfer->buffer + ((int) transfer->iso_packet_desc[0].length * _packet);
2033}
2034
2035/* sync I/O */
2036
2037int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle,
2038 uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
2039 unsigned char *data, uint16_t wLength, unsigned int timeout);
2040
2041int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle,
2042 unsigned char endpoint, unsigned char *data, int length,
2043 int *actual_length, unsigned int timeout);
2044
2045int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle,
2046 unsigned char endpoint, unsigned char *data, int length,
2047 int *actual_length, unsigned int timeout);
2048
2061 static inline int libusb_get_descriptor(libusb_device_handle *dev_handle,
2062 uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
2063{
2064 return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
2065 LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | desc_index),
2066 0, data, (uint16_t) length, 1000);
2067}
2068
2083 static inline int libusb_get_string_descriptor(libusb_device_handle *dev_handle,
2084 uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
2085{
2086 return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
2087 LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t)((LIBUSB_DT_STRING << 8) | desc_index),
2088 langid, data, (uint16_t) length, 1000);
2089}
2090
2091int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle,
2092 uint8_t desc_index, unsigned char *data, int length);
2093
2094/* polling and timeouts */
2095
2096int LIBUSB_CALL libusb_try_lock_events(libusb_context *ctx);
2097void LIBUSB_CALL libusb_lock_events(libusb_context *ctx);
2098void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx);
2099int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx);
2100int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx);
2101void LIBUSB_CALL libusb_interrupt_event_handler(libusb_context *ctx);
2102void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx);
2103void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx);
2104int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
2105
2106int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx,
2107 struct timeval *tv);
2108int LIBUSB_CALL libusb_handle_events_timeout_completed(libusb_context *ctx,
2109 struct timeval *tv, int *completed);
2110int LIBUSB_CALL libusb_handle_events(libusb_context *ctx);
2111int LIBUSB_CALL libusb_handle_events_completed(libusb_context *ctx, int *completed);
2112int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx,
2113 struct timeval *tv);
2114int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);
2115int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx,
2116 struct timeval *tv);
2117
2121 struct libusb_pollfd {
2123 int fd;
2124
2129 short events;
2130};
2131
2142 typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
2143 void *user_data);
2144
2154 typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data);
2155
2156const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
2157 libusb_context *ctx);
2158void LIBUSB_CALL libusb_free_pollfds(const struct libusb_pollfd **pollfds);
2159void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
2160 libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
2161 void *user_data);
2162
2175 typedef int libusb_hotplug_callback_handle;
2176
2182 typedef enum {
2184 LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = (1 << 0),
2185
2189 LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = (1 << 1)
2190} libusb_hotplug_event;
2191
2197 typedef enum {
2199 LIBUSB_HOTPLUG_ENUMERATE = (1 << 0)
2200} libusb_hotplug_flag;
2201
2204#define LIBUSB_HOTPLUG_NO_FLAGS 0
2205
2208#define LIBUSB_HOTPLUG_MATCH_ANY -1
2209
2232 typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
2233 libusb_device *device, libusb_hotplug_event event, void *user_data);
2234
2270int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
2271 int events, int flags,
2272 int vendor_id, int product_id, int dev_class,
2273 libusb_hotplug_callback_fn cb_fn, void *user_data,
2274 libusb_hotplug_callback_handle *callback_handle);
2275
2287void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx,
2288 libusb_hotplug_callback_handle callback_handle);
2289
2298void * LIBUSB_CALL libusb_hotplug_get_user_data(libusb_context *ctx,
2299 libusb_hotplug_callback_handle callback_handle);
2300
2301int LIBUSB_CALLV libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
2302
2303#ifdef _MSC_VER
2304#pragma warning(pop)
2305#endif
2306
2307#if defined(__cplusplus)
2308}
2309#endif
2310
2311#endif
libusb_transfer_cb_fn
void(* libusb_transfer_cb_fn)(struct libusb_transfer *transfer)
Asynchronous transfer callback function type.
Definition libusb.h:1348
libusb_transfer_flags
libusb_transfer_flags
libusb_transfer.flags values
Definition libusb.h:1281
libusb_dev_mem_alloc
unsigned char * libusb_dev_mem_alloc(libusb_device_handle *dev_handle, size_t length)
Attempts to allocate a block of persistent DMA memory suitable for transfers against the given device...
Definition core.c:2038
libusb_fill_iso_transfer
static void libusb_fill_iso_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, int num_iso_packets, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for an isochronous transfer.
Definition libusb.h:1926
libusb_fill_control_transfer
static void libusb_fill_control_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for a control transfer.
Definition libusb.h:1810
libusb_control_transfer_get_data
static unsigned char * libusb_control_transfer_get_data(struct libusb_transfer *transfer)
Get the data section of a control transfer.
Definition libusb.h:1714
libusb_get_iso_packet_buffer_simple
static unsigned char * libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, unsigned int packet)
Convenience function to locate the position of an isochronous packet within the buffer of an isochron...
Definition libusb.h:2017
libusb_fill_control_setup
static void libusb_fill_control_setup(unsigned char *buffer, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength)
Helper function to populate the setup packet (first 8 bytes of the data buffer) for a control transfe...
Definition libusb.h:1761
libusb_transfer_get_stream_id
uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer)
Get a transfers bulk stream id.
Definition io.c:1667
libusb_cancel_transfer
int libusb_cancel_transfer(struct libusb_transfer *transfer)
Asynchronously cancel a previously submitted transfer.
Definition io.c:1606
libusb_free_transfer
void libusb_free_transfer(struct libusb_transfer *transfer)
Free a transfer structure.
Definition io.c:1331
libusb_fill_interrupt_transfer
static void libusb_fill_interrupt_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for an interrupt transfer.
Definition libusb.h:1897
libusb_transfer_status
libusb_transfer_status
Transfer status codes.
Definition libusb.h:1251
libusb_alloc_transfer
struct libusb_transfer * libusb_alloc_transfer(int iso_packets)
Allocate a libusb transfer with a specified number of isochronous packet descriptors.
Definition io.c:1289
libusb_control_transfer_get_setup
static struct libusb_control_setup * libusb_control_transfer_get_setup(struct libusb_transfer *transfer)
Get the control setup packet of a control transfer.
Definition libusb.h:1732
libusb_free_streams
int libusb_free_streams(libusb_device_handle *dev_handle, unsigned char *endpoints, int num_endpoints)
Free usb bulk streams allocated with libusb_alloc_streams().
Definition core.c:1995
libusb_submit_transfer
int libusb_submit_transfer(struct libusb_transfer *transfer)
Submit a transfer.
Definition io.c:1486
libusb_fill_bulk_stream_transfer
static void libusb_fill_bulk_stream_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, uint32_t stream_id, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for a bulk transfer using bulk stream...
Definition libusb.h:1872
libusb_transfer_type
libusb_transfer_type
Transfer type.
Definition libusb.h:1232
libusb_set_iso_packet_lengths
static void libusb_set_iso_packet_lengths(struct libusb_transfer *transfer, unsigned int length)
Convenience function to set the length of all packets in an isochronous transfer, based on the num_is...
Definition libusb.h:1950
libusb_fill_bulk_transfer
static void libusb_fill_bulk_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Helper function to populate the required libusb_transfer fields for a bulk transfer.
Definition libusb.h:1841
libusb_dev_mem_free
int libusb_dev_mem_free(libusb_device_handle *dev_handle, unsigned char *buffer, size_t length)
Free device memory allocated with libusb_dev_mem_alloc().
Definition core.c:2058
libusb_alloc_streams
int libusb_alloc_streams(libusb_device_handle *dev_handle, uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
Allocate up to num_streams usb bulk streams on the specified endpoints.
Definition core.c:1965
libusb_get_iso_packet_buffer
static unsigned char * libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, unsigned int packet)
Convenience function to locate the position of an isochronous packet within the buffer of an isochron...
Definition libusb.h:1975
libusb_transfer_set_stream_id
void libusb_transfer_set_stream_id(struct libusb_transfer *transfer, uint32_t stream_id)
Set a transfers bulk stream id.
Definition io.c:1650
LIBUSB_TRANSFER_ADD_ZERO_PACKET
@ LIBUSB_TRANSFER_ADD_ZERO_PACKET
Terminate transfers that are a multiple of the endpoint's wMaxPacketSize with an extra zero length pa...
Definition libusb.h:1321
LIBUSB_TRANSFER_FREE_TRANSFER
@ LIBUSB_TRANSFER_FREE_TRANSFER
Automatically call libusb_free_transfer() after callback returns.
Definition libusb.h:1295
LIBUSB_TRANSFER_SHORT_NOT_OK
@ LIBUSB_TRANSFER_SHORT_NOT_OK
Report short frames as errors.
Definition libusb.h:1283
LIBUSB_TRANSFER_FREE_BUFFER
@ LIBUSB_TRANSFER_FREE_BUFFER
Automatically free() transfer buffer during libusb_free_transfer().
Definition libusb.h:1289
LIBUSB_TRANSFER_STALL
@ LIBUSB_TRANSFER_STALL
For bulk/interrupt endpoints: halt condition detected (endpoint stalled).
Definition libusb.h:1267
LIBUSB_TRANSFER_COMPLETED
@ LIBUSB_TRANSFER_COMPLETED
Transfer completed without error.
Definition libusb.h:1254
LIBUSB_TRANSFER_CANCELLED
@ LIBUSB_TRANSFER_CANCELLED
Transfer was cancelled.
Definition libusb.h:1263
LIBUSB_TRANSFER_ERROR
@ LIBUSB_TRANSFER_ERROR
Transfer failed.
Definition libusb.h:1257
LIBUSB_TRANSFER_OVERFLOW
@ LIBUSB_TRANSFER_OVERFLOW
Device sent more data than requested.
Definition libusb.h:1273
LIBUSB_TRANSFER_NO_DEVICE
@ LIBUSB_TRANSFER_NO_DEVICE
Device was disconnected.
Definition libusb.h:1270
LIBUSB_TRANSFER_TIMED_OUT
@ LIBUSB_TRANSFER_TIMED_OUT
Transfer timed out.
Definition libusb.h:1260
LIBUSB_TRANSFER_TYPE_BULK_STREAM
@ LIBUSB_TRANSFER_TYPE_BULK_STREAM
Bulk stream transfer.
Definition libusb.h:1246
LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
@ LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
Isochronous transfer.
Definition libusb.h:1237
LIBUSB_TRANSFER_TYPE_CONTROL
@ LIBUSB_TRANSFER_TYPE_CONTROL
Control transfer.
Definition libusb.h:1234
LIBUSB_TRANSFER_TYPE_BULK
@ LIBUSB_TRANSFER_TYPE_BULK
Bulk transfer.
Definition libusb.h:1240
LIBUSB_TRANSFER_TYPE_INTERRUPT
@ LIBUSB_TRANSFER_TYPE_INTERRUPT
Interrupt transfer.
Definition libusb.h:1243
libusb_get_string_descriptor
static int libusb_get_string_descriptor(libusb_device_handle *dev_handle, uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
Retrieve a descriptor from a device.
Definition libusb.h:2083
libusb_descriptor_type
libusb_descriptor_type
Descriptor types as defined by the USB specification.
Definition libusb.h:283
libusb_supported_speed
libusb_supported_speed
Supported speeds (wSpeedSupported) bitfield.
Definition libusb.h:514
libusb_free_config_descriptor
void libusb_free_config_descriptor(struct libusb_config_descriptor *config)
Free a configuration descriptor obtained from libusb_get_active_config_descriptor() or libusb_get_con...
Definition descriptor.c:682
libusb_get_string_descriptor_ascii
int libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle, uint8_t desc_index, unsigned char *data, int length)
Retrieve a string descriptor in C style ASCII.
Definition descriptor.c:1149
libusb_free_platform_descriptor
void libusb_free_platform_descriptor(struct libusb_platform_descriptor *platform_descriptor)
Free a platform descriptor obtained from libusb_get_platform_descriptor().
Definition descriptor.c:1131
libusb_get_config_descriptor_by_value
int libusb_get_config_descriptor_by_value(libusb_device *dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config)
Get a USB configuration descriptor with a specific bConfigurationValue.
Definition descriptor.c:642
libusb_get_interface_association_descriptors
int libusb_get_interface_association_descriptors(libusb_device *dev, uint8_t config_index, struct libusb_interface_association_descriptor_array **iad_array)
Get an array of interface association descriptors (IAD) for a given configuration.
Definition descriptor.c:1305
libusb_get_active_config_descriptor
int libusb_get_active_config_descriptor(libusb_device *dev, struct libusb_config_descriptor **config)
Get the USB configuration descriptor for the currently active configuration.
Definition descriptor.c:555
libusb_free_ss_endpoint_companion_descriptor
void libusb_free_ss_endpoint_companion_descriptor(struct libusb_ss_endpoint_companion_descriptor *ep_comp)
Free a superspeed endpoint companion descriptor obtained from libusb_get_ss_endpoint_companion_descri...
Definition descriptor.c:754
libusb_get_device_descriptor
int libusb_get_device_descriptor(libusb_device *dev, struct libusb_device_descriptor *desc)
Get the USB device descriptor for a given device.
Definition descriptor.c:531
libusb_free_usb_2_0_extension_descriptor
void libusb_free_usb_2_0_extension_descriptor(struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension)
Free a USB 2.0 Extension descriptor obtained from libusb_get_usb_2_0_extension_descriptor().
Definition descriptor.c:957
libusb_get_active_interface_association_descriptors
int libusb_get_active_interface_association_descriptors(libusb_device *dev, struct libusb_interface_association_descriptor_array **iad_array)
Get an array of interface association descriptors (IAD) for the currently active configuration.
Definition descriptor.c:1354
libusb_get_bos_descriptor
int libusb_get_bos_descriptor(libusb_device_handle *dev_handle, struct libusb_bos_descriptor **bos)
Get a Binary Object Store (BOS) descriptor This is a BLOCKING function, which will send requests to t...
Definition descriptor.c:846
libusb_bos_type
libusb_bos_type
USB capability types.
Definition libusb.h:551
libusb_get_container_id_descriptor
int libusb_get_container_id_descriptor(libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_container_id_descriptor **container_id)
Get a Container ID descriptor.
Definition descriptor.c:1032
libusb_endpoint_direction
libusb_endpoint_direction
Endpoint direction.
Definition libusb.h:359
libusb_endpoint_transfer_type
libusb_endpoint_transfer_type
Endpoint transfer type.
Definition libusb.h:373
libusb_free_ss_usb_device_capability_descriptor
void libusb_free_ss_usb_device_capability_descriptor(struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap)
Free a SuperSpeed USB Device Capability descriptor obtained from libusb_get_ss_usb_device_capability_...
Definition descriptor.c:1013
libusb_get_descriptor
static int libusb_get_descriptor(libusb_device_handle *dev_handle, uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
Retrieve a descriptor from the default control pipe.
Definition libusb.h:2061
libusb_iso_sync_type
libusb_iso_sync_type
Synchronization type for isochronous endpoints.
Definition libusb.h:478
libusb_free_interface_association_descriptors
void libusb_free_interface_association_descriptors(struct libusb_interface_association_descriptor_array *iad_array)
Free an array of interface association descriptors (IADs) obtained from libusb_get_interface_associat...
Definition descriptor.c:1390
libusb_get_config_descriptor
int libusb_get_config_descriptor(libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config)
Get a USB configuration descriptor based on its index.
Definition descriptor.c:596
libusb_ss_usb_device_capability_attributes
libusb_ss_usb_device_capability_attributes
Masks for the bits of the bmAttributes field field of the SuperSpeed USB Device Capability descriptor...
Definition libusb.h:543
libusb_get_ss_endpoint_companion_descriptor
int libusb_get_ss_endpoint_companion_descriptor(libusb_context *ctx, const struct libusb_endpoint_descriptor *endpoint, struct libusb_ss_endpoint_companion_descriptor **ep_comp)
Get an endpoints superspeed endpoint companion descriptor (if any)
Definition descriptor.c:705
libusb_iso_usage_type
libusb_iso_usage_type
Usage type for isochronous endpoints.
Definition libusb.h:499
libusb_class_code
libusb_class_code
Device and/or Interface Class codes.
Definition libusb.h:218
libusb_get_ss_usb_device_capability_descriptor
int libusb_get_ss_usb_device_capability_descriptor(libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap)
Get a SuperSpeed USB Device Capability descriptor.
Definition descriptor.c:976
libusb_get_platform_descriptor
int libusb_get_platform_descriptor(libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_platform_descriptor **platform_descriptor)
Get a platform descriptor.
Definition descriptor.c:1088
libusb_free_bos_descriptor
void libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
Free a BOS descriptor obtained from libusb_get_bos_descriptor().
Definition descriptor.c:896
libusb_usb_2_0_extension_attributes
libusb_usb_2_0_extension_attributes
Masks for the bits of the bmAttributes field of the USB 2.0 Extension descriptor.
Definition libusb.h:533
libusb_get_usb_2_0_extension_descriptor
int libusb_get_usb_2_0_extension_descriptor(libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension)
Get an USB 2.0 Extension descriptor.
Definition descriptor.c:921
libusb_free_container_id_descriptor
void libusb_free_container_id_descriptor(struct libusb_container_id_descriptor *container_id)
Free a Container ID descriptor obtained from libusb_get_container_id_descriptor().
Definition descriptor.c:1067
LIBUSB_DT_HUB
@ LIBUSB_DT_HUB
Hub descriptor.
Definition libusb.h:319
LIBUSB_DT_CONFIG
@ LIBUSB_DT_CONFIG
Configuration descriptor.
Definition libusb.h:288
LIBUSB_DT_STRING
@ LIBUSB_DT_STRING
String descriptor.
Definition libusb.h:291
LIBUSB_DT_HID
@ LIBUSB_DT_HID
HID descriptor.
Definition libusb.h:310
LIBUSB_DT_REPORT
@ LIBUSB_DT_REPORT
HID report descriptor.
Definition libusb.h:313
LIBUSB_DT_DEVICE
@ LIBUSB_DT_DEVICE
Device descriptor.
Definition libusb.h:285
LIBUSB_DT_DEVICE_CAPABILITY
@ LIBUSB_DT_DEVICE_CAPABILITY
Device Capability descriptor.
Definition libusb.h:307
LIBUSB_DT_SUPERSPEED_HUB
@ LIBUSB_DT_SUPERSPEED_HUB
SuperSpeed Hub descriptor.
Definition libusb.h:322
LIBUSB_DT_PHYSICAL
@ LIBUSB_DT_PHYSICAL
Physical descriptor.
Definition libusb.h:316
LIBUSB_DT_INTERFACE
@ LIBUSB_DT_INTERFACE
Interface descriptor.
Definition libusb.h:294
LIBUSB_DT_ENDPOINT
@ LIBUSB_DT_ENDPOINT
Endpoint descriptor.
Definition libusb.h:297
LIBUSB_DT_SS_ENDPOINT_COMPANION
@ LIBUSB_DT_SS_ENDPOINT_COMPANION
SuperSpeed Endpoint Companion descriptor.
Definition libusb.h:325
LIBUSB_DT_BOS
@ LIBUSB_DT_BOS
BOS descriptor.
Definition libusb.h:304
LIBUSB_DT_INTERFACE_ASSOCIATION
@ LIBUSB_DT_INTERFACE_ASSOCIATION
Interface Association Descriptor.
Definition libusb.h:301
LIBUSB_HIGH_SPEED_OPERATION
@ LIBUSB_HIGH_SPEED_OPERATION
High speed operation supported (480MBit/s).
Definition libusb.h:522
LIBUSB_LOW_SPEED_OPERATION
@ LIBUSB_LOW_SPEED_OPERATION
Low speed operation supported (1.5MBit/s).
Definition libusb.h:516
LIBUSB_SUPER_SPEED_OPERATION
@ LIBUSB_SUPER_SPEED_OPERATION
Superspeed operation supported (5000MBit/s).
Definition libusb.h:525
LIBUSB_FULL_SPEED_OPERATION
@ LIBUSB_FULL_SPEED_OPERATION
Full speed operation supported (12MBit/s).
Definition libusb.h:519
LIBUSB_BT_USB_2_0_EXTENSION
@ LIBUSB_BT_USB_2_0_EXTENSION
USB 2.0 extensions.
Definition libusb.h:556
LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
@ LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
SuperSpeed USB device capability.
Definition libusb.h:559
LIBUSB_BT_PLATFORM_DESCRIPTOR
@ LIBUSB_BT_PLATFORM_DESCRIPTOR
Platform descriptor.
Definition libusb.h:565
LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY
@ LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY
Wireless USB device capability.
Definition libusb.h:553
LIBUSB_BT_CONTAINER_ID
@ LIBUSB_BT_CONTAINER_ID
Container ID type.
Definition libusb.h:562
LIBUSB_ENDPOINT_IN
@ LIBUSB_ENDPOINT_IN
In: device-to-host.
Definition libusb.h:364
LIBUSB_ENDPOINT_OUT
@ LIBUSB_ENDPOINT_OUT
Out: host-to-device.
Definition libusb.h:361
LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT
@ LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT
Interrupt endpoint.
Definition libusb.h:384
LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS
@ LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS
Isochronous endpoint.
Definition libusb.h:378
LIBUSB_ENDPOINT_TRANSFER_TYPE_BULK
@ LIBUSB_ENDPOINT_TRANSFER_TYPE_BULK
Bulk endpoint.
Definition libusb.h:381
LIBUSB_ENDPOINT_TRANSFER_TYPE_CONTROL
@ LIBUSB_ENDPOINT_TRANSFER_TYPE_CONTROL
Control endpoint.
Definition libusb.h:375
LIBUSB_ISO_SYNC_TYPE_SYNC
@ LIBUSB_ISO_SYNC_TYPE_SYNC
Synchronous.
Definition libusb.h:489
LIBUSB_ISO_SYNC_TYPE_NONE
@ LIBUSB_ISO_SYNC_TYPE_NONE
No synchronization.
Definition libusb.h:480
LIBUSB_ISO_SYNC_TYPE_ADAPTIVE
@ LIBUSB_ISO_SYNC_TYPE_ADAPTIVE
Adaptive.
Definition libusb.h:486
LIBUSB_ISO_SYNC_TYPE_ASYNC
@ LIBUSB_ISO_SYNC_TYPE_ASYNC
Asynchronous.
Definition libusb.h:483
LIBUSB_BM_LTM_SUPPORT
@ LIBUSB_BM_LTM_SUPPORT
Supports Latency Tolerance Messages (LTM)
Definition libusb.h:545
LIBUSB_ISO_USAGE_TYPE_DATA
@ LIBUSB_ISO_USAGE_TYPE_DATA
Data endpoint.
Definition libusb.h:501
LIBUSB_ISO_USAGE_TYPE_FEEDBACK
@ LIBUSB_ISO_USAGE_TYPE_FEEDBACK
Feedback endpoint.
Definition libusb.h:504
LIBUSB_ISO_USAGE_TYPE_IMPLICIT
@ LIBUSB_ISO_USAGE_TYPE_IMPLICIT
Implicit feedback Data endpoint.
Definition libusb.h:507
LIBUSB_CLASS_AUDIO
@ LIBUSB_CLASS_AUDIO
Audio class.
Definition libusb.h:226
LIBUSB_CLASS_HUB
@ LIBUSB_CLASS_HUB
Hub class.
Definition libusb.h:248
LIBUSB_CLASS_MISCELLANEOUS
@ LIBUSB_CLASS_MISCELLANEOUS
Miscellaneous class.
Definition libusb.h:272
LIBUSB_CLASS_APPLICATION
@ LIBUSB_CLASS_APPLICATION
Application class.
Definition libusb.h:275
LIBUSB_CLASS_CONTENT_SECURITY
@ LIBUSB_CLASS_CONTENT_SECURITY
Content Security.
Definition libusb.h:257
LIBUSB_CLASS_DIAGNOSTIC_DEVICE
@ LIBUSB_CLASS_DIAGNOSTIC_DEVICE
Diagnostic Device.
Definition libusb.h:266
LIBUSB_CLASS_PHYSICAL
@ LIBUSB_CLASS_PHYSICAL
Physical.
Definition libusb.h:235
LIBUSB_CLASS_COMM
@ LIBUSB_CLASS_COMM
Communications class.
Definition libusb.h:229
LIBUSB_CLASS_VIDEO
@ LIBUSB_CLASS_VIDEO
Video.
Definition libusb.h:260
LIBUSB_CLASS_DATA
@ LIBUSB_CLASS_DATA
Data class.
Definition libusb.h:251
LIBUSB_CLASS_WIRELESS
@ LIBUSB_CLASS_WIRELESS
Wireless class.
Definition libusb.h:269
LIBUSB_CLASS_PRINTER
@ LIBUSB_CLASS_PRINTER
Printer class.
Definition libusb.h:242
LIBUSB_CLASS_PERSONAL_HEALTHCARE
@ LIBUSB_CLASS_PERSONAL_HEALTHCARE
Personal Healthcare.
Definition libusb.h:263
LIBUSB_CLASS_PER_INTERFACE
@ LIBUSB_CLASS_PER_INTERFACE
In the context of a device descriptor, this bDeviceClass value indicates that each interface specifie...
Definition libusb.h:223
LIBUSB_CLASS_MASS_STORAGE
@ LIBUSB_CLASS_MASS_STORAGE
Mass storage class.
Definition libusb.h:245
LIBUSB_CLASS_HID
@ LIBUSB_CLASS_HID
Human Interface Device class.
Definition libusb.h:232
LIBUSB_CLASS_VENDOR_SPEC
@ LIBUSB_CLASS_VENDOR_SPEC
Class is vendor-specific.
Definition libusb.h:278
LIBUSB_CLASS_IMAGE
@ LIBUSB_CLASS_IMAGE
Image class.
Definition libusb.h:238
LIBUSB_CLASS_SMART_CARD
@ LIBUSB_CLASS_SMART_CARD
Smart Card.
Definition libusb.h:254
LIBUSB_BM_LPM_SUPPORT
@ LIBUSB_BM_LPM_SUPPORT
Supports Link Power Management (LPM)
Definition libusb.h:535
libusb_get_max_alt_packet_size
int libusb_get_max_alt_packet_size(libusb_device *dev, int interface_number, int alternate_setting, unsigned char endpoint)
Calculate the maximum packet size which a specific endpoint is capable of sending or receiving in the...
Definition core.c:1239
libusb_open_device_with_vid_pid
libusb_device_handle * libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id, uint16_t product_id)
Convenience function for finding a device with a particular idVendor/idProduct combination.
Definition core.c:1460
libusb_get_port_number
uint8_t libusb_get_port_number(libusb_device *dev)
Get the number of the port that a device is connected to.
Definition core.c:932
libusb_get_parent
libusb_device * libusb_get_parent(libusb_device *dev)
Get the the parent from the specified device.
Definition core.c:994
libusb_kernel_driver_active
int libusb_kernel_driver_active(libusb_device_handle *dev_handle, int interface_number)
Determine if a kernel driver is active on an interface.
Definition core.c:2084
libusb_ref_device
libusb_device * libusb_ref_device(libusb_device *dev)
Increment the reference count of a device.
Definition core.c:1273
libusb_speed
libusb_speed
Speed codes.
Definition libusb.h:1153
libusb_get_device
libusb_device * libusb_get_device(libusb_device_handle *dev_handle)
Get the underlying device for a device handle.
Definition core.c:1624
libusb_unref_device
void libusb_unref_device(libusb_device *dev)
Decrement the reference count of a device.
Definition core.c:1288
libusb_open
int libusb_open(libusb_device *dev, libusb_device_handle **dev_handle)
Open a device and obtain a device handle.
Definition core.c:1405
libusb_set_interface_alt_setting
int libusb_set_interface_alt_setting(libusb_device_handle *dev_handle, int interface_number, int alternate_setting)
Activate an alternate setting for an interface.
Definition core.c:1862
libusb_release_interface
int libusb_release_interface(libusb_device_handle *dev_handle, int interface_number)
Release an interface previously claimed with libusb_claim_interface().
Definition core.c:1817
libusb_get_device_speed
int libusb_get_device_speed(libusb_device *dev)
Get the negotiated connection speed for a device.
Definition core.c:1015
libusb_detach_kernel_driver
int libusb_detach_kernel_driver(libusb_device_handle *dev_handle, int interface_number)
Detach a kernel driver from an interface.
Definition core.c:2122
libusb_close
void libusb_close(libusb_device_handle *dev_handle)
Close a device handle.
Definition core.c:1562
libusb_device
struct libusb_device libusb_device
Structure representing a USB device detected on the system.
Definition libusb.h:1137
libusb_set_configuration
int libusb_set_configuration(libusb_device_handle *dev_handle, int configuration)
Set the active configuration for a device.
Definition core.c:1736
libusb_device_handle
struct libusb_device_handle libusb_device_handle
Structure representing a handle on a USB device.
Definition libusb.h:1148
libusb_wrap_sys_device
int libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle)
Wrap a platform-specific system device handle and obtain a libusb device handle for the underlying de...
Definition core.c:1350
libusb_get_port_path
int libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *path, uint8_t path_length)
Definition core.c:974
libusb_get_port_numbers
int libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len)
Get the list of all port numbers from root for the specified device.
Definition core.c:948
libusb_get_device_address
uint8_t libusb_get_device_address(libusb_device *dev)
Get the address of the device on the bus it is connected to.
Definition core.c:1004
libusb_clear_halt
int libusb_clear_halt(libusb_device_handle *dev_handle, unsigned char endpoint)
Clear the halt/stall condition for an endpoint.
Definition core.c:1903
libusb_get_device_list
ssize_t libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
Returns a list of USB devices currently attached to the system.
Definition core.c:822
libusb_set_auto_detach_kernel_driver
int libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev_handle, int enable)
Enable/disable libusb's automatic kernel driver detachment.
Definition core.c:2197
libusb_get_max_packet_size
int libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint)
Convenience function to retrieve the wMaxPacketSize value for a particular endpoint in the active dev...
Definition core.c:1061
libusb_free_device_list
void libusb_free_device_list(libusb_device **list, int unref_devices)
Frees a list of devices previously discovered using libusb_get_device_list().
Definition core.c:892
libusb_attach_kernel_driver
int libusb_attach_kernel_driver(libusb_device_handle *dev_handle, int interface_number)
Re-attach an interface's kernel driver, which was previously detached using libusb_detach_kernel_driv...
Definition core.c:2158
libusb_get_configuration
int libusb_get_configuration(libusb_device_handle *dev, int *config)
Determine the bConfigurationValue of the currently active configuration.
Definition core.c:1649
libusb_get_max_iso_packet_size
int libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoint)
Calculate the maximum packet size which a specific endpoint is capable is sending or receiving in the...
Definition core.c:1180
libusb_claim_interface
int libusb_claim_interface(libusb_device_handle *dev_handle, int interface_number)
Claim an interface on a given device handle.
Definition core.c:1773
libusb_get_bus_number
uint8_t libusb_get_bus_number(libusb_device *dev)
Get the number of the bus that a device is connected to.
Definition core.c:913
libusb_reset_device
int libusb_reset_device(libusb_device_handle *dev_handle)
Perform a USB port reset to reinitialize a device.
Definition core.c:1932
LIBUSB_SPEED_FULL
@ LIBUSB_SPEED_FULL
The device is operating at full speed (12MBit/s).
Definition libusb.h:1161
LIBUSB_SPEED_HIGH
@ LIBUSB_SPEED_HIGH
The device is operating at high speed (480MBit/s).
Definition libusb.h:1164
LIBUSB_SPEED_LOW
@ LIBUSB_SPEED_LOW
The device is operating at low speed (1.5MBit/s).
Definition libusb.h:1158
LIBUSB_SPEED_SUPER_PLUS
@ LIBUSB_SPEED_SUPER_PLUS
The device is operating at super speed plus (10000MBit/s).
Definition libusb.h:1170
LIBUSB_SPEED_SUPER
@ LIBUSB_SPEED_SUPER
The device is operating at super speed (5000MBit/s).
Definition libusb.h:1167
LIBUSB_SPEED_UNKNOWN
@ LIBUSB_SPEED_UNKNOWN
The OS doesn't report or know the device speed.
Definition libusb.h:1155
libusb_hotplug_callback_handle
int libusb_hotplug_callback_handle
Callback handle.
Definition libusb.h:2175
libusb_hotplug_event
libusb_hotplug_event
Since version 1.0.16, LIBUSB_API_VERSION >= 0x01000102.
Definition libusb.h:2182
libusb_hotplug_register_callback
int libusb_hotplug_register_callback(libusb_context *ctx, int events, int flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *callback_handle)
Register a hotplug callback function.
Definition hotplug.c:323
libusb_hotplug_callback_fn
int(* libusb_hotplug_callback_fn)(libusb_context *ctx, libusb_device *device, libusb_hotplug_event event, void *user_data)
Hotplug callback function type.
Definition libusb.h:2232
libusb_hotplug_deregister_callback
void libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle callback_handle)
Deregisters a hotplug callback.
Definition hotplug.c:408
libusb_hotplug_flag
libusb_hotplug_flag
Since version 1.0.16, LIBUSB_API_VERSION >= 0x01000102.
Definition libusb.h:2197
libusb_hotplug_get_user_data
void * libusb_hotplug_get_user_data(libusb_context *ctx, libusb_hotplug_callback_handle callback_handle)
Gets the user_data associated with a hotplug callback.
Definition hotplug.c:446
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED
@ LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED
A device has been plugged in and is ready to use.
Definition libusb.h:2184
LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT
@ LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT
A device has left and is no longer available.
Definition libusb.h:2189
LIBUSB_HOTPLUG_ENUMERATE
@ LIBUSB_HOTPLUG_ENUMERATE
Arm the callback and fire it for all matching currently attached devices.
Definition libusb.h:2199
libusb_option
libusb_option
Available option values for libusb_set_option() and libusb_init_context().
Definition libusb.h:1478
libusb_set_option
int LIBUSB_CALLV libusb_set_option(libusb_context *ctx, enum libusb_option option,...)
Set an option in the library.
Definition core.c:2291
libusb_log_cb_mode
libusb_log_cb_mode
Log callback mode.
Definition libusb.h:1467
libusb_log_level
libusb_log_level
Log message levels.
Definition libusb.h:1443
libusb_set_log_cb
void libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode)
Set log handler.
Definition core.c:2262
libusb_context
struct libusb_context libusb_context
Structure representing a libusb session.
Definition libusb.h:1120
libusb_set_debug
void libusb_set_debug(libusb_context *ctx, int level)
Deprecated.
Definition core.c:2211
libusb_log_cb
void(* libusb_log_cb)(libusb_context *ctx, enum libusb_log_level level, const char *str)
Callback function for handling log messages.
Definition libusb.h:1559
libusb_init
int libusb_init(libusb_context **ctx)
Deprecated initialization function.
Definition core.c:2401
libusb_init_context
int libusb_init_context(libusb_context **ctx, const struct libusb_init_option options[], int num_options)
Initialize libusb.
Definition core.c:2424
libusb_exit
void libusb_exit(libusb_context *ctx)
Deinitialize libusb.
Definition core.c:2577
LIBUSB_OPTION_NO_DEVICE_DISCOVERY
@ LIBUSB_OPTION_NO_DEVICE_DISCOVERY
Do not scan for devices.
Definition libusb.h:1530
LIBUSB_OPTION_LOG_CB
@ LIBUSB_OPTION_LOG_CB
Set the context log callback function.
Definition libusb.h:1543
LIBUSB_OPTION_LOG_LEVEL
@ LIBUSB_OPTION_LOG_LEVEL
Set the log message verbosity.
Definition libusb.h:1501
LIBUSB_OPTION_USE_USBDK
@ LIBUSB_OPTION_USE_USBDK
Use the UsbDk backend for a specific context, if available.
Definition libusb.h:1510
LIBUSB_LOG_CB_GLOBAL
@ LIBUSB_LOG_CB_GLOBAL
Callback function handling all log messages.
Definition libusb.h:1469
LIBUSB_LOG_CB_CONTEXT
@ LIBUSB_LOG_CB_CONTEXT
Callback function handling context related log messages.
Definition libusb.h:1472
LIBUSB_LOG_LEVEL_WARNING
@ LIBUSB_LOG_LEVEL_WARNING
(2) : Warning and error messages are emitted
Definition libusb.h:1451
LIBUSB_LOG_LEVEL_INFO
@ LIBUSB_LOG_LEVEL_INFO
(3) : Informational, warning and error messages are emitted
Definition libusb.h:1454
LIBUSB_LOG_LEVEL_ERROR
@ LIBUSB_LOG_LEVEL_ERROR
(1) : Error messages are emitted
Definition libusb.h:1448
LIBUSB_LOG_LEVEL_NONE
@ LIBUSB_LOG_LEVEL_NONE
(0) : No messages ever emitted by the library (default)
Definition libusb.h:1445
LIBUSB_LOG_LEVEL_DEBUG
@ LIBUSB_LOG_LEVEL_DEBUG
(4) : All messages are emitted
Definition libusb.h:1457
libusb_request_type
libusb_request_type
Request type bits of the bmRequestType field in control transfers.
Definition libusb.h:439
libusb_setlocale
int libusb_setlocale(const char *locale)
Set the language, and only the language, not the encoding! used for translatable libusb messages.
Definition strerror.c:178
libusb_get_version
const struct libusb_version * libusb_get_version(void)
Returns a pointer to const struct libusb_version with the version (major, minor, micro,...
Definition core.c:2924
libusb_request_recipient
libusb_request_recipient
Recipient bits of the bmRequestType field in control transfers.
Definition libusb.h:457
libusb_le16_to_cpu
#define libusb_le16_to_cpu
Convert a 16-bit value from little-endian to host-endian format.
Definition libusb.h:212
libusb_strerror
const char * libusb_strerror(int errcode)
Returns a constant string with a short description of the given error code, this description is inten...
Definition strerror.c:213
libusb_standard_request
libusb_standard_request
Standard requests, as defined in table 9-5 of the USB 3.0 specifications.
Definition libusb.h:389
libusb_has_capability
int libusb_has_capability(uint32_t capability)
Check at runtime if the loaded library has a given capability.
Definition core.c:2651
LIBUSB_CALL
#define LIBUSB_CALL
libusb's Windows calling convention.
Definition libusb.h:125
libusb_capability
libusb_capability
Capabilities supported by an instance of libusb on the current running platform.
Definition libusb.h:1422
libusb_error
libusb_error
Error codes.
Definition libusb.h:1180
libusb_cpu_to_le16
static uint16_t libusb_cpu_to_le16(const uint16_t x)
Convert a 16-bit value from host-endian to little-endian format.
Definition libusb.h:193
libusb_error_name
const char * libusb_error_name(int errcode)
Returns a constant NULL-terminated string with the ASCII name of a libusb error or transfer status co...
Definition core.c:2869
LIBUSB_REQUEST_TYPE_VENDOR
@ LIBUSB_REQUEST_TYPE_VENDOR
Vendor.
Definition libusb.h:447
LIBUSB_REQUEST_TYPE_STANDARD
@ LIBUSB_REQUEST_TYPE_STANDARD
Standard.
Definition libusb.h:441
LIBUSB_REQUEST_TYPE_CLASS
@ LIBUSB_REQUEST_TYPE_CLASS
Class.
Definition libusb.h:444
LIBUSB_REQUEST_TYPE_RESERVED
@ LIBUSB_REQUEST_TYPE_RESERVED
Reserved.
Definition libusb.h:450
LIBUSB_RECIPIENT_ENDPOINT
@ LIBUSB_RECIPIENT_ENDPOINT
Endpoint.
Definition libusb.h:465
LIBUSB_RECIPIENT_INTERFACE
@ LIBUSB_RECIPIENT_INTERFACE
Interface.
Definition libusb.h:462
LIBUSB_RECIPIENT_OTHER
@ LIBUSB_RECIPIENT_OTHER
Other.
Definition libusb.h:468
LIBUSB_RECIPIENT_DEVICE
@ LIBUSB_RECIPIENT_DEVICE
Device.
Definition libusb.h:459
LIBUSB_REQUEST_CLEAR_FEATURE
@ LIBUSB_REQUEST_CLEAR_FEATURE
Clear or disable a specific feature.
Definition libusb.h:394
LIBUSB_REQUEST_GET_INTERFACE
@ LIBUSB_REQUEST_GET_INTERFACE
Return the selected alternate setting for the specified interface.
Definition libusb.h:419
LIBUSB_REQUEST_GET_DESCRIPTOR
@ LIBUSB_REQUEST_GET_DESCRIPTOR
Get the specified descriptor.
Definition libusb.h:407
LIBUSB_REQUEST_SET_DESCRIPTOR
@ LIBUSB_REQUEST_SET_DESCRIPTOR
Used to update existing descriptors or add new descriptors.
Definition libusb.h:410
LIBUSB_REQUEST_GET_STATUS
@ LIBUSB_REQUEST_GET_STATUS
Request status of the specific recipient.
Definition libusb.h:391
LIBUSB_REQUEST_SET_FEATURE
@ LIBUSB_REQUEST_SET_FEATURE
Set or enable a specific feature.
Definition libusb.h:399
LIBUSB_REQUEST_SET_INTERFACE
@ LIBUSB_REQUEST_SET_INTERFACE
Select an alternate interface for the specified interface.
Definition libusb.h:422
LIBUSB_REQUEST_SET_ADDRESS
@ LIBUSB_REQUEST_SET_ADDRESS
Set device address for all future accesses.
Definition libusb.h:404
LIBUSB_REQUEST_GET_CONFIGURATION
@ LIBUSB_REQUEST_GET_CONFIGURATION
Get the current device configuration value.
Definition libusb.h:413
LIBUSB_REQUEST_SET_SEL
@ LIBUSB_REQUEST_SET_SEL
Sets both the U1 and U2 Exit Latency.
Definition libusb.h:428
LIBUSB_SET_ISOCH_DELAY
@ LIBUSB_SET_ISOCH_DELAY
Delay from the time a host transmits a packet to the time it is received by the device.
Definition libusb.h:432
LIBUSB_REQUEST_SYNCH_FRAME
@ LIBUSB_REQUEST_SYNCH_FRAME
Set then report an endpoint's synchronization frame.
Definition libusb.h:425
LIBUSB_REQUEST_SET_CONFIGURATION
@ LIBUSB_REQUEST_SET_CONFIGURATION
Set device configuration.
Definition libusb.h:416
LIBUSB_CAP_HAS_CAPABILITY
@ LIBUSB_CAP_HAS_CAPABILITY
The libusb_has_capability() API is available.
Definition libusb.h:1424
LIBUSB_CAP_HAS_HOTPLUG
@ LIBUSB_CAP_HAS_HOTPLUG
Hotplug support is available on this platform.
Definition libusb.h:1427
LIBUSB_CAP_HAS_HID_ACCESS
@ LIBUSB_CAP_HAS_HID_ACCESS
The library can access HID devices without requiring user intervention.
Definition libusb.h:1433
LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER
@ LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER
The library supports detaching of the default USB driver, using libusb_detach_kernel_driver(),...
Definition libusb.h:1437
LIBUSB_ERROR_NOT_SUPPORTED
@ LIBUSB_ERROR_NOT_SUPPORTED
Operation not supported or unimplemented on this platform.
Definition libusb.h:1218
LIBUSB_ERROR_ACCESS
@ LIBUSB_ERROR_ACCESS
Access denied (insufficient permissions)
Definition libusb.h:1191
LIBUSB_ERROR_PIPE
@ LIBUSB_ERROR_PIPE
Pipe error.
Definition libusb.h:1209
LIBUSB_ERROR_NOT_FOUND
@ LIBUSB_ERROR_NOT_FOUND
Entity not found.
Definition libusb.h:1197
LIBUSB_ERROR_BUSY
@ LIBUSB_ERROR_BUSY
Resource busy.
Definition libusb.h:1200
LIBUSB_ERROR_INTERRUPTED
@ LIBUSB_ERROR_INTERRUPTED
System call interrupted (perhaps due to signal)
Definition libusb.h:1212
LIBUSB_SUCCESS
@ LIBUSB_SUCCESS
Success (no error)
Definition libusb.h:1182
LIBUSB_ERROR_INVALID_PARAM
@ LIBUSB_ERROR_INVALID_PARAM
Invalid parameter.
Definition libusb.h:1188
LIBUSB_ERROR_IO
@ LIBUSB_ERROR_IO
Input/output error.
Definition libusb.h:1185
LIBUSB_ERROR_OTHER
@ LIBUSB_ERROR_OTHER
Other error.
Definition libusb.h:1224
LIBUSB_ERROR_TIMEOUT
@ LIBUSB_ERROR_TIMEOUT
Operation timed out.
Definition libusb.h:1203
LIBUSB_ERROR_OVERFLOW
@ LIBUSB_ERROR_OVERFLOW
Overflow.
Definition libusb.h:1206
LIBUSB_ERROR_NO_DEVICE
@ LIBUSB_ERROR_NO_DEVICE
No such device (it may have been disconnected)
Definition libusb.h:1194
LIBUSB_ERROR_NO_MEM
@ LIBUSB_ERROR_NO_MEM
Insufficient memory.
Definition libusb.h:1215
libusb_handle_events_completed
int libusb_handle_events_completed(libusb_context *ctx, int *completed)
Handle any pending events in blocking mode.
Definition io.c:2462
libusb_lock_event_waiters
void libusb_lock_event_waiters(libusb_context *ctx)
Acquire the event waiters lock.
Definition io.c:1983
libusb_interrupt_event_handler
void libusb_interrupt_event_handler(libusb_context *ctx)
Interrupt any active thread that is handling events.
Definition io.c:1947
libusb_set_pollfd_notifiers
void libusb_set_pollfd_notifiers(libusb_context *ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data)
Register notification functions for file descriptor additions/removals.
Definition io.c:2644
libusb_event_handler_active
int libusb_event_handler_active(libusb_context *ctx)
Determine if an active thread is handling events (i.e.
Definition io.c:1918
libusb_unlock_event_waiters
void libusb_unlock_event_waiters(libusb_context *ctx)
Release the event waiters lock.
Definition io.c:1994
libusb_handle_events_timeout_completed
int libusb_handle_events_timeout_completed(libusb_context *ctx, struct timeval *tv, int *completed)
Handle any pending events.
Definition io.c:2348
libusb_handle_events
int libusb_handle_events(libusb_context *ctx)
Handle any pending events in blocking mode.
Definition io.c:2440
libusb_get_next_timeout
int libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv)
Determine the next internal timeout that libusb needs to handle.
Definition io.c:2572
libusb_event_handling_ok
int libusb_event_handling_ok(libusb_context *ctx)
Determine if it is still OK for this thread to be doing event handling.
Definition io.c:1889
libusb_handle_events_timeout
int libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv)
Handle any pending events.
Definition io.c:2420
libusb_try_lock_events
int libusb_try_lock_events(libusb_context *ctx)
Attempt to acquire the event handling lock.
Definition io.c:1796
libusb_handle_events_locked
int libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv)
Handle any pending events by polling file descriptors, without checking if any other threads are alre...
Definition io.c:2490
libusb_pollfd_removed_cb
void(* libusb_pollfd_removed_cb)(int fd, void *user_data)
Callback function, invoked when a file descriptor should be removed from the set of file descriptors ...
Definition libusb.h:2154
libusb_pollfd_added_cb
void(* libusb_pollfd_added_cb)(int fd, short events, void *user_data)
Callback function, invoked when a new file descriptor should be added to the set of file descriptors ...
Definition libusb.h:2142
libusb_lock_events
void libusb_lock_events(libusb_context *ctx)
Acquire the event handling lock, blocking until successful acquisition if it is contended.
Definition io.c:1839
libusb_get_pollfds
const struct libusb_pollfd ** libusb_get_pollfds(libusb_context *ctx)
Retrieve a list of file descriptors that should be polled by your main loop as libusb event sources.
Definition io.c:2752
libusb_unlock_events
void libusb_unlock_events(libusb_context *ctx)
Release the lock previously acquired with libusb_try_lock_events() or libusb_lock_events().
Definition io.c:1854
libusb_free_pollfds
void libusb_free_pollfds(const struct libusb_pollfd **pollfds)
Free a list of libusb_pollfd structures.
Definition io.c:2800
libusb_wait_for_event
int libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
Wait for another thread to signal completion of an event.
Definition io.c:2026
libusb_pollfds_handle_timeouts
int libusb_pollfds_handle_timeouts(libusb_context *ctx)
Determines whether your application must apply special timing considerations when monitoring libusb's...
Definition io.c:2538
libusb_interrupt_transfer
int libusb_interrupt_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout)
Perform a USB interrupt transfer.
Definition sync.c:333
libusb_bulk_transfer
int libusb_bulk_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout)
Perform a USB bulk transfer.
Definition sync.c:279
libusb_control_transfer
int libusb_control_transfer(libusb_device_handle *dev_handle, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout)
Perform a USB control transfer.
Definition sync.c:102
libusb_bos_descriptor
A structure representing the Binary Device Object Store (BOS) descriptor.
Definition libusb.h:895
libusb_bos_descriptor::wTotalLength
uint16_t wTotalLength
Length of this descriptor and all of its sub descriptors.
Definition libusb.h:905
libusb_bos_descriptor::dev_capability
struct libusb_bos_dev_capability_descriptor * dev_capability[LIBUSB_FLEXIBLE_ARRAY]
bNumDeviceCap Device Capability Descriptors
Definition libusb.h:912
libusb_bos_descriptor::bNumDeviceCaps
uint8_t bNumDeviceCaps
The number of separate device capability descriptors in the BOS.
Definition libusb.h:909
libusb_bos_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:897
libusb_bos_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:902
libusb_bos_dev_capability_descriptor
A generic representation of a BOS Device Capability descriptor.
Definition libusb.h:874
libusb_bos_dev_capability_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:876
libusb_bos_dev_capability_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:881
libusb_bos_dev_capability_descriptor::bDevCapabilityType
uint8_t bDevCapabilityType
Device Capability type.
Definition libusb.h:884
libusb_bos_dev_capability_descriptor::dev_capability_data
uint8_t dev_capability_data[LIBUSB_FLEXIBLE_ARRAY]
Device Capability data (bLength - 3 bytes)
Definition libusb.h:887
libusb_config_descriptor
A structure representing the standard USB configuration descriptor.
Definition libusb.h:797
libusb_config_descriptor::bConfigurationValue
uint8_t bConfigurationValue
Identifier value for this configuration.
Definition libusb.h:813
libusb_config_descriptor::iConfiguration
uint8_t iConfiguration
Index of string descriptor describing this configuration.
Definition libusb.h:816
libusb_config_descriptor::extra_length
int extra_length
Length of the extra descriptors, in bytes.
Definition libusb.h:836
libusb_config_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:799
libusb_config_descriptor::bNumInterfaces
uint8_t bNumInterfaces
Number of interfaces supported by this configuration.
Definition libusb.h:810
libusb_config_descriptor::MaxPower
uint8_t MaxPower
Maximum power consumption of the USB device from this bus in this configuration when the device is fu...
Definition libusb.h:825
libusb_config_descriptor::wTotalLength
uint16_t wTotalLength
Total length of data returned for this configuration.
Definition libusb.h:807
libusb_config_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:804
libusb_config_descriptor::extra
const unsigned char * extra
Extra descriptors.
Definition libusb.h:833
libusb_config_descriptor::bmAttributes
uint8_t bmAttributes
Configuration characteristics.
Definition libusb.h:819
libusb_config_descriptor::interface
const struct libusb_interface * interface
Array of interfaces supported by this configuration.
Definition libusb.h:829
libusb_container_id_descriptor
A structure representing the Container ID descriptor.
Definition libusb.h:988
libusb_container_id_descriptor::ContainerID
uint8_t ContainerID[16]
128 bit UUID
Definition libusb.h:1006
libusb_container_id_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:995
libusb_container_id_descriptor::bDevCapabilityType
uint8_t bDevCapabilityType
Capability type.
Definition libusb.h:1000
libusb_container_id_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:990
libusb_container_id_descriptor::bReserved
uint8_t bReserved
Reserved field.
Definition libusb.h:1003
libusb_control_setup
Setup packet for control transfers.
Definition libusb.h:1042
libusb_control_setup::bRequest
uint8_t bRequest
Request.
Definition libusb.h:1055
libusb_control_setup::bmRequestType
uint8_t bmRequestType
Request type.
Definition libusb.h:1048
libusb_control_setup::wLength
uint16_t wLength
Number of bytes to transfer.
Definition libusb.h:1065
libusb_control_setup::wIndex
uint16_t wIndex
Index.
Definition libusb.h:1062
libusb_control_setup::wValue
uint16_t wValue
Value.
Definition libusb.h:1058
libusb_device_descriptor
A structure representing the standard USB device descriptor.
Definition libusb.h:573
libusb_device_descriptor::bNumConfigurations
uint8_t bNumConfigurations
Number of possible configurations.
Definition libusb.h:619
libusb_device_descriptor::iProduct
uint8_t iProduct
Index of string descriptor describing product.
Definition libusb.h:613
libusb_device_descriptor::iSerialNumber
uint8_t iSerialNumber
Index of string descriptor containing device serial number.
Definition libusb.h:616
libusb_device_descriptor::bMaxPacketSize0
uint8_t bMaxPacketSize0
Maximum packet size for endpoint 0.
Definition libusb.h:598
libusb_device_descriptor::bDeviceProtocol
uint8_t bDeviceProtocol
USB-IF protocol code for the device, qualified by the bDeviceClass and bDeviceSubClass values.
Definition libusb.h:595
libusb_device_descriptor::idProduct
uint16_t idProduct
USB-IF product ID.
Definition libusb.h:604
libusb_device_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:580
libusb_device_descriptor::bDeviceSubClass
uint8_t bDeviceSubClass
USB-IF subclass code for the device, qualified by the bDeviceClass value.
Definition libusb.h:591
libusb_device_descriptor::bDeviceClass
uint8_t bDeviceClass
USB-IF class code for the device.
Definition libusb.h:587
libusb_device_descriptor::iManufacturer
uint8_t iManufacturer
Index of string descriptor describing manufacturer.
Definition libusb.h:610
libusb_device_descriptor::idVendor
uint16_t idVendor
USB-IF vendor ID.
Definition libusb.h:601
libusb_device_descriptor::bcdUSB
uint16_t bcdUSB
USB specification release number in binary-coded decimal.
Definition libusb.h:584
libusb_device_descriptor::bcdDevice
uint16_t bcdDevice
Device release number in binary-coded decimal.
Definition libusb.h:607
libusb_device_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:575
libusb_endpoint_descriptor
A structure representing the standard USB endpoint descriptor.
Definition libusb.h:627
libusb_endpoint_descriptor::extra_length
int extra_length
Length of the extra descriptors, in bytes.
Definition libusb.h:667
libusb_endpoint_descriptor::bEndpointAddress
uint8_t bEndpointAddress
The address of the endpoint described by this descriptor.
Definition libusb.h:639
libusb_endpoint_descriptor::extra
const unsigned char * extra
Extra descriptors.
Definition libusb.h:664
libusb_endpoint_descriptor::bInterval
uint8_t bInterval
Interval for polling endpoint for data transfers.
Definition libusb.h:653
libusb_endpoint_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:634
libusb_endpoint_descriptor::bRefresh
uint8_t bRefresh
For audio devices only: the rate at which synchronization feedback is provided.
Definition libusb.h:657
libusb_endpoint_descriptor::bmAttributes
uint8_t bmAttributes
Attributes which apply to the endpoint when it is configured using the bConfigurationValue.
Definition libusb.h:647
libusb_endpoint_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:629
libusb_endpoint_descriptor::bSynchAddress
uint8_t bSynchAddress
For audio devices only: the address if the synch endpoint.
Definition libusb.h:660
libusb_endpoint_descriptor::wMaxPacketSize
uint16_t wMaxPacketSize
Maximum packet size this endpoint is capable of sending/receiving.
Definition libusb.h:650
libusb_init_option
Structure used for setting options through libusb_init_context.
Definition libusb.h:1566
libusb_init_option::option
enum libusb_option option
Which option to set.
Definition libusb.h:1568
libusb_init_option::value
union libusb_init_option::@0 value
An integer value used by the option (if applicable).
libusb_interface_association_descriptor_array
Structure containing an array of 0 or more interface association descriptors.
Definition libusb.h:719
libusb_interface_association_descriptor_array::iad
const struct libusb_interface_association_descriptor * iad
Array of interface association descriptors.
Definition libusb.h:723
libusb_interface_association_descriptor_array::length
int length
Number of interface association descriptors contained.
Definition libusb.h:726
libusb_interface_association_descriptor
A structure representing the standard USB interface association descriptor.
Definition libusb.h:675
libusb_interface_association_descriptor::bFunctionClass
uint8_t bFunctionClass
USB-IF class code for this function.
Definition libusb.h:697
libusb_interface_association_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:682
libusb_interface_association_descriptor::bFunctionSubClass
uint8_t bFunctionSubClass
USB-IF subclass code for this function.
Definition libusb.h:703
libusb_interface_association_descriptor::bFunctionProtocol
uint8_t bFunctionProtocol
USB-IF protocol code for this function.
Definition libusb.h:709
libusb_interface_association_descriptor::bInterfaceCount
uint8_t bInterfaceCount
Number of contiguous interfaces that are associated with this function.
Definition libusb.h:690
libusb_interface_association_descriptor::iFunction
uint8_t iFunction
Index of string descriptor describing this function.
Definition libusb.h:712
libusb_interface_association_descriptor::bFirstInterface
uint8_t bFirstInterface
Interface number of the first interface that is associated with this function.
Definition libusb.h:686
libusb_interface_association_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:677
libusb_interface_descriptor
A structure representing the standard USB interface descriptor.
Definition libusb.h:734
libusb_interface_descriptor::bInterfaceSubClass
uint8_t bInterfaceSubClass
USB-IF subclass code for this interface, qualified by the bInterfaceClass value.
Definition libusb.h:758
libusb_interface_descriptor::iInterface
uint8_t iInterface
Index of string descriptor describing this interface.
Definition libusb.h:765
libusb_interface_descriptor::bInterfaceClass
uint8_t bInterfaceClass
USB-IF class code for this interface.
Definition libusb.h:754
libusb_interface_descriptor::bAlternateSetting
uint8_t bAlternateSetting
Value used to select this alternate setting for this interface.
Definition libusb.h:747
libusb_interface_descriptor::endpoint
const struct libusb_endpoint_descriptor * endpoint
Array of endpoint descriptors.
Definition libusb.h:769
libusb_interface_descriptor::bNumEndpoints
uint8_t bNumEndpoints
Number of endpoints used by this interface (excluding the control endpoint).
Definition libusb.h:751
libusb_interface_descriptor::bInterfaceProtocol
uint8_t bInterfaceProtocol
USB-IF protocol code for this interface, qualified by the bInterfaceClass and bInterfaceSubClass valu...
Definition libusb.h:762
libusb_interface_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:736
libusb_interface_descriptor::bInterfaceNumber
uint8_t bInterfaceNumber
Number of this interface.
Definition libusb.h:744
libusb_interface_descriptor::extra
const unsigned char * extra
Extra descriptors.
Definition libusb.h:773
libusb_interface_descriptor::extra_length
int extra_length
Length of the extra descriptors, in bytes.
Definition libusb.h:776
libusb_interface_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:741
libusb_interface
A collection of alternate settings for a particular USB interface.
Definition libusb.h:782
libusb_interface::altsetting
const struct libusb_interface_descriptor * altsetting
Array of interface descriptors.
Definition libusb.h:785
libusb_interface::num_altsetting
int num_altsetting
The number of alternate settings that belong to this interface.
Definition libusb.h:789
libusb_iso_packet_descriptor
Isochronous packet descriptor.
Definition libusb.h:1326
libusb_iso_packet_descriptor::actual_length
unsigned int actual_length
Amount of data that was actually transferred.
Definition libusb.h:1331
libusb_iso_packet_descriptor::length
unsigned int length
Length of data to request in this packet.
Definition libusb.h:1328
libusb_iso_packet_descriptor::status
enum libusb_transfer_status status
Status code for this packet.
Definition libusb.h:1334
libusb_platform_descriptor
A structure representing a Platform descriptor.
Definition libusb.h:1013
libusb_platform_descriptor::bDevCapabilityType
uint8_t bDevCapabilityType
Capability type.
Definition libusb.h:1025
libusb_platform_descriptor::PlatformCapabilityUUID
uint8_t PlatformCapabilityUUID[16]
128 bit UUID
Definition libusb.h:1031
libusb_platform_descriptor::bReserved
uint8_t bReserved
Reserved field.
Definition libusb.h:1028
libusb_platform_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:1015
libusb_platform_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:1020
libusb_platform_descriptor::CapabilityData
uint8_t CapabilityData[LIBUSB_FLEXIBLE_ARRAY]
Capability data (bLength - 20)
Definition libusb.h:1034
libusb_pollfd
File descriptor for polling.
Definition libusb.h:2121
libusb_pollfd::events
short events
Event flags to poll for from <poll.h>.
Definition libusb.h:2129
libusb_pollfd::fd
int fd
Numeric file descriptor.
Definition libusb.h:2123
libusb_ss_endpoint_companion_descriptor
A structure representing the superspeed endpoint companion descriptor.
Definition libusb.h:845
libusb_ss_endpoint_companion_descriptor::wBytesPerInterval
uint16_t wBytesPerInterval
The total number of bytes this EP will transfer every service interval.
Definition libusb.h:866
libusb_ss_endpoint_companion_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:847
libusb_ss_endpoint_companion_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:852
libusb_ss_endpoint_companion_descriptor::bMaxBurst
uint8_t bMaxBurst
The maximum number of packets the endpoint can send or receive as part of a burst.
Definition libusb.h:856
libusb_ss_endpoint_companion_descriptor::bmAttributes
uint8_t bmAttributes
In bulk EP: bits 4:0 represents the maximum number of streams the EP supports.
Definition libusb.h:862
libusb_ss_usb_device_capability_descriptor
A structure representing the SuperSpeed USB Device Capability descriptor This descriptor is documente...
Definition libusb.h:946
libusb_ss_usb_device_capability_descriptor::bDevCapabilityType
uint8_t bDevCapabilityType
Capability type.
Definition libusb.h:958
libusb_ss_usb_device_capability_descriptor::wSpeedSupported
uint16_t wSpeedSupported
Bitmap encoding of the speed supported by this device when operating in SuperSpeed mode.
Definition libusb.h:968
libusb_ss_usb_device_capability_descriptor::bFunctionalitySupport
uint8_t bFunctionalitySupport
The lowest speed at which all the functionality supported by the device is available to the user.
Definition libusb.h:974
libusb_ss_usb_device_capability_descriptor::bU2DevExitLat
uint16_t bU2DevExitLat
U2 Device Exit Latency.
Definition libusb.h:980
libusb_ss_usb_device_capability_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:948
libusb_ss_usb_device_capability_descriptor::bmAttributes
uint8_t bmAttributes
Bitmap encoding of supported device level features.
Definition libusb.h:964
libusb_ss_usb_device_capability_descriptor::bU1DevExitLat
uint8_t bU1DevExitLat
U1 Device Exit Latency.
Definition libusb.h:977
libusb_ss_usb_device_capability_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:953
libusb_transfer
The generic USB transfer structure.
Definition libusb.h:1356
libusb_transfer::endpoint
unsigned char endpoint
Address of the endpoint where this transfer will be sent.
Definition libusb.h:1364
libusb_transfer::status
enum libusb_transfer_status status
The status of the transfer.
Definition libusb.h:1380
libusb_transfer::length
int length
Length of the data buffer.
Definition libusb.h:1383
libusb_transfer::callback
libusb_transfer_cb_fn callback
Callback function.
Definition libusb.h:1392
libusb_transfer::iso_packet_desc
struct libusb_iso_packet_descriptor iso_packet_desc[LIBUSB_FLEXIBLE_ARRAY]
Isochronous packet descriptors, for isochronous transfers only.
Definition libusb.h:1414
libusb_transfer::type
unsigned char type
Type of the transfer from libusb_transfer_type.
Definition libusb.h:1367
libusb_transfer::actual_length
int actual_length
Actual length of data that was transferred.
Definition libusb.h:1388
libusb_transfer::buffer
unsigned char * buffer
Data buffer.
Definition libusb.h:1407
libusb_transfer::num_iso_packets
int num_iso_packets
Number of isochronous packets.
Definition libusb.h:1411
libusb_transfer::timeout
unsigned int timeout
Timeout for this transfer in milliseconds.
Definition libusb.h:1371
libusb_transfer::user_data
void * user_data
User context data.
Definition libusb.h:1404
libusb_transfer::dev_handle
libusb_device_handle * dev_handle
Handle of the device that this transfer will be submitted to.
Definition libusb.h:1358
libusb_transfer::flags
uint8_t flags
A bitwise OR combination of libusb_transfer_flags.
Definition libusb.h:1361
libusb_usb_2_0_extension_descriptor
A structure representing the USB 2.0 Extension descriptor This descriptor is documented in section 9....
Definition libusb.h:920
libusb_usb_2_0_extension_descriptor::bLength
uint8_t bLength
Size of this descriptor (in bytes)
Definition libusb.h:922
libusb_usb_2_0_extension_descriptor::bDevCapabilityType
uint8_t bDevCapabilityType
Capability type.
Definition libusb.h:932
libusb_usb_2_0_extension_descriptor::bmAttributes
uint32_t bmAttributes
Bitmap encoding of supported device level features.
Definition libusb.h:938
libusb_usb_2_0_extension_descriptor::bDescriptorType
uint8_t bDescriptorType
Descriptor type.
Definition libusb.h:927
libusb_version
Structure providing the version of the libusb runtime.
Definition libusb.h:1082
libusb_version::micro
const uint16_t micro
Library micro version.
Definition libusb.h:1090
libusb_version::major
const uint16_t major
Library major version.
Definition libusb.h:1084
libusb_version::rc
const char * rc
Library release candidate suffix string, e.g.
Definition libusb.h:1096
libusb_version::minor
const uint16_t minor
Library minor version.
Definition libusb.h:1087
libusb_version::describe
const char * describe
For ABI compatibility only.
Definition libusb.h:1099
libusb_version::nano
const uint16_t nano
Library nano version.
Definition libusb.h:1093