~ubuntu-branches/ubuntu/saucy/libusbx/saucy-proposed

« back to all changes in this revision

Viewing changes to libusb/libusb.h

  • Committer: Package Import Robot
  • Author(s): Aurelien Jarno
  • Date: 2013-05-06 17:31:43 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130506173143-wfbiltvcnn7pvdpa
Tags: 2:1.0.15-1
* New upstream version.
* Fix cross-build (closes: #694912, #705658).
* Add a -dbg package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Public libusbx header file
 
3
 * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
3
4
 * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
4
 
 * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
 
5
 * Copyright © 2012 Pete Batard <pete@akeo.ie>
 
6
 * For more information, please visit: http://libusbx.org
5
7
 *
6
8
 * This library is free software; you can redistribute it and/or
7
9
 * modify it under the terms of the GNU Lesser General Public
23
25
 
24
26
#ifdef _MSC_VER
25
27
/* on MS environments, the inline keyword is available in C++ only */
 
28
#if !defined(__cplusplus)
26
29
#define inline __inline
 
30
#endif
27
31
/* ssize_t is also not available (copy/paste from MinGW) */
28
32
#ifndef _SSIZE_T_DEFINED
29
33
#define _SSIZE_T_DEFINED
36
40
#endif /* _SSIZE_T_DEFINED */
37
41
#endif /* _MSC_VER */
38
42
 
39
 
/* stdint.h is also not usually available on MS */
 
43
/* stdint.h is not available on older MSVC */
40
44
#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
41
45
typedef unsigned __int8   uint8_t;
42
46
typedef unsigned __int16  uint16_t;
45
49
#include <stdint.h>
46
50
#endif
47
51
 
 
52
#if !defined(_WIN32_WCE)
48
53
#include <sys/types.h>
 
54
#endif
 
55
 
 
56
#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
 
57
#include <sys/time.h>
 
58
#endif
 
59
 
49
60
#include <time.h>
50
61
#include <limits.h>
51
62
 
52
 
#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
53
 
#include <sys/time.h>
54
 
#endif
55
 
 
56
63
/* 'interface' might be defined as a macro on Windows, so we need to
57
64
 * undefine it so as not to break the current libusbx API, because
58
65
 * libusb_config_descriptor has an 'interface' member
59
66
 * As this can be problematic if you include windows.h after libusb.h
60
67
 * in your sources, we force windows.h to be included first. */
61
 
#if defined(_WIN32) || defined(__CYGWIN__)
 
68
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
62
69
#include <windows.h>
63
70
#if defined(interface)
64
71
#undef interface
65
72
#endif
 
73
#if !defined(__CYGWIN__)
 
74
#include <winsock.h>
 
75
#endif
66
76
#endif
67
77
 
68
78
/** \def LIBUSB_CALL
97
107
 * return type, before the function name. See internal documentation for
98
108
 * API_EXPORTED.
99
109
 */
100
 
#if defined(_WIN32) || defined(__CYGWIN__)
 
110
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
101
111
#define LIBUSB_CALL WINAPI
102
112
#else
103
113
#define LIBUSB_CALL
104
114
#endif
105
115
 
 
116
/** \def LIBUSBX_API_VERSION
 
117
 * \ingroup misc
 
118
 * libusbx's API version.
 
119
 *
 
120
 * Since version 1.0.13, to help with feature detection, libusbx defines
 
121
 * a LIBUSBX_API_VERSION macro that gets increased every time there is a
 
122
 * significant change to the API, such as the introduction of a new call,
 
123
 * the definition of a new macro/enum member, or any other element that
 
124
 * libusbx applications may want to detect at compilation time.
 
125
 *
 
126
 * The macro is typically used in an application as follows:
 
127
 * \code
 
128
 * #if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x01001234)
 
129
 * // Use one of the newer features from the libusbx API
 
130
 * #endif
 
131
 * \endcode
 
132
 *
 
133
 * Another feature of LIBUSBX_API_VERSION is that it can be used to detect
 
134
 * whether you are compiling against the libusb or the libusbx library.
 
135
 *
 
136
 * Internally, LIBUSBX_API_VERSION is defined as follows:
 
137
 * (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental)
 
138
 */
 
139
#define LIBUSBX_API_VERSION 0x01000101
 
140
 
106
141
#ifdef __cplusplus
107
142
extern "C" {
108
143
#endif
229
264
 
230
265
        /** Hub descriptor */
231
266
        LIBUSB_DT_HUB = 0x29,
 
267
 
 
268
        /** SuperSpeed Hub descriptor */
 
269
        LIBUSB_DT_SUPERSPEED_HUB = 0x2A,
232
270
};
233
271
 
234
272
/* Descriptor sizes per descriptor type */
275
313
};
276
314
 
277
315
/** \ingroup misc
278
 
 * Standard requests, as defined in table 9-3 of the USB2 specifications */
 
316
 * Standard requests, as defined in table 9-5 of the USB 3.0 specifications */
279
317
enum libusb_standard_request {
280
318
        /** Request status of the specific recipient */
281
319
        LIBUSB_REQUEST_GET_STATUS = 0x00,
313
351
 
314
352
        /** Set then report an endpoint's synchronization frame */
315
353
        LIBUSB_REQUEST_SYNCH_FRAME = 0x0C,
 
354
 
 
355
        /** Sets both the U1 and U2 Exit Latency */
 
356
        LIBUSB_REQUEST_SET_SEL = 0x30,
 
357
 
 
358
        /** Delay from the time a host transmits a packet to the time it is
 
359
          * received by the device. */
 
360
        LIBUSB_SET_ISOCH_DELAY = 0x31,
316
361
};
317
362
 
318
363
/** \ingroup misc
392
437
 
393
438
/** \ingroup desc
394
439
 * A structure representing the standard USB device descriptor. This
395
 
 * descriptor is documented in section 9.6.1 of the USB 2.0 specification.
 
440
 * descriptor is documented in section 9.6.1 of the USB 3.0 specification.
396
441
 * All multiple-byte fields are represented in host-endian format.
397
442
 */
398
443
struct libusb_device_descriptor {
446
491
 
447
492
/** \ingroup desc
448
493
 * A structure representing the standard USB endpoint descriptor. This
449
 
 * descriptor is documented in section 9.6.3 of the USB 2.0 specification.
 
494
 * descriptor is documented in section 9.6.6 of the USB 3.0 specification.
450
495
 * All multiple-byte fields are represented in host-endian format.
451
496
 */
452
497
struct libusb_endpoint_descriptor {
496
541
 
497
542
/** \ingroup desc
498
543
 * A structure representing the standard USB interface descriptor. This
499
 
 * descriptor is documented in section 9.6.5 of the USB 2.0 specification.
 
544
 * descriptor is documented in section 9.6.5 of the USB 3.0 specification.
500
545
 * All multiple-byte fields are represented in host-endian format.
501
546
 */
502
547
struct libusb_interface_descriptor {
558
603
 
559
604
/** \ingroup desc
560
605
 * A structure representing the standard USB configuration descriptor. This
561
 
 * descriptor is documented in section 9.6.3 of the USB 2.0 specification.
 
606
 * descriptor is documented in section 9.6.3 of the USB 3.0 specification.
562
607
 * All multiple-byte fields are represented in host-endian format.
563
608
 */
564
609
struct libusb_config_descriptor {
806
851
 
807
852
        /** Device sent more data than requested */
808
853
        LIBUSB_TRANSFER_OVERFLOW,
 
854
 
 
855
        /* NB! Remember to update libusb_error_name()
 
856
           when adding new status codes here. */
809
857
};
810
858
 
811
859
/** \ingroup asyncio
946
994
 */
947
995
enum libusb_capability {
948
996
        /** The libusb_has_capability() API is available. */
949
 
        LIBUSB_CAP_HAS_CAPABILITY = 0,
 
997
        LIBUSB_CAP_HAS_CAPABILITY = 0x0000,
 
998
        /** Hotplug support is available. */
 
999
        LIBUSB_CAP_HAS_HOTPLUG = 0x0001,
 
1000
        /** The library can access HID devices without requiring user intervention.
 
1001
         * Note that before being able to actually access an HID device, you may
 
1002
         * still have to call additional libusbx functions such as
 
1003
         * \ref libusb_detach_kernel_driver(). */
 
1004
        LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
 
1005
        /** The library supports detaching of the default USB driver, using 
 
1006
         * \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */
 
1007
        LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101
950
1008
};
951
1009
 
952
1010
/** \ingroup lib