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>
40 typedef 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)
182 extern "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 
224 
227 
230 
233 
236 
239  LIBUSB_CLASS_PTP = 0x06, /* legacy name from libusb-0.1 usb.h */
240 
243 
246 
249 
252 
255 
258 
261 
264 
267 
270 
273 
276 
279 };
280 
286 
289 
292 
295 
298 
302 
305 
308 
311 
314 
317 
320 
323 
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 
362 
364  LIBUSB_ENDPOINT_IN = 0x80
365 };
366 
367 #define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
368 
376 
379 
382 
385 };
386 
392 
395 
396  /* 0x02 is reserved */
397 
400 
401  /* 0x04 is reserved */
402 
405 
408 
411 
414 
417 
420 
423 
426 
429 
433 };
434 
442 
445 
448 
450  LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5)
451 };
452 
460 
463 
466 
469 };
470 
471 #define LIBUSB_ISO_SYNC_TYPE_MASK 0x0c
472 
481 
484 
487 
490 };
491 
492 #define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
493 
502 
505 
508 };
509 
517 
520 
523 
526 };
527 
535  LIBUSB_BM_LPM_SUPPORT = (1 << 1)
536 };
537 
545  LIBUSB_BM_LTM_SUPPORT = (1 << 1)
546 };
547 
554 
557 
560 
563 
566 };
567 
575  uint8_t bLength;
576 
581 
584  uint16_t bcdUSB;
585 
587  uint8_t bDeviceClass;
588 
592 
596 
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 
620 };
621 
629  uint8_t bLength;
630 
635 
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 
668 };
669 
677  uint8_t bLength;
678 
683 
687 
691 
697  uint8_t bFunctionClass;
698 
704 
710 
712  uint8_t iFunction;
713 };
714 
724 
726  int length;
727 };
728 
736  uint8_t bLength;
737 
742 
745 
748 
751  uint8_t bNumEndpoints;
752 
755 
759 
763 
765  uint8_t iInterface;
766 
770 
773  const unsigned char *extra;
774 
777 };
778 
786 
790 };
791 
799  uint8_t bLength;
800 
805 
807  uint16_t wTotalLength;
808 
810  uint8_t bNumInterfaces;
811 
814 
816  uint8_t iConfiguration;
817 
819  uint8_t bmAttributes;
820 
825  uint8_t MaxPower;
826 
830 
833  const unsigned char *extra;
834 
837 };
838 
847  uint8_t bLength;
848 
853 
856  uint8_t bMaxBurst;
857 
862  uint8_t bmAttributes;
863 
867 };
868 
876  uint8_t bLength;
877 
882 
885 
887  uint8_t dev_capability_data[LIBUSB_FLEXIBLE_ARRAY];
888 };
889 
897  uint8_t bLength;
898 
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 
922  uint8_t bLength;
923 
928 
933 
938  uint32_t bmAttributes;
939 };
940 
948  uint8_t bLength;
949 
954 
959 
964  uint8_t bmAttributes;
965 
968  uint16_t wSpeedSupported;
969 
975 
977  uint8_t bU1DevExitLat;
978 
980  uint16_t bU2DevExitLat;
981 };
982 
990  uint8_t bLength;
991 
996 
1001 
1003  uint8_t bReserved;
1004 
1006  uint8_t ContainerID[16];
1007 };
1008 
1015  uint8_t bLength;
1016 
1021 
1026 
1028  uint8_t bReserved;
1029 
1032 
1034  uint8_t CapabilityData[LIBUSB_FLEXIBLE_ARRAY];
1035 };
1036 
1039 #if defined(_MSC_VER) || defined(__WATCOMC__)
1040 #pragma pack(push, 1)
1041 #endif
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 
1075 struct libusb_context;
1076 struct libusb_device;
1077 struct libusb_device_handle;
1078 
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 
1149 
1156 
1159 
1162 
1165 
1168 
1171 };
1172 
1183 
1186 
1189 
1192 
1195 
1198 
1201 
1204 
1207 
1210 
1213 
1216 
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 
1235 
1238 
1241 
1244 
1247 };
1248 
1255 
1258 
1261 
1264 
1268 
1271 
1274 
1275  /* NB! Remember to update libusb_error_name()
1276  when adding new status codes here. */
1277 };
1278 
1284 
1290 
1296 
1322 };
1323 
1328  unsigned int length;
1329 
1331  unsigned int actual_length;
1332 
1335 };
1336 
1337 struct libusb_transfer;
1338 
1348 typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
1349 
1359 
1361  uint8_t flags;
1362 
1364  unsigned char endpoint;
1365 
1367  unsigned char type;
1368 
1371  unsigned int timeout;
1372 
1381 
1383  int length;
1384 
1389 
1393 
1404  void *user_data;
1405 
1407  unsigned char *buffer;
1408 
1412 
1414  struct libusb_iso_packet_descriptor iso_packet_desc[LIBUSB_FLEXIBLE_ARRAY];
1415 };
1416 
1425 
1428 
1434 
1438 };
1439 
1446 
1449 
1452 
1455 
1458 };
1459 
1470 
1472  LIBUSB_LOG_CB_CONTEXT = (1 << 1)
1473 };
1474 
1502 
1511 
1531 
1532 #define LIBUSB_OPTION_WEAK_AUTHORITY LIBUSB_OPTION_NO_DEVICE_DISCOVERY
1533 
1544 
1545  LIBUSB_OPTION_MAX = 4
1546 };
1547 
1560  enum libusb_log_level level, const char *str);
1561 
1568  enum libusb_option option;
1570  union {
1571  int ival;
1572  libusb_log_cb log_cbval;
1574 };
1575 
1577 int LIBUSB_CALL libusb_init_context(libusb_context **ctx, const struct libusb_init_option options[], int num_options);
1579 void 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() */
1582 const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
1583 int LIBUSB_CALL libusb_has_capability(uint32_t capability);
1584 const char * LIBUSB_CALL libusb_error_name(int errcode);
1585 int LIBUSB_CALL libusb_setlocale(const char *locale);
1586 const char * LIBUSB_CALL libusb_strerror(int errcode);
1587 
1589  libusb_device ***list);
1591  int unref_devices);
1594 
1596  int *config);
1598  struct libusb_device_descriptor *desc);
1600  struct libusb_config_descriptor **config);
1602  uint8_t config_index, struct libusb_config_descriptor **config);
1604  uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
1606  struct libusb_config_descriptor *config);
1608  libusb_context *ctx,
1609  const struct libusb_endpoint_descriptor *endpoint,
1610  struct libusb_ss_endpoint_companion_descriptor **ep_comp);
1612  struct libusb_ss_endpoint_companion_descriptor *ep_comp);
1614  struct libusb_bos_descriptor **bos);
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);
1621  struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
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);
1627  struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
1629  struct libusb_bos_dev_capability_descriptor *dev_cap,
1630  struct libusb_container_id_descriptor **container_id);
1632  struct libusb_container_id_descriptor *container_id);
1634  struct libusb_bos_dev_capability_descriptor *dev_cap,
1635  struct libusb_platform_descriptor **platform_descriptor);
1637  struct libusb_platform_descriptor *platform_descriptor);
1640 int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len);
1641 LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
1642 int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *path, uint8_t path_length);
1647  unsigned char endpoint);
1649  unsigned char endpoint);
1651  int interface_number, int alternate_setting, unsigned char endpoint);
1652 
1654  uint8_t config_index, struct libusb_interface_association_descriptor_array **iad_array);
1659 
1660 int LIBUSB_CALL libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle);
1664 
1666  int configuration);
1668  int interface_number);
1670  int interface_number);
1671 
1673  libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
1674 
1676  int interface_number, int alternate_setting);
1678  unsigned char endpoint);
1680 
1682  uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
1684  unsigned char *endpoints, int num_endpoints);
1685 
1686 unsigned char * LIBUSB_CALL libusb_dev_mem_alloc(libusb_device_handle *dev_handle,
1687  size_t length);
1689  unsigned char *buffer, size_t length);
1690 
1692  int interface_number);
1694  int interface_number);
1696  int interface_number);
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 
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);
1771 }
1772 
1773 struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
1774 int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
1775 int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
1776 void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
1778  struct libusb_transfer *transfer, uint32_t 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 
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);
1881  libusb_transfer_set_stream_id(transfer, stream_id);
1882 }
1883 
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;
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;
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 
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 
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 
2042  unsigned char endpoint, unsigned char *data, int length,
2043  int *actual_length, unsigned int timeout);
2044 
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 
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 
2092  uint8_t desc_index, unsigned char *data, int length);
2093 
2094 /* polling and timeouts */
2095 
2104 int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
2105 
2107  struct timeval *tv);
2109  struct timeval *tv, int *completed);
2113  struct timeval *tv);
2116  struct timeval *tv);
2117 
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 
2157  libusb_context *ctx);
2158 void LIBUSB_CALL libusb_free_pollfds(const struct libusb_pollfd **pollfds);
2160  libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
2161  void *user_data);
2162 
2176 
2182 typedef enum {
2185 
2191 
2197 typedef enum {
2199  LIBUSB_HOTPLUG_ENUMERATE = (1 << 0)
2201 
2204 #define LIBUSB_HOTPLUG_NO_FLAGS 0
2205 
2208 #define LIBUSB_HOTPLUG_MATCH_ANY -1
2209 
2233  libusb_device *device, libusb_hotplug_event event, void *user_data);
2234 
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 
2288  libusb_hotplug_callback_handle callback_handle);
2289 
2299  libusb_hotplug_callback_handle callback_handle);
2300 
2301 int 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
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_transfer_flags
libusb_transfer.flags values
Definition: libusb.h:1281
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
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
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
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
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
uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer)
Get a transfers bulk stream id.
Definition: io.c:1667
int libusb_cancel_transfer(struct libusb_transfer *transfer)
Asynchronously cancel a previously submitted transfer.
Definition: io.c:1606
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
void libusb_free_transfer(struct libusb_transfer *transfer)
Free a transfer structure.
Definition: io.c:1331
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
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
Transfer status codes.
Definition: libusb.h:1251
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
int libusb_submit_transfer(struct libusb_transfer *transfer)
Submit a transfer.
Definition: io.c:1486
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
void(* libusb_transfer_cb_fn)(struct libusb_transfer *transfer)
Asynchronous transfer callback function type.
Definition: libusb.h:1348
libusb_transfer_type
Transfer type.
Definition: libusb.h:1232
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
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
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
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
static unsigned char * libusb_control_transfer_get_data(struct libusb_transfer *transfer)
Get the data section of a control transfer.
Definition: libusb.h:1714
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
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
Automatically call libusb_free_transfer() after callback returns.
Definition: libusb.h:1295
@ LIBUSB_TRANSFER_SHORT_NOT_OK
Report short frames as errors.
Definition: libusb.h:1283
@ LIBUSB_TRANSFER_FREE_BUFFER
Automatically free() transfer buffer during libusb_free_transfer().
Definition: libusb.h:1289
@ LIBUSB_TRANSFER_STALL
For bulk/interrupt endpoints: halt condition detected (endpoint stalled).
Definition: libusb.h:1267
@ LIBUSB_TRANSFER_COMPLETED
Transfer completed without error.
Definition: libusb.h:1254
@ LIBUSB_TRANSFER_CANCELLED
Transfer was cancelled.
Definition: libusb.h:1263
@ LIBUSB_TRANSFER_ERROR
Transfer failed.
Definition: libusb.h:1257
@ LIBUSB_TRANSFER_OVERFLOW
Device sent more data than requested.
Definition: libusb.h:1273
@ LIBUSB_TRANSFER_NO_DEVICE
Device was disconnected.
Definition: libusb.h:1270
@ LIBUSB_TRANSFER_TIMED_OUT
Transfer timed out.
Definition: libusb.h:1260
@ LIBUSB_TRANSFER_TYPE_BULK_STREAM
Bulk stream transfer.
Definition: libusb.h:1246
@ LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
Isochronous transfer.
Definition: libusb.h:1237
@ LIBUSB_TRANSFER_TYPE_CONTROL
Control transfer.
Definition: libusb.h:1234
@ LIBUSB_TRANSFER_TYPE_BULK
Bulk transfer.
Definition: libusb.h:1240
@ LIBUSB_TRANSFER_TYPE_INTERRUPT
Interrupt transfer.
Definition: libusb.h:1243
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
Descriptor types as defined by the USB specification.
Definition: libusb.h:283
libusb_supported_speed
Supported speeds (wSpeedSupported) bitfield.
Definition: libusb.h:514
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
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
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
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
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
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
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
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
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
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
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
USB capability types.
Definition: libusb.h:551
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
Endpoint direction.
Definition: libusb.h:359
libusb_endpoint_transfer_type
Endpoint transfer type.
Definition: libusb.h:373
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
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
Synchronization type for isochronous endpoints.
Definition: libusb.h:478
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
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
Masks for the bits of the bmAttributes field field of the SuperSpeed USB Device Capability descriptor...
Definition: libusb.h:543
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
Usage type for isochronous endpoints.
Definition: libusb.h:499
libusb_class_code
Device and/or Interface Class codes.
Definition: libusb.h:218
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
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
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
Masks for the bits of the bmAttributes field of the USB 2.0 Extension descriptor.
Definition: libusb.h:533
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
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
Hub descriptor.
Definition: libusb.h:319
@ LIBUSB_DT_CONFIG
Configuration descriptor.
Definition: libusb.h:288
@ LIBUSB_DT_STRING
String descriptor.
Definition: libusb.h:291
@ LIBUSB_DT_HID
HID descriptor.
Definition: libusb.h:310
@ LIBUSB_DT_REPORT
HID report descriptor.
Definition: libusb.h:313
@ LIBUSB_DT_DEVICE
Device descriptor.
Definition: libusb.h:285
@ LIBUSB_DT_DEVICE_CAPABILITY
Device Capability descriptor.
Definition: libusb.h:307
@ LIBUSB_DT_SUPERSPEED_HUB
SuperSpeed Hub descriptor.
Definition: libusb.h:322
@ LIBUSB_DT_PHYSICAL
Physical descriptor.
Definition: libusb.h:316
@ LIBUSB_DT_INTERFACE
Interface descriptor.
Definition: libusb.h:294
@ LIBUSB_DT_ENDPOINT
Endpoint descriptor.
Definition: libusb.h:297
@ LIBUSB_DT_SS_ENDPOINT_COMPANION
SuperSpeed Endpoint Companion descriptor.
Definition: libusb.h:325
@ LIBUSB_DT_BOS
BOS descriptor.
Definition: libusb.h:304
@ LIBUSB_DT_INTERFACE_ASSOCIATION
Interface Association Descriptor.
Definition: libusb.h:301
@ LIBUSB_HIGH_SPEED_OPERATION
High speed operation supported (480MBit/s).
Definition: libusb.h:522
@ LIBUSB_LOW_SPEED_OPERATION
Low speed operation supported (1.5MBit/s).
Definition: libusb.h:516
@ LIBUSB_SUPER_SPEED_OPERATION
Superspeed operation supported (5000MBit/s).
Definition: libusb.h:525
@ LIBUSB_FULL_SPEED_OPERATION
Full speed operation supported (12MBit/s).
Definition: libusb.h:519
@ LIBUSB_BT_USB_2_0_EXTENSION
USB 2.0 extensions.
Definition: libusb.h:556
@ LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
SuperSpeed USB device capability.
Definition: libusb.h:559
@ LIBUSB_BT_PLATFORM_DESCRIPTOR
Platform descriptor.
Definition: libusb.h:565
@ LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY
Wireless USB device capability.
Definition: libusb.h:553
@ LIBUSB_BT_CONTAINER_ID
Container ID type.
Definition: libusb.h:562
@ LIBUSB_ENDPOINT_IN
In: device-to-host.
Definition: libusb.h:364
@ LIBUSB_ENDPOINT_OUT
Out: host-to-device.
Definition: libusb.h:361
@ LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT
Interrupt endpoint.
Definition: libusb.h:384
@ LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS
Isochronous endpoint.
Definition: libusb.h:378
@ LIBUSB_ENDPOINT_TRANSFER_TYPE_BULK
Bulk endpoint.
Definition: libusb.h:381
@ LIBUSB_ENDPOINT_TRANSFER_TYPE_CONTROL
Control endpoint.
Definition: libusb.h:375
@ LIBUSB_ISO_SYNC_TYPE_SYNC
Synchronous.
Definition: libusb.h:489
@ LIBUSB_ISO_SYNC_TYPE_NONE
No synchronization.
Definition: libusb.h:480
@ LIBUSB_ISO_SYNC_TYPE_ADAPTIVE
Adaptive.
Definition: libusb.h:486
@ LIBUSB_ISO_SYNC_TYPE_ASYNC
Asynchronous.
Definition: libusb.h:483
@ LIBUSB_BM_LTM_SUPPORT
Supports Latency Tolerance Messages (LTM)
Definition: libusb.h:545
@ LIBUSB_ISO_USAGE_TYPE_DATA
Data endpoint.
Definition: libusb.h:501
@ LIBUSB_ISO_USAGE_TYPE_FEEDBACK
Feedback endpoint.
Definition: libusb.h:504
@ LIBUSB_ISO_USAGE_TYPE_IMPLICIT
Implicit feedback Data endpoint.
Definition: libusb.h:507
@ LIBUSB_CLASS_AUDIO
Audio class.
Definition: libusb.h:226
@ LIBUSB_CLASS_HUB
Hub class.
Definition: libusb.h:248
@ LIBUSB_CLASS_MISCELLANEOUS
Miscellaneous class.
Definition: libusb.h:272
@ LIBUSB_CLASS_APPLICATION
Application class.
Definition: libusb.h:275
@ LIBUSB_CLASS_CONTENT_SECURITY
Content Security.
Definition: libusb.h:257
@ LIBUSB_CLASS_DIAGNOSTIC_DEVICE
Diagnostic Device.
Definition: libusb.h:266
@ LIBUSB_CLASS_PHYSICAL
Physical.
Definition: libusb.h:235
@ LIBUSB_CLASS_COMM
Communications class.
Definition: libusb.h:229
@ LIBUSB_CLASS_VIDEO
Video.
Definition: libusb.h:260
@ LIBUSB_CLASS_DATA
Data class.
Definition: libusb.h:251
@ LIBUSB_CLASS_WIRELESS
Wireless class.
Definition: libusb.h:269
@ LIBUSB_CLASS_PRINTER
Printer class.
Definition: libusb.h:242
@ LIBUSB_CLASS_PERSONAL_HEALTHCARE
Personal Healthcare.
Definition: libusb.h:263
@ 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
Mass storage class.
Definition: libusb.h:245
@ LIBUSB_CLASS_HID
Human Interface Device class.
Definition: libusb.h:232
@ LIBUSB_CLASS_VENDOR_SPEC
Class is vendor-specific.
Definition: libusb.h:278
@ LIBUSB_CLASS_IMAGE
Image class.
Definition: libusb.h:238
@ LIBUSB_CLASS_SMART_CARD
Smart Card.
Definition: libusb.h:254
@ LIBUSB_BM_LPM_SUPPORT
Supports Link Power Management (LPM)
Definition: libusb.h:535
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_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
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
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_speed
Speed codes.
Definition: libusb.h:1153
void libusb_unref_device(libusb_device *dev)
Decrement the reference count of a device.
Definition: core.c:1288
int libusb_open(libusb_device *dev, libusb_device_handle **dev_handle)
Open a device and obtain a device handle.
Definition: core.c:1405
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
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
int libusb_get_device_speed(libusb_device *dev)
Get the negotiated connection speed for a device.
Definition: core.c:1015
int libusb_detach_kernel_driver(libusb_device_handle *dev_handle, int interface_number)
Detach a kernel driver from an interface.
Definition: core.c:2122
void libusb_close(libusb_device_handle *dev_handle)
Close a device handle.
Definition: core.c:1562
struct libusb_device libusb_device
Structure representing a USB device detected on the system.
Definition: libusb.h:1137
int libusb_set_configuration(libusb_device_handle *dev_handle, int configuration)
Set the active configuration for a device.
Definition: core.c:1736
struct libusb_device_handle libusb_device_handle
Structure representing a handle on a USB device.
Definition: libusb.h:1148
libusb_device * libusb_get_parent(libusb_device *dev)
Get the the parent from the specified device.
Definition: core.c:994
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
int libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *path, uint8_t path_length)
Definition: core.c:974
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_device * libusb_ref_device(libusb_device *dev)
Increment the reference count of a device.
Definition: core.c:1273
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
int libusb_clear_halt(libusb_device_handle *dev_handle, unsigned char endpoint)
Clear the halt/stall condition for an endpoint.
Definition: core.c:1903
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
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
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
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
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
int libusb_get_configuration(libusb_device_handle *dev, int *config)
Determine the bConfigurationValue of the currently active configuration.
Definition: core.c:1649
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
int libusb_claim_interface(libusb_device_handle *dev_handle, int interface_number)
Claim an interface on a given device handle.
Definition: core.c:1773
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_device * libusb_get_device(libusb_device_handle *dev_handle)
Get the underlying device for a device handle.
Definition: core.c:1624
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
The device is operating at full speed (12MBit/s).
Definition: libusb.h:1161
@ LIBUSB_SPEED_HIGH
The device is operating at high speed (480MBit/s).
Definition: libusb.h:1164
@ LIBUSB_SPEED_LOW
The device is operating at low speed (1.5MBit/s).
Definition: libusb.h:1158
@ LIBUSB_SPEED_SUPER_PLUS
The device is operating at super speed plus (10000MBit/s).
Definition: libusb.h:1170
@ LIBUSB_SPEED_SUPER
The device is operating at super speed (5000MBit/s).
Definition: libusb.h:1167
@ LIBUSB_SPEED_UNKNOWN
The OS doesn't report or know the device speed.
Definition: libusb.h:1155
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
int libusb_hotplug_callback_handle
Callback handle.
Definition: libusb.h:2175
libusb_hotplug_event
Since version 1.0.16, LIBUSB_API_VERSION >= 0x01000102.
Definition: libusb.h:2182
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
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
Since version 1.0.16, LIBUSB_API_VERSION >= 0x01000102.
Definition: libusb.h:2197
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
A device has been plugged in and is ready to use.
Definition: libusb.h:2184
@ LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT
A device has left and is no longer available.
Definition: libusb.h:2189
@ LIBUSB_HOTPLUG_ENUMERATE
Arm the callback and fire it for all matching currently attached devices.
Definition: libusb.h:2199
libusb_option
Available option values for libusb_set_option() and libusb_init_context().
Definition: libusb.h:1478
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
Log callback mode.
Definition: libusb.h:1467
libusb_log_level
Log message levels.
Definition: libusb.h:1443
void libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode)
Set log handler.
Definition: core.c:2262
struct libusb_context libusb_context
Structure representing a libusb session.
Definition: libusb.h:1120
void libusb_set_debug(libusb_context *ctx, int level)
Deprecated.
Definition: core.c:2211
int libusb_init(libusb_context **ctx)
Deprecated initialization function.
Definition: core.c:2401
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
int libusb_init_context(libusb_context **ctx, const struct libusb_init_option options[], int num_options)
Initialize libusb.
Definition: core.c:2424
void libusb_exit(libusb_context *ctx)
Deinitialize libusb.
Definition: core.c:2577
@ LIBUSB_OPTION_NO_DEVICE_DISCOVERY
Do not scan for devices.
Definition: libusb.h:1530
@ LIBUSB_OPTION_LOG_CB
Set the context log callback function.
Definition: libusb.h:1543
@ LIBUSB_OPTION_LOG_LEVEL
Set the log message verbosity.
Definition: libusb.h:1501
@ LIBUSB_OPTION_USE_USBDK
Use the UsbDk backend for a specific context, if available.
Definition: libusb.h:1510
@ LIBUSB_LOG_CB_GLOBAL
Callback function handling all log messages.
Definition: libusb.h:1469
@ LIBUSB_LOG_CB_CONTEXT
Callback function handling context related log messages.
Definition: libusb.h:1472
@ LIBUSB_LOG_LEVEL_WARNING
(2) : Warning and error messages are emitted
Definition: libusb.h:1451
@ LIBUSB_LOG_LEVEL_INFO
(3) : Informational, warning and error messages are emitted
Definition: libusb.h:1454
@ LIBUSB_LOG_LEVEL_ERROR
(1) : Error messages are emitted
Definition: libusb.h:1448
@ LIBUSB_LOG_LEVEL_NONE
(0) : No messages ever emitted by the library (default)
Definition: libusb.h:1445
@ LIBUSB_LOG_LEVEL_DEBUG
(4) : All messages are emitted
Definition: libusb.h:1457
libusb_request_type
Request type bits of the bmRequestType field in control transfers.
Definition: libusb.h:439
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_request_recipient
Recipient bits of the bmRequestType field in control transfers.
Definition: libusb.h:457
#define libusb_le16_to_cpu
Convert a 16-bit value from little-endian to host-endian format.
Definition: libusb.h:212
libusb_standard_request
Standard requests, as defined in table 9-5 of the USB 3.0 specifications.
Definition: libusb.h:389
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
int libusb_has_capability(uint32_t capability)
Check at runtime if the loaded library has a given capability.
Definition: core.c:2651
#define LIBUSB_CALL
libusb's Windows calling convention.
Definition: libusb.h:125
libusb_capability
Capabilities supported by an instance of libusb on the current running platform.
Definition: libusb.h:1422
libusb_error
Error codes.
Definition: libusb.h:1180
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
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
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_REQUEST_TYPE_VENDOR
Vendor.
Definition: libusb.h:447
@ LIBUSB_REQUEST_TYPE_STANDARD
Standard.
Definition: libusb.h:441
@ LIBUSB_REQUEST_TYPE_CLASS
Class.
Definition: libusb.h:444
@ LIBUSB_REQUEST_TYPE_RESERVED
Reserved.
Definition: libusb.h:450
@ LIBUSB_RECIPIENT_ENDPOINT
Endpoint.
Definition: libusb.h:465
@ LIBUSB_RECIPIENT_INTERFACE
Interface.
Definition: libusb.h:462
@ LIBUSB_RECIPIENT_OTHER
Other.
Definition: libusb.h:468
@ LIBUSB_RECIPIENT_DEVICE
Device.
Definition: libusb.h:459
@ LIBUSB_REQUEST_CLEAR_FEATURE
Clear or disable a specific feature.
Definition: libusb.h:394
@ LIBUSB_REQUEST_GET_INTERFACE
Return the selected alternate setting for the specified interface.
Definition: libusb.h:419
@ LIBUSB_REQUEST_GET_DESCRIPTOR
Get the specified descriptor.
Definition: libusb.h:407
@ LIBUSB_REQUEST_SET_DESCRIPTOR
Used to update existing descriptors or add new descriptors.
Definition: libusb.h:410
@ LIBUSB_REQUEST_GET_STATUS
Request status of the specific recipient.
Definition: libusb.h:391
@ LIBUSB_REQUEST_SET_FEATURE
Set or enable a specific feature.
Definition: libusb.h:399
@ LIBUSB_REQUEST_SET_INTERFACE
Select an alternate interface for the specified interface.
Definition: libusb.h:422
@ LIBUSB_REQUEST_SET_ADDRESS
Set device address for all future accesses.
Definition: libusb.h:404
@ LIBUSB_REQUEST_GET_CONFIGURATION
Get the current device configuration value.
Definition: libusb.h:413
@ LIBUSB_REQUEST_SET_SEL
Sets both the U1 and U2 Exit Latency.
Definition: libusb.h:428
@ 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
Set then report an endpoint's synchronization frame.
Definition: libusb.h:425
@ LIBUSB_REQUEST_SET_CONFIGURATION
Set device configuration.
Definition: libusb.h:416
@ LIBUSB_CAP_HAS_CAPABILITY
The libusb_has_capability() API is available.
Definition: libusb.h:1424
@ LIBUSB_CAP_HAS_HOTPLUG
Hotplug support is available on this platform.
Definition: libusb.h:1427
@ 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
The library supports detaching of the default USB driver, using libusb_detach_kernel_driver(),...
Definition: libusb.h:1437
@ LIBUSB_ERROR_NOT_SUPPORTED
Operation not supported or unimplemented on this platform.
Definition: libusb.h:1218
@ LIBUSB_ERROR_ACCESS
Access denied (insufficient permissions)
Definition: libusb.h:1191
@ LIBUSB_ERROR_PIPE
Pipe error.
Definition: libusb.h:1209
@ LIBUSB_ERROR_NOT_FOUND
Entity not found.
Definition: libusb.h:1197
@ LIBUSB_ERROR_BUSY
Resource busy.
Definition: libusb.h:1200
@ LIBUSB_ERROR_INTERRUPTED
System call interrupted (perhaps due to signal)
Definition: libusb.h:1212
@ LIBUSB_SUCCESS
Success (no error)
Definition: libusb.h:1182
@ LIBUSB_ERROR_INVALID_PARAM
Invalid parameter.
Definition: libusb.h:1188
@ LIBUSB_ERROR_IO
Input/output error.
Definition: libusb.h:1185
@ LIBUSB_ERROR_OTHER
Other error.
Definition: libusb.h:1224
@ LIBUSB_ERROR_TIMEOUT
Operation timed out.
Definition: libusb.h:1203
@ LIBUSB_ERROR_OVERFLOW
Overflow.
Definition: libusb.h:1206
@ LIBUSB_ERROR_NO_DEVICE
No such device (it may have been disconnected)
Definition: libusb.h:1194
@ LIBUSB_ERROR_NO_MEM
Insufficient memory.
Definition: libusb.h:1215
int libusb_handle_events_completed(libusb_context *ctx, int *completed)
Handle any pending events in blocking mode.
Definition: io.c:2462
void libusb_lock_event_waiters(libusb_context *ctx)
Acquire the event waiters lock.
Definition: io.c:1983
void libusb_interrupt_event_handler(libusb_context *ctx)
Interrupt any active thread that is handling events.
Definition: io.c:1947
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
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
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
int libusb_event_handler_active(libusb_context *ctx)
Determine if an active thread is handling events (i.e.
Definition: io.c:1918
void libusb_unlock_event_waiters(libusb_context *ctx)
Release the event waiters lock.
Definition: io.c:1994
int libusb_handle_events_timeout_completed(libusb_context *ctx, struct timeval *tv, int *completed)
Handle any pending events.
Definition: io.c:2348
int libusb_handle_events(libusb_context *ctx)
Handle any pending events in blocking mode.
Definition: io.c:2440
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
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
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
int libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv)
Handle any pending events.
Definition: io.c:2420
int libusb_try_lock_events(libusb_context *ctx)
Attempt to acquire the event handling lock.
Definition: io.c:1796
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
void libusb_lock_events(libusb_context *ctx)
Acquire the event handling lock, blocking until successful acquisition if it is contended.
Definition: io.c:1839
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
void libusb_free_pollfds(const struct libusb_pollfd **pollfds)
Free a list of libusb_pollfd structures.
Definition: io.c:2800
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
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
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
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
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
A structure representing the Binary Device Object Store (BOS) descriptor.
Definition: libusb.h:895
uint16_t wTotalLength
Length of this descriptor and all of its sub descriptors.
Definition: libusb.h:905
struct libusb_bos_dev_capability_descriptor * dev_capability[LIBUSB_FLEXIBLE_ARRAY]
bNumDeviceCap Device Capability Descriptors
Definition: libusb.h:912
uint8_t bNumDeviceCaps
The number of separate device capability descriptors in the BOS.
Definition: libusb.h:909
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:897
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:902
A generic representation of a BOS Device Capability descriptor.
Definition: libusb.h:874
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:876
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:881
uint8_t bDevCapabilityType
Device Capability type.
Definition: libusb.h:884
uint8_t dev_capability_data[LIBUSB_FLEXIBLE_ARRAY]
Device Capability data (bLength - 3 bytes)
Definition: libusb.h:887
A structure representing the standard USB configuration descriptor.
Definition: libusb.h:797
uint8_t bConfigurationValue
Identifier value for this configuration.
Definition: libusb.h:813
uint8_t iConfiguration
Index of string descriptor describing this configuration.
Definition: libusb.h:816
int extra_length
Length of the extra descriptors, in bytes.
Definition: libusb.h:836
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:799
uint8_t bNumInterfaces
Number of interfaces supported by this configuration.
Definition: libusb.h:810
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
uint16_t wTotalLength
Total length of data returned for this configuration.
Definition: libusb.h:807
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:804
const unsigned char * extra
Extra descriptors.
Definition: libusb.h:833
uint8_t bmAttributes
Configuration characteristics.
Definition: libusb.h:819
const struct libusb_interface * interface
Array of interfaces supported by this configuration.
Definition: libusb.h:829
A structure representing the Container ID descriptor.
Definition: libusb.h:988
uint8_t ContainerID[16]
128 bit UUID
Definition: libusb.h:1006
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:995
uint8_t bDevCapabilityType
Capability type.
Definition: libusb.h:1000
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:990
uint8_t bReserved
Reserved field.
Definition: libusb.h:1003
Setup packet for control transfers.
Definition: libusb.h:1042
uint8_t bRequest
Request.
Definition: libusb.h:1055
uint8_t bmRequestType
Request type.
Definition: libusb.h:1048
uint16_t wLength
Number of bytes to transfer.
Definition: libusb.h:1065
uint16_t wIndex
Index.
Definition: libusb.h:1062
uint16_t wValue
Value.
Definition: libusb.h:1058
A structure representing the standard USB device descriptor.
Definition: libusb.h:573
uint8_t bNumConfigurations
Number of possible configurations.
Definition: libusb.h:619
uint8_t iProduct
Index of string descriptor describing product.
Definition: libusb.h:613
uint8_t iSerialNumber
Index of string descriptor containing device serial number.
Definition: libusb.h:616
uint8_t bMaxPacketSize0
Maximum packet size for endpoint 0.
Definition: libusb.h:598
uint8_t bDeviceProtocol
USB-IF protocol code for the device, qualified by the bDeviceClass and bDeviceSubClass values.
Definition: libusb.h:595
uint16_t idProduct
USB-IF product ID.
Definition: libusb.h:604
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:580
uint8_t bDeviceSubClass
USB-IF subclass code for the device, qualified by the bDeviceClass value.
Definition: libusb.h:591
uint8_t bDeviceClass
USB-IF class code for the device.
Definition: libusb.h:587
uint8_t iManufacturer
Index of string descriptor describing manufacturer.
Definition: libusb.h:610
uint16_t idVendor
USB-IF vendor ID.
Definition: libusb.h:601
uint16_t bcdUSB
USB specification release number in binary-coded decimal.
Definition: libusb.h:584
uint16_t bcdDevice
Device release number in binary-coded decimal.
Definition: libusb.h:607
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:575
A structure representing the standard USB endpoint descriptor.
Definition: libusb.h:627
int extra_length
Length of the extra descriptors, in bytes.
Definition: libusb.h:667
uint8_t bEndpointAddress
The address of the endpoint described by this descriptor.
Definition: libusb.h:639
const unsigned char * extra
Extra descriptors.
Definition: libusb.h:664
uint8_t bInterval
Interval for polling endpoint for data transfers.
Definition: libusb.h:653
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:634
uint8_t bRefresh
For audio devices only: the rate at which synchronization feedback is provided.
Definition: libusb.h:657
uint8_t bmAttributes
Attributes which apply to the endpoint when it is configured using the bConfigurationValue.
Definition: libusb.h:647
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:629
uint8_t bSynchAddress
For audio devices only: the address if the synch endpoint.
Definition: libusb.h:660
uint16_t wMaxPacketSize
Maximum packet size this endpoint is capable of sending/receiving.
Definition: libusb.h:650
Structure used for setting options through libusb_init_context.
Definition: libusb.h:1566
enum libusb_option option
Which option to set.
Definition: libusb.h:1568
union libusb_init_option::@0 value
An integer value used by the option (if applicable).
Structure containing an array of 0 or more interface association descriptors.
Definition: libusb.h:719
const struct libusb_interface_association_descriptor * iad
Array of interface association descriptors.
Definition: libusb.h:723
int length
Number of interface association descriptors contained.
Definition: libusb.h:726
A structure representing the standard USB interface association descriptor.
Definition: libusb.h:675
uint8_t bFunctionClass
USB-IF class code for this function.
Definition: libusb.h:697
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:682
uint8_t bFunctionSubClass
USB-IF subclass code for this function.
Definition: libusb.h:703
uint8_t bFunctionProtocol
USB-IF protocol code for this function.
Definition: libusb.h:709
uint8_t bInterfaceCount
Number of contiguous interfaces that are associated with this function.
Definition: libusb.h:690
uint8_t iFunction
Index of string descriptor describing this function.
Definition: libusb.h:712
uint8_t bFirstInterface
Interface number of the first interface that is associated with this function.
Definition: libusb.h:686
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:677
A structure representing the standard USB interface descriptor.
Definition: libusb.h:734
uint8_t bInterfaceSubClass
USB-IF subclass code for this interface, qualified by the bInterfaceClass value.
Definition: libusb.h:758
uint8_t iInterface
Index of string descriptor describing this interface.
Definition: libusb.h:765
uint8_t bInterfaceClass
USB-IF class code for this interface.
Definition: libusb.h:754
uint8_t bAlternateSetting
Value used to select this alternate setting for this interface.
Definition: libusb.h:747
const struct libusb_endpoint_descriptor * endpoint
Array of endpoint descriptors.
Definition: libusb.h:769
uint8_t bNumEndpoints
Number of endpoints used by this interface (excluding the control endpoint).
Definition: libusb.h:751
uint8_t bInterfaceProtocol
USB-IF protocol code for this interface, qualified by the bInterfaceClass and bInterfaceSubClass valu...
Definition: libusb.h:762
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:736
uint8_t bInterfaceNumber
Number of this interface.
Definition: libusb.h:744
const unsigned char * extra
Extra descriptors.
Definition: libusb.h:773
int extra_length
Length of the extra descriptors, in bytes.
Definition: libusb.h:776
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:741
A collection of alternate settings for a particular USB interface.
Definition: libusb.h:782
const struct libusb_interface_descriptor * altsetting
Array of interface descriptors.
Definition: libusb.h:785
int num_altsetting
The number of alternate settings that belong to this interface.
Definition: libusb.h:789
Isochronous packet descriptor.
Definition: libusb.h:1326
unsigned int actual_length
Amount of data that was actually transferred.
Definition: libusb.h:1331
unsigned int length
Length of data to request in this packet.
Definition: libusb.h:1328
enum libusb_transfer_status status
Status code for this packet.
Definition: libusb.h:1334
A structure representing a Platform descriptor.
Definition: libusb.h:1013
uint8_t bDevCapabilityType
Capability type.
Definition: libusb.h:1025
uint8_t PlatformCapabilityUUID[16]
128 bit UUID
Definition: libusb.h:1031
uint8_t bReserved
Reserved field.
Definition: libusb.h:1028
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:1015
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:1020
uint8_t CapabilityData[LIBUSB_FLEXIBLE_ARRAY]
Capability data (bLength - 20)
Definition: libusb.h:1034
File descriptor for polling.
Definition: libusb.h:2121
short events
Event flags to poll for from <poll.h>.
Definition: libusb.h:2129
int fd
Numeric file descriptor.
Definition: libusb.h:2123
A structure representing the superspeed endpoint companion descriptor.
Definition: libusb.h:845
uint16_t wBytesPerInterval
The total number of bytes this EP will transfer every service interval.
Definition: libusb.h:866
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:847
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:852
uint8_t bMaxBurst
The maximum number of packets the endpoint can send or receive as part of a burst.
Definition: libusb.h:856
uint8_t bmAttributes
In bulk EP: bits 4:0 represents the maximum number of streams the EP supports.
Definition: libusb.h:862
A structure representing the SuperSpeed USB Device Capability descriptor This descriptor is documente...
Definition: libusb.h:946
uint8_t bDevCapabilityType
Capability type.
Definition: libusb.h:958
uint16_t wSpeedSupported
Bitmap encoding of the speed supported by this device when operating in SuperSpeed mode.
Definition: libusb.h:968
uint8_t bFunctionalitySupport
The lowest speed at which all the functionality supported by the device is available to the user.
Definition: libusb.h:974
uint16_t bU2DevExitLat
U2 Device Exit Latency.
Definition: libusb.h:980
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:948
uint8_t bmAttributes
Bitmap encoding of supported device level features.
Definition: libusb.h:964
uint8_t bU1DevExitLat
U1 Device Exit Latency.
Definition: libusb.h:977
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:953
The generic USB transfer structure.
Definition: libusb.h:1356
unsigned char endpoint
Address of the endpoint where this transfer will be sent.
Definition: libusb.h:1364
enum libusb_transfer_status status
The status of the transfer.
Definition: libusb.h:1380
int length
Length of the data buffer.
Definition: libusb.h:1383
libusb_transfer_cb_fn callback
Callback function.
Definition: libusb.h:1392
struct libusb_iso_packet_descriptor iso_packet_desc[LIBUSB_FLEXIBLE_ARRAY]
Isochronous packet descriptors, for isochronous transfers only.
Definition: libusb.h:1414
unsigned char type
Type of the transfer from libusb_transfer_type.
Definition: libusb.h:1367
int actual_length
Actual length of data that was transferred.
Definition: libusb.h:1388
unsigned char * buffer
Data buffer.
Definition: libusb.h:1407
int num_iso_packets
Number of isochronous packets.
Definition: libusb.h:1411
unsigned int timeout
Timeout for this transfer in milliseconds.
Definition: libusb.h:1371
void * user_data
User context data.
Definition: libusb.h:1404
libusb_device_handle * dev_handle
Handle of the device that this transfer will be submitted to.
Definition: libusb.h:1358
uint8_t flags
A bitwise OR combination of libusb_transfer_flags.
Definition: libusb.h:1361
A structure representing the USB 2.0 Extension descriptor This descriptor is documented in section 9....
Definition: libusb.h:920
uint8_t bLength
Size of this descriptor (in bytes)
Definition: libusb.h:922
uint8_t bDevCapabilityType
Capability type.
Definition: libusb.h:932
uint32_t bmAttributes
Bitmap encoding of supported device level features.
Definition: libusb.h:938
uint8_t bDescriptorType
Descriptor type.
Definition: libusb.h:927
Structure providing the version of the libusb runtime.
Definition: libusb.h:1082
const uint16_t micro
Library micro version.
Definition: libusb.h:1090
const uint16_t major
Library major version.
Definition: libusb.h:1084
const char * rc
Library release candidate suffix string, e.g.
Definition: libusb.h:1096
const uint16_t minor
Library minor version.
Definition: libusb.h:1087
const char * describe
For ABI compatibility only.
Definition: libusb.h:1099
const uint16_t nano
Library nano version.
Definition: libusb.h:1093