libusb.h   libusb.h 
skipping to change at line 21 skipping to change at line 21
* 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.
* *
* 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
/* on MS environments, the inline keyword is available in C++ only */
#define inline __inline
/* ssize_t is also not available (copy/paste from MinGW) */
#ifndef _SSIZE_T_DEFINED
#define _SSIZE_T_DEFINED
#undef ssize_t
#ifdef _WIN64
typedef __int64 ssize_t;
#else
typedef int ssize_t;
#endif /* _WIN64 */
#endif /* _SSIZE_T_DEFINED */
#endif /* _MSC_VER */
/* stdint.h is also not usually available on MS */
#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defi
ned(_STDINT_H))
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#else
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> #endif
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
#include <limits.h> #include <limits.h>
#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
#include <sys/time.h>
#endif
/* 'interface' might be defined as a macro on Windows, so we need to
* undefine it so as not to break the current libusb API, because
* libusb_config_descriptor has an 'interface' member
* As this can be problematic if you include windows.h after libusb.h
* in your sources, we force windows.h to be included first. */
#if defined(_WIN32) || defined(__CYGWIN__)
#include <windows.h>
#if defined(interface)
#undef interface
#endif
#endif
/** \def LIBUSB_CALL
* \ingroup misc
* libusb's Windows calling convention.
*
* Under Windows, the selection of available compilers and configurations
* means that, unlike other platforms, there is not <em>one true calling
* convention</em> (calling convention: the manner in which parameters are
* passed to funcions in the generated assembly code).
*
* Matching the Windows API itself, libusb uses the WINAPI convention (whic
h
* translates to the <tt>stdcall</tt> convention) and guarantees that the
* library is compiled in this way. The public header file also includes
* appropriate annotations so that your own software will use the right
* convention, even if another convention is being used by default within
* your codebase.
*
* The one consideration that you must apply in your software is to mark
* all functions which you use as libusb callbacks with this LIBUSB_CALL
* annotation, so that they too get compiled for the correct calling
* convention.
*
* On non-Windows operating systems, this macro is defined as nothing. This
* means that you can apply it to your code without worrying about
* cross-platform compatibility.
*/
/* LIBUSB_CALL must be defined on both definition and declaration of libusb
* functions. You'd think that declaration would be enough, but cygwin will
* complain about conflicting types unless both are marked this way.
* The placement of this macro is important too; it must appear after the
* return type, before the function name. See internal documentation for
* API_EXPORTED.
*/
#if defined(_WIN32) || defined(__CYGWIN__)
#define LIBUSB_CALL WINAPI
#else
#define LIBUSB_CALL
#endif
#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
*/ */
#define libusb_cpu_to_le16(x) ({ \ static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
union { \ {
uint8_t b8[2]; \ union {
uint16_t b16; \ uint8_t b8[2];
} _tmp; \ uint16_t b16;
uint16_t _tmp2 = (uint16_t)(x); \ } _tmp;
_tmp.b8[1] = _tmp2 >> 8; \ _tmp.b8[1] = x >> 8;
_tmp.b8[0] = _tmp2 & 0xff; \ _tmp.b8[0] = x & 0xff;
_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
*/ */
#define libusb_le16_to_cpu libusb_cpu_to_le16 #define libusb_le16_to_cpu libusb_cpu_to_le16
skipping to change at line 83 skipping to change at line 159
/** Audio class */ /** Audio class */
LIBUSB_CLASS_AUDIO = 1, LIBUSB_CLASS_AUDIO = 1,
/** Communications class */ /** Communications class */
LIBUSB_CLASS_COMM = 2, LIBUSB_CLASS_COMM = 2,
/** Human Interface Device class */ /** Human Interface Device class */
LIBUSB_CLASS_HID = 3, LIBUSB_CLASS_HID = 3,
/** Printer dclass */ /** Physical */
LIBUSB_CLASS_PHYSICAL = 5,
/** Printer class */
LIBUSB_CLASS_PRINTER = 7, LIBUSB_CLASS_PRINTER = 7,
/** Picture transfer protocol class */ /** Image class */
LIBUSB_CLASS_PTP = 6, LIBUSB_CLASS_PTP = 6, /* legacy name from libusb-0.1 usb.h */
LIBUSB_CLASS_IMAGE = 6,
/** Mass storage class */ /** Mass storage class */
LIBUSB_CLASS_MASS_STORAGE = 8, LIBUSB_CLASS_MASS_STORAGE = 8,
/** Hub class */ /** Hub class */
LIBUSB_CLASS_HUB = 9, LIBUSB_CLASS_HUB = 9,
/** Data class */ /** Data class */
LIBUSB_CLASS_DATA = 10, LIBUSB_CLASS_DATA = 10,
/** Smart Card */
LIBUSB_CLASS_SMART_CARD = 0x0b,
/** Content Security */
LIBUSB_CLASS_CONTENT_SECURITY = 0x0d,
/** Video */
LIBUSB_CLASS_VIDEO = 0x0e,
/** Personal Healthcare */
LIBUSB_CLASS_PERSONAL_HEALTHCARE = 0x0f,
/** Diagnostic Device */
LIBUSB_CLASS_DIAGNOSTIC_DEVICE = 0xdc,
/** Wireless class */ /** Wireless class */
LIBUSB_CLASS_WIRELESS = 0xe0, LIBUSB_CLASS_WIRELESS = 0xe0,
/** Application class */ /** Application class */
LIBUSB_CLASS_APPLICATION = 0xfe, LIBUSB_CLASS_APPLICATION = 0xfe,
/** Class is vendor-specific */ /** Class is vendor-specific */
LIBUSB_CLASS_VENDOR_SPEC = 0xff LIBUSB_CLASS_VENDOR_SPEC = 0xff
}; };
skipping to change at line 136 skipping to change at line 231
/** 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,
}; };
/* 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 220 skipping to change at line 315
/** Set device configuration */ /** Set device configuration */
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,
}; };
/** \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 256 skipping to change at line 351
/** Device */ /** Device */
LIBUSB_RECIPIENT_DEVICE = 0x00, LIBUSB_RECIPIENT_DEVICE = 0x00,
/** Interface */ /** Interface */
LIBUSB_RECIPIENT_INTERFACE = 0x01, LIBUSB_RECIPIENT_INTERFACE = 0x01,
/** Endpoint */ /** Endpoint */
LIBUSB_RECIPIENT_ENDPOINT = 0x02, LIBUSB_RECIPIENT_ENDPOINT = 0x02,
/** Other */ /** Other */
LIBUSB_RECIPIENT_OTHER = 0x03 LIBUSB_RECIPIENT_OTHER = 0x03,
}; };
#define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C #define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C
/** \ingroup desc /** \ingroup desc
* Synchronization type for isochronous endpoints. Values for bits 2:3 of t he * Synchronization type for isochronous endpoints. Values for bits 2:3 of t he
* \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
* libusb_endpoint_descriptor. * libusb_endpoint_descriptor.
*/ */
enum libusb_iso_sync_type { enum libusb_iso_sync_type {
skipping to change at line 295 skipping to change at line 390
* libusb_endpoint_descriptor. * libusb_endpoint_descriptor.
*/ */
enum libusb_iso_usage_type { enum libusb_iso_usage_type {
/** Data endpoint */ /** Data endpoint */
LIBUSB_ISO_USAGE_TYPE_DATA = 0, LIBUSB_ISO_USAGE_TYPE_DATA = 0,
/** 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 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_device_descriptor { struct libusb_device_descriptor {
/** Size of this descriptor (in bytes) */ /** Size of this descriptor (in bytes) */
uint8_t bLength; uint8_t bLength;
skipping to change at line 547 skipping to change at line 642
#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;
/** \ingroup lib /** \ingroup lib
* Structure representing the libusb version.
*/
struct libusb_version {
/** Library major version. */
const uint16_t major;
/** Library minor version. */
const uint16_t minor;
/** Library micro version. */
const uint16_t micro;
/** Library nano version. This field is only nonzero on Windows. */
const uint16_t nano;
/** Library release candidate suffix string, e.g. "-rc4". */
const char *rc;
/** Output of `git describe --tags` at library build time. */
const char *describe;
};
/** \ingroup lib
* Structure representing a libusb session. The concept of individual libus b * Structure representing a libusb session. The concept of individual libus b
* sessions allows for your program to use two libraries (or dynamically * sessions allows for your program to use two libraries (or dynamically
* load two modules) which both independently use libusb. This will prevent * load two modules) which both independently use libusb. This will prevent
* interference between the individual libusb users - for example * interference between the individual libusb users - for example
* libusb_set_debug() will not affect the other user of the library, and * libusb_set_debug() will not affect the other user of the library, and
* libusb_exit() will not destroy resources that the other user is still * libusb_exit() will not destroy resources that the other user is still
* using. * using.
* *
* Sessions are created by libusb_init() and destroyed through libusb_exit( ). * Sessions are created by libusb_init() and destroyed through libusb_exit( ).
* If your application is guaranteed to only ever include a single libusb * If your application is guaranteed to only ever include a single libusb
skipping to change at line 592 skipping to change at line 710
/** \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
* libusb_open(). * libusb_open().
* *
* A device handle is used to perform I/O and other operations. When finish ed * A device handle is used to perform I/O and other operations. When finish ed
* with a device handle, you should call libusb_close(). * with a device handle, you should call libusb_close().
*/ */
typedef struct libusb_device_handle libusb_device_handle; typedef struct libusb_device_handle libusb_device_handle;
/** \ingroup dev
* Speed codes. Indicates the speed at which the device is operating.
*/
enum libusb_speed {
/** The OS doesn't report or know the device speed. */
LIBUSB_SPEED_UNKNOWN = 0,
/** The device is operating at low speed (1.5MBit/s). */
LIBUSB_SPEED_LOW = 1,
/** The device is operating at full speed (12MBit/s). */
LIBUSB_SPEED_FULL = 2,
/** The device is operating at high speed (480MBit/s). */
LIBUSB_SPEED_HIGH = 3,
/** The device is operating at super speed (5000MBit/s). */
LIBUSB_SPEED_SUPER = 4,
};
/** \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
* 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 636 skipping to change at line 776
/** 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()
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. */
LIBUSB_TRANSFER_COMPLETED, LIBUSB_TRANSFER_COMPLETED,
/** Transfer failed */ /** Transfer failed */
skipping to change at line 664 skipping to change at line 807
LIBUSB_TRANSFER_CANCELLED, LIBUSB_TRANSFER_CANCELLED,
/** 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,
}; };
/** \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,
/** Automatically call libusb_free_transfer() after callback returns . /** Automatically call libusb_free_transfer() after callback returns .
* If this flag is set, it is illegal to call libusb_free_transfer() * If this flag is set, it is illegal to call libusb_free_transfer()
* from your transfer callback, as this will result in a double-free * from your transfer callback, as this will result in a double-free
* when this flag is acted upon. */ * when this flag is acted upon. */
LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2 LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2,
/** Terminate transfers that are a multiple of the endpoint's
* wMaxPacketSize with an extra zero length packet. This is useful
* when a device protocol mandates that each logical request is
* terminated by an incomplete packet (i.e. the logical requests are
* not separated by other means).
*
* This flag only affects host-to-device transfers to bulk and inter
rupt
* endpoints. In other situations, it is ignored.
*
* This flag only affects transfers with a length that is a multiple
of
* the endpoint's wMaxPacketSize. On transfers of other lengths, thi
s
* flag has no effect. Therefore, if you are working with a device t
hat
* needs a ZLP whenever the end of the logical request falls on a pa
cket
* boundary, then it is sensible to set this flag on <em>every</em>
* transfer (you do not have to worry about only setting it on trans
fers
* that end on the boundary).
*
* This flag is currently only supported on Linux.
* On other systems, libusb_submit_transfer() will return
* LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this flag is
set.
*
* Available since libusb-1.0.9.
*/
LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1 << 3,
}; };
/** \ingroup asyncio /** \ingroup asyncio
* Isochronous packet descriptor. */ * Isochronous packet descriptor. */
struct libusb_iso_packet_descriptor { struct libusb_iso_packet_descriptor {
/** Length of data to request in this packet */ /** Length of data to request in this packet */
unsigned int length; unsigned int length;
/** Amount of data that was actually transferred */ /** Amount of data that was actually transferred */
unsigned int actual_length; unsigned int actual_length;
skipping to change at line 707 skipping to change at line 875
/** \ingroup asyncio /** \ingroup asyncio
* Asynchronous transfer callback function type. When submitting asynchrono us * Asynchronous transfer callback function type. When submitting asynchrono us
* transfers, you pass a pointer to a callback function of this type via th e * transfers, you pass a pointer to a callback function of this type via th e
* \ref libusb_transfer::callback "callback" member of the libusb_transfer * \ref libusb_transfer::callback "callback" member of the libusb_transfer
* structure. libusb will call this function later, when the transfer has * structure. libusb will call this function later, when the transfer has
* completed or failed. See \ref asyncio for more information. * completed or failed. See \ref asyncio for more information.
* \param transfer The libusb_transfer struct the callback function is bein g * \param transfer The libusb_transfer struct the callback function is bein g
* notified about. * notified about.
*/ */
typedef void (*libusb_transfer_cb_fn)(struct libusb_transfer *transfer); typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *t ransfer);
/** \ingroup asyncio /** \ingroup asyncio
* The generic USB transfer structure. The user populates this structure an d * The generic USB transfer structure. The user populates this structure an d
* then submits it in order to request a transfer. After the transfer has * then submits it in order to request a transfer. After the transfer has
* completed, the library populates the transfer with the results and passe s * completed, the library populates the transfer with the results and passe s
* it back to the user. * it back to the user.
*/ */
struct libusb_transfer { struct libusb_transfer {
/** Handle of the device that this transfer will be submitted to */ /** Handle of the device that this transfer will be submitted to */
libusb_device_handle *dev_handle; libusb_device_handle *dev_handle;
skipping to change at line 773 skipping to change at line 941
/** Isochronous packet descriptors, for isochronous transfers only. */ /** Isochronous packet descriptors, for isochronous transfers only. */
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
; ;
}; };
int libusb_init(libusb_context **ctx); /** \ingroup misc
void libusb_exit(libusb_context *ctx); * Capabilities supported by this instance of libusb. Test if the loaded
void libusb_set_debug(libusb_context *ctx, int level); * library supports a given capability by calling
* \ref libusb_has_capability().
*/
enum libusb_capability {
/** The libusb_has_capability() API is available. */
LIBUSB_CAP_HAS_CAPABILITY = 0,
};
ssize_t libusb_get_device_list(libusb_context *ctx, int LIBUSB_CALL libusb_init(libusb_context **ctx);
void LIBUSB_CALL libusb_exit(libusb_context *ctx);
void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
int LIBUSB_CALL libusb_has_capability(uint32_t capability);
const char * LIBUSB_CALL libusb_error_name(int errcode);
ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
libusb_device ***list); libusb_device ***list);
void libusb_free_device_list(libusb_device **list, int unref_devices); void LIBUSB_CALL libusb_free_device_list(libusb_device **list,
libusb_device *libusb_ref_device(libusb_device *dev); int unref_devices);
void libusb_unref_device(libusb_device *dev); libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev);
void LIBUSB_CALL libusb_unref_device(libusb_device *dev);
int libusb_get_configuration(libusb_device_handle *dev, int *config); int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev,
int libusb_get_device_descriptor(libusb_device *dev, int *config);
int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev,
struct libusb_device_descriptor *desc); struct libusb_device_descriptor *desc);
int libusb_get_active_config_descriptor(libusb_device *dev, int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev,
struct libusb_config_descriptor **config);
int libusb_get_config_descriptor(libusb_device *dev, uint8_t config_index,
struct libusb_config_descriptor **config); struct libusb_config_descriptor **config);
int libusb_get_config_descriptor_by_value(libusb_device *dev, int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev,
uint8_t config_index, struct libusb_config_descriptor **config);
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_free_config_descriptor(struct libusb_config_descriptor *config) void LIBUSB_CALL libusb_free_config_descriptor(
; struct libusb_config_descriptor *config);
uint8_t libusb_get_bus_number(libusb_device *dev); uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
uint8_t libusb_get_device_address(libusb_device *dev); uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
int libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint); int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
int libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoi int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
nt); unsigned char endpoint);
int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
unsigned char endpoint);
int libusb_open(libusb_device *dev, libusb_device_handle **handle); int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **hand
void libusb_close(libusb_device_handle *dev_handle); le);
libusb_device *libusb_get_device(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);
int libusb_set_configuration(libusb_device_handle *dev, int configuration); int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev,
int libusb_claim_interface(libusb_device_handle *dev, int iface); int configuration);
int libusb_release_interface(libusb_device_handle *dev, int iface); int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev,
int interface_number);
int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev,
int interface_number);
libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context *ctx, libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
uint16_t vendor_id, uint16_t product_id); libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
int libusb_set_interface_alt_setting(libusb_device_handle *dev, int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev,
int interface_number, int alternate_setting); int interface_number, int alternate_setting);
int libusb_clear_halt(libusb_device_handle *dev, unsigned char endpoint); int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev,
int libusb_reset_device(libusb_device_handle *dev); unsigned char endpoint);
int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev);
int libusb_kernel_driver_active(libusb_device_handle *dev, int interface); int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev,
int libusb_detach_kernel_driver(libusb_device_handle *dev, int interface); int interface_number);
int libusb_attach_kernel_driver(libusb_device_handle *dev, int interface); int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev,
int interface_number);
int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev,
int interface_number);
/* 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 890 skipping to change at line 1084
uint16_t wLength) uint16_t wLength)
{ {
struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer;
setup->bmRequestType = bmRequestType; setup->bmRequestType = bmRequestType;
setup->bRequest = bRequest; setup->bRequest = bRequest;
setup->wValue = libusb_cpu_to_le16(wValue); setup->wValue = libusb_cpu_to_le16(wValue);
setup->wIndex = libusb_cpu_to_le16(wIndex); setup->wIndex = libusb_cpu_to_le16(wIndex);
setup->wLength = libusb_cpu_to_le16(wLength); setup->wLength = libusb_cpu_to_le16(wLength);
} }
struct libusb_transfer *libusb_alloc_transfer(int iso_packets); struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets)
int libusb_submit_transfer(struct libusb_transfer *transfer); ;
int libusb_cancel_transfer(struct libusb_transfer *transfer); int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
void libusb_free_transfer(struct libusb_transfer *transfer); int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
/** \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 control transfer. * for a control transfer.
* *
* If you pass a transfer buffer to this function, the first 8 bytes will * If you pass a transfer buffer to this function, the first 8 bytes will
* be interpreted as a control setup packet, and the wLength field will be * be interpreted as a control setup packet, and the wLength field will be
* used to automatically populate the \ref libusb_transfer::length "length" * used to automatically populate the \ref libusb_transfer::length "length"
* field of the transfer. Therefore the recommended approach is: * field of the transfer. Therefore the recommended approach is:
* -# Allocate a suitably sized data buffer (including space for control se tup) * -# Allocate a suitably sized data buffer (including space for control se tup)
skipping to change at line 1120 skipping to change at line 1314
_packet = packet; _packet = 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 + (transfer->iso_packet_desc[0].length * _pa cket);
} }
/* sync I/O */ /* sync I/O */
int 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 request, uint16_t value, uint16_t inde uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wI
x, ndex,
unsigned char *data, uint16_t length, unsigned int timeout); unsigned char *data, uint16_t wLength, unsigned int timeout);
int 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,
int *actual_length, unsigned int timeout); int *actual_length, unsigned int timeout);
int libusb_interrupt_transfer(libusb_device_handle *dev_handle, int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle,
unsigned char endpoint, unsigned char *data, int length, unsigned char endpoint, unsigned char *data, int length,
int *actual_length, unsigned int timeout); int *actual_length, unsigned int timeout);
/** \ingroup desc /** \ingroup desc
* Retrieve a descriptor from the default control pipe. * Retrieve a descriptor from the default control pipe.
* 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. * message to retrieve the descriptor.
* *
* \param dev a device handle * \param dev a device handle
* \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 , 0, data, LIBUSB_REQUEST_GET_DESCRIPTOR, (desc_type << 8) | desc_index , 0, data,
length, 1000); (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
* \param langid the language ID for the string descriptor * \param langid the language ID for the string descriptor
* \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
* \see libusb_get_string_descriptor_ascii() * \see libusb_get_string_descriptor_ascii()
*/ */
static inline int libusb_get_string_descriptor(libusb_device_handle *dev, static inline int libusb_get_string_descriptor(libusb_device_handle *dev,
uint8_t desc_index, uint16_t langid, unsigned char *data, int length ) uint8_t desc_index, uint16_t langid, unsigned char *data, int length )
{ {
return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN,
LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | des LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t)((LIBUSB_DT_STRING
c_index, << 8) | desc_index),
langid, data, length, 1000); langid, data, (uint16_t) length, 1000);
} }
int libusb_get_string_descriptor_ascii(libusb_device_handle *dev, int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *de
uint8_t index, unsigned char *data, int length); v,
uint8_t desc_index, unsigned char *data, int length);
/* polling and timeouts */ /* polling and timeouts */
int libusb_try_lock_events(libusb_context *ctx); int LIBUSB_CALL libusb_try_lock_events(libusb_context *ctx);
void libusb_lock_events(libusb_context *ctx); void LIBUSB_CALL libusb_lock_events(libusb_context *ctx);
void libusb_unlock_events(libusb_context *ctx); void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx);
int libusb_event_handling_ok(libusb_context *ctx); int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx);
int libusb_event_handler_active(libusb_context *ctx); int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx);
void libusb_lock_event_waiters(libusb_context *ctx); void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx);
void libusb_unlock_event_waiters(libusb_context *ctx); void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx);
int libusb_wait_for_event(libusb_context *ctx, struct timeval *tv); int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *
tv);
int libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv); int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx,
int libusb_handle_events(libusb_context *ctx); struct timeval *tv);
int libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv); int LIBUSB_CALL libusb_handle_events_timeout_completed(libusb_context *ctx,
int libusb_pollfds_handle_timeouts(libusb_context *ctx); struct timeval *tv, int *completed);
int libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv); int LIBUSB_CALL libusb_handle_events(libusb_context *ctx);
int LIBUSB_CALL libusb_handle_events_completed(libusb_context *ctx, int *co
mpleted);
int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx,
struct timeval *tv);
int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);
int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx,
struct timeval *tv);
/** \ingroup poll /** \ingroup poll
* File descriptor for polling * File descriptor for polling
*/ */
struct libusb_pollfd { struct libusb_pollfd {
/** Numeric file descriptor */ /** Numeric file descriptor */
int fd; int fd;
/** Event flags to poll for from <poll.h>. POLLIN indicates that you /** Event flags to poll for from <poll.h>. POLLIN indicates that you
* should monitor this file descriptor for becoming ready to read fr om, * should monitor this file descriptor for becoming ready to read fr om,
skipping to change at line 1218 skipping to change at line 1418
/** \ingroup poll /** \ingroup poll
* Callback function, invoked when a new file descriptor should be added * Callback function, invoked when a new file descriptor should be added
* to the set of file descriptors monitored for events. * to the set of file descriptors monitored for events.
* \param fd the new file descriptor * \param fd the new file descriptor
* \param events events to monitor for, see \ref libusb_pollfd for a * \param events events to monitor for, see \ref libusb_pollfd for a
* description * description
* \param user_data User data pointer specified in * \param user_data User data pointer specified in
* libusb_set_pollfd_notifiers() call * libusb_set_pollfd_notifiers() call
* \see libusb_set_pollfd_notifiers() * \see libusb_set_pollfd_notifiers()
*/ */
typedef void (*libusb_pollfd_added_cb)(int fd, short events, void *user_dat typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
a); void *user_data);
/** \ingroup poll /** \ingroup poll
* Callback function, invoked when a file descriptor should be removed from * Callback function, invoked when a file descriptor should be removed from
* the set of file descriptors being monitored for events. After returning * the set of file descriptors being monitored for events. After returning
* from this callback, do not use that file descriptor again. * from this callback, do not use that file descriptor again.
* \param fd the file descriptor to stop monitoring * \param fd the file descriptor to stop monitoring
* \param user_data User data pointer specified in * \param user_data User data pointer specified in
* libusb_set_pollfd_notifiers() call * libusb_set_pollfd_notifiers() call
* \see libusb_set_pollfd_notifiers() * \see libusb_set_pollfd_notifiers()
*/ */
typedef void (*libusb_pollfd_removed_cb)(int fd, void *user_data); typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_dat a);
const struct libusb_pollfd **libusb_get_pollfds(libusb_context *ctx); const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
void libusb_set_pollfd_notifiers(libusb_context *ctx, 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);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 45 change blocks. 
92 lines changed or deleted 307 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/