libusb.h   libusb.h 
/* /*
* Public libusbx header file * Public libusbx header file
* Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com> * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
* Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
* Copyright © 2012 Pete Batard <pete@akeo.ie>
* 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
* Lesser General Public License for more details. * Lesser General Public License for more details.
skipping to change at line 26 skipping to change at line 28
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef LIBUSB_H #ifndef LIBUSB_H
#define LIBUSB_H #define LIBUSB_H
#ifdef _MSC_VER #ifdef _MSC_VER
/* on MS environments, the inline keyword is available in C++ only */ /* on MS environments, the inline keyword is available in C++ only */
#if !defined(__cplusplus)
#define inline __inline #define inline __inline
#endif
/* ssize_t is also not available (copy/paste from MinGW) */ /* ssize_t is also not available (copy/paste from MinGW) */
#ifndef _SSIZE_T_DEFINED #ifndef _SSIZE_T_DEFINED
#define _SSIZE_T_DEFINED #define _SSIZE_T_DEFINED
#undef ssize_t #undef ssize_t
#ifdef _WIN64 #ifdef _WIN64
typedef __int64 ssize_t; typedef __int64 ssize_t;
#else #else
typedef int ssize_t; typedef int ssize_t;
#endif /* _WIN64 */ #endif /* _WIN64 */
#endif /* _SSIZE_T_DEFINED */ #endif /* _SSIZE_T_DEFINED */
skipping to change at line 106 skipping to change at line 110
* The placement of this macro is important too; it must appear after the * The placement of this macro is important too; it must appear after the
* return type, before the function name. See internal documentation for * return type, before the function name. See internal documentation for
* API_EXPORTED. * API_EXPORTED.
*/ */
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
#define LIBUSB_CALL WINAPI #define LIBUSB_CALL WINAPI
#else #else
#define LIBUSB_CALL #define LIBUSB_CALL
#endif #endif
/** \def LIBUSBX_API_VERSION
* \ingroup misc
* libusbx's API version.
*
* Since version 1.0.13, to help with feature detection, libusbx defines
* a LIBUSBX_API_VERSION macro that gets increased every time there is a
* significant change to the API, such as the introduction of a new call,
* the definition of a new macro/enum member, or any other element that
* libusbx applications may want to detect at compilation time.
*
* The macro is typically used in an application as follows:
* \code
* #if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x01001234)
* // Use one of the newer features from the libusbx API
* #endif
* \endcode
*
* 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.
*
* Internally, LIBUSBX_API_VERSION is defined as follows:
* (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental)
*/
#define LIBUSBX_API_VERSION 0x01000100
#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
skipping to change at line 232 skipping to change at line 261
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 */
LIBUSB_DT_SUPERSPEED_HUB = 0x2A,
}; };
/* 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
skipping to change at line 278 skipping to change at line 310
LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1, LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
/** Bulk endpoint */ /** Bulk endpoint */
LIBUSB_TRANSFER_TYPE_BULK = 2, LIBUSB_TRANSFER_TYPE_BULK = 2,
/** Interrupt endpoint */ /** Interrupt endpoint */
LIBUSB_TRANSFER_TYPE_INTERRUPT = 3 LIBUSB_TRANSFER_TYPE_INTERRUPT = 3
}; };
/** \ingroup misc /** \ingroup misc
* Standard requests, as defined in table 9-3 of the USB2 specifications */ * Standard requests, as defined in table 9-5 of the USB 3.0 specifications */
enum libusb_standard_request { enum libusb_standard_request {
/** Request status of the specific recipient */ /** Request status of the specific recipient */
LIBUSB_REQUEST_GET_STATUS = 0x00, LIBUSB_REQUEST_GET_STATUS = 0x00,
/** Clear or disable a specific feature */ /** Clear or disable a specific feature */
LIBUSB_REQUEST_CLEAR_FEATURE = 0x01, LIBUSB_REQUEST_CLEAR_FEATURE = 0x01,
/* 0x02 is reserved */ /* 0x02 is reserved */
/** Set or enable a specific feature */ /** Set or enable a specific feature */
skipping to change at line 316 skipping to change at line 348
LIBUSB_REQUEST_SET_CONFIGURATION = 0x09, LIBUSB_REQUEST_SET_CONFIGURATION = 0x09,
/** Return the selected alternate setting for the specified interfac e */ /** Return the selected alternate setting for the specified interfac e */
LIBUSB_REQUEST_GET_INTERFACE = 0x0A, LIBUSB_REQUEST_GET_INTERFACE = 0x0A,
/** Select an alternate interface for the specified interface */ /** Select an alternate interface for the specified interface */
LIBUSB_REQUEST_SET_INTERFACE = 0x0B, LIBUSB_REQUEST_SET_INTERFACE = 0x0B,
/** Set then report an endpoint's synchronization frame */ /** Set then report an endpoint's synchronization frame */
LIBUSB_REQUEST_SYNCH_FRAME = 0x0C, LIBUSB_REQUEST_SYNCH_FRAME = 0x0C,
/** Sets both the U1 and U2 Exit Latency */
LIBUSB_REQUEST_SET_SEL = 0x30,
/** Delay from the time a host transmits a packet to the time it is
* received by the device. */
LIBUSB_SET_ISOCH_DELAY = 0x31,
}; };
/** \ingroup misc /** \ingroup misc
* Request type bits of the * Request type bits of the
* \ref libusb_control_setup::bmRequestType "bmRequestType" field in contro l * \ref libusb_control_setup::bmRequestType "bmRequestType" field in contro l
* transfers. */ * transfers. */
enum libusb_request_type { enum libusb_request_type {
/** Standard */ /** Standard */
LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5), LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5),
skipping to change at line 395 skipping to change at line 434
/** Feedback endpoint */ /** Feedback endpoint */
LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1, LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1,
/** Implicit feedback Data endpoint */ /** Implicit feedback Data endpoint */
LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2, LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2,
}; };
/** \ingroup desc /** \ingroup desc
* A structure representing the standard USB device descriptor. This * A structure representing the standard USB device descriptor. This
* descriptor is documented in section 9.6.1 of the USB 2.0 specification. * descriptor is documented in section 9.6.1 of the USB 3.0 specification.
* All multiple-byte fields are represented in host-endian format. * All multiple-byte fields are represented in host-endian format.
*/ */
struct libusb_device_descriptor { struct libusb_device_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_DEVICE LIBUSB_DT_DEVICE in this * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE LIBUSB_DT_DEVICE in this
* context. */ * context. */
uint8_t bDescriptorType; uint8_t bDescriptorType;
skipping to change at line 449 skipping to change at line 488
/** 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 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.6 of the USB 3.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
* this context. */ * this context. */
uint8_t bDescriptorType; uint8_t bDescriptorType;
skipping to change at line 499 skipping to change at line 538
/** Extra descriptors. If libusbx encounters unknown endpoint descri ptors, /** Extra descriptors. If libusbx encounters unknown endpoint descri ptors,
* it will store them here, should you wish to parse them. */ * it will store them here, should you wish to parse them. */
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 /** \ingroup desc
* A structure representing the standard USB interface descriptor. This * A structure representing the standard USB interface descriptor. This
* descriptor is documented in section 9.6.5 of the USB 2.0 specification. * descriptor is documented in section 9.6.5 of the USB 3.0 specification.
* All multiple-byte fields are represented in host-endian format. * All multiple-byte fields are represented in host-endian format.
*/ */
struct libusb_interface_descriptor { struct libusb_interface_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_INTERFACE LIBUSB_DT_INTERF ACE * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE LIBUSB_DT_INTERF ACE
* in this context. */ * in this context. */
uint8_t bDescriptorType; uint8_t bDescriptorType;
skipping to change at line 561 skipping to change at line 600
/** Array of interface descriptors. The length of this array is dete rmined /** Array of interface descriptors. The length of this array is dete rmined
* by the num_altsetting field. */ * by the num_altsetting field. */
const struct libusb_interface_descriptor *altsetting; const struct libusb_interface_descriptor *altsetting;
/** The number of alternate settings that belong to this interface * / /** The number of alternate settings that belong to this interface * /
int num_altsetting; int num_altsetting;
}; };
/** \ingroup desc /** \ingroup desc
* A structure representing the standard USB configuration descriptor. This * A structure representing the standard USB configuration 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 3.0 specification.
* All multiple-byte fields are represented in host-endian format. * All multiple-byte fields are represented in host-endian format.
*/ */
struct libusb_config_descriptor { struct libusb_config_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_CONFIG LIBUSB_DT_CONFIG * \ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG
* in this context. */ * in this context. */
uint8_t bDescriptorType; uint8_t bDescriptorType;
skipping to change at line 591 skipping to change at line 630
/** Index of string descriptor describing this configuration */ /** Index of string descriptor describing this configuration */
uint8_t iConfiguration; uint8_t iConfiguration;
/** Configuration characteristics */ /** Configuration characteristics */
uint8_t bmAttributes; uint8_t bmAttributes;
/** Maximum power consumption of the USB device from this bus in thi s /** Maximum power consumption of the USB device from this bus in thi s
* configuration when the device is fully opreation. Expressed in un its * configuration when the device is fully opreation. Expressed in un its
* of 2 mA. */ * of 2 mA. */
uint8_t MaxPower; uint8_t bMaxPower;
/** Array of interfaces supported by this configuration. The length of /** Array of interfaces supported by this configuration. The length of
* this array is determined by the bNumInterfaces field. */ * this array is determined by the bNumInterfaces field. */
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. */
skipping to change at line 808 skipping to change at line 847
/** For bulk/interrupt endpoints: halt condition detected (endpoint /** For bulk/interrupt endpoints: halt condition detected (endpoint
* stalled). For control endpoints: control request not supported. * / * stalled). For control endpoints: control request not supported. * /
LIBUSB_TRANSFER_STALL, LIBUSB_TRANSFER_STALL,
/** Device was disconnected */ /** Device was disconnected */
LIBUSB_TRANSFER_NO_DEVICE, LIBUSB_TRANSFER_NO_DEVICE,
/** Device sent more data than requested */ /** Device sent more data than requested */
LIBUSB_TRANSFER_OVERFLOW, LIBUSB_TRANSFER_OVERFLOW,
/* NB! Remember to update libusb_error_name()
when adding new status codes here. */
}; };
/** \ingroup asyncio /** \ingroup asyncio
* libusb_transfer.flags values */ * libusb_transfer.flags values */
enum libusb_transfer_flags { enum libusb_transfer_flags {
/** Report short frames as errors */ /** Report short frames as errors */
LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0, LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0,
/** Automatically free() transfer buffer during libusb_free_transfer () */ /** Automatically free() transfer buffer during libusb_free_transfer () */
LIBUSB_TRANSFER_FREE_BUFFER = 1<<1, LIBUSB_TRANSFER_FREE_BUFFER = 1<<1,
skipping to change at line 953 skipping to change at line 995
* 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,
}; };
/** \ingroup lib /** \ingroup lib
* Log message levels. * Log message levels.
* - LOG_LEVEL_NONE (0) : no messages ever printed by the library (defa * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the librar
ult) y (default)
* - LOG_LEVEL_ERROR (1) : error messages are printed to stderr * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
* - LOG_LEVEL_WARNING (2) : warning and error messages are printed to std * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed
err to stderr
* - LOG_LEVEL_INFO (3) : informational messages are printed to stdout, * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to
warning stdout, warning
* and error messages are printed to stderr * and error messages are printed to stderr
* - LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout, * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are p rinted to stdout,
* warnings and errors to stderr * warnings and errors to stderr
*/ */
enum usbi_log_level { enum libusb_log_level {
LOG_LEVEL_NONE = 0, LIBUSB_LOG_LEVEL_NONE = 0,
LOG_LEVEL_ERROR, LIBUSB_LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING, LIBUSB_LOG_LEVEL_WARNING,
LOG_LEVEL_INFO, LIBUSB_LOG_LEVEL_INFO,
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);
ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx, ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
 End of changes. 17 change blocks. 
21 lines changed or deleted 63 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/