Externals: Update libusb to version 1.0.21

1.0.21 adds a usbdk backend, which may be helpful as it could be
used in the future to work around the missing isochronous transfer
support for WinUSB backends.

Here is the full changelog (from libusb).

2016-10-01: v1.0.21:
* Core: Refactor code related to transfer flags and timeout handling
* Darwin: Ignore root hub simulation devices
* Darwin: Improved support for OS X El Capitan
* Darwin: Work around devices with buggy endpoint descriptors
* Darwin: Do not use objc_registerThreadWithCollector after its deprecation
* Darwin: Use C11 atomics on 10.12+ as the OS atomics are now deprecated
* Linux: Support preallocating kernel memory for zerocopy USB
* Linux: Deal with receiving POLLERR before all transfers have completed
* Solaris: Add solaris backend
* Windows: Add Visual Studio 2015 support
* Windows: Add usbdk backend
* Prevent attempts to recursively handle events
* Fix race condition in handle_timeout()
* Allow transferred argument to be optional in bulk APIs
* Various other bug fixes and improvements
This commit is contained in:
Léo Lam committed 2016-11-20 18:11:42 +01:00
1 parent 3d21169dfc
commit 04db41adf3
81 files changed
+14306 -1649

No files matched your search

+42 -52
View File
@@ -35,7 +35,7 @@
#define ENDPOINT_DESC_LENGTH 7
#define ENDPOINT_AUDIO_DESC_LENGTH 9
/** @defgroup desc USB descriptors
/** @defgroup libusb_desc USB descriptors
* This page details how to examine the various standard USB descriptors
* for detected devices
*/
@@ -94,8 +94,7 @@ int usbi_parse_descriptor(const unsigned char *source, const char *descriptor,
static void clear_endpoint(struct libusb_endpoint_descriptor *endpoint)
{
if (endpoint->extra)
free((unsigned char *) endpoint->extra);
free((void *) endpoint->extra);
}
static int parse_endpoint(struct libusb_context *ctx,
@@ -198,19 +197,17 @@ static void clear_interface(struct libusb_interface *usb_interface)
struct libusb_interface_descriptor *ifp =
(struct libusb_interface_descriptor *)
usb_interface->altsetting + i;
if (ifp->extra)
free((void *) ifp->extra);
free((void *) ifp->extra);
if (ifp->endpoint) {
for (j = 0; j < ifp->bNumEndpoints; j++)
clear_endpoint((struct libusb_endpoint_descriptor *)
ifp->endpoint + j);
free((void *) ifp->endpoint);
ifp->endpoint + j);
}
free((void *) ifp->endpoint);
}
free((void *) usb_interface->altsetting);
usb_interface->altsetting = NULL;
}
free((void *) usb_interface->altsetting);
usb_interface->altsetting = NULL;
}
static int parse_interface(libusb_context *ctx,
@@ -222,7 +219,6 @@ static int parse_interface(libusb_context *ctx,
int r;
int parsed = 0;
int interface_number = -1;
size_t tmp;
struct usb_descriptor_header header;
struct libusb_interface_descriptor *ifp;
unsigned char *begin;
@@ -323,15 +319,13 @@ static int parse_interface(libusb_context *ctx,
if (ifp->bNumEndpoints > 0) {
struct libusb_endpoint_descriptor *endpoint;
tmp = ifp->bNumEndpoints * sizeof(struct libusb_endpoint_descriptor);
endpoint = malloc(tmp);
endpoint = calloc(ifp->bNumEndpoints, sizeof(struct libusb_endpoint_descriptor));
ifp->endpoint = endpoint;
if (!endpoint) {
r = LIBUSB_ERROR_NO_MEM;
goto err;
}
memset(endpoint, 0, tmp);
for (i = 0; i < ifp->bNumEndpoints; i++) {
r = parse_endpoint(ctx, endpoint + i, buffer, size,
host_endian);
@@ -364,15 +358,14 @@ err:
static void clear_configuration(struct libusb_config_descriptor *config)
{
int i;
if (config->interface) {
int i;
for (i = 0; i < config->bNumInterfaces; i++)
clear_interface((struct libusb_interface *)
config->interface + i);
free((void *) config->interface);
config->interface + i);
}
if (config->extra)
free((void *) config->extra);
free((void *) config->interface);
free((void *) config->extra);
}
static int parse_configuration(struct libusb_context *ctx,
@@ -381,7 +374,6 @@ static int parse_configuration(struct libusb_context *ctx,
{
int i;
int r;
size_t tmp;
struct usb_descriptor_header header;
struct libusb_interface *usb_interface;
@@ -411,13 +403,11 @@ static int parse_configuration(struct libusb_context *ctx,
return LIBUSB_ERROR_IO;
}
tmp = config->bNumInterfaces * sizeof(struct libusb_interface);
usb_interface = malloc(tmp);
usb_interface = calloc(config->bNumInterfaces, sizeof(struct libusb_interface));
config->interface = usb_interface;
if (!config->interface)
if (!usb_interface)
return LIBUSB_ERROR_NO_MEM;
memset(usb_interface, 0, tmp);
buffer += config->bLength;
size -= config->bLength;
@@ -538,7 +528,7 @@ int usbi_device_cache_descriptor(libusb_device *dev)
return LIBUSB_SUCCESS;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get the USB device descriptor for a given device.
*
* This is a non-blocking function; the device descriptor is cached in memory.
@@ -559,7 +549,7 @@ int API_EXPORTED libusb_get_device_descriptor(libusb_device *dev,
return 0;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get the USB configuration descriptor for the currently active configuration.
* This is a non-blocking function which does not involve any requests being
* sent to the device.
@@ -606,7 +596,7 @@ int API_EXPORTED libusb_get_active_config_descriptor(libusb_device *dev,
return r;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get a USB configuration descriptor based on its index.
* This is a non-blocking function which does not involve any requests being
* sent to the device.
@@ -689,7 +679,7 @@ int usbi_get_config_index_by_value(struct libusb_device *dev,
return 0;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get a USB configuration descriptor with a specific bConfigurationValue.
* This is a non-blocking function which does not involve any requests being
* sent to the device.
@@ -729,7 +719,7 @@ int API_EXPORTED libusb_get_config_descriptor_by_value(libusb_device *dev,
return libusb_get_config_descriptor(dev, (uint8_t) idx, config);
}
/** \ingroup desc
/** \ingroup libusb_desc
* Free a configuration descriptor obtained from
* libusb_get_active_config_descriptor() or libusb_get_config_descriptor().
* It is safe to call this function with a NULL config parameter, in which
@@ -747,7 +737,7 @@ void API_EXPORTED libusb_free_config_descriptor(
free(config);
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get an endpoints superspeed endpoint companion descriptor (if any)
*
* \param ctx the context to operate on, or NULL for the default context
@@ -797,7 +787,7 @@ int API_EXPORTED libusb_get_ss_endpoint_companion_descriptor(
return LIBUSB_ERROR_NOT_FOUND;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Free a superspeed endpoint companion descriptor obtained from
* libusb_get_ss_endpoint_companion_descriptor().
* It is safe to call this function with a NULL ep_comp parameter, in which
@@ -890,18 +880,18 @@ static int parse_bos(struct libusb_context *ctx,
return LIBUSB_SUCCESS;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get a Binary Object Store (BOS) descriptor
* This is a BLOCKING function, which will send requests to the device.
*
* \param handle the handle of an open libusb device
* \param dev_handle the handle of an open libusb device
* \param bos output location for the BOS descriptor. Only valid if 0 was returned.
* Must be freed with \ref libusb_free_bos_descriptor() after use.
* \returns 0 on success
* \returns LIBUSB_ERROR_NOT_FOUND if the device doesn't have a BOS descriptor
* \returns another LIBUSB_ERROR code on error
*/
int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *handle,
int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
struct libusb_bos_descriptor **bos)
{
struct libusb_bos_descriptor _bos;
@@ -912,15 +902,15 @@ int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *handle,
/* Read the BOS. This generates 2 requests on the bus,
* one for the header, and one for the full BOS */
r = libusb_get_descriptor(handle, LIBUSB_DT_BOS, 0, bos_header,
r = libusb_get_descriptor(dev_handle, LIBUSB_DT_BOS, 0, bos_header,
LIBUSB_DT_BOS_SIZE);
if (r < 0) {
if (r != LIBUSB_ERROR_PIPE)
usbi_err(handle->dev->ctx, "failed to read BOS (%d)", r);
usbi_err(HANDLE_CTX(dev_handle), "failed to read BOS (%d)", r);
return r;
}
if (r < LIBUSB_DT_BOS_SIZE) {
usbi_err(handle->dev->ctx, "short BOS read %d/%d",
usbi_err(HANDLE_CTX(dev_handle), "short BOS read %d/%d",
r, LIBUSB_DT_BOS_SIZE);
return LIBUSB_ERROR_IO;
}
@@ -932,18 +922,18 @@ int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *handle,
if (bos_data == NULL)
return LIBUSB_ERROR_NO_MEM;
r = libusb_get_descriptor(handle, LIBUSB_DT_BOS, 0, bos_data,
r = libusb_get_descriptor(dev_handle, LIBUSB_DT_BOS, 0, bos_data,
_bos.wTotalLength);
if (r >= 0)
r = parse_bos(handle->dev->ctx, bos, bos_data, r, host_endian);
r = parse_bos(HANDLE_CTX(dev_handle), bos, bos_data, r, host_endian);
else
usbi_err(handle->dev->ctx, "failed to read BOS (%d)", r);
usbi_err(HANDLE_CTX(dev_handle), "failed to read BOS (%d)", r);
free(bos_data);
return r;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Free a BOS descriptor obtained from libusb_get_bos_descriptor().
* It is safe to call this function with a NULL bos parameter, in which
* case the function simply returns.
@@ -962,7 +952,7 @@ void API_EXPORTED libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
free(bos);
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get an USB 2.0 Extension descriptor
*
* \param ctx the context to operate on, or NULL for the default context
@@ -1006,7 +996,7 @@ int API_EXPORTED libusb_get_usb_2_0_extension_descriptor(
return LIBUSB_SUCCESS;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Free a USB 2.0 Extension descriptor obtained from
* libusb_get_usb_2_0_extension_descriptor().
* It is safe to call this function with a NULL usb_2_0_extension parameter,
@@ -1020,7 +1010,7 @@ void API_EXPORTED libusb_free_usb_2_0_extension_descriptor(
free(usb_2_0_extension);
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get a SuperSpeed USB Device Capability descriptor
*
* \param ctx the context to operate on, or NULL for the default context
@@ -1064,7 +1054,7 @@ int API_EXPORTED libusb_get_ss_usb_device_capability_descriptor(
return LIBUSB_SUCCESS;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Free a SuperSpeed USB Device Capability descriptor obtained from
* libusb_get_ss_usb_device_capability_descriptor().
* It is safe to call this function with a NULL ss_usb_device_cap
@@ -1078,7 +1068,7 @@ void API_EXPORTED libusb_free_ss_usb_device_capability_descriptor(
free(ss_usb_device_cap);
}
/** \ingroup desc
/** \ingroup libusb_desc
* Get a Container ID descriptor
*
* \param ctx the context to operate on, or NULL for the default context
@@ -1121,7 +1111,7 @@ int API_EXPORTED libusb_get_container_id_descriptor(struct libusb_context *ctx,
return LIBUSB_SUCCESS;
}
/** \ingroup desc
/** \ingroup libusb_desc
* Free a Container ID descriptor obtained from
* libusb_get_container_id_descriptor().
* It is safe to call this function with a NULL container_id parameter,
@@ -1135,19 +1125,19 @@ void API_EXPORTED libusb_free_container_id_descriptor(
free(container_id);
}
/** \ingroup desc
/** \ingroup libusb_desc
* Retrieve a string descriptor in C style ASCII.
*
* Wrapper around libusb_get_string_descriptor(). Uses the first language
* supported by the device.
*
* \param dev a device handle
* \param dev_handle a device handle
* \param desc_index the index of the descriptor to retrieve
* \param data output buffer for ASCII string descriptor
* \param length size of data buffer
* \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
*/
int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev,
int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle,
uint8_t desc_index, unsigned char *data, int length)
{
unsigned char tbuf[255]; /* Some devices choke on size > 255 */
@@ -1166,7 +1156,7 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev,
if (desc_index == 0)
return LIBUSB_ERROR_INVALID_PARAM;
r = libusb_get_string_descriptor(dev, 0, 0, tbuf, sizeof(tbuf));
r = libusb_get_string_descriptor(dev_handle, 0, 0, tbuf, sizeof(tbuf));
if (r < 0)
return r;
@@ -1175,7 +1165,7 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev,
langid = tbuf[2] | (tbuf[3] << 8);
r = libusb_get_string_descriptor(dev, desc_index, langid, tbuf,
r = libusb_get_string_descriptor(dev_handle, desc_index, langid, tbuf,
sizeof(tbuf));
if (r < 0)
return r;