summaryrefslogtreecommitdiff
path: root/libusb/libusb.h
Commit message (Collapse)AuthorAgeFilesLines
* Fixed many compiler warnings about sign and size mismatchSean McBride2019-01-301-14/+15
| | | | | | | | | | - added various casts - added some asserts where the casts made assumptions - enabled additional warnings in Xcode project (especially -Wshorten-64-to-32) Closes #509 Signed-off-by: Nathan Hjelm <hjelmn@me.com>
* core: Add libusb_wrap_sys_device() APIVianney le Clément de Saint-Marcq2019-01-081-0/+1
| | | | | | | | Introduce a new API function for wrapping an existing platform-specific device handle as a libusb_device_handle. Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu> Signed-off-by: Nathan Hjelm <hjelmn@me.com>
* Bump libusb API version for next releaseNathan Hjelm2018-12-051-2/+2
| | | | Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
* core: new API libusb_set_log_cb() to redirect global and per context log ↵dmitrykos2018-12-051-0/+25
| | | | | | | | messages to the provided log handling function Closes #486 Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
* core: Add definition for LIBUSB_SUPER_SPEED_PLUS (10Gb/s)Chris Dickens2018-01-081-0/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Enable dynamic selection between WinUSB and UsbDk backendsChris Dickens2018-01-081-0/+9
| | | | | | | | | | | | | This commit unifies the two Windows backends into a single project and enables the user to switch to the UsbDk backend, if available, using the libusb_set_option() function. All contexts will use the WinUSB backend by default for backwards compatibility. With this change, the UsbDk-specific projects are no longer required. Closes #309 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Fixed deprecated attribute to work on clangSean McBride2017-12-281-0/+2
| | | | | | | | | | | | | | clang was warning: core.c:2011:5: Declaration is marked with '\deprecated' command but does not have a deprecation attribute This was because LIBUSB_DEPRECATED_FOR was checking for gcc >= 4.5 whereas clang identifies itself as gcc 4.2. So fallback to __attribute__((deprecated)) without a message string on older GCCs (and thus clang). Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Introduce libusb_set_option() API functionChris Dickens2017-07-161-10/+39
| | | | | | | | | | | | | | This new function allows more flexibility in extending the library to support more user-configurable options. It is intended to provide a single API that can support a wide variety of needs and eliminates the need for new API functions to set future options. The function is introduced with a single option (LIBUSB_OPTION_LOG_LEVEL) that replaces the libusb_set_debug() function. Documentation relating to libusb_set_debug() and the uses of this function in the examples and tests have been updated accordingly. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Refactor zero-length array declarationsChris Dickens2017-07-061-21/+9
| | | | | | | | Instead of checking for __STDC_VERSION__ at every instance, define a ZERO_SIZED_ARRAY macro that has the appropriate definition and use that everywhere it is needed. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* libusb.h: use __linux__ instead of __linuxAdrian Bunk2017-06-191-1/+1
| | | | | | | | | The check was added since sys/time.h is not available on Windows, but breaks on PowerPC where __linux is not defined by GCC in strict standards modes. Signed-off-by: Adrian Bunk <bunk@debian.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Misc: Fix a Doxygen comment typomojocorp2017-01-041-1/+1
|
* Add support for persistent device memory.Steinar H. Gunderson2016-05-291-1/+9
| | | | | | | | | | | | | | | | | | | Add a function to allocate memory belonging to a specific device, so that the operating system can DMA straight into it for zerocopy, and also avoid some clearing. Also, this allows up-front memory allocation in the kernel at program startup; memory allocation is otherwise done per-transfer, which can fail in a system where memory has become fragmented over time). This mirrors new functionality going into Linux' USB stack (recently reviewed and acked upstream); only Linux is supported as a backend currently. [Chris Dickens] Modified to fix doxygen documentation, correct parameter naming, reposition function declarations, and address a missing request during the patch review process. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Prefix doxygen references in order to namespace libusbChris Dickens2016-02-241-69/+69
| | | | | | | | | | | This change add "libusb_" to every group and page definition (and updates all references accordingly) so that generated man pages are namespaced for libusb, thus avoiding possible conflict with other packages. Closes #131 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Make API parameter names consistent and sensibleChris Dickens2016-02-241-25/+25
| | | | | | | | | | | Prior to this commit, API functions taking a libusb_device_handle argument had the parameter named dev, handle, or dev_handle. This commit changes the name of all libusb_device_handle parameters to dev_handle in both the documentation and actual code. Closes #132 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Spelling fixesTobias Klauser2016-01-051-1/+1
| | | | | | | | | | Fix spelling errors found by codespell, some of them in API documentation and user visible messages. Closes #102 Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* API: Add libusb_interrupt_event_handler() functionChris Dickens2015-12-171-1/+2
| | | | | | | | | This new function will allow the user to purposely interrupt an event handling thread, causing it to return from the event handling function. This is mainly useful for cleanly exiting from a dedicated event handling thread during application shutdown. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* API: Add libusb_free_pollfds() functionChris Dickens2015-07-291-1/+2
| | | | | | | | | This patch adds a new API call to ensure that the same memory allocator is used to both allocate and free the list of libusb_pollfd structures. It is an incorrect assumption that the user's free() will use the same memory allocator that libusb uses internally. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Fix doxygen comment for MaxPower field with respect to super-speedTobias Klauser2015-05-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | The MaxPower field of a configuration descriptor is in units of 8 mA when the device is operating in super-speed mode according to the USB 3.0 specification, section 9.6.3, table 9-12: Maximum power consumption of the device from the bus in this specific configuration when the device is fully operational. Expressed in 2-mA units when the device is operating in high-speed mode and in 8-mA units when operating at Gen X speed. (i.e., 50 = 100 mA when operating at high-speed and 50 = 400 mA when operating at Gen X speed). Adjust the doxygen comment for the MaxPower member of struct libusb_config_descriptor accordingly. Closes #69 Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Remove comment that no longer makes senseChris Dickens2015-03-011-3/+0
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* misc: fix typos in commentsorbitcowboy2015-02-161-2/+2
| | | | * Closes #53
* hotplug: Provide a default enum value for libusb_hotplug_flagChris Dickens2015-01-121-1/+4
| | | | | | * Closes #35 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* API: remove unused libusb_hotplug_callback structLudovic Rousseau2014-12-161-1/+0
| | | | | The structure libusb_hotplug_callback was declared (but not defined) and never used in the public API.
* haiku: Add Haiku supportAkshay Jaggi2014-09-251-1/+1
|
* Add API for using bulk streamsHans de Goede2014-04-221-2/+37
| | | | | | | | | | | | | | | | | | | | | | Being able to allocate bulk-streams is not really useful if the user cannot specify the stream ids when submitting transfers. The actual stream id gets added to our private itransfer struct, and a setter + getter are added to get to it. Unfortunately this is the only way to add support for stream ids without breaking ABI. So this is another item to fix when we do break ABI in libusb-2.0. Bulk streams also use a separate transer type, to allow backends to determine if a transfer is a bulk stream transfer or an ordinary bulk transfer. This is added because there is no other reliable way to determine if a transfer is a stream as the stream_id is part of the private itransfer struct so apps re-using a transfer may not set it to 0. Adding a separate transfer-type for this was suggested (and coded) by Nathan Hjelm. Most users will likely use the new libusb_fill_bulk_stream_transfer() though, and will never know the difference. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Add API for allocating / freeing usb3 bulk streams + Linux implementationHans de Goede2014-04-221-0/+5
| | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Misc: Revert all references to libusb/libusb.infohjelmn@cs.unm.edu2014-01-081-38/+41
|
* core: fix Doxygen warningLudovic Rousseau2013-12-061-1/+1
| | | | | | | | | libusbx/libusb/libusb.h:153: warning: no matching file member found for libusb_cpu_to_le16()Possible candidates: static uint16_t libusb_cpu_to_le16(const uint16_t x) Thanks to Serhat Sevki Dincer for the bug report http://sourceforge.net/mailarchive/message.php?msg_id=31719691
* Clarify alignment requirements for the control transfer bufferPaul Fertser2013-08-211-3/+5
| | | | | | | | | | | | | | | | | | | | | | | Since the buffer pointer will later be casted to ``struct libusb_control_setup *'', it should point to memory aligned to at least 2 bytes boundary as that's the strictest requirement of the struct fields. Also, use a (void *) casting trick to convince the compiler the cast is safe, to fix warnings such as: /usr/local/include/libusb-1.0/libusb.h: In function 'libusb_control_transfer_get_setup': /usr/local/include/libusb-1.0/libusb.h:1435:9: error: cast increases required alignment of target type [-Werror=cast-align] /usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_setup': /usr/local/include/libusb-1.0/libusb.h:1464:39: error: cast increases required alignment of target type [-Werror=cast-align] /usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_transfer': /usr/local/include/libusb-1.0/libusb.h:1509:39: error: cast increases required alignment of target type [-Werror=cast-align] cc1: all warnings being treated as errors This actually can lead to failure to build from the sources for certain projects which use -Werror=cast-align on ARM. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* hotplug: Document LIBUSB_HOTPLUG_ENUMERATE gotchasHans de Goede2013-08-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | When libusb_hotplug_register_callback gets called with the LIBUSB_HOTPLUG_ENUMERATE flag, there may still be hotplug events pending in the hotplug pipe, waiting for dispatching from libusb_handle_events. This means that the user callback can be called twice for arrival of the same device, once from libusb_hotplug_register_callback, since the device is already part of the usb_devs list, and once from libusb_handle_events when it reads the event from the hotplug pipe. This could be fixed by adding a mechanism to pause hotplug handling, then drain the hotplug pipe (ie by calling libusb_handle_events from libusb_hotplug_register_callback), before iterating over the usb_devs list, and then un-pausing hotplug handling afterwards, doing this however requires a lot of hairy code, which will be prone to dead-locking. OTOH it is quite simple for user applications which care about this to detect this and ignore the 2nd call, so lets simply document this may happen and be done with it. Note that this is also the solution which ie libudev has choosen, there is no way with libudev to get a device-list + listen for device arrival / removal without running into the same problem. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* fixed some clang -Wdocumentation warnings from bad doxygen markupSean McBride2013-07-301-2/+2
|
* Doc: update hotplug, topology and descriptor documentationPete Batard2013-07-041-3/+3
| | | | | * Also fix some typos * Closes #95
* Fix several -Wconversion warnings from GCC inside the static inline functions.Luca Longinotti2013-06-191-9/+9
| | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* libusb: Add auto-detach-kernel-driver functionalityHans de Goede2013-06-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Add auto-detach-kernel-driver functionality, and a libusb_set_auto_detach_kernel_driver() function. Note that I went with a libusb_set_auto_detach_kernel_driver() function, rather then with a libusb_enable_auto_detach_kernel_driver(), so that apps can also disable it again. This is necessary to handle 2 corner cases: 1) When an app wants to do a libusb_set_configuration after claiming 1 or more interfaces, it needs to first release the interface(s), and in this case libusb_release_interface() should *not* (re-)attach the kernel driver 2) Some usb classes use multiple interfaces for one function, ie usb-audio devices do this. In this case attaching the driver will fail until all interfaces are released, so the app should first release all interfaces, and only then (re-)attach the kernel driver. auto-detach-kernel-driver functionality is still useful for these apps, since doing libusb_detach_kernel_driver() followed by libusb_claim_interface() in 2 separate calls is inherently racy, but they need to be able to disable the auto-detach functionality before releasing interfaces to be able to properly handle the 2 described corner cases. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Core: Add a libusb_strerror() functionHans de Goede2013-06-101-4/+10
| | | | | | | | | | | | | | | | | | | This patch adds the much requested libusb_strerror() function, taking into account all issues people raised wrt previous attempts. Criteria / Decisions underlying this implementation: - Must support translated messages - Must not use gettext as that does not work well in combination with Windows (when building with Visual C, or for Windows CE) - API compatible with FreeBSD and various patched libusb-s floating around - KISS: - Do not add any (other) library dependencies - Do not try to deal with message encodings (iconv), simply always return UTF-8 making encoding the problem of the application using libusb_strerror. - Defaults to English, so apps which don't want translated messages, don't need to do anything special - Defaults to English (with pure ASCII messages), so apps which don't call libusb_setlocale() don't need to worry about encoding
* Add BOS descriptor supportHans de Goede2013-05-301-0/+230
| | | | | | | Based on earlier work done on this by Maya Erez <merez@codeaurora.org>, Nathan Hjelm <hjelmn@me.com> and Pete Batard <pete@akeo.ie>. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Add superspeed endpoint companion descriptor supportHans de Goede2013-05-301-3/+58
| | | | | | | Based on earlier work done on this by Maya Erez <merez@codeaurora.org>, Nathan Hjelm <hjelmn@me.com> and Pete Batard <pete@akeo.ie>. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* core: Add a new public libusb_get_port_numbers functionHans de Goede2013-05-171-1/+10
| | | | | | | | | | | | This new function replaces the now deprecated libusb_get_port_path function, as that is the only function operating on a libusb_device which also takes a libusb_context, which is rather inconsistent. Note we will keep libusb_get_port_path around in the 1.0.x for the forseeable future for ABI compatibility reasons, but it should not be used in any new code. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Bump LIBUSBX_API_VERSION for new hotplug APIHans de Goede2013-05-151-1/+15
| | | | | | And document the minimum version under which hotplug is supported Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Add hotplug support.Nathan Hjelm2013-05-151-0/+103
| | | | | | | | | | | | | | | | | | | | | | | | The internal API is changing as follows: - Adding two new functions. usbi_connect_device, and usbi_disconnect_device. Backends must call these functions to add them to the context's device list at one of two places: initial enumeration (done at init), and on device attach and removal. These functions need to be called once per context. - Backends that support hotplug should not provide a get_device_list funtion. This function is now deprecated and will likely be removed once all backends support hotplug. The external API is changing as follows: - Two new functions have been added to register and deregister callbacks for hotplug notification: libusb_hotplug_register_callback(), libusb_hotplug_deregister_callback(). Hotplug callbacks are called by libusb_handle_events(). Details of the new API can be found in libusb.h. - A new capability check has been added to check for hotplug support. See LIBUSB_CAP_HAS_HOTPLUG. Aa suggested by Xiaofan add new example has been added to show how to use the new external hotplug API. See examples/hotplugtest.c. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* libusb.h: Correct errors in doxygen comment for struct libusb_deviceHans de Goede2013-04-231-2/+2
| | | | | | | | The comment refers to the non-existing libusb_device_ref and libusb_device_unref functions, this should be libusb_ref_device resp. libusb_unref_device. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Core: Add HID and kernel detach capability detection for all backendsPete Batard2013-04-021-2/+12
| | | | | | | | | | * Also remove Linux special case from xusb sample. * Note that LIBUSBX_API_VERSION is incremented as a result of libusb_has_capability() returning nonzero rather than 1 when a capability is supported. * A LIBUSB_CAP_HAS_HOTPLUG is also added, though it is currently not implemented on any platform * Closes #102
* Misc: Simplify includes and misc. cleanupPete Batard2013-02-271-6/+6
| | | | | | | | | | | * fxload sample provenance * No need for <sys/types.h> in samples as already in libusb.h * Don't bother about sscanf_s in xusb * Use HAVE_### and rely on config.h where possible * Formal inclusion of <winsock.h> in libusb.h for WinCE and WDK * Cleanup of Windows' config.h * Avoid ENAMETOOLONG and ENOTEMPTY conflict between errno.h and winsock.h for WinCE * Additional newlines & braces cleanup
* WinCE: Add support for WinCE (sources)Toby Gray2013-01-231-2/+8
|
* libusbx-1.0.14v1.0.14Pete Batard2012-09-251-2/+2
|
* Doc: Fix doxygen warnings and issuesPete Batard2012-09-161-0/+2
| | | | | | | | * Remove obsolete tags * Use QUIET = yes to make issues more prominent * Fix code display for LIBUSBX_API_VERSION and missing parameter documentation for libusb_get_port_path() * Most of the above suggested by Ludovic Rousseau
* Core: Introduce LIBUSBX_API_VERSION macroPete Batard2012-09-151-0/+23
| | | | | | * This macro can be used to detect if the version of libusbx being compiled against has a specific API feature, as well as to detect whether compilation occurs against libusb or libusbx.
* Core: Make libusb_error_name also handle transfer status codesHans de Goede2012-09-151-0/+3
| | | | | | Note that for the code 0 which means success resp. completed we have an overlap in the codes. This is not a problem since normally one would not call libusb_error_name on success / normal completion.
* Core: Update libusb.h header in accordance with the latest USB specsPete Batard2012-09-151-7/+19
| | | | | | | | | | | | | | * IMPORTANT: This update fixes a typo in the API where MaxPower was being used instead of bMaxPower, with the latter being what is actually in the specs. * As a result, applications that were using MaxPower need to be updated for bMaxPower. * If you must maintain compatibility with libusb or older versions of libusbx, you may also want to either use a #define or copy/paste struct libusb_config_descriptor from libusb.h under a new name, and then use a cast on calls that require it. For more info, see the 1.0.13 release notes in the NEWS file. * Also update copyright notice
* Windows: Fix C4005 warning under VS2012 for inline.Anthony Clay, ZarthCode LLC2012-08-201-0/+2
| | | | | * Changed inline macro to not fire when using Visual Studio/C++, which attempts to redefine the macro - resulting in a C4005 warning.
* Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflictsPete Batard2012-07-031-11/+11
| | | | | | | | | * The LOG_LEVEL_ enums, that were moved to the public API in 933a319469bcccc962031c989e39d9d1f44f2885 may conflict with applications/headers that also define their own LOG_LEVEL_ values internally. * As a matter of fact, as per Trac #31, this produces a conflict with libusb-compat, as it defines its own levels.