libusb.h | libusb.h | |||
---|---|---|---|---|
/* | /* | |||
* Public libusb header file | * Public libusb header file | |||
* Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org> | * Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org> | |||
* Copyright (c) 2001 Johannes Erdfelt <johannes@erdfelt.com> | * Copyright (c) 2001 Johannes Erdfelt <johannes@erdfelt.com> | |||
* Copyright (C) 2012-2013 Nathan Hjelm <hjelmn@cs.unm.edu> | ||||
* Copyright (C) 2012 Peter Stuge <peter@stuge.se> | ||||
* | * | |||
* 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 | |||
* Lesser General Public License for more details. | * Lesser General Public License for more details. | |||
skipping to change at line 232 | skipping to change at line 234 | |||
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, | |||
/** BOS descriptor */ | ||||
LIBUSB_DT_BOS = 0x0f, | ||||
/** Device Capability descriptor */ | ||||
LIBUSB_DT_DEVICE_CAPABILITY = 0x10, | ||||
/** 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_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE 7 | ||||
#define LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE 10 | ||||
#define LIBUSB_DT_BOS_MAX_SIZE ((LIBUSB_DT_BOS_SIZE) + \ | ||||
(LIBUSB_USB_2_0_EXTENSION_DEVICE_CAP | ||||
ABILITY_SIZE) + \ | ||||
(LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZ | ||||
E)) | ||||
#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 448 | skipping to change at line 466 | |||
uint8_t iProduct; | uint8_t iProduct; | |||
/** Index of string descriptor containing device serial number */ | /** Index of string descriptor containing device serial number */ | |||
uint8_t iSerialNumber; | uint8_t iSerialNumber; | |||
/** Number of possible configurations */ | /** Number of possible configurations */ | |||
uint8_t bNumConfigurations; | uint8_t bNumConfigurations; | |||
}; | }; | |||
/** \ingroup desc | /** \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 ultiple-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 structure representing the standard USB endpoint descriptor. This | * A structure representing the standard USB endpoint descriptor. This | |||
* descriptor is documented in section 9.6.3 of the USB 2.0 specification. | * descriptor is documented in section 9.6.3 of the USB 2.0 specification. | |||
* All multiple-byte fields are represented in host-endian format. | * All multiple-byte fields are represented in host-endian format. | |||
*/ | */ | |||
struct libusb_endpoint_descriptor { | struct libusb_endpoint_descriptor { | |||
/** Size of this descriptor (in bytes) */ | /** Size of this descriptor (in bytes) */ | |||
uint8_t bLength; | uint8_t bLength; | |||
/** Descriptor type. Will have value | /** Descriptor type. Will have value | |||
* \ref libusb_descriptor_type::LIBUSB_DT_ENDPOINT LIBUSB_DT_ENDPOIN T in | * \ref libusb_descriptor_type::LIBUSB_DT_ENDPOINT LIBUSB_DT_ENDPOIN T in | |||
skipping to change at line 605 | skipping to change at line 654 | |||
const struct libusb_interface *interface; | const struct libusb_interface *interface; | |||
/** Extra descriptors. If libusb encounters unknown configuration | /** Extra descriptors. If libusb 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 BOS descriptor. This | ||||
* descriptor is documented in section 9.6.2 of the USB 3.0 | ||||
* specification. 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; | ||||
/** USB 2.0 extension capability descriptor */ | ||||
struct libusb_usb_2_0_device_capability_descriptor *usb_2_0_ext_cap; | ||||
/** SuperSpeed capabilty descriptor */ | ||||
struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap; | ||||
}; | ||||
/** \ingroup desc | ||||
* A structure representing the device capability descriptor for | ||||
* USB 2.0. This descriptor is documented in section 9.6.2.1 of | ||||
* the USB 3.0 specification. All mutiple-byte fields are represented | ||||
* in host-endian format. | ||||
*/ | ||||
struct libusb_usb_2_0_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_USB_CAP_TYPE_EXT | ||||
* LIBUSB_USB_CAP_TYPE_EXT 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_capability_attributes. */ | ||||
uint32_t bmAttributes; | ||||
}; | ||||
/** \ingroup desc | ||||
* A structure representing the device capability descriptor for | ||||
* USB 3.0. This descriptor is documented in section 9.6.2.2 of | ||||
* the USB 3.0 specification. All mutiple-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_SS_USB_CAP_TYPE | ||||
* LIBUSB_SS_USB_CAP_TYPE 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_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 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 640 | skipping to change at line 788 | |||
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)) | |||
/* libusb */ | /* libusb */ | |||
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 representing the libusb version. | * Structure representing the libusb version. | |||
*/ | */ | |||
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 691 | skipping to change at line 840 | |||
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 730 | skipping to change at line 879 | |||
/** 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_5GBPS_OPERATION = 8, | ||||
}; | ||||
/** \ingroup dev | ||||
* Capability attributes | ||||
*/ | ||||
enum libusb_capability_attributes { | ||||
/** Supports Link Power Management (LPM) */ | ||||
LIBUSB_LPM_SUPPORT = 2, | ||||
}; | ||||
/** \ingroup dev | ||||
* USB capability types | ||||
*/ | ||||
enum libusb_capability_type { | ||||
/** USB 2.0 extension capability type */ | ||||
LIBUSB_USB_CAP_TYPE_EXT = 2, | ||||
/** SuperSpeed capability type */ | ||||
LIBUSB_SS_USB_CAP_TYPE = 3, | ||||
}; | ||||
/** \ingroup misc | /** \ingroup misc | |||
* Error codes. Most libusb functions return 0 on success or one of these | * Error codes. Most libusb 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 n | * You can call \ref libusb_error_name() to retrieve a string representatio n | |||
* of an error code or \ret libusb_strerror() to get an english description | ||||
* of an error code. | * 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 */ | |||
skipping to change at line 776 | skipping to change at line 963 | |||
/** 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_name() and | |||
when adding new error codes here. */ | libusb_strerror() when adding new error codes here. */ | |||
/** Other error */ | /** Other error */ | |||
LIBUSB_ERROR_OTHER = -99, | LIBUSB_ERROR_OTHER = -99, | |||
}; | }; | |||
/** \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. */ | |||
skipping to change at line 949 | skipping to change at line 1136 | |||
}; | }; | |||
/** \ingroup misc | /** \ingroup misc | |||
* Capabilities supported by this instance of libusb. Test if the loaded | * Capabilities supported by this instance of libusb. Test if the loaded | |||
* library supports a given capability by calling | * library supports a given capability by calling | |||
* \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 = 0, | LIBUSB_CAP_HAS_CAPABILITY = 0, | |||
/** The libusb hotplug API is available. */ | ||||
LIBUSB_CAP_HAS_HOTPLUG = 1, | ||||
}; | }; | |||
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); | |||
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); | |||
skipping to change at line 1438 | skipping to change at line 1628 | |||
* \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 desc | ||||
* Parse a USB 3.0 endpoint companion descriptor. | ||||
* | ||||
* \param[in] buf the buffer containing the endpoint companion descriptor | ||||
* \param[in] len the length of the buffer | ||||
* \param[out] ep_comp a parsed endpoint companion descriptor. must be free | ||||
d by | ||||
* libusb_free_ss_endpoint_comp() | ||||
* | ||||
* \returns LIBUSB_SUCCESS on success | ||||
* \returns LIBUSB_ERROR code on error | ||||
*/ | ||||
int LIBUSB_CALL libusb_parse_ss_endpoint_comp(const void *buf, int len, | ||||
struct libusb_ss_endpoint_comp | ||||
anion_descriptor **ep_comp); | ||||
/** \ingroup desc | ||||
* Free a USB 3.0 endpoint companion descriptor. | ||||
* | ||||
* \param[in] ep_comp the descriptor to free | ||||
*/ | ||||
void LIBUSB_CALL libusb_free_ss_endpoint_comp(struct libusb_ss_endpoint_com | ||||
panion_descriptor *ep_comp); | ||||
/** \ingroup desc | ||||
* Parse a Binary Object Store (BOS) descriptor. | ||||
* | ||||
* \param[in] buf the buffer containing the BOS descriptor | ||||
* \param[in] len the length of the buffer | ||||
* \param[out] bos a parsed BOS descriptor. must be freed by | ||||
* libusb_free_bos_descriptor() | ||||
* | ||||
* \returns LIBUSB_SUCCESS on success | ||||
* \returns LIBUSB_ERROR code on error | ||||
*/ | ||||
int LIBUSB_CALL libusb_parse_bos_descriptor(const void *buf, int len, | ||||
struct libusb_bos_descriptor **b | ||||
os); | ||||
/** \ingroup desc | ||||
* Free a Binary Object Store (BOS) descriptor. | ||||
* | ||||
* \param[in] bos the descriptor to free | ||||
*/ | ||||
void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *b | ||||
os); | ||||
/** \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. | ||||
* | ||||
* For more information, see \ref hotplug. | ||||
*/ | ||||
typedef int libusb_hotplug_callback_handle; | ||||
/** \ingroup hotplug | ||||
* 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 | ||||
* 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. | ||||
* | ||||
* libusb will call this function later, when a matching event had happened | ||||
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. | ||||
* | ||||
* \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 e | ||||
vent, | ||||
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. | ||||
* | ||||
* \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_ | ||||
id, | ||||
int dev_class, | ||||
libusb_hotplug_callback_fn | ||||
cb_fn, | ||||
void *user_data, | ||||
libusb_hotplug_callback_han | ||||
dle *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. | ||||
* | ||||
* \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_ | ||||
handle handle); | ||||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 13 change blocks. | ||||
4 lines changed or deleted | 367 lines changed or added | |||