libusb.h | libusb.h | |||
---|---|---|---|---|
/* | /* | |||
* Public libusbx header file | * Public libusbx header file | |||
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com> | * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com> | |||
* Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org> | * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org> | |||
* Copyright © 2012 Pete Batard <pete@akeo.ie> | * Copyright © 2012 Pete Batard <pete@akeo.ie> | |||
* Copyright © 2012 Nathan Hjelm <hjelmn@cs.unm.edu> | ||||
* For more information, please visit: http://libusbx.org | * For more information, please visit: http://libusbx.org | |||
* | * | |||
* This library is free software; you can redistribute it and/or | * This library is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | * modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | * License as published by the Free Software Foundation; either | |||
* version 2.1 of the License, or (at your option) any later version. | * version 2.1 of the License, or (at your option) any later version. | |||
* | * | |||
* This library is distributed in the hope that it will be useful, | * This library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
skipping to change at line 78 | skipping to change at line 79 | |||
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) | #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) | |||
#include <windows.h> | #include <windows.h> | |||
#if defined(interface) | #if defined(interface) | |||
#undef interface | #undef interface | |||
#endif | #endif | |||
#if !defined(__CYGWIN__) | #if !defined(__CYGWIN__) | |||
#include <winsock.h> | #include <winsock.h> | |||
#endif | #endif | |||
#endif | #endif | |||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) | ||||
#define LIBUSB_DEPRECATED_FOR(f) \ | ||||
__attribute__((deprecated("Use " #f " instead"))) | ||||
#else | ||||
#define LIBUSB_DEPRECATED_FOR(f) | ||||
#endif /* __GNUC__ */ | ||||
/** \def LIBUSB_CALL | /** \def LIBUSB_CALL | |||
* \ingroup misc | * \ingroup misc | |||
* libusbx's Windows calling convention. | * libusbx's Windows calling convention. | |||
* | * | |||
* Under Windows, the selection of available compilers and configurations | * Under Windows, the selection of available compilers and configurations | |||
* means that, unlike other platforms, there is not <em>one true calling | * means that, unlike other platforms, there is not <em>one true calling | |||
* convention</em> (calling convention: the manner in which parameters are | * convention</em> (calling convention: the manner in which parameters are | |||
* passed to funcions in the generated assembly code). | * passed to funcions in the generated assembly code). | |||
* | * | |||
* Matching the Windows API itself, libusbx uses the WINAPI convention (whi ch | * Matching the Windows API itself, libusbx uses the WINAPI convention (whi ch | |||
skipping to change at line 139 | skipping to change at line 147 | |||
* // Use one of the newer features from the libusbx API | * // Use one of the newer features from the libusbx API | |||
* #endif | * #endif | |||
* \endcode | * \endcode | |||
* | * | |||
* Another feature of LIBUSBX_API_VERSION is that it can be used to detect | * Another feature of LIBUSBX_API_VERSION is that it can be used to detect | |||
* whether you are compiling against the libusb or the libusbx library. | * whether you are compiling against the libusb or the libusbx library. | |||
* | * | |||
* Internally, LIBUSBX_API_VERSION is defined as follows: | * Internally, LIBUSBX_API_VERSION is defined as follows: | |||
* (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental) | * (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental) | |||
*/ | */ | |||
#define LIBUSBX_API_VERSION 0x01000101 | #define LIBUSBX_API_VERSION 0x01000102 | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
/** \def libusb_cpu_to_le16 | /** \def libusb_cpu_to_le16 | |||
* \ingroup misc | * \ingroup misc | |||
* Convert a 16-bit value from host-endian to little-endian format. On | * Convert a 16-bit value from host-endian to little-endian format. On | |||
* little endian systems, this function does nothing. On big endian systems , | * little endian systems, this function does nothing. On big endian systems , | |||
* the bytes are swapped. | * the bytes are swapped. | |||
* \param x the host-endian value to convert | * \param x the host-endian value to convert | |||
* \returns the value in little-endian byte order | * \returns the value in little-endian byte order | |||
*/ | */ | |||
static inline uint16_t libusb_cpu_to_le16(const uint16_t x) | static inline uint16_t libusb_cpu_to_le16(const uint16_t x) | |||
{ | { | |||
union { | union { | |||
uint8_t b8[2]; | uint8_t b8[2]; | |||
uint16_t b16; | uint16_t b16; | |||
} _tmp; | } _tmp; | |||
_tmp.b8[1] = x >> 8; | _tmp.b8[1] = (uint8_t) (x >> 8); | |||
_tmp.b8[0] = x & 0xff; | _tmp.b8[0] = (uint8_t) (x & 0xff); | |||
return _tmp.b16; | return _tmp.b16; | |||
} | } | |||
/** \def libusb_le16_to_cpu | /** \def libusb_le16_to_cpu | |||
* \ingroup misc | * \ingroup misc | |||
* Convert a 16-bit value from little-endian to host-endian format. On | * Convert a 16-bit value from little-endian to host-endian format. On | |||
* little endian systems, this function does nothing. On big endian systems , | * little endian systems, this function does nothing. On big endian systems , | |||
* the bytes are swapped. | * the bytes are swapped. | |||
* \param x the little-endian value to convert | * \param x the little-endian value to convert | |||
* \returns the value in host-endian byte order | * \returns the value in host-endian byte order | |||
skipping to change at line 256 | skipping to change at line 264 | |||
/** String descriptor */ | /** String descriptor */ | |||
LIBUSB_DT_STRING = 0x03, | LIBUSB_DT_STRING = 0x03, | |||
/** Interface descriptor. See libusb_interface_descriptor. */ | /** Interface descriptor. See libusb_interface_descriptor. */ | |||
LIBUSB_DT_INTERFACE = 0x04, | LIBUSB_DT_INTERFACE = 0x04, | |||
/** Endpoint descriptor. See libusb_endpoint_descriptor. */ | /** Endpoint descriptor. See libusb_endpoint_descriptor. */ | |||
LIBUSB_DT_ENDPOINT = 0x05, | LIBUSB_DT_ENDPOINT = 0x05, | |||
/** BOS descriptor */ | ||||
LIBUSB_DT_BOS = 0x0f, | ||||
/** Device Capability descriptor */ | ||||
LIBUSB_DT_DEVICE_CAPABILITY = 0x10, | ||||
/** HID descriptor */ | /** HID descriptor */ | |||
LIBUSB_DT_HID = 0x21, | LIBUSB_DT_HID = 0x21, | |||
/** HID report descriptor */ | /** HID report descriptor */ | |||
LIBUSB_DT_REPORT = 0x22, | LIBUSB_DT_REPORT = 0x22, | |||
/** Physical descriptor */ | /** Physical descriptor */ | |||
LIBUSB_DT_PHYSICAL = 0x23, | LIBUSB_DT_PHYSICAL = 0x23, | |||
/** Hub descriptor */ | /** Hub descriptor */ | |||
LIBUSB_DT_HUB = 0x29, | LIBUSB_DT_HUB = 0x29, | |||
/** SuperSpeed Hub descriptor */ | /** SuperSpeed Hub descriptor */ | |||
LIBUSB_DT_SUPERSPEED_HUB = 0x2A, | LIBUSB_DT_SUPERSPEED_HUB = 0x2a, | |||
/** SuperSpeed Endpoint Companion descriptor */ | ||||
LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30 | ||||
}; | }; | |||
/* Descriptor sizes per descriptor type */ | /* Descriptor sizes per descriptor type */ | |||
#define LIBUSB_DT_DEVICE_SIZE 18 | #define LIBUSB_DT_DEVICE_SIZE 18 | |||
#define LIBUSB_DT_CONFIG_SIZE 9 | #define LIBUSB_DT_CONFIG_SIZE 9 | |||
#define LIBUSB_DT_INTERFACE_SIZE 9 | #define LIBUSB_DT_INTERFACE_SIZE 9 | |||
#define LIBUSB_DT_ENDPOINT_SIZE 7 | #define LIBUSB_DT_ENDPOINT_SIZE 7 | |||
#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ | #define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension * | |||
/ | ||||
#define LIBUSB_DT_HUB_NONVAR_SIZE 7 | #define LIBUSB_DT_HUB_NONVAR_SIZE 7 | |||
#define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6 | ||||
#define LIBUSB_DT_BOS_SIZE 5 | ||||
#define LIBUSB_DT_DEVICE_CAPABILITY_SIZE 3 | ||||
/* BOS descriptor sizes */ | ||||
#define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7 | ||||
#define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10 | ||||
#define LIBUSB_BT_CONTAINER_ID_SIZE 20 | ||||
/* We unwrap the BOS => define its max size */ | ||||
#define LIBUSB_DT_BOS_MAX_SIZE ((LIBUSB_DT_BOS_SIZE) +\ | ||||
(LIBUSB_BT_USB_2_0_EXTENSION_SIZE) | ||||
+\ | ||||
(LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_ | ||||
SIZE) +\ | ||||
(LIBUSB_BT_CONTAINER_ID_SIZE)) | ||||
#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ | #define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ | |||
#define LIBUSB_ENDPOINT_DIR_MASK 0x80 | #define LIBUSB_ENDPOINT_DIR_MASK 0x80 | |||
/** \ingroup desc | /** \ingroup desc | |||
* Endpoint direction. Values for bit 7 of the | * Endpoint direction. Values for bit 7 of the | |||
* \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" sch eme. | * \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" sch eme. | |||
*/ | */ | |||
enum libusb_endpoint_direction { | enum libusb_endpoint_direction { | |||
/** In: device-to-host */ | /** In: device-to-host */ | |||
skipping to change at line 650 | skipping to change at line 681 | |||
const struct libusb_interface *interface; | const struct libusb_interface *interface; | |||
/** Extra descriptors. If libusbx encounters unknown configuration | /** Extra descriptors. If libusbx encounters unknown configuration | |||
* descriptors, it will store them here, should you wish to parse th em. */ | * descriptors, it will store them here, should you wish to parse th em. */ | |||
const unsigned char *extra; | const unsigned char *extra; | |||
/** Length of the extra descriptors, in bytes. */ | /** Length of the extra descriptors, in bytes. */ | |||
int extra_length; | int extra_length; | |||
}; | }; | |||
/** \ingroup desc | ||||
* A structure representing the superspeed endpoint companion | ||||
* descriptor. This descriptor is documented in section 9.6.7 of | ||||
* the USB 3.0 specification. All multiple-byte fields are represented in | ||||
* host-endian format. | ||||
*/ | ||||
struct libusb_ss_endpoint_companion_descriptor { | ||||
/** Size of this descriptor (in bytes) */ | ||||
uint8_t bLength; | ||||
/** Descriptor type. Will have value | ||||
* \ref libusb_descriptor_type::LIBUSB_DT_SS_ENDPOINT_COMPANION in | ||||
* this context. */ | ||||
uint8_t bDescriptorType; | ||||
/** The maximum number of packets the endpoint can send or | ||||
* recieve as part of a burst. */ | ||||
uint8_t bMaxBurst; | ||||
/** In bulk EP: bits 4:0 represents the maximum number of | ||||
* streams the EP supports. In isochronous EP: bits 1:0 | ||||
* represents the Mult - a zero based value that determines | ||||
* the maximum number of packets within a service interval */ | ||||
uint8_t bmAttributes; | ||||
/** The total number of bytes this EP will transfer every | ||||
* service interval. valid only for periodic EPs. */ | ||||
uint16_t wBytesPerInterval; | ||||
}; | ||||
/** \ingroup desc | ||||
* A generic representation of a BOS Device Capability descriptor. It is | ||||
* advised to check bDevCapabilityType and call the matching | ||||
* libusb_get_*_descriptor function to get a structure fully matching the t | ||||
ype. | ||||
*/ | ||||
struct libusb_bos_dev_capability_descriptor { | ||||
/** Size of this descriptor (in bytes) */ | ||||
uint8_t bLength; | ||||
/** Descriptor type. Will have value | ||||
* \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY | ||||
* LIBUSB_DT_DEVICE_CAPABILITY in this context. */ | ||||
uint8_t bDescriptorType; | ||||
/** Device Capability type */ | ||||
uint8_t bDevCapabilityType; | ||||
/** Device Capability data (bLength - 3 bytes) */ | ||||
uint8_t dev_capability_data | ||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) | ||||
[] /* valid C99 code */ | ||||
#else | ||||
[0] /* non-standard, but usually working code */ | ||||
#endif | ||||
; | ||||
}; | ||||
/** \ingroup desc | ||||
* A structure representing the Binary Device Object Store (BOS) descriptor | ||||
. | ||||
* This descriptor is documented in section 9.6.2 of the USB 3.0 specificat | ||||
ion. | ||||
* All multiple-byte fields are represented in host-endian format. | ||||
*/ | ||||
struct libusb_bos_descriptor { | ||||
/** Size of this descriptor (in bytes) */ | ||||
uint8_t bLength; | ||||
/** Descriptor type. Will have value | ||||
* \ref libusb_descriptor_type::LIBUSB_DT_BOS LIBUSB_DT_BOS | ||||
* in this context. */ | ||||
uint8_t bDescriptorType; | ||||
/** Length of this descriptor and all of its sub descriptors */ | ||||
uint16_t wTotalLength; | ||||
/** The number of separate device capability descriptors in | ||||
* the BOS */ | ||||
uint8_t bNumDeviceCaps; | ||||
/** bNumDeviceCap Device Capability Descriptors */ | ||||
struct libusb_bos_dev_capability_descriptor *dev_capability | ||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) | ||||
[] /* valid C99 code */ | ||||
#else | ||||
[0] /* non-standard, but usually working code */ | ||||
#endif | ||||
; | ||||
}; | ||||
/** \ingroup desc | ||||
* A structure representing the USB 2.0 Extension descriptor | ||||
* This descriptor is documented in section 9.6.2.1 of the USB 3.0 specific | ||||
ation. | ||||
* All multiple-byte fields are represented in host-endian format. | ||||
*/ | ||||
struct libusb_usb_2_0_extension_descriptor { | ||||
/** Size of this descriptor (in bytes) */ | ||||
uint8_t bLength; | ||||
/** Descriptor type. Will have value | ||||
* \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY | ||||
* LIBUSB_DT_DEVICE_CAPABILITY in this context. */ | ||||
uint8_t bDescriptorType; | ||||
/** Capability type. Will have value | ||||
* \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION | ||||
* LIBUSB_BT_USB_2_0_EXTENSION in this context. */ | ||||
uint8_t bDevCapabilityType; | ||||
/** Bitmap encoding of supported device level features. | ||||
* A value of one in a bit location indicates a feature is | ||||
* supported; a value of zero indicates it is not supported. | ||||
* See \ref libusb_usb_2_0_extension_attributes. */ | ||||
uint32_t bmAttributes; | ||||
}; | ||||
/** \ingroup desc | ||||
* A structure representing the SuperSpeed USB Device Capability descriptor | ||||
* This descriptor is documented in section 9.6.2.2 of the USB 3.0 specific | ||||
ation. | ||||
* All multiple-byte fields are represented in host-endian format. | ||||
*/ | ||||
struct libusb_ss_usb_device_capability_descriptor { | ||||
/** Size of this descriptor (in bytes) */ | ||||
uint8_t bLength; | ||||
/** Descriptor type. Will have value | ||||
* \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY | ||||
* LIBUSB_DT_DEVICE_CAPABILITY in this context. */ | ||||
uint8_t bDescriptorType; | ||||
/** Capability type. Will have value | ||||
* \ref libusb_capability_type::LIBUSB_BT_SS_USB_DEVICE_CAPABILITY | ||||
* LIBUSB_BT_SS_USB_DEVICE_CAPABILITY in this context. */ | ||||
uint8_t bDevCapabilityType; | ||||
/** Bitmap encoding of supported device level features. | ||||
* A value of one in a bit location indicates a feature is | ||||
* supported; a value of zero indicates it is not supported. | ||||
* See \ref libusb_ss_usb_device_capability_attributes. */ | ||||
uint8_t bmAttributes; | ||||
/** Bitmap encoding of the speed supported by this device when | ||||
* operating in SuperSpeed mode. See \ref libusb_supported_speed. */ | ||||
uint16_t wSpeedSupported; | ||||
/** The lowest speed at which all the functionality supported | ||||
* by the device is available to the user. For example if the | ||||
* device supports all its functionality when connected at | ||||
* full speed and above then it sets this value to 1. */ | ||||
uint8_t bFunctionalitySupport; | ||||
/** U1 Device Exit Latency. */ | ||||
uint8_t bU1DevExitLat; | ||||
/** U2 Device Exit Latency. */ | ||||
uint16_t bU2DevExitLat; | ||||
}; | ||||
/** \ingroup desc | ||||
* A structure representing the Container ID descriptor. | ||||
* This descriptor is documented in section 9.6.2.3 of the USB 3.0 specific | ||||
ation. | ||||
* All multiple-byte fields, except UUIDs, are represented in host-endian f | ||||
ormat. | ||||
*/ | ||||
struct libusb_container_id_descriptor { | ||||
/** Size of this descriptor (in bytes) */ | ||||
uint8_t bLength; | ||||
/** Descriptor type. Will have value | ||||
* \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY | ||||
* LIBUSB_DT_DEVICE_CAPABILITY in this context. */ | ||||
uint8_t bDescriptorType; | ||||
/** Capability type. Will have value | ||||
* \ref libusb_capability_type::LIBUSB_BT_CONTAINER_ID | ||||
* LIBUSB_BT_CONTAINER_ID in this context. */ | ||||
uint8_t bDevCapabilityType; | ||||
/** Reserved field */ | ||||
uint8_t bReserved; | ||||
/** 128 bit UUID */ | ||||
uint8_t ContainerID[16]; | ||||
}; | ||||
/** \ingroup asyncio | /** \ingroup asyncio | |||
* Setup packet for control transfers. */ | * Setup packet for control transfers. */ | |||
struct libusb_control_setup { | struct libusb_control_setup { | |||
/** Request type. Bits 0:4 determine recipient, see | /** Request type. Bits 0:4 determine recipient, see | |||
* \ref libusb_request_recipient. Bits 5:6 determine type, see | * \ref libusb_request_recipient. Bits 5:6 determine type, see | |||
* \ref libusb_request_type. Bit 7 determines data transfer directio n, see | * \ref libusb_request_type. Bit 7 determines data transfer directio n, see | |||
* \ref libusb_endpoint_direction. | * \ref libusb_endpoint_direction. | |||
*/ | */ | |||
uint8_t bmRequestType; | uint8_t bmRequestType; | |||
skipping to change at line 685 | skipping to change at line 896 | |||
uint16_t wLength; | uint16_t wLength; | |||
}; | }; | |||
#define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup)) | #define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup)) | |||
/* libusbx */ | /* libusbx */ | |||
struct libusb_context; | struct libusb_context; | |||
struct libusb_device; | struct libusb_device; | |||
struct libusb_device_handle; | struct libusb_device_handle; | |||
struct libusb_hotplug_callback; | ||||
/** \ingroup lib | /** \ingroup lib | |||
* Structure providing the version of the libusbx runtime | * Structure providing the version of the libusbx runtime | |||
*/ | */ | |||
struct libusb_version { | struct libusb_version { | |||
/** Library major version. */ | /** Library major version. */ | |||
const uint16_t major; | const uint16_t major; | |||
/** Library minor version. */ | /** Library minor version. */ | |||
const uint16_t minor; | const uint16_t minor; | |||
skipping to change at line 736 | skipping to change at line 948 | |||
typedef struct libusb_context libusb_context; | typedef struct libusb_context libusb_context; | |||
/** \ingroup dev | /** \ingroup dev | |||
* Structure representing a USB device detected on the system. This is an | * Structure representing a USB device detected on the system. This is an | |||
* opaque type for which you are only ever provided with a pointer, usually | * opaque type for which you are only ever provided with a pointer, usually | |||
* originating from libusb_get_device_list(). | * originating from libusb_get_device_list(). | |||
* | * | |||
* Certain operations can be performed on a device, but in order to do any | * Certain operations can be performed on a device, but in order to do any | |||
* I/O you will have to first obtain a device handle using libusb_open(). | * I/O you will have to first obtain a device handle using libusb_open(). | |||
* | * | |||
* Devices are reference counted with libusb_device_ref() and | * Devices are reference counted with libusb_ref_device() and | |||
* libusb_device_unref(), and are freed when the reference count reaches 0. | * libusb_unref_device(), and are freed when the reference count reaches 0. | |||
* New devices presented by libusb_get_device_list() have a reference count of | * New devices presented by libusb_get_device_list() have a reference count of | |||
* 1, and libusb_free_device_list() can optionally decrease the reference c ount | * 1, and libusb_free_device_list() can optionally decrease the reference c ount | |||
* on all devices in the list. libusb_open() adds another reference which i s | * on all devices in the list. libusb_open() adds another reference which i s | |||
* later destroyed by libusb_close(). | * later destroyed by libusb_close(). | |||
*/ | */ | |||
typedef struct libusb_device libusb_device; | typedef struct libusb_device libusb_device; | |||
/** \ingroup dev | /** \ingroup dev | |||
* Structure representing a handle on a USB device. This is an opaque type for | * Structure representing a handle on a USB device. This is an opaque type for | |||
* which you are only ever provided with a pointer, usually originating fro m | * which you are only ever provided with a pointer, usually originating fro m | |||
skipping to change at line 775 | skipping to change at line 987 | |||
/** The device is operating at full speed (12MBit/s). */ | /** The device is operating at full speed (12MBit/s). */ | |||
LIBUSB_SPEED_FULL = 2, | LIBUSB_SPEED_FULL = 2, | |||
/** The device is operating at high speed (480MBit/s). */ | /** The device is operating at high speed (480MBit/s). */ | |||
LIBUSB_SPEED_HIGH = 3, | LIBUSB_SPEED_HIGH = 3, | |||
/** The device is operating at super speed (5000MBit/s). */ | /** The device is operating at super speed (5000MBit/s). */ | |||
LIBUSB_SPEED_SUPER = 4, | LIBUSB_SPEED_SUPER = 4, | |||
}; | }; | |||
/** \ingroup dev | ||||
* Supported speeds (wSpeedSupported) bitfield. Indicates what | ||||
* speeds the device supports. | ||||
*/ | ||||
enum libusb_supported_speed { | ||||
/** Low speed operation supported (1.5MBit/s). */ | ||||
LIBUSB_LOW_SPEED_OPERATION = 1, | ||||
/** Full speed operation supported (12MBit/s). */ | ||||
LIBUSB_FULL_SPEED_OPERATION = 2, | ||||
/** High speed operation supported (480MBit/s). */ | ||||
LIBUSB_HIGH_SPEED_OPERATION = 4, | ||||
/** Superspeed operation supported (5000MBit/s). */ | ||||
LIBUSB_SUPER_SPEED_OPERATION = 8, | ||||
}; | ||||
/** \ingroup dev | ||||
* Masks for the bits of the | ||||
* \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" fi | ||||
eld | ||||
* of the USB 2.0 Extension descriptor. | ||||
*/ | ||||
enum libusb_usb_2_0_extension_attributes { | ||||
/** Supports Link Power Management (LPM) */ | ||||
LIBUSB_BM_LPM_SUPPORT = 2, | ||||
}; | ||||
/** \ingroup dev | ||||
* Masks for the bits of the | ||||
* \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttribu | ||||
tes" field | ||||
* field of the SuperSpeed USB Device Capability descriptor. | ||||
*/ | ||||
enum libusb_ss_usb_device_capability_attributes { | ||||
/** Supports Latency Tolerance Messages (LTM) */ | ||||
LIBUSB_BM_LTM_SUPPORT = 2, | ||||
}; | ||||
/** \ingroup dev | ||||
* USB capability types | ||||
*/ | ||||
enum libusb_bos_type { | ||||
/** Wireless USB device capability */ | ||||
LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1, | ||||
/** USB 2.0 extensions */ | ||||
LIBUSB_BT_USB_2_0_EXTENSION = 2, | ||||
/** SuperSpeed USB device capability */ | ||||
LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3, | ||||
/** Container ID type */ | ||||
LIBUSB_BT_CONTAINER_ID = 4, | ||||
}; | ||||
/** \ingroup misc | /** \ingroup misc | |||
* Error codes. Most libusbx functions return 0 on success or one of these | * Error codes. Most libusbx functions return 0 on success or one of these | |||
* codes on failure. | * codes on failure. | |||
* You can call \ref libusb_error_name() to retrieve a string representatio | * You can call libusb_error_name() to retrieve a string representation of | |||
n | an | |||
* of an error code. | * error code or libusb_strerror() to get an end-user suitable description | |||
of | ||||
* an error code. | ||||
*/ | */ | |||
enum libusb_error { | enum libusb_error { | |||
/** Success (no error) */ | /** Success (no error) */ | |||
LIBUSB_SUCCESS = 0, | LIBUSB_SUCCESS = 0, | |||
/** Input/output error */ | /** Input/output error */ | |||
LIBUSB_ERROR_IO = -1, | LIBUSB_ERROR_IO = -1, | |||
/** Invalid parameter */ | /** Invalid parameter */ | |||
LIBUSB_ERROR_INVALID_PARAM = -2, | LIBUSB_ERROR_INVALID_PARAM = -2, | |||
skipping to change at line 821 | skipping to change at line 1089 | |||
/** System call interrupted (perhaps due to signal) */ | /** System call interrupted (perhaps due to signal) */ | |||
LIBUSB_ERROR_INTERRUPTED = -10, | LIBUSB_ERROR_INTERRUPTED = -10, | |||
/** Insufficient memory */ | /** Insufficient memory */ | |||
LIBUSB_ERROR_NO_MEM = -11, | LIBUSB_ERROR_NO_MEM = -11, | |||
/** Operation not supported or unimplemented on this platform */ | /** Operation not supported or unimplemented on this platform */ | |||
LIBUSB_ERROR_NOT_SUPPORTED = -12, | LIBUSB_ERROR_NOT_SUPPORTED = -12, | |||
/* NB! Remember to update libusb_error_name() | /* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the | |||
when adding new error codes here. */ | message strings in strerror.c when adding new error codes here. * | |||
/ | ||||
/** Other error */ | /** Other error */ | |||
LIBUSB_ERROR_OTHER = -99, | LIBUSB_ERROR_OTHER = -99, | |||
}; | }; | |||
/* Total number of error codes in enum libusb_error */ | ||||
#define LIBUSB_ERROR_COUNT 14 | ||||
/** \ingroup asyncio | /** \ingroup asyncio | |||
* Transfer status codes */ | * Transfer status codes */ | |||
enum libusb_transfer_status { | enum libusb_transfer_status { | |||
/** Transfer completed without error. Note that this does not indica te | /** Transfer completed without error. Note that this does not indica te | |||
* that the entire amount of requested data was transferred. */ | * that the entire amount of requested data was transferred. */ | |||
LIBUSB_TRANSFER_COMPLETED, | LIBUSB_TRANSFER_COMPLETED, | |||
/** Transfer failed */ | /** Transfer failed */ | |||
LIBUSB_TRANSFER_ERROR, | LIBUSB_TRANSFER_ERROR, | |||
skipping to change at line 990 | skipping to change at line 1261 | |||
struct libusb_iso_packet_descriptor iso_packet_desc | struct libusb_iso_packet_descriptor iso_packet_desc | |||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) | #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) | |||
[] /* valid C99 code */ | [] /* valid C99 code */ | |||
#else | #else | |||
[0] /* non-standard, but usually working code */ | [0] /* non-standard, but usually working code */ | |||
#endif | #endif | |||
; | ; | |||
}; | }; | |||
/** \ingroup misc | /** \ingroup misc | |||
* Capabilities supported by this instance of libusb. Test if the loaded | * Capabilities supported by an instance of libusb on the current running | |||
* library supports a given capability by calling | * platform. Test if the loaded library supports a given capability by call | |||
ing | ||||
* \ref libusb_has_capability(). | * \ref libusb_has_capability(). | |||
*/ | */ | |||
enum libusb_capability { | enum libusb_capability { | |||
/** The libusb_has_capability() API is available. */ | /** The libusb_has_capability() API is available. */ | |||
LIBUSB_CAP_HAS_CAPABILITY = 0x0000, | LIBUSB_CAP_HAS_CAPABILITY = 0x0000, | |||
/** Hotplug support is available. */ | /** Hotplug support is available on this platform. */ | |||
LIBUSB_CAP_HAS_HOTPLUG = 0x0001, | LIBUSB_CAP_HAS_HOTPLUG = 0x0001, | |||
/** The library can access HID devices without requiring user interv ention. | /** The library can access HID devices without requiring user interv ention. | |||
* Note that before being able to actually access an HID device, you may | * Note that before being able to actually access an HID device, you may | |||
* still have to call additional libusbx functions such as | * still have to call additional libusbx functions such as | |||
* \ref libusb_detach_kernel_driver(). */ | * \ref libusb_detach_kernel_driver(). */ | |||
LIBUSB_CAP_HAS_HID_ACCESS = 0x0100, | LIBUSB_CAP_HAS_HID_ACCESS = 0x0100, | |||
/** The library supports detaching of the default USB driver, using | /** The library supports detaching of the default USB driver, using | |||
* \ref libusb_detach_kernel_driver(), if one is set by the OS kerne l */ | * \ref libusb_detach_kernel_driver(), if one is set by the OS kerne l */ | |||
LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101 | LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101 | |||
}; | }; | |||
skipping to change at line 1033 | skipping to change at line 1304 | |||
LIBUSB_LOG_LEVEL_INFO, | LIBUSB_LOG_LEVEL_INFO, | |||
LIBUSB_LOG_LEVEL_DEBUG, | LIBUSB_LOG_LEVEL_DEBUG, | |||
}; | }; | |||
int LIBUSB_CALL libusb_init(libusb_context **ctx); | int LIBUSB_CALL libusb_init(libusb_context **ctx); | |||
void LIBUSB_CALL libusb_exit(libusb_context *ctx); | void LIBUSB_CALL libusb_exit(libusb_context *ctx); | |||
void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level); | void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level); | |||
const struct libusb_version * LIBUSB_CALL libusb_get_version(void); | const struct libusb_version * LIBUSB_CALL libusb_get_version(void); | |||
int LIBUSB_CALL libusb_has_capability(uint32_t capability); | int LIBUSB_CALL libusb_has_capability(uint32_t capability); | |||
const char * LIBUSB_CALL libusb_error_name(int errcode); | const char * LIBUSB_CALL libusb_error_name(int errcode); | |||
int LIBUSB_CALL libusb_setlocale(const char *locale); | ||||
const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode); | ||||
ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx, | ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx, | |||
libusb_device ***list); | libusb_device ***list); | |||
void LIBUSB_CALL libusb_free_device_list(libusb_device **list, | void LIBUSB_CALL libusb_free_device_list(libusb_device **list, | |||
int unref_devices); | int unref_devices); | |||
libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev); | libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev); | |||
void LIBUSB_CALL libusb_unref_device(libusb_device *dev); | void LIBUSB_CALL libusb_unref_device(libusb_device *dev); | |||
int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev, | int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev, | |||
int *config); | int *config); | |||
int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev, | int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev, | |||
struct libusb_device_descriptor *desc); | struct libusb_device_descriptor *desc); | |||
int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev, | int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev, | |||
struct libusb_config_descriptor **config); | struct libusb_config_descriptor **config); | |||
int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev, | int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev, | |||
uint8_t config_index, struct libusb_config_descriptor **config); | uint8_t config_index, struct libusb_config_descriptor **config); | |||
int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev, | int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev, | |||
uint8_t bConfigurationValue, struct libusb_config_descriptor **confi g); | uint8_t bConfigurationValue, struct libusb_config_descriptor **confi g); | |||
void LIBUSB_CALL libusb_free_config_descriptor( | void LIBUSB_CALL libusb_free_config_descriptor( | |||
struct libusb_config_descriptor *config); | struct libusb_config_descriptor *config); | |||
int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor( | ||||
struct libusb_context *ctx, | ||||
const struct libusb_endpoint_descriptor *endpoint, | ||||
struct libusb_ss_endpoint_companion_descriptor **ep_comp); | ||||
void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor( | ||||
struct libusb_ss_endpoint_companion_descriptor *ep_comp); | ||||
int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *handle, | ||||
struct libusb_bos_descriptor **bos); | ||||
void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *b | ||||
os); | ||||
int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor( | ||||
struct libusb_context *ctx, | ||||
struct libusb_bos_dev_capability_descriptor *dev_cap, | ||||
struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension); | ||||
void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor( | ||||
struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension); | ||||
int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor( | ||||
struct libusb_context *ctx, | ||||
struct libusb_bos_dev_capability_descriptor *dev_cap, | ||||
struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_ca | ||||
p); | ||||
void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor( | ||||
struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap | ||||
); | ||||
int LIBUSB_CALL libusb_get_container_id_descriptor(struct libusb_context *c | ||||
tx, | ||||
struct libusb_bos_dev_capability_descriptor *dev_cap, | ||||
struct libusb_container_id_descriptor **container_id); | ||||
void LIBUSB_CALL libusb_free_container_id_descriptor( | ||||
struct libusb_container_id_descriptor *container_id); | ||||
uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev); | uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev); | |||
uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev); | uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev); | |||
libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev); | int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_n | |||
umbers, int port_numbers_len); | ||||
LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers) | ||||
int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *de v, uint8_t* path, uint8_t path_length); | int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *de v, uint8_t* path, uint8_t path_length); | |||
libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev); | ||||
uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev); | uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev); | |||
int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev); | int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev); | |||
int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev, | int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev, | |||
unsigned char endpoint); | unsigned char endpoint); | |||
int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev, | int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev, | |||
unsigned char endpoint); | unsigned char endpoint); | |||
int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **hand le); | int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **hand le); | |||
void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle); | void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle); | |||
libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_han dle); | libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_han dle); | |||
skipping to change at line 1090 | skipping to change at line 1391 | |||
int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev, | int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev, | |||
unsigned char endpoint); | unsigned char endpoint); | |||
int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev); | int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev); | |||
int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev, | int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev, | |||
int interface_number); | int interface_number); | |||
int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev, | int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev, | |||
int interface_number); | int interface_number); | |||
int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev, | int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev, | |||
int interface_number); | int interface_number); | |||
int LIBUSB_CALL libusb_set_auto_detach_kernel_driver( | ||||
libusb_device_handle *dev, int enable); | ||||
/* async I/O */ | /* async I/O */ | |||
/** \ingroup asyncio | /** \ingroup asyncio | |||
* Get the data section of a control transfer. This convenience function is here | * Get the data section of a control transfer. This convenience function is here | |||
* to remind you that the data does not start until 8 bytes into the actual | * to remind you that the data does not start until 8 bytes into the actual | |||
* buffer, as the setup packet comes first. | * buffer, as the setup packet comes first. | |||
* | * | |||
* Calling this function only makes sense from a transfer callback function , | * Calling this function only makes sense from a transfer callback function , | |||
* or situations where you have already allocated a suitably sized buffer a t | * or situations where you have already allocated a suitably sized buffer a t | |||
skipping to change at line 1207 | skipping to change at line 1510 | |||
unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_da ta, | unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_da ta, | |||
unsigned int timeout) | unsigned int timeout) | |||
{ | { | |||
struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; | struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; | |||
transfer->dev_handle = dev_handle; | transfer->dev_handle = dev_handle; | |||
transfer->endpoint = 0; | transfer->endpoint = 0; | |||
transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL; | transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL; | |||
transfer->timeout = timeout; | transfer->timeout = timeout; | |||
transfer->buffer = buffer; | transfer->buffer = buffer; | |||
if (setup) | if (setup) | |||
transfer->length = LIBUSB_CONTROL_SETUP_SIZE | transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE | |||
+ libusb_le16_to_cpu(setup->wLength); | + libusb_le16_to_cpu(setup->wLength)); | |||
transfer->user_data = user_data; | transfer->user_data = user_data; | |||
transfer->callback = callback; | transfer->callback = callback; | |||
} | } | |||
/** \ingroup asyncio | /** \ingroup asyncio | |||
* Helper function to populate the required \ref libusb_transfer fields | * Helper function to populate the required \ref libusb_transfer fields | |||
* for a bulk transfer. | * for a bulk transfer. | |||
* | * | |||
* \param transfer the transfer to populate | * \param transfer the transfer to populate | |||
* \param dev_handle handle of the device that will handle the transfer | * \param dev_handle handle of the device that will handle the transfer | |||
skipping to change at line 1343 | skipping to change at line 1646 | |||
{ | { | |||
int i; | int i; | |||
size_t offset = 0; | size_t offset = 0; | |||
int _packet; | int _packet; | |||
/* oops..slight bug in the API. packet is an unsigned int, but we us e | /* oops..slight bug in the API. packet is an unsigned int, but we us e | |||
* signed integers almost everywhere else. range-check and convert t o | * signed integers almost everywhere else. range-check and convert t o | |||
* signed to avoid compiler warnings. FIXME for libusb-2. */ | * signed to avoid compiler warnings. FIXME for libusb-2. */ | |||
if (packet > INT_MAX) | if (packet > INT_MAX) | |||
return NULL; | return NULL; | |||
_packet = packet; | _packet = (int) packet; | |||
if (_packet >= transfer->num_iso_packets) | if (_packet >= transfer->num_iso_packets) | |||
return NULL; | return NULL; | |||
for (i = 0; i < _packet; i++) | for (i = 0; i < _packet; i++) | |||
offset += transfer->iso_packet_desc[i].length; | offset += transfer->iso_packet_desc[i].length; | |||
return transfer->buffer + offset; | return transfer->buffer + offset; | |||
} | } | |||
skipping to change at line 1383 | skipping to change at line 1686 | |||
static inline unsigned char *libusb_get_iso_packet_buffer_simple( | static inline unsigned char *libusb_get_iso_packet_buffer_simple( | |||
struct libusb_transfer *transfer, unsigned int packet) | struct libusb_transfer *transfer, unsigned int packet) | |||
{ | { | |||
int _packet; | int _packet; | |||
/* oops..slight bug in the API. packet is an unsigned int, but we us e | /* oops..slight bug in the API. packet is an unsigned int, but we us e | |||
* signed integers almost everywhere else. range-check and convert t o | * signed integers almost everywhere else. range-check and convert t o | |||
* signed to avoid compiler warnings. FIXME for libusb-2. */ | * signed to avoid compiler warnings. FIXME for libusb-2. */ | |||
if (packet > INT_MAX) | if (packet > INT_MAX) | |||
return NULL; | return NULL; | |||
_packet = packet; | _packet = (int) packet; | |||
if (_packet >= transfer->num_iso_packets) | if (_packet >= transfer->num_iso_packets) | |||
return NULL; | return NULL; | |||
return transfer->buffer + (transfer->iso_packet_desc[0].length * _pa cket); | return transfer->buffer + ((int) transfer->iso_packet_desc[0].length * _packet); | |||
} | } | |||
/* sync I/O */ | /* sync I/O */ | |||
int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle, | int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle, | |||
uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wI ndex, | uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wI ndex, | |||
unsigned char *data, uint16_t wLength, unsigned int timeout); | unsigned char *data, uint16_t wLength, unsigned int timeout); | |||
int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle, | int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle, | |||
unsigned char endpoint, unsigned char *data, int length, | unsigned char endpoint, unsigned char *data, int length, | |||
skipping to change at line 1421 | skipping to change at line 1724 | |||
* \param desc_type the descriptor type, see \ref libusb_descriptor_type | * \param desc_type the descriptor type, see \ref libusb_descriptor_type | |||
* \param desc_index the index of the descriptor to retrieve | * \param desc_index the index of the descriptor to retrieve | |||
* \param data output buffer for descriptor | * \param data output buffer for descriptor | |||
* \param length size of data buffer | * \param length size of data buffer | |||
* \returns number of bytes returned in data, or LIBUSB_ERROR code on failu re | * \returns number of bytes returned in data, or LIBUSB_ERROR code on failu re | |||
*/ | */ | |||
static inline int libusb_get_descriptor(libusb_device_handle *dev, | static inline int libusb_get_descriptor(libusb_device_handle *dev, | |||
uint8_t desc_type, uint8_t desc_index, unsigned char *data, int leng th) | uint8_t desc_type, uint8_t desc_index, unsigned char *data, int leng th) | |||
{ | { | |||
return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, | return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, | |||
LIBUSB_REQUEST_GET_DESCRIPTOR, (desc_type << 8) | desc_index | LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | |||
, 0, data, | | desc_index), | |||
(uint16_t) length, 1000); | 0, data, (uint16_t) length, 1000); | |||
} | } | |||
/** \ingroup desc | /** \ingroup desc | |||
* Retrieve a descriptor from a device. | * Retrieve a descriptor from a device. | |||
* This is a convenience function which formulates the appropriate control | * This is a convenience function which formulates the appropriate control | |||
* message to retrieve the descriptor. The string returned is Unicode, as | * message to retrieve the descriptor. The string returned is Unicode, as | |||
* detailed in the USB specifications. | * detailed in the USB specifications. | |||
* | * | |||
* \param dev a device handle | * \param dev a device handle | |||
* \param desc_index the index of the descriptor to retrieve | * \param desc_index the index of the descriptor to retrieve | |||
skipping to change at line 1517 | skipping to change at line 1820 | |||
* \see libusb_set_pollfd_notifiers() | * \see libusb_set_pollfd_notifiers() | |||
*/ | */ | |||
typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_dat a); | typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_dat a); | |||
const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds( | const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds( | |||
libusb_context *ctx); | libusb_context *ctx); | |||
void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx, | void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx, | |||
libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb , | libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb , | |||
void *user_data); | void *user_data); | |||
/** \ingroup hotplug | ||||
* Callback handle. | ||||
* | ||||
* Callbacks handles are generated by libusb_hotplug_register_callback() | ||||
* and can be used to deregister callbacks. Callback handles are unique | ||||
* per libusb_context and it is safe to call libusb_hotplug_deregister_call | ||||
back() | ||||
* on an already deregisted callback. | ||||
* | ||||
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | ||||
* | ||||
* For more information, see \ref hotplug. | ||||
*/ | ||||
typedef int libusb_hotplug_callback_handle; | ||||
/** \ingroup hotplug | ||||
* | ||||
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | ||||
* | ||||
* Flags for hotplug events */ | ||||
typedef enum { | ||||
/** Arm the callback and fire it for all matching currently attached | ||||
devices. */ | ||||
LIBUSB_HOTPLUG_ENUMERATE = 1, | ||||
} libusb_hotplug_flag; | ||||
/** \ingroup hotplug | ||||
* | ||||
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | ||||
* | ||||
* Hotplug events */ | ||||
typedef enum { | ||||
/** A device has been plugged in and is ready to use */ | ||||
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01, | ||||
/** A device has left and is no longer available. | ||||
* It is the user's responsibility to call libusb_close on any handl | ||||
e associated with a disconnected device. | ||||
* It is safe to call libusb_get_device_descriptor on a device that | ||||
has left */ | ||||
LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 0x02, | ||||
} libusb_hotplug_event; | ||||
/** \ingroup hotplug | ||||
* Wildcard matching for hotplug events */ | ||||
#define LIBUSB_HOTPLUG_MATCH_ANY -1 | ||||
/** \ingroup hotplug | ||||
* Hotplug callback function type. When requesting hotplug event notificati | ||||
ons, | ||||
* you pass a pointer to a callback function of this type. | ||||
* | ||||
* This callback may be called by an internal event thread and as such it i | ||||
s | ||||
* recommended the callback do minimal processing before returning. | ||||
* | ||||
* libusbx will call this function later, when a matching event had happene | ||||
d on | ||||
* a matching device. See \ref hotplug for more information. | ||||
* | ||||
* It is safe to call either libusb_hotplug_register_callback() or | ||||
* libusb_hotplug_deregister_callback() from within a callback function. | ||||
* | ||||
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | ||||
* | ||||
* \param libusb_context context of this notification | ||||
* \param device libusb_device this event occurred on | ||||
* \param event event that occurred | ||||
* \param user_data user data provided when this callback was register | ||||
ed | ||||
* \returns bool whether this callback is finished processing events. | ||||
* returning 1 will cause this callback to be deregis | ||||
tered | ||||
*/ | ||||
typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx, | ||||
libusb_device *device, | ||||
libusb_hotplug_event event, | ||||
void *user_data); | ||||
/** \ingroup hotplug | ||||
* Register a hotplug callback function | ||||
* | ||||
* Register a callback with the libusb_context. The callback will fire | ||||
* when a matching event occurs on a matching device. The callback is | ||||
* armed until either it is deregistered with libusb_hotplug_deregister_cal | ||||
lback() | ||||
* or the supplied callback returns 1 to indicate it is finished processing | ||||
events. | ||||
* | ||||
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | ||||
* | ||||
* \param[in] ctx context to register this callback with | ||||
* \param[in] events bitwise or of events that will trigger this callback. | ||||
See \ref | ||||
* libusb_hotplug_event | ||||
* \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag | ||||
* \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH | ||||
_ANY | ||||
* \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MAT | ||||
CH_ANY | ||||
* \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MA | ||||
TCH_ANY | ||||
* \param[in] cb_fn the function to be invoked on a matching event/device | ||||
* \param[in] user_data user data to pass to the callback function | ||||
* \param[out] handle pointer to store the handle of the allocated callback | ||||
(can be NULL) | ||||
* \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure | ||||
*/ | ||||
int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx, | ||||
libusb_hotplug_event events, | ||||
libusb_hotplug_flag flags, | ||||
int vendor_id, int product_i | ||||
d, | ||||
int dev_class, | ||||
libusb_hotplug_callback_fn c | ||||
b_fn, | ||||
void *user_data, | ||||
libusb_hotplug_callback_hand | ||||
le *handle); | ||||
/** \ingroup hotplug | ||||
* Deregisters a hotplug callback. | ||||
* | ||||
* Deregister a callback from a libusb_context. This function is safe to ca | ||||
ll from within | ||||
* a hotplug callback. | ||||
* | ||||
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | ||||
* | ||||
* \param[in] ctx context this callback is registered with | ||||
* \param[in] handle the handle of the callback to deregister | ||||
*/ | ||||
void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx, | ||||
libusb_hotplug_callback_hand | ||||
le handle); | ||||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 28 change blocks. | ||||
25 lines changed or deleted | 484 lines changed or added | |||