Blame libusb/libusb.h

Packit Service b0a153
/*
Packit Service b0a153
 * Public libusb header file
Packit Service b0a153
 * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
Packit Service b0a153
 * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
Packit Service b0a153
 * Copyright © 2012 Pete Batard <pete@akeo.ie>
Packit Service b0a153
 * Copyright © 2012-2018 Nathan Hjelm <hjelmn@cs.unm.edu>
Packit Service b0a153
 * For more information, please visit: http://libusb.info
Packit Service b0a153
 *
Packit Service b0a153
 * This library is free software; you can redistribute it and/or
Packit Service b0a153
 * modify it under the terms of the GNU Lesser General Public
Packit Service b0a153
 * License as published by the Free Software Foundation; either
Packit Service b0a153
 * version 2.1 of the License, or (at your option) any later version.
Packit Service b0a153
 *
Packit Service b0a153
 * This library is distributed in the hope that it will be useful,
Packit Service b0a153
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service b0a153
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service b0a153
 * Lesser General Public License for more details.
Packit Service b0a153
 *
Packit Service b0a153
 * You should have received a copy of the GNU Lesser General Public
Packit Service b0a153
 * License along with this library; if not, write to the Free Software
Packit Service b0a153
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit Service b0a153
 */
Packit Service b0a153
Packit Service b0a153
#ifndef LIBUSB_H
Packit Service b0a153
#define LIBUSB_H
Packit Service b0a153
Packit Service b0a153
#ifdef _MSC_VER
Packit Service b0a153
/* on MS environments, the inline keyword is available in C++ only */
Packit Service b0a153
#if !defined(__cplusplus)
Packit Service b0a153
#define inline __inline
Packit Service b0a153
#endif
Packit Service b0a153
/* ssize_t is also not available (copy/paste from MinGW) */
Packit Service b0a153
#ifndef _SSIZE_T_DEFINED
Packit Service b0a153
#define _SSIZE_T_DEFINED
Packit Service b0a153
#undef ssize_t
Packit Service b0a153
#ifdef _WIN64
Packit Service b0a153
  typedef __int64 ssize_t;
Packit Service b0a153
#else
Packit Service b0a153
  typedef int ssize_t;
Packit Service b0a153
#endif /* _WIN64 */
Packit Service b0a153
#endif /* _SSIZE_T_DEFINED */
Packit Service b0a153
#endif /* _MSC_VER */
Packit Service b0a153
Packit Service b0a153
/* stdint.h is not available on older MSVC */
Packit Service b0a153
#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
Packit Service b0a153
typedef unsigned __int8   uint8_t;
Packit Service b0a153
typedef unsigned __int16  uint16_t;
Packit Service b0a153
typedef unsigned __int32  uint32_t;
Packit Service b0a153
#else
Packit Service b0a153
#include <stdint.h>
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#if !defined(_WIN32_WCE)
Packit Service b0a153
#include <sys/types.h>
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__HAIKU__)
Packit Service b0a153
#include <sys/time.h>
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#include <time.h>
Packit Service b0a153
#include <limits.h>
Packit Service b0a153
Packit Service b0a153
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
Packit Service b0a153
#define ZERO_SIZED_ARRAY		/* [] - valid C99 code */
Packit Service b0a153
#else
Packit Service b0a153
#define ZERO_SIZED_ARRAY	0	/* [0] - non-standard, but usually working code */
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
/* 'interface' might be defined as a macro on Windows, so we need to
Packit Service b0a153
 * undefine it so as not to break the current libusb API, because
Packit Service b0a153
 * libusb_config_descriptor has an 'interface' member
Packit Service b0a153
 * As this can be problematic if you include windows.h after libusb.h
Packit Service b0a153
 * in your sources, we force windows.h to be included first. */
Packit Service b0a153
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
Packit Service b0a153
#include <windows.h>
Packit Service b0a153
#if defined(interface)
Packit Service b0a153
#undef interface
Packit Service b0a153
#endif
Packit Service b0a153
#if !defined(__CYGWIN__)
Packit Service b0a153
#include <winsock.h>
Packit Service b0a153
#endif
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
Packit Service b0a153
#define LIBUSB_DEPRECATED_FOR(f) \
Packit Service b0a153
  __attribute__((deprecated("Use " #f " instead")))
Packit Service b0a153
#elif __GNUC__ >= 3
Packit Service b0a153
#define LIBUSB_DEPRECATED_FOR(f) __attribute__((deprecated))
Packit Service b0a153
#else
Packit Service b0a153
#define LIBUSB_DEPRECATED_FOR(f)
Packit Service b0a153
#endif /* __GNUC__ */
Packit Service b0a153
Packit Service b0a153
/** \def LIBUSB_CALL
Packit Service b0a153
 * \ingroup libusb_misc
Packit Service b0a153
 * libusb's Windows calling convention.
Packit Service b0a153
 *
Packit Service b0a153
 * Under Windows, the selection of available compilers and configurations
Packit Service b0a153
 * means that, unlike other platforms, there is not one true calling
Packit Service b0a153
 * convention (calling convention: the manner in which parameters are
Packit Service b0a153
 * passed to functions in the generated assembly code).
Packit Service b0a153
 *
Packit Service b0a153
 * Matching the Windows API itself, libusb uses the WINAPI convention (which
Packit Service b0a153
 * translates to the <tt>stdcall</tt> convention) and guarantees that the
Packit Service b0a153
 * library is compiled in this way. The public header file also includes
Packit Service b0a153
 * appropriate annotations so that your own software will use the right
Packit Service b0a153
 * convention, even if another convention is being used by default within
Packit Service b0a153
 * your codebase.
Packit Service b0a153
 *
Packit Service b0a153
 * The one consideration that you must apply in your software is to mark
Packit Service b0a153
 * all functions which you use as libusb callbacks with this LIBUSB_CALL
Packit Service b0a153
 * annotation, so that they too get compiled for the correct calling
Packit Service b0a153
 * convention.
Packit Service b0a153
 *
Packit Service b0a153
 * On non-Windows operating systems, this macro is defined as nothing. This
Packit Service b0a153
 * means that you can apply it to your code without worrying about
Packit Service b0a153
 * cross-platform compatibility.
Packit Service b0a153
 */
Packit Service b0a153
/* LIBUSB_CALL must be defined on both definition and declaration of libusb
Packit Service b0a153
 * functions. You'd think that declaration would be enough, but cygwin will
Packit Service b0a153
 * complain about conflicting types unless both are marked this way.
Packit Service b0a153
 * The placement of this macro is important too; it must appear after the
Packit Service b0a153
 * return type, before the function name. See internal documentation for
Packit Service b0a153
 * API_EXPORTED.
Packit Service b0a153
 */
Packit Service b0a153
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
Packit Service b0a153
#define LIBUSB_CALL WINAPI
Packit Service b0a153
#else
Packit Service b0a153
#define LIBUSB_CALL
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
/** \def LIBUSB_API_VERSION
Packit Service b0a153
 * \ingroup libusb_misc
Packit Service b0a153
 * libusb's API version.
Packit Service b0a153
 *
Packit Service b0a153
 * Since version 1.0.13, to help with feature detection, libusb defines
Packit Service b0a153
 * a LIBUSB_API_VERSION macro that gets increased every time there is a
Packit Service b0a153
 * significant change to the API, such as the introduction of a new call,
Packit Service b0a153
 * the definition of a new macro/enum member, or any other element that
Packit Service b0a153
 * libusb applications may want to detect at compilation time.
Packit Service b0a153
 *
Packit Service b0a153
 * The macro is typically used in an application as follows:
Packit Service b0a153
 * \code
Packit Service b0a153
 * #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234)
Packit Service b0a153
 * // Use one of the newer features from the libusb API
Packit Service b0a153
 * #endif
Packit Service b0a153
 * \endcode
Packit Service b0a153
 *
Packit Service b0a153
 * Internally, LIBUSB_API_VERSION is defined as follows:
Packit Service b0a153
 * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
Packit Service b0a153
 */
Packit Service b0a153
#define LIBUSB_API_VERSION 0x01000107
Packit Service b0a153
Packit Service b0a153
/* The following is kept for compatibility, but will be deprecated in the future */
Packit Service b0a153
#define LIBUSBX_API_VERSION LIBUSB_API_VERSION
Packit Service b0a153
Packit Service b0a153
#ifdef __cplusplus
Packit Service b0a153
extern "C" {
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
/**
Packit Service b0a153
 * \ingroup libusb_misc
Packit Service b0a153
 * Convert a 16-bit value from host-endian to little-endian format. On
Packit Service b0a153
 * little endian systems, this function does nothing. On big endian systems,
Packit Service b0a153
 * the bytes are swapped.
Packit Service b0a153
 * \param x the host-endian value to convert
Packit Service b0a153
 * \returns the value in little-endian byte order
Packit Service b0a153
 */
Packit Service b0a153
static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
Packit Service b0a153
{
Packit Service b0a153
	union {
Packit Service b0a153
		uint8_t  b8[2];
Packit Service b0a153
		uint16_t b16;
Packit Service b0a153
	} _tmp;
Packit Service b0a153
	_tmp.b8[1] = (uint8_t) (x >> 8);
Packit Service b0a153
	_tmp.b8[0] = (uint8_t) (x & 0xff);
Packit Service b0a153
	return _tmp.b16;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \def libusb_le16_to_cpu
Packit Service b0a153
 * \ingroup libusb_misc
Packit Service b0a153
 * Convert a 16-bit value from little-endian to host-endian format. On
Packit Service b0a153
 * little endian systems, this function does nothing. On big endian systems,
Packit Service b0a153
 * the bytes are swapped.
Packit Service b0a153
 * \param x the little-endian value to convert
Packit Service b0a153
 * \returns the value in host-endian byte order
Packit Service b0a153
 */
Packit Service b0a153
#define libusb_le16_to_cpu libusb_cpu_to_le16
Packit Service b0a153
Packit Service b0a153
/* standard USB stuff */
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * Device and/or Interface Class codes */
Packit Service b0a153
enum libusb_class_code {
Packit Service b0a153
	/** In the context of a \ref libusb_device_descriptor "device descriptor",
Packit Service b0a153
	 * this bDeviceClass value indicates that each interface specifies its
Packit Service b0a153
	 * own class information and all interfaces operate independently.
Packit Service b0a153
	 */
Packit Service b0a153
	LIBUSB_CLASS_PER_INTERFACE = 0,
Packit Service b0a153
Packit Service b0a153
	/** Audio class */
Packit Service b0a153
	LIBUSB_CLASS_AUDIO = 1,
Packit Service b0a153
Packit Service b0a153
	/** Communications class */
Packit Service b0a153
	LIBUSB_CLASS_COMM = 2,
Packit Service b0a153
Packit Service b0a153
	/** Human Interface Device class */
Packit Service b0a153
	LIBUSB_CLASS_HID = 3,
Packit Service b0a153
Packit Service b0a153
	/** Physical */
Packit Service b0a153
	LIBUSB_CLASS_PHYSICAL = 5,
Packit Service b0a153
Packit Service b0a153
	/** Printer class */
Packit Service b0a153
	LIBUSB_CLASS_PRINTER = 7,
Packit Service b0a153
Packit Service b0a153
	/** Image class */
Packit Service b0a153
	LIBUSB_CLASS_PTP = 6, /* legacy name from libusb-0.1 usb.h */
Packit Service b0a153
	LIBUSB_CLASS_IMAGE = 6,
Packit Service b0a153
Packit Service b0a153
	/** Mass storage class */
Packit Service b0a153
	LIBUSB_CLASS_MASS_STORAGE = 8,
Packit Service b0a153
Packit Service b0a153
	/** Hub class */
Packit Service b0a153
	LIBUSB_CLASS_HUB = 9,
Packit Service b0a153
Packit Service b0a153
	/** Data class */
Packit Service b0a153
	LIBUSB_CLASS_DATA = 10,
Packit Service b0a153
Packit Service b0a153
	/** Smart Card */
Packit Service b0a153
	LIBUSB_CLASS_SMART_CARD = 0x0b,
Packit Service b0a153
Packit Service b0a153
	/** Content Security */
Packit Service b0a153
	LIBUSB_CLASS_CONTENT_SECURITY = 0x0d,
Packit Service b0a153
Packit Service b0a153
	/** Video */
Packit Service b0a153
	LIBUSB_CLASS_VIDEO = 0x0e,
Packit Service b0a153
Packit Service b0a153
	/** Personal Healthcare */
Packit Service b0a153
	LIBUSB_CLASS_PERSONAL_HEALTHCARE = 0x0f,
Packit Service b0a153
Packit Service b0a153
	/** Diagnostic Device */
Packit Service b0a153
	LIBUSB_CLASS_DIAGNOSTIC_DEVICE = 0xdc,
Packit Service b0a153
Packit Service b0a153
	/** Wireless class */
Packit Service b0a153
	LIBUSB_CLASS_WIRELESS = 0xe0,
Packit Service b0a153
Packit Service b0a153
	/** Application class */
Packit Service b0a153
	LIBUSB_CLASS_APPLICATION = 0xfe,
Packit Service b0a153
Packit Service b0a153
	/** Class is vendor-specific */
Packit Service b0a153
	LIBUSB_CLASS_VENDOR_SPEC = 0xff
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * Descriptor types as defined by the USB specification. */
Packit Service b0a153
enum libusb_descriptor_type {
Packit Service b0a153
	/** Device descriptor. See libusb_device_descriptor. */
Packit Service b0a153
	LIBUSB_DT_DEVICE = 0x01,
Packit Service b0a153
Packit Service b0a153
	/** Configuration descriptor. See libusb_config_descriptor. */
Packit Service b0a153
	LIBUSB_DT_CONFIG = 0x02,
Packit Service b0a153
Packit Service b0a153
	/** String descriptor */
Packit Service b0a153
	LIBUSB_DT_STRING = 0x03,
Packit Service b0a153
Packit Service b0a153
	/** Interface descriptor. See libusb_interface_descriptor. */
Packit Service b0a153
	LIBUSB_DT_INTERFACE = 0x04,
Packit Service b0a153
Packit Service b0a153
	/** Endpoint descriptor. See libusb_endpoint_descriptor. */
Packit Service b0a153
	LIBUSB_DT_ENDPOINT = 0x05,
Packit Service b0a153
Packit Service b0a153
	/** BOS descriptor */
Packit Service b0a153
	LIBUSB_DT_BOS = 0x0f,
Packit Service b0a153
Packit Service b0a153
	/** Device Capability descriptor */
Packit Service b0a153
	LIBUSB_DT_DEVICE_CAPABILITY = 0x10,
Packit Service b0a153
Packit Service b0a153
	/** HID descriptor */
Packit Service b0a153
	LIBUSB_DT_HID = 0x21,
Packit Service b0a153
Packit Service b0a153
	/** HID report descriptor */
Packit Service b0a153
	LIBUSB_DT_REPORT = 0x22,
Packit Service b0a153
Packit Service b0a153
	/** Physical descriptor */
Packit Service b0a153
	LIBUSB_DT_PHYSICAL = 0x23,
Packit Service b0a153
Packit Service b0a153
	/** Hub descriptor */
Packit Service b0a153
	LIBUSB_DT_HUB = 0x29,
Packit Service b0a153
Packit Service b0a153
	/** SuperSpeed Hub descriptor */
Packit Service b0a153
	LIBUSB_DT_SUPERSPEED_HUB = 0x2a,
Packit Service b0a153
Packit Service b0a153
	/** SuperSpeed Endpoint Companion descriptor */
Packit Service b0a153
	LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/* Descriptor sizes per descriptor type */
Packit Service b0a153
#define LIBUSB_DT_DEVICE_SIZE			18
Packit Service b0a153
#define LIBUSB_DT_CONFIG_SIZE			9
Packit Service b0a153
#define LIBUSB_DT_INTERFACE_SIZE		9
Packit Service b0a153
#define LIBUSB_DT_ENDPOINT_SIZE			7
Packit Service b0a153
#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE		9	/* Audio extension */
Packit Service b0a153
#define LIBUSB_DT_HUB_NONVAR_SIZE		7
Packit Service b0a153
#define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE	6
Packit Service b0a153
#define LIBUSB_DT_BOS_SIZE			5
Packit Service b0a153
#define LIBUSB_DT_DEVICE_CAPABILITY_SIZE	3
Packit Service b0a153
Packit Service b0a153
/* BOS descriptor sizes */
Packit Service b0a153
#define LIBUSB_BT_USB_2_0_EXTENSION_SIZE	7
Packit Service b0a153
#define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE	10
Packit Service b0a153
#define LIBUSB_BT_CONTAINER_ID_SIZE		20
Packit Service b0a153
Packit Service b0a153
/* We unwrap the BOS => define its max size */
Packit Service b0a153
#define LIBUSB_DT_BOS_MAX_SIZE		((LIBUSB_DT_BOS_SIZE)     +\
Packit Service b0a153
					(LIBUSB_BT_USB_2_0_EXTENSION_SIZE)       +\
Packit Service b0a153
					(LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) +\
Packit Service b0a153
					(LIBUSB_BT_CONTAINER_ID_SIZE))
Packit Service b0a153
Packit Service b0a153
#define LIBUSB_ENDPOINT_ADDRESS_MASK	0x0f    /* in bEndpointAddress */
Packit Service b0a153
#define LIBUSB_ENDPOINT_DIR_MASK		0x80
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * Endpoint direction. Values for bit 7 of the
Packit Service b0a153
 * \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" scheme.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_endpoint_direction {
Packit Service b0a153
	/** In: device-to-host */
Packit Service b0a153
	LIBUSB_ENDPOINT_IN = 0x80,
Packit Service b0a153
Packit Service b0a153
	/** Out: host-to-device */
Packit Service b0a153
	LIBUSB_ENDPOINT_OUT = 0x00
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
#define LIBUSB_TRANSFER_TYPE_MASK			0x03    /* in bmAttributes */
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * Endpoint transfer type. Values for bits 0:1 of the
Packit Service b0a153
 * \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_transfer_type {
Packit Service b0a153
	/** Control endpoint */
Packit Service b0a153
	LIBUSB_TRANSFER_TYPE_CONTROL = 0,
Packit Service b0a153
Packit Service b0a153
	/** Isochronous endpoint */
Packit Service b0a153
	LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
Packit Service b0a153
Packit Service b0a153
	/** Bulk endpoint */
Packit Service b0a153
	LIBUSB_TRANSFER_TYPE_BULK = 2,
Packit Service b0a153
Packit Service b0a153
	/** Interrupt endpoint */
Packit Service b0a153
	LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
Packit Service b0a153
Packit Service b0a153
	/** Stream endpoint */
Packit Service b0a153
	LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_misc
Packit Service b0a153
 * Standard requests, as defined in table 9-5 of the USB 3.0 specifications */
Packit Service b0a153
enum libusb_standard_request {
Packit Service b0a153
	/** Request status of the specific recipient */
Packit Service b0a153
	LIBUSB_REQUEST_GET_STATUS = 0x00,
Packit Service b0a153
Packit Service b0a153
	/** Clear or disable a specific feature */
Packit Service b0a153
	LIBUSB_REQUEST_CLEAR_FEATURE = 0x01,
Packit Service b0a153
Packit Service b0a153
	/* 0x02 is reserved */
Packit Service b0a153
Packit Service b0a153
	/** Set or enable a specific feature */
Packit Service b0a153
	LIBUSB_REQUEST_SET_FEATURE = 0x03,
Packit Service b0a153
Packit Service b0a153
	/* 0x04 is reserved */
Packit Service b0a153
Packit Service b0a153
	/** Set device address for all future accesses */
Packit Service b0a153
	LIBUSB_REQUEST_SET_ADDRESS = 0x05,
Packit Service b0a153
Packit Service b0a153
	/** Get the specified descriptor */
Packit Service b0a153
	LIBUSB_REQUEST_GET_DESCRIPTOR = 0x06,
Packit Service b0a153
Packit Service b0a153
	/** Used to update existing descriptors or add new descriptors */
Packit Service b0a153
	LIBUSB_REQUEST_SET_DESCRIPTOR = 0x07,
Packit Service b0a153
Packit Service b0a153
	/** Get the current device configuration value */
Packit Service b0a153
	LIBUSB_REQUEST_GET_CONFIGURATION = 0x08,
Packit Service b0a153
Packit Service b0a153
	/** Set device configuration */
Packit Service b0a153
	LIBUSB_REQUEST_SET_CONFIGURATION = 0x09,
Packit Service b0a153
Packit Service b0a153
	/** Return the selected alternate setting for the specified interface */
Packit Service b0a153
	LIBUSB_REQUEST_GET_INTERFACE = 0x0A,
Packit Service b0a153
Packit Service b0a153
	/** Select an alternate interface for the specified interface */
Packit Service b0a153
	LIBUSB_REQUEST_SET_INTERFACE = 0x0B,
Packit Service b0a153
Packit Service b0a153
	/** Set then report an endpoint's synchronization frame */
Packit Service b0a153
	LIBUSB_REQUEST_SYNCH_FRAME = 0x0C,
Packit Service b0a153
Packit Service b0a153
	/** Sets both the U1 and U2 Exit Latency */
Packit Service b0a153
	LIBUSB_REQUEST_SET_SEL = 0x30,
Packit Service b0a153
Packit Service b0a153
	/** Delay from the time a host transmits a packet to the time it is
Packit Service b0a153
	  * received by the device. */
Packit Service b0a153
	LIBUSB_SET_ISOCH_DELAY = 0x31,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_misc
Packit Service b0a153
 * Request type bits of the
Packit Service b0a153
 * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
Packit Service b0a153
 * transfers. */
Packit Service b0a153
enum libusb_request_type {
Packit Service b0a153
	/** Standard */
Packit Service b0a153
	LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5),
Packit Service b0a153
Packit Service b0a153
	/** Class */
Packit Service b0a153
	LIBUSB_REQUEST_TYPE_CLASS = (0x01 << 5),
Packit Service b0a153
Packit Service b0a153
	/** Vendor */
Packit Service b0a153
	LIBUSB_REQUEST_TYPE_VENDOR = (0x02 << 5),
Packit Service b0a153
Packit Service b0a153
	/** Reserved */
Packit Service b0a153
	LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5)
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_misc
Packit Service b0a153
 * Recipient bits of the
Packit Service b0a153
 * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
Packit Service b0a153
 * transfers. Values 4 through 31 are reserved. */
Packit Service b0a153
enum libusb_request_recipient {
Packit Service b0a153
	/** Device */
Packit Service b0a153
	LIBUSB_RECIPIENT_DEVICE = 0x00,
Packit Service b0a153
Packit Service b0a153
	/** Interface */
Packit Service b0a153
	LIBUSB_RECIPIENT_INTERFACE = 0x01,
Packit Service b0a153
Packit Service b0a153
	/** Endpoint */
Packit Service b0a153
	LIBUSB_RECIPIENT_ENDPOINT = 0x02,
Packit Service b0a153
Packit Service b0a153
	/** Other */
Packit Service b0a153
	LIBUSB_RECIPIENT_OTHER = 0x03,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
#define LIBUSB_ISO_SYNC_TYPE_MASK		0x0C
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * Synchronization type for isochronous endpoints. Values for bits 2:3 of the
Packit Service b0a153
 * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
Packit Service b0a153
 * libusb_endpoint_descriptor.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_iso_sync_type {
Packit Service b0a153
	/** No synchronization */
Packit Service b0a153
	LIBUSB_ISO_SYNC_TYPE_NONE = 0,
Packit Service b0a153
Packit Service b0a153
	/** Asynchronous */
Packit Service b0a153
	LIBUSB_ISO_SYNC_TYPE_ASYNC = 1,
Packit Service b0a153
Packit Service b0a153
	/** Adaptive */
Packit Service b0a153
	LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2,
Packit Service b0a153
Packit Service b0a153
	/** Synchronous */
Packit Service b0a153
	LIBUSB_ISO_SYNC_TYPE_SYNC = 3
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
#define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * Usage type for isochronous endpoints. Values for bits 4:5 of the
Packit Service b0a153
 * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
Packit Service b0a153
 * libusb_endpoint_descriptor.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_iso_usage_type {
Packit Service b0a153
	/** Data endpoint */
Packit Service b0a153
	LIBUSB_ISO_USAGE_TYPE_DATA = 0,
Packit Service b0a153
Packit Service b0a153
	/** Feedback endpoint */
Packit Service b0a153
	LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1,
Packit Service b0a153
Packit Service b0a153
	/** Implicit feedback Data endpoint */
Packit Service b0a153
	LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the standard USB device descriptor. This
Packit Service b0a153
 * descriptor is documented in section 9.6.1 of the USB 3.0 specification.
Packit Service b0a153
 * All multiple-byte fields are represented in host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_device_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE LIBUSB_DT_DEVICE in this
Packit Service b0a153
	 * context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
	/** USB specification release number in binary-coded decimal. A value of
Packit Service b0a153
	 * 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc. */
Packit Service b0a153
	uint16_t bcdUSB;
Packit Service b0a153
Packit Service b0a153
	/** USB-IF class code for the device. See \ref libusb_class_code. */
Packit Service b0a153
	uint8_t  bDeviceClass;
Packit Service b0a153
Packit Service b0a153
	/** USB-IF subclass code for the device, qualified by the bDeviceClass
Packit Service b0a153
	 * value */
Packit Service b0a153
	uint8_t  bDeviceSubClass;
Packit Service b0a153
Packit Service b0a153
	/** USB-IF protocol code for the device, qualified by the bDeviceClass and
Packit Service b0a153
	 * bDeviceSubClass values */
Packit Service b0a153
	uint8_t  bDeviceProtocol;
Packit Service b0a153
Packit Service b0a153
	/** Maximum packet size for endpoint 0 */
Packit Service b0a153
	uint8_t  bMaxPacketSize0;
Packit Service b0a153
Packit Service b0a153
	/** USB-IF vendor ID */
Packit Service b0a153
	uint16_t idVendor;
Packit Service b0a153
Packit Service b0a153
	/** USB-IF product ID */
Packit Service b0a153
	uint16_t idProduct;
Packit Service b0a153
Packit Service b0a153
	/** Device release number in binary-coded decimal */
Packit Service b0a153
	uint16_t bcdDevice;
Packit Service b0a153
Packit Service b0a153
	/** Index of string descriptor describing manufacturer */
Packit Service b0a153
	uint8_t  iManufacturer;
Packit Service b0a153
Packit Service b0a153
	/** Index of string descriptor describing product */
Packit Service b0a153
	uint8_t  iProduct;
Packit Service b0a153
Packit Service b0a153
	/** Index of string descriptor containing device serial number */
Packit Service b0a153
	uint8_t  iSerialNumber;
Packit Service b0a153
Packit Service b0a153
	/** Number of possible configurations */
Packit Service b0a153
	uint8_t  bNumConfigurations;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the standard USB endpoint descriptor. This
Packit Service b0a153
 * descriptor is documented in section 9.6.6 of the USB 3.0 specification.
Packit Service b0a153
 * All multiple-byte fields are represented in host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_endpoint_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_ENDPOINT LIBUSB_DT_ENDPOINT in
Packit Service b0a153
	 * this context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
	/** The address of the endpoint described by this descriptor. Bits 0:3 are
Packit Service b0a153
	 * the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction,
Packit Service b0a153
	 * see \ref libusb_endpoint_direction.
Packit Service b0a153
	 */
Packit Service b0a153
	uint8_t  bEndpointAddress;
Packit Service b0a153
Packit Service b0a153
	/** Attributes which apply to the endpoint when it is configured using
Packit Service b0a153
	 * the bConfigurationValue. Bits 0:1 determine the transfer type and
Packit Service b0a153
	 * correspond to \ref libusb_transfer_type. Bits 2:3 are only used for
Packit Service b0a153
	 * isochronous endpoints and correspond to \ref libusb_iso_sync_type.
Packit Service b0a153
	 * Bits 4:5 are also only used for isochronous endpoints and correspond to
Packit Service b0a153
	 * \ref libusb_iso_usage_type. Bits 6:7 are reserved.
Packit Service b0a153
	 */
Packit Service b0a153
	uint8_t  bmAttributes;
Packit Service b0a153
Packit Service b0a153
	/** Maximum packet size this endpoint is capable of sending/receiving. */
Packit Service b0a153
	uint16_t wMaxPacketSize;
Packit Service b0a153
Packit Service b0a153
	/** Interval for polling endpoint for data transfers. */
Packit Service b0a153
	uint8_t  bInterval;
Packit Service b0a153
Packit Service b0a153
	/** For audio devices only: the rate at which synchronization feedback
Packit Service b0a153
	 * is provided. */
Packit Service b0a153
	uint8_t  bRefresh;
Packit Service b0a153
Packit Service b0a153
	/** For audio devices only: the address if the synch endpoint */
Packit Service b0a153
	uint8_t  bSynchAddress;
Packit Service b0a153
Packit Service b0a153
	/** Extra descriptors. If libusb encounters unknown endpoint descriptors,
Packit Service b0a153
	 * it will store them here, should you wish to parse them. */
Packit Service b0a153
	const unsigned char *extra;
Packit Service b0a153
Packit Service b0a153
	/** Length of the extra descriptors, in bytes. Must be non-negative. */
Packit Service b0a153
	int extra_length;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the standard USB interface descriptor. This
Packit Service b0a153
 * descriptor is documented in section 9.6.5 of the USB 3.0 specification.
Packit Service b0a153
 * All multiple-byte fields are represented in host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_interface_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE LIBUSB_DT_INTERFACE
Packit Service b0a153
	 * in this context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
	/** Number of this interface */
Packit Service b0a153
	uint8_t  bInterfaceNumber;
Packit Service b0a153
Packit Service b0a153
	/** Value used to select this alternate setting for this interface */
Packit Service b0a153
	uint8_t  bAlternateSetting;
Packit Service b0a153
Packit Service b0a153
	/** Number of endpoints used by this interface (excluding the control
Packit Service b0a153
	 * endpoint). */
Packit Service b0a153
	uint8_t  bNumEndpoints;
Packit Service b0a153
Packit Service b0a153
	/** USB-IF class code for this interface. See \ref libusb_class_code. */
Packit Service b0a153
	uint8_t  bInterfaceClass;
Packit Service b0a153
Packit Service b0a153
	/** USB-IF subclass code for this interface, qualified by the
Packit Service b0a153
	 * bInterfaceClass value */
Packit Service b0a153
	uint8_t  bInterfaceSubClass;
Packit Service b0a153
Packit Service b0a153
	/** USB-IF protocol code for this interface, qualified by the
Packit Service b0a153
	 * bInterfaceClass and bInterfaceSubClass values */
Packit Service b0a153
	uint8_t  bInterfaceProtocol;
Packit Service b0a153
Packit Service b0a153
	/** Index of string descriptor describing this interface */
Packit Service b0a153
	uint8_t  iInterface;
Packit Service b0a153
Packit Service b0a153
	/** Array of endpoint descriptors. This length of this array is determined
Packit Service b0a153
	 * by the bNumEndpoints field. */
Packit Service b0a153
	const struct libusb_endpoint_descriptor *endpoint;
Packit Service b0a153
Packit Service b0a153
	/** Extra descriptors. If libusb encounters unknown interface descriptors,
Packit Service b0a153
	 * it will store them here, should you wish to parse them. */
Packit Service b0a153
	const unsigned char *extra;
Packit Service b0a153
Packit Service b0a153
	/** Length of the extra descriptors, in bytes. Must be non-negative. */
Packit Service b0a153
	int extra_length;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A collection of alternate settings for a particular USB interface.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_interface {
Packit Service b0a153
	/** Array of interface descriptors. The length of this array is determined
Packit Service b0a153
	 * by the num_altsetting field. */
Packit Service b0a153
	const struct libusb_interface_descriptor *altsetting;
Packit Service b0a153
Packit Service b0a153
	/** The number of alternate settings that belong to this interface.
Packit Service b0a153
	 * Must be non-negative. */
Packit Service b0a153
	int num_altsetting;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the standard USB configuration descriptor. This
Packit Service b0a153
 * descriptor is documented in section 9.6.3 of the USB 3.0 specification.
Packit Service b0a153
 * All multiple-byte fields are represented in host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_config_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG
Packit Service b0a153
	 * in this context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
	/** Total length of data returned for this configuration */
Packit Service b0a153
	uint16_t wTotalLength;
Packit Service b0a153
Packit Service b0a153
	/** Number of interfaces supported by this configuration */
Packit Service b0a153
	uint8_t  bNumInterfaces;
Packit Service b0a153
Packit Service b0a153
	/** Identifier value for this configuration */
Packit Service b0a153
	uint8_t  bConfigurationValue;
Packit Service b0a153
Packit Service b0a153
	/** Index of string descriptor describing this configuration */
Packit Service b0a153
	uint8_t  iConfiguration;
Packit Service b0a153
Packit Service b0a153
	/** Configuration characteristics */
Packit Service b0a153
	uint8_t  bmAttributes;
Packit Service b0a153
Packit Service b0a153
	/** Maximum power consumption of the USB device from this bus in this
Packit Service b0a153
	 * configuration when the device is fully operation. Expressed in units
Packit Service b0a153
	 * of 2 mA when the device is operating in high-speed mode and in units
Packit Service b0a153
	 * of 8 mA when the device is operating in super-speed mode. */
Packit Service b0a153
	uint8_t  MaxPower;
Packit Service b0a153
Packit Service b0a153
	/** Array of interfaces supported by this configuration. The length of
Packit Service b0a153
	 * this array is determined by the bNumInterfaces field. */
Packit Service b0a153
	const struct libusb_interface *interface;
Packit Service b0a153
Packit Service b0a153
	/** Extra descriptors. If libusb encounters unknown configuration
Packit Service b0a153
	 * descriptors, it will store them here, should you wish to parse them. */
Packit Service b0a153
	const unsigned char *extra;
Packit Service b0a153
Packit Service b0a153
	/** Length of the extra descriptors, in bytes. Must be non-negative. */
Packit Service b0a153
	int extra_length;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the superspeed endpoint companion
Packit Service b0a153
 * descriptor. This descriptor is documented in section 9.6.7 of
Packit Service b0a153
 * the USB 3.0 specification. All multiple-byte fields are represented in
Packit Service b0a153
 * host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_ss_endpoint_companion_descriptor {
Packit Service b0a153
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_SS_ENDPOINT_COMPANION in
Packit Service b0a153
	 * this context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
Packit Service b0a153
	/** The maximum number of packets the endpoint can send or
Packit Service b0a153
	 *  receive as part of a burst. */
Packit Service b0a153
	uint8_t  bMaxBurst;
Packit Service b0a153
Packit Service b0a153
	/** In bulk EP:	bits 4:0 represents the	maximum	number of
Packit Service b0a153
	 *  streams the	EP supports. In	isochronous EP:	bits 1:0
Packit Service b0a153
	 *  represents the Mult	- a zero based value that determines
Packit Service b0a153
	 *  the	maximum	number of packets within a service interval  */
Packit Service b0a153
	uint8_t  bmAttributes;
Packit Service b0a153
Packit Service b0a153
	/** The	total number of bytes this EP will transfer every
Packit Service b0a153
	 *  service interval. valid only for periodic EPs. */
Packit Service b0a153
	uint16_t wBytesPerInterval;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A generic representation of a BOS Device Capability descriptor. It is
Packit Service b0a153
 * advised to check bDevCapabilityType and call the matching
Packit Service b0a153
 * libusb_get_*_descriptor function to get a structure fully matching the type.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_bos_dev_capability_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t bLength;
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
Packit Service b0a153
	 * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
Packit Service b0a153
	uint8_t bDescriptorType;
Packit Service b0a153
	/** Device Capability type */
Packit Service b0a153
	uint8_t bDevCapabilityType;
Packit Service b0a153
	/** Device Capability data (bLength - 3 bytes) */
Packit Service b0a153
	uint8_t dev_capability_data[ZERO_SIZED_ARRAY];
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the Binary Device Object Store (BOS) descriptor.
Packit Service b0a153
 * This descriptor is documented in section 9.6.2 of the USB 3.0 specification.
Packit Service b0a153
 * All multiple-byte fields are represented in host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_bos_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_BOS LIBUSB_DT_BOS
Packit Service b0a153
	 * in this context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
	/** Length of this descriptor and all of its sub descriptors */
Packit Service b0a153
	uint16_t wTotalLength;
Packit Service b0a153
Packit Service b0a153
	/** The number of separate device capability descriptors in
Packit Service b0a153
	 * the BOS */
Packit Service b0a153
	uint8_t  bNumDeviceCaps;
Packit Service b0a153
Packit Service b0a153
	/** bNumDeviceCap Device Capability Descriptors */
Packit Service b0a153
	struct libusb_bos_dev_capability_descriptor *dev_capability[ZERO_SIZED_ARRAY];
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the USB 2.0 Extension descriptor
Packit Service b0a153
 * This descriptor is documented in section 9.6.2.1 of the USB 3.0 specification.
Packit Service b0a153
 * All multiple-byte fields are represented in host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_usb_2_0_extension_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
Packit Service b0a153
	 * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
	/** Capability type. Will have value
Packit Service b0a153
	 * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION
Packit Service b0a153
	 * LIBUSB_BT_USB_2_0_EXTENSION in this context. */
Packit Service b0a153
	uint8_t  bDevCapabilityType;
Packit Service b0a153
Packit Service b0a153
	/** Bitmap encoding of supported device level features.
Packit Service b0a153
	 * A value of one in a bit location indicates a feature is
Packit Service b0a153
	 * supported; a value of zero indicates it is not supported.
Packit Service b0a153
	 * See \ref libusb_usb_2_0_extension_attributes. */
Packit Service b0a153
	uint32_t  bmAttributes;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the SuperSpeed USB Device Capability descriptor
Packit Service b0a153
 * This descriptor is documented in section 9.6.2.2 of the USB 3.0 specification.
Packit Service b0a153
 * All multiple-byte fields are represented in host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_ss_usb_device_capability_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
Packit Service b0a153
	 * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
	/** Capability type. Will have value
Packit Service b0a153
	 * \ref libusb_capability_type::LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
Packit Service b0a153
	 * LIBUSB_BT_SS_USB_DEVICE_CAPABILITY in this context. */
Packit Service b0a153
	uint8_t  bDevCapabilityType;
Packit Service b0a153
Packit Service b0a153
	/** Bitmap encoding of supported device level features.
Packit Service b0a153
	 * A value of one in a bit location indicates a feature is
Packit Service b0a153
	 * supported; a value of zero indicates it is not supported.
Packit Service b0a153
	 * See \ref libusb_ss_usb_device_capability_attributes. */
Packit Service b0a153
	uint8_t  bmAttributes;
Packit Service b0a153
Packit Service b0a153
	/** Bitmap encoding of the speed supported by this device when
Packit Service b0a153
	 * operating in SuperSpeed mode. See \ref libusb_supported_speed. */
Packit Service b0a153
	uint16_t wSpeedSupported;
Packit Service b0a153
Packit Service b0a153
	/** The lowest speed at which all the functionality supported
Packit Service b0a153
	 * by the device is available to the user. For example if the
Packit Service b0a153
	 * device supports all its functionality when connected at
Packit Service b0a153
	 * full speed and above then it sets this value to 1. */
Packit Service b0a153
	uint8_t  bFunctionalitySupport;
Packit Service b0a153
Packit Service b0a153
	/** U1 Device Exit Latency. */
Packit Service b0a153
	uint8_t  bU1DevExitLat;
Packit Service b0a153
Packit Service b0a153
	/** U2 Device Exit Latency. */
Packit Service b0a153
	uint16_t bU2DevExitLat;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * A structure representing the Container ID descriptor.
Packit Service b0a153
 * This descriptor is documented in section 9.6.2.3 of the USB 3.0 specification.
Packit Service b0a153
 * All multiple-byte fields, except UUIDs, are represented in host-endian format.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_container_id_descriptor {
Packit Service b0a153
	/** Size of this descriptor (in bytes) */
Packit Service b0a153
	uint8_t  bLength;
Packit Service b0a153
Packit Service b0a153
	/** Descriptor type. Will have value
Packit Service b0a153
	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
Packit Service b0a153
	 * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
Packit Service b0a153
	uint8_t  bDescriptorType;
Packit Service b0a153
Packit Service b0a153
	/** Capability type. Will have value
Packit Service b0a153
	 * \ref libusb_capability_type::LIBUSB_BT_CONTAINER_ID
Packit Service b0a153
	 * LIBUSB_BT_CONTAINER_ID in this context. */
Packit Service b0a153
	uint8_t  bDevCapabilityType;
Packit Service b0a153
Packit Service b0a153
	/** Reserved field */
Packit Service b0a153
	uint8_t bReserved;
Packit Service b0a153
Packit Service b0a153
	/** 128 bit UUID */
Packit Service b0a153
	uint8_t  ContainerID[16];
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Setup packet for control transfers. */
Packit Service b0a153
struct libusb_control_setup {
Packit Service b0a153
	/** Request type. Bits 0:4 determine recipient, see
Packit Service b0a153
	 * \ref libusb_request_recipient. Bits 5:6 determine type, see
Packit Service b0a153
	 * \ref libusb_request_type. Bit 7 determines data transfer direction, see
Packit Service b0a153
	 * \ref libusb_endpoint_direction.
Packit Service b0a153
	 */
Packit Service b0a153
	uint8_t  bmRequestType;
Packit Service b0a153
Packit Service b0a153
	/** Request. If the type bits of bmRequestType are equal to
Packit Service b0a153
	 * \ref libusb_request_type::LIBUSB_REQUEST_TYPE_STANDARD
Packit Service b0a153
	 * "LIBUSB_REQUEST_TYPE_STANDARD" then this field refers to
Packit Service b0a153
	 * \ref libusb_standard_request. For other cases, use of this field is
Packit Service b0a153
	 * application-specific. */
Packit Service b0a153
	uint8_t  bRequest;
Packit Service b0a153
Packit Service b0a153
	/** Value. Varies according to request */
Packit Service b0a153
	uint16_t wValue;
Packit Service b0a153
Packit Service b0a153
	/** Index. Varies according to request, typically used to pass an index
Packit Service b0a153
	 * or offset */
Packit Service b0a153
	uint16_t wIndex;
Packit Service b0a153
Packit Service b0a153
	/** Number of bytes to transfer */
Packit Service b0a153
	uint16_t wLength;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
#define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
Packit Service b0a153
Packit Service b0a153
/* libusb */
Packit Service b0a153
Packit Service b0a153
struct libusb_context;
Packit Service b0a153
struct libusb_device;
Packit Service b0a153
struct libusb_device_handle;
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_lib
Packit Service b0a153
 * Structure providing the version of the libusb runtime
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_version {
Packit Service b0a153
	/** Library major version. */
Packit Service b0a153
	const uint16_t major;
Packit Service b0a153
Packit Service b0a153
	/** Library minor version. */
Packit Service b0a153
	const uint16_t minor;
Packit Service b0a153
Packit Service b0a153
	/** Library micro version. */
Packit Service b0a153
	const uint16_t micro;
Packit Service b0a153
Packit Service b0a153
	/** Library nano version. */
Packit Service b0a153
	const uint16_t nano;
Packit Service b0a153
Packit Service b0a153
	/** Library release candidate suffix string, e.g. "-rc4". */
Packit Service b0a153
	const char *rc;
Packit Service b0a153
Packit Service b0a153
	/** For ABI compatibility only. */
Packit Service b0a153
	const char* describe;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_lib
Packit Service b0a153
 * Structure representing a libusb session. The concept of individual libusb
Packit Service b0a153
 * sessions allows for your program to use two libraries (or dynamically
Packit Service b0a153
 * load two modules) which both independently use libusb. This will prevent
Packit Service b0a153
 * interference between the individual libusb users - for example
Packit Service b0a153
 * libusb_set_option() will not affect the other user of the library, and
Packit Service b0a153
 * libusb_exit() will not destroy resources that the other user is still
Packit Service b0a153
 * using.
Packit Service b0a153
 *
Packit Service b0a153
 * Sessions are created by libusb_init() and destroyed through libusb_exit().
Packit Service b0a153
 * If your application is guaranteed to only ever include a single libusb
Packit Service b0a153
 * user (i.e. you), you do not have to worry about contexts: pass NULL in
Packit Service b0a153
 * every function call where a context is required. The default context
Packit Service b0a153
 * will be used.
Packit Service b0a153
 *
Packit Service b0a153
 * For more information, see \ref libusb_contexts.
Packit Service b0a153
 */
Packit Service b0a153
typedef struct libusb_context libusb_context;
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_dev
Packit Service b0a153
 * Structure representing a USB device detected on the system. This is an
Packit Service b0a153
 * opaque type for which you are only ever provided with a pointer, usually
Packit Service b0a153
 * originating from libusb_get_device_list().
Packit Service b0a153
 *
Packit Service b0a153
 * Certain operations can be performed on a device, but in order to do any
Packit Service b0a153
 * I/O you will have to first obtain a device handle using libusb_open().
Packit Service b0a153
 *
Packit Service b0a153
 * Devices are reference counted with libusb_ref_device() and
Packit Service b0a153
 * libusb_unref_device(), and are freed when the reference count reaches 0.
Packit Service b0a153
 * New devices presented by libusb_get_device_list() have a reference count of
Packit Service b0a153
 * 1, and libusb_free_device_list() can optionally decrease the reference count
Packit Service b0a153
 * on all devices in the list. libusb_open() adds another reference which is
Packit Service b0a153
 * later destroyed by libusb_close().
Packit Service b0a153
 */
Packit Service b0a153
typedef struct libusb_device libusb_device;
Packit Service b0a153
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_dev
Packit Service b0a153
 * Structure representing a handle on a USB device. This is an opaque type for
Packit Service b0a153
 * which you are only ever provided with a pointer, usually originating from
Packit Service b0a153
 * libusb_open().
Packit Service b0a153
 *
Packit Service b0a153
 * A device handle is used to perform I/O and other operations. When finished
Packit Service b0a153
 * with a device handle, you should call libusb_close().
Packit Service b0a153
 */
Packit Service b0a153
typedef struct libusb_device_handle libusb_device_handle;
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_dev
Packit Service b0a153
 * Speed codes. Indicates the speed at which the device is operating.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_speed {
Packit Service b0a153
	/** The OS doesn't report or know the device speed. */
Packit Service b0a153
	LIBUSB_SPEED_UNKNOWN = 0,
Packit Service b0a153
Packit Service b0a153
	/** The device is operating at low speed (1.5MBit/s). */
Packit Service b0a153
	LIBUSB_SPEED_LOW = 1,
Packit Service b0a153
Packit Service b0a153
	/** The device is operating at full speed (12MBit/s). */
Packit Service b0a153
	LIBUSB_SPEED_FULL = 2,
Packit Service b0a153
Packit Service b0a153
	/** The device is operating at high speed (480MBit/s). */
Packit Service b0a153
	LIBUSB_SPEED_HIGH = 3,
Packit Service b0a153
Packit Service b0a153
	/** The device is operating at super speed (5000MBit/s). */
Packit Service b0a153
	LIBUSB_SPEED_SUPER = 4,
Packit Service b0a153
Packit Service b0a153
	/** The device is operating at super speed plus (10000MBit/s). */
Packit Service b0a153
	LIBUSB_SPEED_SUPER_PLUS = 5,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_dev
Packit Service b0a153
 * Supported speeds (wSpeedSupported) bitfield. Indicates what
Packit Service b0a153
 * speeds the device supports.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_supported_speed {
Packit Service b0a153
	/** Low speed operation supported (1.5MBit/s). */
Packit Service b0a153
	LIBUSB_LOW_SPEED_OPERATION   = 1,
Packit Service b0a153
Packit Service b0a153
	/** Full speed operation supported (12MBit/s). */
Packit Service b0a153
	LIBUSB_FULL_SPEED_OPERATION  = 2,
Packit Service b0a153
Packit Service b0a153
	/** High speed operation supported (480MBit/s). */
Packit Service b0a153
	LIBUSB_HIGH_SPEED_OPERATION  = 4,
Packit Service b0a153
Packit Service b0a153
	/** Superspeed operation supported (5000MBit/s). */
Packit Service b0a153
	LIBUSB_SUPER_SPEED_OPERATION = 8,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_dev
Packit Service b0a153
 * Masks for the bits of the
Packit Service b0a153
 * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field
Packit Service b0a153
 * of the USB 2.0 Extension descriptor.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_usb_2_0_extension_attributes {
Packit Service b0a153
	/** Supports Link Power Management (LPM) */
Packit Service b0a153
	LIBUSB_BM_LPM_SUPPORT = 2,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_dev
Packit Service b0a153
 * Masks for the bits of the
Packit Service b0a153
 * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field
Packit Service b0a153
 * field of the SuperSpeed USB Device Capability descriptor.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_ss_usb_device_capability_attributes {
Packit Service b0a153
	/** Supports Latency Tolerance Messages (LTM) */
Packit Service b0a153
	LIBUSB_BM_LTM_SUPPORT = 2,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_dev
Packit Service b0a153
 * USB capability types
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_bos_type {
Packit Service b0a153
	/** Wireless USB device capability */
Packit Service b0a153
	LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY	= 1,
Packit Service b0a153
Packit Service b0a153
	/** USB 2.0 extensions */
Packit Service b0a153
	LIBUSB_BT_USB_2_0_EXTENSION			= 2,
Packit Service b0a153
Packit Service b0a153
	/** SuperSpeed USB device capability */
Packit Service b0a153
	LIBUSB_BT_SS_USB_DEVICE_CAPABILITY		= 3,
Packit Service b0a153
Packit Service b0a153
	/** Container ID type */
Packit Service b0a153
	LIBUSB_BT_CONTAINER_ID				= 4,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_misc
Packit Service b0a153
 * Error codes. Most libusb functions return 0 on success or one of these
Packit Service b0a153
 * codes on failure.
Packit Service b0a153
 * You can call libusb_error_name() to retrieve a string representation of an
Packit Service b0a153
 * error code or libusb_strerror() to get an end-user suitable description of
Packit Service b0a153
 * an error code.
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_error {
Packit Service b0a153
	/** Success (no error) */
Packit Service b0a153
	LIBUSB_SUCCESS = 0,
Packit Service b0a153
Packit Service b0a153
	/** Input/output error */
Packit Service b0a153
	LIBUSB_ERROR_IO = -1,
Packit Service b0a153
Packit Service b0a153
	/** Invalid parameter */
Packit Service b0a153
	LIBUSB_ERROR_INVALID_PARAM = -2,
Packit Service b0a153
Packit Service b0a153
	/** Access denied (insufficient permissions) */
Packit Service b0a153
	LIBUSB_ERROR_ACCESS = -3,
Packit Service b0a153
Packit Service b0a153
	/** No such device (it may have been disconnected) */
Packit Service b0a153
	LIBUSB_ERROR_NO_DEVICE = -4,
Packit Service b0a153
Packit Service b0a153
	/** Entity not found */
Packit Service b0a153
	LIBUSB_ERROR_NOT_FOUND = -5,
Packit Service b0a153
Packit Service b0a153
	/** Resource busy */
Packit Service b0a153
	LIBUSB_ERROR_BUSY = -6,
Packit Service b0a153
Packit Service b0a153
	/** Operation timed out */
Packit Service b0a153
	LIBUSB_ERROR_TIMEOUT = -7,
Packit Service b0a153
Packit Service b0a153
	/** Overflow */
Packit Service b0a153
	LIBUSB_ERROR_OVERFLOW = -8,
Packit Service b0a153
Packit Service b0a153
	/** Pipe error */
Packit Service b0a153
	LIBUSB_ERROR_PIPE = -9,
Packit Service b0a153
Packit Service b0a153
	/** System call interrupted (perhaps due to signal) */
Packit Service b0a153
	LIBUSB_ERROR_INTERRUPTED = -10,
Packit Service b0a153
Packit Service b0a153
	/** Insufficient memory */
Packit Service b0a153
	LIBUSB_ERROR_NO_MEM = -11,
Packit Service b0a153
Packit Service b0a153
	/** Operation not supported or unimplemented on this platform */
Packit Service b0a153
	LIBUSB_ERROR_NOT_SUPPORTED = -12,
Packit Service b0a153
Packit Service b0a153
	/* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
Packit Service b0a153
	   message strings in strerror.c when adding new error codes here. */
Packit Service b0a153
Packit Service b0a153
	/** Other error */
Packit Service b0a153
	LIBUSB_ERROR_OTHER = -99,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/* Total number of error codes in enum libusb_error */
Packit Service b0a153
#define LIBUSB_ERROR_COUNT 14
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Transfer status codes */
Packit Service b0a153
enum libusb_transfer_status {
Packit Service b0a153
	/** Transfer completed without error. Note that this does not indicate
Packit Service b0a153
	 * that the entire amount of requested data was transferred. */
Packit Service b0a153
	LIBUSB_TRANSFER_COMPLETED,
Packit Service b0a153
Packit Service b0a153
	/** Transfer failed */
Packit Service b0a153
	LIBUSB_TRANSFER_ERROR,
Packit Service b0a153
Packit Service b0a153
	/** Transfer timed out */
Packit Service b0a153
	LIBUSB_TRANSFER_TIMED_OUT,
Packit Service b0a153
Packit Service b0a153
	/** Transfer was cancelled */
Packit Service b0a153
	LIBUSB_TRANSFER_CANCELLED,
Packit Service b0a153
Packit Service b0a153
	/** For bulk/interrupt endpoints: halt condition detected (endpoint
Packit Service b0a153
	 * stalled). For control endpoints: control request not supported. */
Packit Service b0a153
	LIBUSB_TRANSFER_STALL,
Packit Service b0a153
Packit Service b0a153
	/** Device was disconnected */
Packit Service b0a153
	LIBUSB_TRANSFER_NO_DEVICE,
Packit Service b0a153
Packit Service b0a153
	/** Device sent more data than requested */
Packit Service b0a153
	LIBUSB_TRANSFER_OVERFLOW,
Packit Service b0a153
Packit Service b0a153
	/* NB! Remember to update libusb_error_name()
Packit Service b0a153
	   when adding new status codes here. */
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * libusb_transfer.flags values */
Packit Service b0a153
enum libusb_transfer_flags {
Packit Service b0a153
	/** Report short frames as errors */
Packit Service b0a153
	LIBUSB_TRANSFER_SHORT_NOT_OK = 1U << 0,
Packit Service b0a153
Packit Service b0a153
	/** Automatically free() transfer buffer during libusb_free_transfer().
Packit Service b0a153
	 * Note that buffers allocated with libusb_dev_mem_alloc() should not
Packit Service b0a153
	 * be attempted freed in this way, since free() is not an appropriate
Packit Service b0a153
	 * way to release such memory. */
Packit Service b0a153
	LIBUSB_TRANSFER_FREE_BUFFER = 1U << 1,
Packit Service b0a153
Packit Service b0a153
	/** Automatically call libusb_free_transfer() after callback returns.
Packit Service b0a153
	 * If this flag is set, it is illegal to call libusb_free_transfer()
Packit Service b0a153
	 * from your transfer callback, as this will result in a double-free
Packit Service b0a153
	 * when this flag is acted upon. */
Packit Service b0a153
	LIBUSB_TRANSFER_FREE_TRANSFER = 1U << 2,
Packit Service b0a153
Packit Service b0a153
	/** Terminate transfers that are a multiple of the endpoint's
Packit Service b0a153
	 * wMaxPacketSize with an extra zero length packet. This is useful
Packit Service b0a153
	 * when a device protocol mandates that each logical request is
Packit Service b0a153
	 * terminated by an incomplete packet (i.e. the logical requests are
Packit Service b0a153
	 * not separated by other means).
Packit Service b0a153
	 *
Packit Service b0a153
	 * This flag only affects host-to-device transfers to bulk and interrupt
Packit Service b0a153
	 * endpoints. In other situations, it is ignored.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This flag only affects transfers with a length that is a multiple of
Packit Service b0a153
	 * the endpoint's wMaxPacketSize. On transfers of other lengths, this
Packit Service b0a153
	 * flag has no effect. Therefore, if you are working with a device that
Packit Service b0a153
	 * needs a ZLP whenever the end of the logical request falls on a packet
Packit Service b0a153
	 * boundary, then it is sensible to set this flag on every
Packit Service b0a153
	 * transfer (you do not have to worry about only setting it on transfers
Packit Service b0a153
	 * that end on the boundary).
Packit Service b0a153
	 *
Packit Service b0a153
	 * This flag is currently only supported on Linux.
Packit Service b0a153
	 * On other systems, libusb_submit_transfer() will return
Packit Service b0a153
	 * LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this flag is set.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Available since libusb-1.0.9.
Packit Service b0a153
	 */
Packit Service b0a153
	LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1U << 3,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Isochronous packet descriptor. */
Packit Service b0a153
struct libusb_iso_packet_descriptor {
Packit Service b0a153
	/** Length of data to request in this packet */
Packit Service b0a153
	unsigned int length;
Packit Service b0a153
Packit Service b0a153
	/** Amount of data that was actually transferred */
Packit Service b0a153
	unsigned int actual_length;
Packit Service b0a153
Packit Service b0a153
	/** Status code for this packet */
Packit Service b0a153
	enum libusb_transfer_status status;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
struct libusb_transfer;
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Asynchronous transfer callback function type. When submitting asynchronous
Packit Service b0a153
 * transfers, you pass a pointer to a callback function of this type via the
Packit Service b0a153
 * \ref libusb_transfer::callback "callback" member of the libusb_transfer
Packit Service b0a153
 * structure. libusb will call this function later, when the transfer has
Packit Service b0a153
 * completed or failed. See \ref libusb_asyncio for more information.
Packit Service b0a153
 * \param transfer The libusb_transfer struct the callback function is being
Packit Service b0a153
 * notified about.
Packit Service b0a153
 */
Packit Service b0a153
typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * The generic USB transfer structure. The user populates this structure and
Packit Service b0a153
 * then submits it in order to request a transfer. After the transfer has
Packit Service b0a153
 * completed, the library populates the transfer with the results and passes
Packit Service b0a153
 * it back to the user.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_transfer {
Packit Service b0a153
	/** Handle of the device that this transfer will be submitted to */
Packit Service b0a153
	libusb_device_handle *dev_handle;
Packit Service b0a153
Packit Service b0a153
	/** A bitwise OR combination of \ref libusb_transfer_flags. */
Packit Service b0a153
	uint8_t flags;
Packit Service b0a153
Packit Service b0a153
	/** Address of the endpoint where this transfer will be sent. */
Packit Service b0a153
	unsigned char endpoint;
Packit Service b0a153
Packit Service b0a153
	/** Type of the endpoint from \ref libusb_transfer_type */
Packit Service b0a153
	unsigned char type;
Packit Service b0a153
Packit Service b0a153
	/** Timeout for this transfer in milliseconds. A value of 0 indicates no
Packit Service b0a153
	 * timeout. */
Packit Service b0a153
	unsigned int timeout;
Packit Service b0a153
Packit Service b0a153
	/** The status of the transfer. Read-only, and only for use within
Packit Service b0a153
	 * transfer callback function.
Packit Service b0a153
	 *
Packit Service b0a153
	 * If this is an isochronous transfer, this field may read COMPLETED even
Packit Service b0a153
	 * if there were errors in the frames. Use the
Packit Service b0a153
	 * \ref libusb_iso_packet_descriptor::status "status" field in each packet
Packit Service b0a153
	 * to determine if errors occurred. */
Packit Service b0a153
	enum libusb_transfer_status status;
Packit Service b0a153
Packit Service b0a153
	/** Length of the data buffer. Must be non-negative. */
Packit Service b0a153
	int length;
Packit Service b0a153
Packit Service b0a153
	/** Actual length of data that was transferred. Read-only, and only for
Packit Service b0a153
	 * use within transfer callback function. Not valid for isochronous
Packit Service b0a153
	 * endpoint transfers. */
Packit Service b0a153
	int actual_length;
Packit Service b0a153
Packit Service b0a153
	/** Callback function. This will be invoked when the transfer completes,
Packit Service b0a153
	 * fails, or is cancelled. */
Packit Service b0a153
	libusb_transfer_cb_fn callback;
Packit Service b0a153
Packit Service b0a153
	/** User context data to pass to the callback function. */
Packit Service b0a153
	void *user_data;
Packit Service b0a153
Packit Service b0a153
	/** Data buffer */
Packit Service b0a153
	unsigned char *buffer;
Packit Service b0a153
Packit Service b0a153
	/** Number of isochronous packets. Only used for I/O with isochronous
Packit Service b0a153
	 * endpoints. Must be non-negative. */
Packit Service b0a153
	int num_iso_packets;
Packit Service b0a153
Packit Service b0a153
	/** Isochronous packet descriptors, for isochronous transfers only. */
Packit Service b0a153
	struct libusb_iso_packet_descriptor iso_packet_desc[ZERO_SIZED_ARRAY];
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_misc
Packit Service b0a153
 * Capabilities supported by an instance of libusb on the current running
Packit Service b0a153
 * platform. Test if the loaded library supports a given capability by calling
Packit Service b0a153
 * \ref libusb_has_capability().
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_capability {
Packit Service b0a153
	/** The libusb_has_capability() API is available. */
Packit Service b0a153
	LIBUSB_CAP_HAS_CAPABILITY = 0x0000,
Packit Service b0a153
	/** Hotplug support is available on this platform. */
Packit Service b0a153
	LIBUSB_CAP_HAS_HOTPLUG = 0x0001,
Packit Service b0a153
	/** The library can access HID devices without requiring user intervention.
Packit Service b0a153
	 * Note that before being able to actually access an HID device, you may
Packit Service b0a153
	 * still have to call additional libusb functions such as
Packit Service b0a153
	 * \ref libusb_detach_kernel_driver(). */
Packit Service b0a153
	LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
Packit Service b0a153
	/** The library supports detaching of the default USB driver, using 
Packit Service b0a153
	 * \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */
Packit Service b0a153
	LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_lib
Packit Service b0a153
 *  Log message levels.
Packit Service b0a153
 *  - LIBUSB_LOG_LEVEL_NONE (0)    : no messages ever printed by the library (default)
Packit Service b0a153
 *  - LIBUSB_LOG_LEVEL_ERROR (1)   : error messages are printed to stderr
Packit Service b0a153
 *  - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
Packit Service b0a153
 *  - LIBUSB_LOG_LEVEL_INFO (3)    : informational messages are printed to stderr
Packit Service b0a153
 *  - LIBUSB_LOG_LEVEL_DEBUG (4)   : debug and informational messages are printed to stderr
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_log_level {
Packit Service b0a153
	LIBUSB_LOG_LEVEL_NONE = 0,
Packit Service b0a153
	LIBUSB_LOG_LEVEL_ERROR = 1,
Packit Service b0a153
	LIBUSB_LOG_LEVEL_WARNING = 2,
Packit Service b0a153
	LIBUSB_LOG_LEVEL_INFO = 3,
Packit Service b0a153
	LIBUSB_LOG_LEVEL_DEBUG = 4,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_lib
Packit Service b0a153
 *  Log callback mode.
Packit Service b0a153
 * \see libusb_set_log_cb()
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_log_cb_mode {
Packit Service b0a153
Packit Service b0a153
	/** Callback function handling all log mesages. */
Packit Service b0a153
	LIBUSB_LOG_CB_GLOBAL = 1 << 0,
Packit Service b0a153
Packit Service b0a153
	/** Callback function handling context related log mesages. */
Packit Service b0a153
	LIBUSB_LOG_CB_CONTEXT = 1 << 1
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_lib
Packit Service b0a153
 * Callback function for handling log messages.
Packit Service b0a153
 * \param ctx the context which is related to the log message, or NULL if it
Packit Service b0a153
 * is a global log message
Packit Service b0a153
 * \param level the log level, see \ref libusb_log_level for a description
Packit Service b0a153
 * \param str the log message
Packit Service b0a153
 * \see libusb_set_log_cb()
Packit Service b0a153
 */
Packit Service b0a153
typedef void (LIBUSB_CALL *libusb_log_cb)(libusb_context *ctx,
Packit Service b0a153
	enum libusb_log_level level, const char *str);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_init(libusb_context **ctx);
Packit Service b0a153
void LIBUSB_CALL libusb_exit(libusb_context *ctx);
Packit Service b0a153
LIBUSB_DEPRECATED_FOR(libusb_set_option)
Packit Service b0a153
void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
Packit Service b0a153
void LIBUSB_CALL libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode);
Packit Service b0a153
const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
Packit Service b0a153
int LIBUSB_CALL libusb_has_capability(uint32_t capability);
Packit Service b0a153
const char * LIBUSB_CALL libusb_error_name(int errcode);
Packit Service b0a153
int LIBUSB_CALL libusb_setlocale(const char *locale);
Packit Service b0a153
const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode);
Packit Service b0a153
Packit Service b0a153
ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
Packit Service b0a153
	libusb_device ***list);
Packit Service b0a153
void LIBUSB_CALL libusb_free_device_list(libusb_device **list,
Packit Service b0a153
	int unref_devices);
Packit Service b0a153
libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev);
Packit Service b0a153
void LIBUSB_CALL libusb_unref_device(libusb_device *dev);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev,
Packit Service b0a153
	int *config);
Packit Service b0a153
int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev,
Packit Service b0a153
	struct libusb_device_descriptor *desc);
Packit Service b0a153
int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev,
Packit Service b0a153
	struct libusb_config_descriptor **config);
Packit Service b0a153
int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev,
Packit Service b0a153
	uint8_t config_index, struct libusb_config_descriptor **config);
Packit Service b0a153
int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev,
Packit Service b0a153
	uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
Packit Service b0a153
void LIBUSB_CALL libusb_free_config_descriptor(
Packit Service b0a153
	struct libusb_config_descriptor *config);
Packit Service b0a153
int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor(
Packit Service b0a153
	struct libusb_context *ctx,
Packit Service b0a153
	const struct libusb_endpoint_descriptor *endpoint,
Packit Service b0a153
	struct libusb_ss_endpoint_companion_descriptor **ep_comp);
Packit Service b0a153
void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor(
Packit Service b0a153
	struct libusb_ss_endpoint_companion_descriptor *ep_comp);
Packit Service b0a153
int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
Packit Service b0a153
	struct libusb_bos_descriptor **bos);
Packit Service b0a153
void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
Packit Service b0a153
int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor(
Packit Service b0a153
	struct libusb_context *ctx,
Packit Service b0a153
	struct libusb_bos_dev_capability_descriptor *dev_cap,
Packit Service b0a153
	struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
Packit Service b0a153
void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor(
Packit Service b0a153
	struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
Packit Service b0a153
int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor(
Packit Service b0a153
	struct libusb_context *ctx,
Packit Service b0a153
	struct libusb_bos_dev_capability_descriptor *dev_cap,
Packit Service b0a153
	struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
Packit Service b0a153
void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor(
Packit Service b0a153
	struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
Packit Service b0a153
int LIBUSB_CALL libusb_get_container_id_descriptor(struct libusb_context *ctx,
Packit Service b0a153
	struct libusb_bos_dev_capability_descriptor *dev_cap,
Packit Service b0a153
	struct libusb_container_id_descriptor **container_id);
Packit Service b0a153
void LIBUSB_CALL libusb_free_container_id_descriptor(
Packit Service b0a153
	struct libusb_container_id_descriptor *container_id);
Packit Service b0a153
uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
Packit Service b0a153
uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
Packit Service b0a153
int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
Packit Service b0a153
LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
Packit Service b0a153
int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length);
Packit Service b0a153
libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev);
Packit Service b0a153
uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
Packit Service b0a153
int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
Packit Service b0a153
int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
Packit Service b0a153
	unsigned char endpoint);
Packit Service b0a153
int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
Packit Service b0a153
	unsigned char endpoint);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle);
Packit Service b0a153
int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **dev_handle);
Packit Service b0a153
void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle);
Packit Service b0a153
libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev_handle,
Packit Service b0a153
	int configuration);
Packit Service b0a153
int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev_handle,
Packit Service b0a153
	int interface_number);
Packit Service b0a153
int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev_handle,
Packit Service b0a153
	int interface_number);
Packit Service b0a153
Packit Service b0a153
libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
Packit Service b0a153
	libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev_handle,
Packit Service b0a153
	int interface_number, int alternate_setting);
Packit Service b0a153
int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev_handle,
Packit Service b0a153
	unsigned char endpoint);
Packit Service b0a153
int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev_handle);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev_handle,
Packit Service b0a153
	uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
Packit Service b0a153
int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev_handle,
Packit Service b0a153
	unsigned char *endpoints, int num_endpoints);
Packit Service b0a153
Packit Service b0a153
unsigned char * LIBUSB_CALL libusb_dev_mem_alloc(libusb_device_handle *dev_handle,
Packit Service b0a153
	size_t length);
Packit Service b0a153
int LIBUSB_CALL libusb_dev_mem_free(libusb_device_handle *dev_handle,
Packit Service b0a153
	unsigned char *buffer, size_t length);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev_handle,
Packit Service b0a153
	int interface_number);
Packit Service b0a153
int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev_handle,
Packit Service b0a153
	int interface_number);
Packit Service b0a153
int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev_handle,
Packit Service b0a153
	int interface_number);
Packit Service b0a153
int LIBUSB_CALL libusb_set_auto_detach_kernel_driver(
Packit Service b0a153
	libusb_device_handle *dev_handle, int enable);
Packit Service b0a153
Packit Service b0a153
/* async I/O */
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Get the data section of a control transfer. This convenience function is here
Packit Service b0a153
 * to remind you that the data does not start until 8 bytes into the actual
Packit Service b0a153
 * buffer, as the setup packet comes first.
Packit Service b0a153
 *
Packit Service b0a153
 * Calling this function only makes sense from a transfer callback function,
Packit Service b0a153
 * or situations where you have already allocated a suitably sized buffer at
Packit Service b0a153
 * transfer->buffer.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer a transfer
Packit Service b0a153
 * \returns pointer to the first byte of the data section
Packit Service b0a153
 */
Packit Service b0a153
static inline unsigned char *libusb_control_transfer_get_data(
Packit Service b0a153
	struct libusb_transfer *transfer)
Packit Service b0a153
{
Packit Service b0a153
	return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Get the control setup packet of a control transfer. This convenience
Packit Service b0a153
 * function is here to remind you that the control setup occupies the first
Packit Service b0a153
 * 8 bytes of the transfer data buffer.
Packit Service b0a153
 *
Packit Service b0a153
 * Calling this function only makes sense from a transfer callback function,
Packit Service b0a153
 * or situations where you have already allocated a suitably sized buffer at
Packit Service b0a153
 * transfer->buffer.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer a transfer
Packit Service b0a153
 * \returns a casted pointer to the start of the transfer data buffer
Packit Service b0a153
 */
Packit Service b0a153
static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
Packit Service b0a153
	struct libusb_transfer *transfer)
Packit Service b0a153
{
Packit Service b0a153
	return (struct libusb_control_setup *)(void *) transfer->buffer;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Helper function to populate the setup packet (first 8 bytes of the data
Packit Service b0a153
 * buffer) for a control transfer. The wIndex, wValue and wLength values should
Packit Service b0a153
 * be given in host-endian byte order.
Packit Service b0a153
 *
Packit Service b0a153
 * \param buffer buffer to output the setup packet into
Packit Service b0a153
 * This pointer must be aligned to at least 2 bytes boundary.
Packit Service b0a153
 * \param bmRequestType see the
Packit Service b0a153
 * \ref libusb_control_setup::bmRequestType "bmRequestType" field of
Packit Service b0a153
 * \ref libusb_control_setup
Packit Service b0a153
 * \param bRequest see the
Packit Service b0a153
 * \ref libusb_control_setup::bRequest "bRequest" field of
Packit Service b0a153
 * \ref libusb_control_setup
Packit Service b0a153
 * \param wValue see the
Packit Service b0a153
 * \ref libusb_control_setup::wValue "wValue" field of
Packit Service b0a153
 * \ref libusb_control_setup
Packit Service b0a153
 * \param wIndex see the
Packit Service b0a153
 * \ref libusb_control_setup::wIndex "wIndex" field of
Packit Service b0a153
 * \ref libusb_control_setup
Packit Service b0a153
 * \param wLength see the
Packit Service b0a153
 * \ref libusb_control_setup::wLength "wLength" field of
Packit Service b0a153
 * \ref libusb_control_setup
Packit Service b0a153
 */
Packit Service b0a153
static inline void libusb_fill_control_setup(unsigned char *buffer,
Packit Service b0a153
	uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
Packit Service b0a153
	uint16_t wLength)
Packit Service b0a153
{
Packit Service b0a153
	struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
Packit Service b0a153
	setup->bmRequestType = bmRequestType;
Packit Service b0a153
	setup->bRequest = bRequest;
Packit Service b0a153
	setup->wValue = libusb_cpu_to_le16(wValue);
Packit Service b0a153
	setup->wIndex = libusb_cpu_to_le16(wIndex);
Packit Service b0a153
	setup->wLength = libusb_cpu_to_le16(wLength);
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
Packit Service b0a153
int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
Packit Service b0a153
int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
Packit Service b0a153
void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
Packit Service b0a153
void LIBUSB_CALL libusb_transfer_set_stream_id(
Packit Service b0a153
	struct libusb_transfer *transfer, uint32_t stream_id);
Packit Service b0a153
uint32_t LIBUSB_CALL libusb_transfer_get_stream_id(
Packit Service b0a153
	struct libusb_transfer *transfer);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Helper function to populate the required \ref libusb_transfer fields
Packit Service b0a153
 * for a control transfer.
Packit Service b0a153
 *
Packit Service b0a153
 * If you pass a transfer buffer to this function, the first 8 bytes will
Packit Service b0a153
 * be interpreted as a control setup packet, and the wLength field will be
Packit Service b0a153
 * used to automatically populate the \ref libusb_transfer::length "length"
Packit Service b0a153
 * field of the transfer. Therefore the recommended approach is:
Packit Service b0a153
 * -# Allocate a suitably sized data buffer (including space for control setup)
Packit Service b0a153
 * -# Call libusb_fill_control_setup()
Packit Service b0a153
 * -# If this is a host-to-device transfer with a data stage, put the data
Packit Service b0a153
 *    in place after the setup packet
Packit Service b0a153
 * -# Call this function
Packit Service b0a153
 * -# Call libusb_submit_transfer()
Packit Service b0a153
 *
Packit Service b0a153
 * It is also legal to pass a NULL buffer to this function, in which case this
Packit Service b0a153
 * function will not attempt to populate the length field. Remember that you
Packit Service b0a153
 * must then populate the buffer and length fields later.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer the transfer to populate
Packit Service b0a153
 * \param dev_handle handle of the device that will handle the transfer
Packit Service b0a153
 * \param buffer data buffer. If provided, this function will interpret the
Packit Service b0a153
 * first 8 bytes as a setup packet and infer the transfer length from that.
Packit Service b0a153
 * This pointer must be aligned to at least 2 bytes boundary.
Packit Service b0a153
 * \param callback callback function to be invoked on transfer completion
Packit Service b0a153
 * \param user_data user data to pass to callback function
Packit Service b0a153
 * \param timeout timeout for the transfer in milliseconds
Packit Service b0a153
 */
Packit Service b0a153
static inline void libusb_fill_control_transfer(
Packit Service b0a153
	struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
Packit Service b0a153
	unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
Packit Service b0a153
	unsigned int timeout)
Packit Service b0a153
{
Packit Service b0a153
	struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
Packit Service b0a153
	transfer->dev_handle = dev_handle;
Packit Service b0a153
	transfer->endpoint = 0;
Packit Service b0a153
	transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
Packit Service b0a153
	transfer->timeout = timeout;
Packit Service b0a153
	transfer->buffer = buffer;
Packit Service b0a153
	if (setup)
Packit Service b0a153
		transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE
Packit Service b0a153
			+ libusb_le16_to_cpu(setup->wLength));
Packit Service b0a153
	transfer->user_data = user_data;
Packit Service b0a153
	transfer->callback = callback;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Helper function to populate the required \ref libusb_transfer fields
Packit Service b0a153
 * for a bulk transfer.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer the transfer to populate
Packit Service b0a153
 * \param dev_handle handle of the device that will handle the transfer
Packit Service b0a153
 * \param endpoint address of the endpoint where this transfer will be sent
Packit Service b0a153
 * \param buffer data buffer
Packit Service b0a153
 * \param length length of data buffer
Packit Service b0a153
 * \param callback callback function to be invoked on transfer completion
Packit Service b0a153
 * \param user_data user data to pass to callback function
Packit Service b0a153
 * \param timeout timeout for the transfer in milliseconds
Packit Service b0a153
 */
Packit Service b0a153
static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
Packit Service b0a153
	libusb_device_handle *dev_handle, unsigned char endpoint,
Packit Service b0a153
	unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
Packit Service b0a153
	void *user_data, unsigned int timeout)
Packit Service b0a153
{
Packit Service b0a153
	transfer->dev_handle = dev_handle;
Packit Service b0a153
	transfer->endpoint = endpoint;
Packit Service b0a153
	transfer->type = LIBUSB_TRANSFER_TYPE_BULK;
Packit Service b0a153
	transfer->timeout = timeout;
Packit Service b0a153
	transfer->buffer = buffer;
Packit Service b0a153
	transfer->length = length;
Packit Service b0a153
	transfer->user_data = user_data;
Packit Service b0a153
	transfer->callback = callback;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Helper function to populate the required \ref libusb_transfer fields
Packit Service b0a153
 * for a bulk transfer using bulk streams.
Packit Service b0a153
 *
Packit Service b0a153
 * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer the transfer to populate
Packit Service b0a153
 * \param dev_handle handle of the device that will handle the transfer
Packit Service b0a153
 * \param endpoint address of the endpoint where this transfer will be sent
Packit Service b0a153
 * \param stream_id bulk stream id for this transfer
Packit Service b0a153
 * \param buffer data buffer
Packit Service b0a153
 * \param length length of data buffer
Packit Service b0a153
 * \param callback callback function to be invoked on transfer completion
Packit Service b0a153
 * \param user_data user data to pass to callback function
Packit Service b0a153
 * \param timeout timeout for the transfer in milliseconds
Packit Service b0a153
 */
Packit Service b0a153
static inline void libusb_fill_bulk_stream_transfer(
Packit Service b0a153
	struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
Packit Service b0a153
	unsigned char endpoint, uint32_t stream_id,
Packit Service b0a153
	unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
Packit Service b0a153
	void *user_data, unsigned int timeout)
Packit Service b0a153
{
Packit Service b0a153
	libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
Packit Service b0a153
				  length, callback, user_data, timeout);
Packit Service b0a153
	transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
Packit Service b0a153
	libusb_transfer_set_stream_id(transfer, stream_id);
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Helper function to populate the required \ref libusb_transfer fields
Packit Service b0a153
 * for an interrupt transfer.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer the transfer to populate
Packit Service b0a153
 * \param dev_handle handle of the device that will handle the transfer
Packit Service b0a153
 * \param endpoint address of the endpoint where this transfer will be sent
Packit Service b0a153
 * \param buffer data buffer
Packit Service b0a153
 * \param length length of data buffer
Packit Service b0a153
 * \param callback callback function to be invoked on transfer completion
Packit Service b0a153
 * \param user_data user data to pass to callback function
Packit Service b0a153
 * \param timeout timeout for the transfer in milliseconds
Packit Service b0a153
 */
Packit Service b0a153
static inline void libusb_fill_interrupt_transfer(
Packit Service b0a153
	struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
Packit Service b0a153
	unsigned char endpoint, unsigned char *buffer, int length,
Packit Service b0a153
	libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Packit Service b0a153
{
Packit Service b0a153
	transfer->dev_handle = dev_handle;
Packit Service b0a153
	transfer->endpoint = endpoint;
Packit Service b0a153
	transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT;
Packit Service b0a153
	transfer->timeout = timeout;
Packit Service b0a153
	transfer->buffer = buffer;
Packit Service b0a153
	transfer->length = length;
Packit Service b0a153
	transfer->user_data = user_data;
Packit Service b0a153
	transfer->callback = callback;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Helper function to populate the required \ref libusb_transfer fields
Packit Service b0a153
 * for an isochronous transfer.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer the transfer to populate
Packit Service b0a153
 * \param dev_handle handle of the device that will handle the transfer
Packit Service b0a153
 * \param endpoint address of the endpoint where this transfer will be sent
Packit Service b0a153
 * \param buffer data buffer
Packit Service b0a153
 * \param length length of data buffer
Packit Service b0a153
 * \param num_iso_packets the number of isochronous packets
Packit Service b0a153
 * \param callback callback function to be invoked on transfer completion
Packit Service b0a153
 * \param user_data user data to pass to callback function
Packit Service b0a153
 * \param timeout timeout for the transfer in milliseconds
Packit Service b0a153
 */
Packit Service b0a153
static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer,
Packit Service b0a153
	libusb_device_handle *dev_handle, unsigned char endpoint,
Packit Service b0a153
	unsigned char *buffer, int length, int num_iso_packets,
Packit Service b0a153
	libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Packit Service b0a153
{
Packit Service b0a153
	transfer->dev_handle = dev_handle;
Packit Service b0a153
	transfer->endpoint = endpoint;
Packit Service b0a153
	transfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS;
Packit Service b0a153
	transfer->timeout = timeout;
Packit Service b0a153
	transfer->buffer = buffer;
Packit Service b0a153
	transfer->length = length;
Packit Service b0a153
	transfer->num_iso_packets = num_iso_packets;
Packit Service b0a153
	transfer->user_data = user_data;
Packit Service b0a153
	transfer->callback = callback;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Convenience function to set the length of all packets in an isochronous
Packit Service b0a153
 * transfer, based on the num_iso_packets field in the transfer structure.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer a transfer
Packit Service b0a153
 * \param length the length to set in each isochronous packet descriptor
Packit Service b0a153
 * \see libusb_get_max_packet_size()
Packit Service b0a153
 */
Packit Service b0a153
static inline void libusb_set_iso_packet_lengths(
Packit Service b0a153
	struct libusb_transfer *transfer, unsigned int length)
Packit Service b0a153
{
Packit Service b0a153
	int i;
Packit Service b0a153
	for (i = 0; i < transfer->num_iso_packets; i++)
Packit Service b0a153
		transfer->iso_packet_desc[i].length = length;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Convenience function to locate the position of an isochronous packet
Packit Service b0a153
 * within the buffer of an isochronous transfer.
Packit Service b0a153
 *
Packit Service b0a153
 * This is a thorough function which loops through all preceding packets,
Packit Service b0a153
 * accumulating their lengths to find the position of the specified packet.
Packit Service b0a153
 * Typically you will assign equal lengths to each packet in the transfer,
Packit Service b0a153
 * and hence the above method is sub-optimal. You may wish to use
Packit Service b0a153
 * libusb_get_iso_packet_buffer_simple() instead.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer a transfer
Packit Service b0a153
 * \param packet the packet to return the address of
Packit Service b0a153
 * \returns the base address of the packet buffer inside the transfer buffer,
Packit Service b0a153
 * or NULL if the packet does not exist.
Packit Service b0a153
 * \see libusb_get_iso_packet_buffer_simple()
Packit Service b0a153
 */
Packit Service b0a153
static inline unsigned char *libusb_get_iso_packet_buffer(
Packit Service b0a153
	struct libusb_transfer *transfer, unsigned int packet)
Packit Service b0a153
{
Packit Service b0a153
	int i;
Packit Service b0a153
	size_t offset = 0;
Packit Service b0a153
	int _packet;
Packit Service b0a153
Packit Service b0a153
	/* oops..slight bug in the API. packet is an unsigned int, but we use
Packit Service b0a153
	 * signed integers almost everywhere else. range-check and convert to
Packit Service b0a153
	 * signed to avoid compiler warnings. FIXME for libusb-2. */
Packit Service b0a153
	if (packet > INT_MAX)
Packit Service b0a153
		return NULL;
Packit Service b0a153
	_packet = (int) packet;
Packit Service b0a153
Packit Service b0a153
	if (_packet >= transfer->num_iso_packets)
Packit Service b0a153
		return NULL;
Packit Service b0a153
Packit Service b0a153
	for (i = 0; i < _packet; i++)
Packit Service b0a153
		offset += transfer->iso_packet_desc[i].length;
Packit Service b0a153
Packit Service b0a153
	return transfer->buffer + offset;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_asyncio
Packit Service b0a153
 * Convenience function to locate the position of an isochronous packet
Packit Service b0a153
 * within the buffer of an isochronous transfer, for transfers where each
Packit Service b0a153
 * packet is of identical size.
Packit Service b0a153
 *
Packit Service b0a153
 * This function relies on the assumption that every packet within the transfer
Packit Service b0a153
 * is of identical size to the first packet. Calculating the location of
Packit Service b0a153
 * the packet buffer is then just a simple calculation:
Packit Service b0a153
 * <tt>buffer + (packet_size * packet)</tt>
Packit Service b0a153
 *
Packit Service b0a153
 * Do not use this function on transfers other than those that have identical
Packit Service b0a153
 * packet lengths for each packet.
Packit Service b0a153
 *
Packit Service b0a153
 * \param transfer a transfer
Packit Service b0a153
 * \param packet the packet to return the address of
Packit Service b0a153
 * \returns the base address of the packet buffer inside the transfer buffer,
Packit Service b0a153
 * or NULL if the packet does not exist.
Packit Service b0a153
 * \see libusb_get_iso_packet_buffer()
Packit Service b0a153
 */
Packit Service b0a153
static inline unsigned char *libusb_get_iso_packet_buffer_simple(
Packit Service b0a153
	struct libusb_transfer *transfer, unsigned int packet)
Packit Service b0a153
{
Packit Service b0a153
	int _packet;
Packit Service b0a153
Packit Service b0a153
	/* oops..slight bug in the API. packet is an unsigned int, but we use
Packit Service b0a153
	 * signed integers almost everywhere else. range-check and convert to
Packit Service b0a153
	 * signed to avoid compiler warnings. FIXME for libusb-2. */
Packit Service b0a153
	if (packet > INT_MAX)
Packit Service b0a153
		return NULL;
Packit Service b0a153
	_packet = (int) packet;
Packit Service b0a153
Packit Service b0a153
	if (_packet >= transfer->num_iso_packets)
Packit Service b0a153
		return NULL;
Packit Service b0a153
Packit Service b0a153
	return transfer->buffer + ((int) transfer->iso_packet_desc[0].length * _packet);
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/* sync I/O */
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle,
Packit Service b0a153
	uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
Packit Service b0a153
	unsigned char *data, uint16_t wLength, unsigned int timeout);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle,
Packit Service b0a153
	unsigned char endpoint, unsigned char *data, int length,
Packit Service b0a153
	int *actual_length, unsigned int timeout);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle,
Packit Service b0a153
	unsigned char endpoint, unsigned char *data, int length,
Packit Service b0a153
	int *actual_length, unsigned int timeout);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * Retrieve a descriptor from the default control pipe.
Packit Service b0a153
 * This is a convenience function which formulates the appropriate control
Packit Service b0a153
 * message to retrieve the descriptor.
Packit Service b0a153
 *
Packit Service b0a153
 * \param dev_handle a device handle
Packit Service b0a153
 * \param desc_type the descriptor type, see \ref libusb_descriptor_type
Packit Service b0a153
 * \param desc_index the index of the descriptor to retrieve
Packit Service b0a153
 * \param data output buffer for descriptor
Packit Service b0a153
 * \param length size of data buffer
Packit Service b0a153
 * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
Packit Service b0a153
 */
Packit Service b0a153
static inline int libusb_get_descriptor(libusb_device_handle *dev_handle,
Packit Service b0a153
	uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
Packit Service b0a153
{
Packit Service b0a153
	return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
Packit Service b0a153
		LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | desc_index),
Packit Service b0a153
		0, data, (uint16_t) length, 1000);
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_desc
Packit Service b0a153
 * Retrieve a descriptor from a device.
Packit Service b0a153
 * This is a convenience function which formulates the appropriate control
Packit Service b0a153
 * message to retrieve the descriptor. The string returned is Unicode, as
Packit Service b0a153
 * detailed in the USB specifications.
Packit Service b0a153
 *
Packit Service b0a153
 * \param dev_handle a device handle
Packit Service b0a153
 * \param desc_index the index of the descriptor to retrieve
Packit Service b0a153
 * \param langid the language ID for the string descriptor
Packit Service b0a153
 * \param data output buffer for descriptor
Packit Service b0a153
 * \param length size of data buffer
Packit Service b0a153
 * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
Packit Service b0a153
 * \see libusb_get_string_descriptor_ascii()
Packit Service b0a153
 */
Packit Service b0a153
static inline int libusb_get_string_descriptor(libusb_device_handle *dev_handle,
Packit Service b0a153
	uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
Packit Service b0a153
{
Packit Service b0a153
	return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
Packit Service b0a153
		LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t)((LIBUSB_DT_STRING << 8) | desc_index),
Packit Service b0a153
		langid, data, (uint16_t) length, 1000);
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle,
Packit Service b0a153
	uint8_t desc_index, unsigned char *data, int length);
Packit Service b0a153
Packit Service b0a153
/* polling and timeouts */
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_try_lock_events(libusb_context *ctx);
Packit Service b0a153
void LIBUSB_CALL libusb_lock_events(libusb_context *ctx);
Packit Service b0a153
void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx);
Packit Service b0a153
int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx);
Packit Service b0a153
int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx);
Packit Service b0a153
void LIBUSB_CALL libusb_interrupt_event_handler(libusb_context *ctx);
Packit Service b0a153
void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx);
Packit Service b0a153
void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx);
Packit Service b0a153
int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx,
Packit Service b0a153
	struct timeval *tv);
Packit Service b0a153
int LIBUSB_CALL libusb_handle_events_timeout_completed(libusb_context *ctx,
Packit Service b0a153
	struct timeval *tv, int *completed);
Packit Service b0a153
int LIBUSB_CALL libusb_handle_events(libusb_context *ctx);
Packit Service b0a153
int LIBUSB_CALL libusb_handle_events_completed(libusb_context *ctx, int *completed);
Packit Service b0a153
int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx,
Packit Service b0a153
	struct timeval *tv);
Packit Service b0a153
int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);
Packit Service b0a153
int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx,
Packit Service b0a153
	struct timeval *tv);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_poll
Packit Service b0a153
 * File descriptor for polling
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_pollfd {
Packit Service b0a153
	/** Numeric file descriptor */
Packit Service b0a153
	int fd;
Packit Service b0a153
Packit Service b0a153
	/** Event flags to poll for from <poll.h>. POLLIN indicates that you
Packit Service b0a153
	 * should monitor this file descriptor for becoming ready to read from,
Packit Service b0a153
	 * and POLLOUT indicates that you should monitor this file descriptor for
Packit Service b0a153
	 * nonblocking write readiness. */
Packit Service b0a153
	short events;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_poll
Packit Service b0a153
 * Callback function, invoked when a new file descriptor should be added
Packit Service b0a153
 * to the set of file descriptors monitored for events.
Packit Service b0a153
 * \param fd the new file descriptor
Packit Service b0a153
 * \param events events to monitor for, see \ref libusb_pollfd for a
Packit Service b0a153
 * description
Packit Service b0a153
 * \param user_data User data pointer specified in
Packit Service b0a153
 * libusb_set_pollfd_notifiers() call
Packit Service b0a153
 * \see libusb_set_pollfd_notifiers()
Packit Service b0a153
 */
Packit Service b0a153
typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
Packit Service b0a153
	void *user_data);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_poll
Packit Service b0a153
 * Callback function, invoked when a file descriptor should be removed from
Packit Service b0a153
 * the set of file descriptors being monitored for events. After returning
Packit Service b0a153
 * from this callback, do not use that file descriptor again.
Packit Service b0a153
 * \param fd the file descriptor to stop monitoring
Packit Service b0a153
 * \param user_data User data pointer specified in
Packit Service b0a153
 * libusb_set_pollfd_notifiers() call
Packit Service b0a153
 * \see libusb_set_pollfd_notifiers()
Packit Service b0a153
 */
Packit Service b0a153
typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data);
Packit Service b0a153
Packit Service b0a153
const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
Packit Service b0a153
	libusb_context *ctx);
Packit Service b0a153
void LIBUSB_CALL libusb_free_pollfds(const struct libusb_pollfd **pollfds);
Packit Service b0a153
void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
Packit Service b0a153
	libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
Packit Service b0a153
	void *user_data);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_hotplug
Packit Service b0a153
 * Callback handle.
Packit Service b0a153
 *
Packit Service b0a153
 * Callbacks handles are generated by libusb_hotplug_register_callback()
Packit Service b0a153
 * and can be used to deregister callbacks. Callback handles are unique
Packit Service b0a153
 * per libusb_context and it is safe to call libusb_hotplug_deregister_callback()
Packit Service b0a153
 * on an already deregisted callback.
Packit Service b0a153
 *
Packit Service b0a153
 * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
Packit Service b0a153
 *
Packit Service b0a153
 * For more information, see \ref libusb_hotplug.
Packit Service b0a153
 */
Packit Service b0a153
typedef int libusb_hotplug_callback_handle;
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_hotplug
Packit Service b0a153
 *
Packit Service b0a153
 * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
Packit Service b0a153
 *
Packit Service b0a153
 * Flags for hotplug events */
Packit Service b0a153
typedef enum {
Packit Service b0a153
	/** Default value when not using any flags. */
Packit Service b0a153
	LIBUSB_HOTPLUG_NO_FLAGS = 0U,
Packit Service b0a153
Packit Service b0a153
	/** Arm the callback and fire it for all matching currently attached devices. */
Packit Service b0a153
	LIBUSB_HOTPLUG_ENUMERATE = 1U << 0,
Packit Service b0a153
} libusb_hotplug_flag;
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_hotplug
Packit Service b0a153
 *
Packit Service b0a153
 * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
Packit Service b0a153
 *
Packit Service b0a153
 * Hotplug events */
Packit Service b0a153
typedef enum {
Packit Service b0a153
	/** A device has been plugged in and is ready to use */
Packit Service b0a153
	LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01U,
Packit Service b0a153
Packit Service b0a153
	/** A device has left and is no longer available.
Packit Service b0a153
	 * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
Packit Service b0a153
	 * It is safe to call libusb_get_device_descriptor on a device that has left */
Packit Service b0a153
	LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT    = 0x02U,
Packit Service b0a153
} libusb_hotplug_event;
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_hotplug
Packit Service b0a153
 * Wildcard matching for hotplug events */
Packit Service b0a153
#define LIBUSB_HOTPLUG_MATCH_ANY -1
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_hotplug
Packit Service b0a153
 * Hotplug callback function type. When requesting hotplug event notifications,
Packit Service b0a153
 * you pass a pointer to a callback function of this type.
Packit Service b0a153
 *
Packit Service b0a153
 * This callback may be called by an internal event thread and as such it is
Packit Service b0a153
 * recommended the callback do minimal processing before returning.
Packit Service b0a153
 *
Packit Service b0a153
 * libusb will call this function later, when a matching event had happened on
Packit Service b0a153
 * a matching device. See \ref libusb_hotplug for more information.
Packit Service b0a153
 *
Packit Service b0a153
 * It is safe to call either libusb_hotplug_register_callback() or
Packit Service b0a153
 * libusb_hotplug_deregister_callback() from within a callback function.
Packit Service b0a153
 *
Packit Service b0a153
 * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
Packit Service b0a153
 *
Packit Service b0a153
 * \param ctx            context of this notification
Packit Service b0a153
 * \param device         libusb_device this event occurred on
Packit Service b0a153
 * \param event          event that occurred
Packit Service b0a153
 * \param user_data      user data provided when this callback was registered
Packit Service b0a153
 * \returns bool whether this callback is finished processing events.
Packit Service b0a153
 *                       returning 1 will cause this callback to be deregistered
Packit Service b0a153
 */
Packit Service b0a153
typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
Packit Service b0a153
						libusb_device *device,
Packit Service b0a153
						libusb_hotplug_event event,
Packit Service b0a153
						void *user_data);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_hotplug
Packit Service b0a153
 * Register a hotplug callback function
Packit Service b0a153
 *
Packit Service b0a153
 * Register a callback with the libusb_context. The callback will fire
Packit Service b0a153
 * when a matching event occurs on a matching device. The callback is
Packit Service b0a153
 * armed until either it is deregistered with libusb_hotplug_deregister_callback()
Packit Service b0a153
 * or the supplied callback returns 1 to indicate it is finished processing events.
Packit Service b0a153
 *
Packit Service b0a153
 * If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be
Packit Service b0a153
 * called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices
Packit Service b0a153
 * already plugged into the machine. Note that libusb modifies its internal
Packit Service b0a153
 * device list from a separate thread, while calling hotplug callbacks from
Packit Service b0a153
 * libusb_handle_events(), so it is possible for a device to already be present
Packit Service b0a153
 * on, or removed from, its internal device list, while the hotplug callbacks
Packit Service b0a153
 * still need to be dispatched. This means that when using \ref
Packit Service b0a153
 * LIBUSB_HOTPLUG_ENUMERATE, your callback may be called twice for the arrival
Packit Service b0a153
 * of the same device, once from libusb_hotplug_register_callback() and once
Packit Service b0a153
 * from libusb_handle_events(); and/or your callback may be called for the
Packit Service b0a153
 * removal of a device for which an arrived call was never made.
Packit Service b0a153
 *
Packit Service b0a153
 * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
Packit Service b0a153
 *
Packit Service b0a153
 * \param[in] ctx context to register this callback with
Packit Service b0a153
 * \param[in] events bitwise or of events that will trigger this callback. See \ref
Packit Service b0a153
 *            libusb_hotplug_event
Packit Service b0a153
 * \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag
Packit Service b0a153
 * \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
Packit Service b0a153
 * \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
Packit Service b0a153
 * \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
Packit Service b0a153
 * \param[in] cb_fn the function to be invoked on a matching event/device
Packit Service b0a153
 * \param[in] user_data user data to pass to the callback function
Packit Service b0a153
 * \param[out] callback_handle pointer to store the handle of the allocated callback (can be NULL)
Packit Service b0a153
 * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
Packit Service b0a153
 */
Packit Service b0a153
int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
Packit Service b0a153
						libusb_hotplug_event events,
Packit Service b0a153
						libusb_hotplug_flag flags,
Packit Service b0a153
						int vendor_id, int product_id,
Packit Service b0a153
						int dev_class,
Packit Service b0a153
						libusb_hotplug_callback_fn cb_fn,
Packit Service b0a153
						void *user_data,
Packit Service b0a153
						libusb_hotplug_callback_handle *callback_handle);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_hotplug
Packit Service b0a153
 * Deregisters a hotplug callback.
Packit Service b0a153
 *
Packit Service b0a153
 * Deregister a callback from a libusb_context. This function is safe to call from within
Packit Service b0a153
 * a hotplug callback.
Packit Service b0a153
 *
Packit Service b0a153
 * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
Packit Service b0a153
 *
Packit Service b0a153
 * \param[in] ctx context this callback is registered with
Packit Service b0a153
 * \param[in] callback_handle the handle of the callback to deregister
Packit Service b0a153
 */
Packit Service b0a153
void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx,
Packit Service b0a153
						libusb_hotplug_callback_handle callback_handle);
Packit Service b0a153
Packit Service b0a153
/** \ingroup libusb_lib
Packit Service b0a153
 * Available option values for libusb_set_option().
Packit Service b0a153
 */
Packit Service b0a153
enum libusb_option {
Packit Service b0a153
	/** Set the log message verbosity.
Packit Service b0a153
	 *
Packit Service b0a153
	 * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
Packit Service b0a153
	 * printed. If you choose to increase the message verbosity level, ensure
Packit Service b0a153
	 * that your application does not close the stderr file descriptor.
Packit Service b0a153
	 *
Packit Service b0a153
	 * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative
Packit Service b0a153
	 * with its message logging and most of the time, will only log messages that
Packit Service b0a153
	 * explain error conditions and other oddities. This will help you debug
Packit Service b0a153
	 * your software.
Packit Service b0a153
	 *
Packit Service b0a153
	 * If the LIBUSB_DEBUG environment variable was set when libusb was
Packit Service b0a153
	 * initialized, this function does nothing: the message verbosity is fixed
Packit Service b0a153
	 * to the value in the environment variable.
Packit Service b0a153
	 *
Packit Service b0a153
	 * If libusb was compiled without any message logging, this function does
Packit Service b0a153
	 * nothing: you'll never get any messages.
Packit Service b0a153
	 *
Packit Service b0a153
	 * If libusb was compiled with verbose debug message logging, this function
Packit Service b0a153
	 * does nothing: you'll always get messages from all levels.
Packit Service b0a153
	 */
Packit Service b0a153
	LIBUSB_OPTION_LOG_LEVEL,
Packit Service b0a153
Packit Service b0a153
	/** Use the UsbDk backend for a specific context, if available.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This option should be set immediately after calling libusb_init(), otherwise
Packit Service b0a153
	 * unspecified behavior may occur.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Only valid on Windows.
Packit Service b0a153
	 */
Packit Service b0a153
	LIBUSB_OPTION_USE_USBDK,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
int LIBUSB_CALL libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
Packit Service b0a153
Packit Service b0a153
#ifdef __cplusplus
Packit Service b0a153
}
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#endif