platform/upstream/libusb.git
13 years agoAdd missing argument to libusb_wait_for_event() documentation, fix #55
Ludovic Rousseau [Thu, 24 Jun 2010 08:14:24 +0000 (10:14 +0200)]
Add missing argument to libusb_wait_for_event() documentation, fix #55

In the libusb_wait_for_event() sample code in the section "Letting other
threads do the work for you" the call to libusb_wait_for_event() was not
updated by commit 1df713d622ab4f0b03aad72d903ac7beb8fb3b90, which added
the libusb_context *ctx parameter to the function, so the sample code
was broken until now.

13 years agoexamples: Silence warnings about return value of fwrite()
Peter Stuge [Sat, 16 Oct 2010 12:22:30 +0000 (14:22 +0200)]
examples: Silence warnings about return value of fwrite()

13 years agoLinux: Don't free() URBs prematurely on hardware error; fix #54
Peter Stuge [Sat, 16 Oct 2010 09:47:14 +0000 (11:47 +0200)]
Linux: Don't free() URBs prematurely on hardware error; fix #54

When an URB in a multi-URB transfer had an error, handle_bulk_completion()
would free all URBs and segfault once the next one completed, instead of
cancelling the remaining URBs and cleaning up as usual.

This is basically the patch from the ticket, plus some restructuring
for increased readability of the function.

Many thanks to Brian Shirley and National Instruments for finding and
fixing this!

13 years agoWindows: add support for filter drivers
Pete Batard [Tue, 5 Oct 2010 11:43:41 +0000 (12:43 +0100)]
Windows: add support for filter drivers

* precedence is driver > upper filter > lower filter, and defined
  in struct driver_lookup lookup from set_device_paths()

13 years agoWindows: fix errcode shadow warning, and string and DLL_DECLARE fixes
Pete Batard [Tue, 5 Oct 2010 11:36:49 +0000 (12:36 +0100)]
Windows: fix errcode shadow warning, and string and DLL_DECLARE fixes

* use FormatMessageA, and overall improvement of windows_error_str()
* use safe_strlen() always
* better typing/init default
* more explicit debug message for devices with no driver

13 years agoWindows: use IOCTLs for HID input, output and feature reports
Pete Batard [Tue, 5 Oct 2010 11:29:32 +0000 (12:29 +0100)]
Windows: use IOCTLs for HID input, output and feature reports

* fixes feature reports not providing actual read size
  (reported by Axel Rohde http://marc.info/?m=127033070021994)
* removes the USE_HIDD_FOR_REPORTS macro
* IOCTL usage inspired from HIDAPI by Alan Ott

13 years agoFix libtool version setting
Daniel Drake [Mon, 4 Oct 2010 19:03:58 +0000 (20:03 +0100)]
Fix libtool version setting

This was being set too early to take effect.

13 years agoPopulate the pkg-config Libs.private field
Mike Frysinger [Mon, 4 Oct 2010 19:01:07 +0000 (20:01 +0100)]
Populate the pkg-config Libs.private field

13 years agoLinux: fix build failure when CLOCK_MONOTONIC does not exist
Mike Frysinger [Fri, 20 Aug 2010 04:09:46 +0000 (00:09 -0400)]
Linux: fix build failure when CLOCK_MONOTONIC does not exist

This is not available on all platforms.

13 years agoUpdate libtool version info
Daniel Drake [Mon, 4 Oct 2010 17:45:18 +0000 (18:45 +0100)]
Update libtool version info

With input from various people on the mailing list, update the libtool
versioning info and start to update this on every release.

The next libusb release will not need a change here. All following ones
will.

13 years agoUpdated documentation for unsupported Darwin/Windows calls
Pete Batard [Thu, 5 Aug 2010 15:40:09 +0000 (16:40 +0100)]
Updated documentation for unsupported Darwin/Windows calls

13 years agoWindows: Make libusb_pollfd() return error
Pete Batard [Sun, 19 Sep 2010 13:24:25 +0000 (14:24 +0100)]
Windows: Make libusb_pollfd() return error

Windows does not have numerical file descriptors but does have the
concept of event sources. Exposing these event sources will require
some careful thought and design, to be completed later.

13 years agoMinGW: Use --add-stdcall-alias linker option
Daniel Drake [Sun, 19 Sep 2010 13:21:01 +0000 (14:21 +0100)]
MinGW: Use --add-stdcall-alias linker option

Naming of symbols inside the library is inconsistent on Windows:
http://wyw.dcweb.cn/stdcall.htm

Use this linker option to add aliases which add compatibility with
the "MSVC DLL" platform when a DEF file is used. It also better matches
the appearance of the Windows API itself.

13 years agoIntroduced calling convention (for Windows)
Pete Batard [Fri, 13 Aug 2010 10:59:49 +0000 (11:59 +0100)]
Introduced calling convention (for Windows)

Under Windows, a variety of compilers and configurations are available,
meaning that the manner of parameter passing (e.g. registers vs stack)
can vary.

Match the Windows API calling convention and document this appropriately.
This calling convention will be used regardless of the configuration of
the user's development platform.

The only user-level complication is that all functions used as libusb
callbacks must use the same calling convention as libusb. The
LIBUSB_CALL macro is provided to make this easy.

Signed-off-by: Michael Plante <michael.plante@gmail.com>
Signed-off-by: Pete Batard <pbatard@gmail.com>
[dsd: slight change of strategy, add documentation]

13 years agoWindows: fix string copy in sanitize_path
Pete Batard [Sat, 7 Aug 2010 03:56:04 +0000 (21:56 -0600)]
Windows: fix string copy in sanitize_path

The NULL byte was not being copied.

13 years agoWindows: DuplicateHandle failure is not a warning
Pete Batard [Thu, 29 Jul 2010 23:30:31 +0000 (00:30 +0100)]
Windows: DuplicateHandle failure is not a warning

This is because WinUSB handles are not duplicable, and generate a
lot of these warnings.

13 years agoremoved trailing whitespaces
Pete Batard [Thu, 29 Jul 2010 23:23:05 +0000 (00:23 +0100)]
removed trailing whitespaces

13 years agoWindows: Mark interfaces as unused when releasing
Pete Batard [Thu, 5 Aug 2010 00:18:32 +0000 (18:18 -0600)]
Windows: Mark interfaces as unused when releasing

Without this important cleanup, the autoclaim code could attempt to
reuse an unclaimed interface as if it were already claimed.

13 years agoWindows: fix device path string duplication
Pete Batard [Thu, 5 Aug 2010 00:15:59 +0000 (18:15 -0600)]
Windows: fix device path string duplication

13 years agoDarwin: Cache device configuration value
Nathan Hjelm [Tue, 3 Aug 2010 03:27:38 +0000 (21:27 -0600)]
Darwin: Cache device configuration value

Cache device configuration value to bring the Darwin backend more in
line with the libusb spec. To handle buggy devices GetConfiguration is
not called unless the device has more than one configuration.

13 years agoFix inconsistencies between prototypes and definitions
Xiaofan Chen [Fri, 30 Jul 2010 14:56:43 +0000 (15:56 +0100)]
Fix inconsistencies between prototypes and definitions

This removes some warnings on cygwin regarding a name clash against
the standard library "index" function.

13 years agoDarwin: handle kIOReturnUnderrun
Hoi-Ho Chan [Wed, 28 Jul 2010 03:04:17 +0000 (21:04 -0600)]
Darwin: handle kIOReturnUnderrun

This return code indicates that the device returned a data packet
less than the max packet size. In libusb backend terms, this is
a successful transfer.

13 years agoAdd Windows support
Pete Batard [Sat, 10 Jul 2010 23:51:13 +0000 (17:51 -0600)]
Add Windows support

Via Cygwin/MinGW, libusb now has windows support.
Thanks to contributors: Michael Plante, Orin Eman, Peter Stuge,
Stephan Meyer, Xiaofan Chen.

13 years agoDarwin: write iso transfer details into correct packets
Hoi-Ho Chan [Sat, 24 Jul 2010 19:48:00 +0000 (13:48 -0600)]
Darwin: write iso transfer details into correct packets

13 years agoDarwin: fix interface object leak
Nathan Hjelm [Sat, 24 Jul 2010 19:42:57 +0000 (13:42 -0600)]
Darwin: fix interface object leak

13 years agoDarwin: clean up some debug messages
Nathan Hjelm [Sat, 24 Jul 2010 19:41:03 +0000 (13:41 -0600)]
Darwin: clean up some debug messages

13 years agoDarwin: Don't open devices during scan unless we have to unsuspend
Nathan Hjelm [Sat, 24 Jul 2010 19:39:16 +0000 (13:39 -0600)]
Darwin: Don't open devices during scan unless we have to unsuspend

13 years agoLinux: Handle early complete of multi-URB transfer
Peter Stuge [Fri, 25 Jun 2010 06:08:13 +0000 (08:08 +0200)]
Linux: Handle early complete of multi-URB transfer

14 years agoOnly compile dpfp examples when sigaction is available
Daniel Drake [Wed, 21 Jul 2010 23:49:21 +0000 (17:49 -0600)]
Only compile dpfp examples when sigaction is available

It's not available on MinGW.

14 years agoconfigure.ac: fix bashisms
Aurelien Jarno [Tue, 25 May 2010 07:32:19 +0000 (09:32 +0200)]
configure.ac: fix bashisms

14 years agoOnly include sys/time.h on appropriate platforms
Daniel Drake [Fri, 25 Jun 2010 17:01:58 +0000 (12:01 -0500)]
Only include sys/time.h on appropriate platforms

This header doesn't exist on windows.
For libusb, determine at configure-time if the header is available.
For libusb.h, use gcc predefined macros to only include the header
on platforms that need it.

14 years agoLinux: Fix log message commit
Daniel Drake [Tue, 22 Jun 2010 23:45:38 +0000 (18:45 -0500)]
Linux: Fix log message commit

Forgot to test this.

14 years agoOnly initialize the default context when it is requested
Ludovic Rousseau [Mon, 21 Jun 2010 08:19:29 +0000 (10:19 +0200)]
Only initialize the default context when it is requested

14 years agoLinux: fix log message that was being unconditionally sent to stderr (#44)
Daniel Drake [Tue, 22 Jun 2010 23:20:23 +0000 (18:20 -0500)]
Linux: fix log message that was being unconditionally sent to stderr (#44)

This message was put in place to aid libusb-compat-0.1 users, who
may run into the change that libusb-0.1 allowed you to usb_open() a
device that you don't have write access to, but libusb-1.0 does not.

As explained on the ticket this change is dangerous so it should go through
the usual logging mechanism. I also added a similar regular log message
to libusb-compat-0.1.

14 years agoFix 2 documentation typos
Ludovic Rousseau [Thu, 10 Jun 2010 16:41:27 +0000 (18:41 +0200)]
Fix 2 documentation typos

14 years agoadd AM_MAINTAINER_MODE
Ludovic Rousseau [Wed, 21 Apr 2010 14:49:33 +0000 (16:49 +0200)]
add AM_MAINTAINER_MODE

14 years agoFactorize event handler interruption code
Pete Batard [Thu, 10 Jun 2010 22:00:25 +0000 (17:00 -0500)]
Factorize event handler interruption code

This will be additionally used by the windows backend which modifies
the fd set frequently.

14 years agoAbstract low-level event handler operations
Pete Batard [Sat, 5 Jun 2010 17:14:19 +0000 (12:14 -0500)]
Abstract low-level event handler operations

The Windows backend uses something other than UNIX file descriptors
for event handling. Abstract out the operations to allow for this.

14 years agofixes the possibility of using a broken timercmp on Windows
Pete Batard [Tue, 1 Jun 2010 10:38:14 +0000 (11:38 +0100)]
fixes the possibility of using a broken timercmp on Windows

Microsoft's implementation of timercmp does not work for >= or <=.

14 years agoSwitched to standard int pointer type for windows 64-bit compat
Pete Batard [Mon, 1 Feb 2010 19:26:13 +0000 (19:26 +0000)]
Switched to standard int pointer type for windows 64-bit compat

On 64-bit Windows a pointer is 64 bit, but long is still 32 bit for
backwards compatibility.
uintptr_t nicely hides this difference and also works on Linux.

[dsd: add appropriate include]

14 years agoadded doxygen, dpfp, msvc, and xusb stuff to gitignore
Michael Plante [Tue, 9 Mar 2010 22:39:46 +0000 (16:39 -0600)]
added doxygen, dpfp, msvc, and xusb stuff to gitignore

14 years agoAdd reference counting to default context
Daniel Drake [Tue, 1 Jun 2010 00:56:34 +0000 (19:56 -0500)]
Add reference counting to default context

Michael Plante pointed out that if 2 users call libusb_init(NULL) within
a process, we end up creating 2 default contexts, one of which is lost.

Add reference counting so that the default context is reused and
destroyed only after the last user.

14 years agoFix libusb_init() error handling
Daniel Drake [Thu, 27 May 2010 23:24:49 +0000 (19:24 -0400)]
Fix libusb_init() error handling

9996ccaed7 introduced a problem in that mutexes could be destroyed
in the error handling codepath before they had been created.
Pointed out by Michael Plante.

14 years agoModify log functions to compile with MSVC6
Michael Plante [Mon, 24 May 2010 14:57:10 +0000 (11:57 -0300)]
Modify log functions to compile with MSVC6

MSVC6 does not support variadics.

14 years agoAdd type parameter to the list_for_each_entry() and _safe() macros
Pete Batard [Mon, 15 Feb 2010 01:46:05 +0000 (19:46 -0600)]
Add type parameter to the list_for_each_entry() and _safe() macros

typeof() is a GCC extension, not supported by target compilers such
as MSVC.

14 years agoFix a usbi_pollfd leak in error path
Daniel Drake [Wed, 19 May 2010 20:37:29 +0000 (17:37 -0300)]
Fix a usbi_pollfd leak in error path

I accidently missed this when applying Pete Batard's earlier patch.
Pointed out by Michael Plante.

14 years agoRename all interface parameters to usb_interface or interface_number
Pete Batard [Mon, 15 Feb 2010 01:47:30 +0000 (19:47 -0600)]
Rename all interface parameters to usb_interface or interface_number

Remove the use of the ambiguous "interface" where possible without
breaking the API.
'interface' is a preprocessor #define already associated with COM on Windows,
that can cause a conflict as soon as windows.h is included.

There are a few more places where interface is still used, which should
be changed for libusb-2.0

14 years agoStricter types and casts
Pete Batard [Mon, 17 May 2010 22:30:27 +0000 (19:30 -0300)]
Stricter types and casts

14 years agoFixes to error handling and exit codepaths
Pete Batard [Mon, 17 May 2010 22:16:54 +0000 (19:16 -0300)]
Fixes to error handling and exit codepaths

Various locks and things were being leaked/left open when handling
errors and during deinitialization.

[dsd: small tweaks]

14 years agoDarwin: Define IO_OBJECT_NULL if not already defined
Nathan Hjelm [Thu, 13 May 2010 22:38:05 +0000 (19:38 -0300)]
Darwin: Define IO_OBJECT_NULL if not already defined

Needed on Mac OSX 10.3

14 years agolibusb_cpu_to_le16: macro->static inline function
Hans Ulrich Niedermann [Fri, 29 Jan 2010 11:08:52 +0000 (12:08 +0100)]
libusb_cpu_to_le16: macro->static inline function

The libusb_cpu_to_le16 macro was a ({ ... }) expression, which
generates the following compiler warning every time it is used,
(and that is several times for every #include <libusb.h>):

libusb.h:880: warning: ISO C forbids braced-groups within expressions

With this patch, #include <libusb.h> stops generating compiler
warnings on gcc 4.4.

As libusb.h heavily relies on the use of static inline functions
those can be relied on to work properly, and there should not be
any significant difference in the code the compiler generates.

14 years agoAdd libusb_strerror() to get short error message in English from enum
Francesco [Tue, 9 Mar 2010 22:35:35 +0000 (16:35 -0600)]
Add libusb_strerror() to get short error message in English from enum

[dsd: small tweaks]

14 years agoFix libusb_device::lock memory leak
Michael Plante [Fri, 26 Feb 2010 01:39:22 +0000 (19:39 -0600)]
Fix libusb_device::lock memory leak

14 years agoWhitespace cleanup
Pete Batard [Thu, 13 May 2010 00:46:31 +0000 (21:46 -0300)]
Whitespace cleanup

14 years agoAdd internal abstraction for POSIX Threads
Peter Stuge [Mon, 10 May 2010 23:51:43 +0000 (00:51 +0100)]
Add internal abstraction for POSIX Threads

This prepares for a Windows backend without dependency on pthreads-w32.

pthread_* is renamed to usbi_* and PTHREAD_* to USBI_*.

A usbi_mutex_static_t and usbi_mutex_static_lock() and _unlock() are
introduced for statically initialized mutexes, since they may be
implemented using other types when pthreads mutexes aren't used.

Move -pthread from libusb/Makefile.am to host-specific THREAD_CFLAGS in
configure.ac. This will enable optional use of -lpthread for cygwin.

[dsd: minor tweaks, and roll in a change based on patches from Pete
Batard to only build dpfp_threaded example when we're using pthreads]

14 years agov1.0.8 release
Daniel Drake [Tue, 4 May 2010 22:01:59 +0000 (19:01 -0300)]
v1.0.8 release

14 years agoLinux: don't set SHORT_NOT_OK on bulk out URBs (#20
Daniel Drake [Thu, 22 Apr 2010 21:12:51 +0000 (18:12 -0300)]
Linux: don't set SHORT_NOT_OK on bulk out URBs (#20

Setting this flag is illegal, and the behaviour we're looking for
is already in place for host-to-device transfers without this flag.

14 years agoLinux: Handle failure to read active configuration during enumeration
Daniel Drake [Tue, 20 Apr 2010 23:14:09 +0000 (20:14 -0300)]
Linux: Handle failure to read active configuration during enumeration

14 years agoDarwin: don't reuse cached descriptors during enumeration
Nathan Hjelm [Tue, 20 Apr 2010 22:43:06 +0000 (19:43 -0300)]
Darwin: don't reuse cached descriptors during enumeration

Descriptor reuse was causing scans to return invalid information when
the device at a location has changed.

14 years agov1.0.7 release
Daniel Drake [Mon, 19 Apr 2010 22:36:55 +0000 (19:36 -0300)]
v1.0.7 release

14 years agoDocument that fd set contents are an internal implementation detail (#36)
Daniel Drake [Mon, 19 Apr 2010 22:31:12 +0000 (19:31 -0300)]
Document that fd set contents are an internal implementation detail (#36)

14 years agoLinux: correct config descriptor endianness fix
Martin Koegler [Mon, 19 Apr 2010 22:22:46 +0000 (19:22 -0300)]
Linux: correct config descriptor endianness fix

The seek_to_next_config codepath deals with both sysfs and usbfs;
make sure we only convert values in the usbfs path.

14 years agoLinux: Fix endianness handling of usbfs config descriptors (#27)
Martin Koegler [Mon, 5 Apr 2010 15:11:32 +0000 (17:11 +0200)]
Linux: Fix endianness handling of usbfs config descriptors (#27)

driver/usb/core/devio.c function usbdev_read translate the follwing files
to CPU endianess:

le16_to_cpus(&temp_desc.bcdUSB);
le16_to_cpus(&temp_desc.idVendor);
le16_to_cpus(&temp_desc.idProduct);
le16_to_cpus(&temp_desc.bcdDevice);

All other data is passed without any change.

libusb/os/linux_usbfs.c calls usbi_parse_descriptor with host_endian=1
for config descriptors. According to the kernel code, they must be
processed with host_endian=0, as they are not translated by the kernel.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
14 years agoDarwin: fix enumeration of devices with non-consecutive addresses (#23)
Nathan Hjelm [Tue, 23 Mar 2010 22:22:08 +0000 (16:22 -0600)]
Darwin: fix enumeration of devices with non-consecutive addresses (#23)

14 years agoAdd more interface classes
Bastien Nocera [Mon, 8 Mar 2010 10:50:51 +0000 (10:50 +0000)]
Add more interface classes

As used in bluez.

14 years agoDarwin: Cleanup async callback code, catch request timeouts
Nathan Hjelm [Thu, 18 Mar 2010 17:32:32 +0000 (11:32 -0600)]
Darwin: Cleanup async callback code, catch request timeouts

14 years agoDarwin: fix endianness of control setup packet
Nathan Hjelm [Thu, 18 Mar 2010 17:31:46 +0000 (11:31 -0600)]
Darwin: fix endianness of control setup packet

IOUSBLib expects the control request to be in host byte order.
Swap the request into host byte order.

14 years agoDarwin: fix memory leak in process_device
Nathan Hjelm [Mon, 15 Feb 2010 20:10:08 +0000 (14:10 -0600)]
Darwin: fix memory leak in process_device

Credit to Mike Colagrosso for finding this bug.

14 years agoDarwin: use logging functions
Nathan Hjelm [Mon, 15 Feb 2010 20:09:19 +0000 (14:09 -0600)]
Darwin: use logging functions

Use usbi_warn, usbi_err, and usbi_info instead of _usbi_log.

14 years agoDarwin: support multiple calls to libusb_init
Nathan Hjelm [Mon, 15 Feb 2010 20:07:44 +0000 (14:07 -0600)]
Darwin: support multiple calls to libusb_init

Credit to Orin Eman for finding this bug.

14 years agov1.0.6 release
Daniel Drake [Sun, 22 Nov 2009 17:20:53 +0000 (17:20 +0000)]
v1.0.6 release

14 years agolsusb example: make print_devs() static
Ludovic Rousseau [Sun, 25 Oct 2009 09:06:41 +0000 (10:06 +0100)]
lsusb example: make print_devs() static

lsusb.c:26: warning: no previous prototype for ‘print_devs’

14 years agoDarwin: fix warning in darwin_error_str()
Ludovic Rousseau [Sun, 25 Oct 2009 09:05:10 +0000 (10:05 +0100)]
Darwin: fix warning in darwin_error_str()

os/darwin_usb.c:63: warning: return discards qualifiers from pointer
target type

14 years agoDarwin: allow devices to be opened multiple times
Nathan Hjelm [Sat, 21 Nov 2009 17:06:43 +0000 (17:06 +0000)]
Darwin: allow devices to be opened multiple times

Allows libusb applications to access multiple interfaces of the same
device in the same application.

Also fixes a set alt interface bug.

14 years agoIncrease libusb_handle_events() timeout to 60 seconds
Daniel Drake [Sat, 21 Nov 2009 17:01:32 +0000 (17:01 +0000)]
Increase libusb_handle_events() timeout to 60 seconds

The internal timing seems to be working, this will be a better test of
it before we make this timeout unlimited.

14 years agoRefine timerfd header check (#18)
Daniel Drake [Sat, 21 Nov 2009 16:57:25 +0000 (16:57 +0000)]
Refine timerfd header check (#18)

Require glibc-2.9 for the working timerfd support.

14 years agov1.0.5 release
Daniel Drake [Sun, 15 Nov 2009 12:17:13 +0000 (12:17 +0000)]
v1.0.5 release

14 years agoUpdate documentation about early completion caveats
Daniel Drake [Sat, 7 Nov 2009 10:43:59 +0000 (10:43 +0000)]
Update documentation about early completion caveats

14 years agoAdd libusb_get_max_iso_packet_size() to libusb.h
Ludovic Rousseau [Sun, 25 Oct 2009 08:59:51 +0000 (09:59 +0100)]
Add libusb_get_max_iso_packet_size() to libusb.h

core.c:777: warning: no previous prototype for 'libusb_get_max_iso_packet_size'

14 years agoUse timerfd for timeout handling
Daniel Drake [Wed, 28 Oct 2009 14:48:49 +0000 (20:33 +0545)]
Use timerfd for timeout handling

Use a new file descriptor from the timerfd system calls to handle
timeouts. On supported systems, this means that there is less hassle
figuring out when the poll() timeout should be, since
libusb_get_next_timeout() will always return 0 and the timeout events will
be triggered as regular activity on the file descriptor set.

Add API function libusb_pollfds_handle_timeouts() to detect whether
you're on a platform with the timing headache, and flesh out the
surrounding documentation.

14 years agoUse AM_SILENT_RULES for building
Daniel Drake [Sat, 7 Nov 2009 10:03:07 +0000 (10:03 +0000)]
Use AM_SILENT_RULES for building

14 years agov1.0.4 release
Daniel Drake [Fri, 6 Nov 2009 21:54:08 +0000 (21:54 +0000)]
v1.0.4 release

14 years agoLinux: Add support for the new URB_BULK_CONTINUATION flag
David Moore [Fri, 6 Nov 2009 21:37:25 +0000 (21:37 +0000)]
Linux: Add support for the new URB_BULK_CONTINUATION flag

Add support for the new USBDEVFS_URB_BULK_CONTINUATION flag to libusb.

This flag, which is expected to be available in usbfs starting with
kernel 2.6.32, allows the kernel to cancel multiple URBs upon receipt
of a short packet.  This capability allows libusb to preserve data
integrity of large bulk transfers that are split into multiple URBs.
Without this support, these URBs must be canceled in userspace upon
receipt of a short packet, a race condition against future transfers
which might partially fill these canceled URBs.

This patch automatically detects whether a supported kernel is present
and enables the use of the flag when possible.

[dsd: tweaks to supported kernel detection, and some inline
 documentation of this mechanism]

14 years agoTransfer locking
Daniel Drake [Wed, 28 Oct 2009 09:28:22 +0000 (15:13 +0545)]
Transfer locking

At least on Linux, there were some possible races that could occur if
a transfer is cancelled from one thread while another thread is handling
an event for that transfer, or for if a transfer completes while it is
still being submitted from another thread, etc.

On the global level, transfers could be submitted and cancelled at the
same time.

Fix those issues with transfer-level locks.

14 years agoClarify that timeout 0 means unlimited timeout
Daniel Drake [Mon, 14 Sep 2009 07:01:24 +0000 (08:01 +0100)]
Clarify that timeout 0 means unlimited timeout

14 years agoLinux: more flexibility with monotonic clock
Daniel Drake [Fri, 11 Sep 2009 21:09:12 +0000 (22:09 +0100)]
Linux: more flexibility with monotonic clock

Some users have reported that CLOCK_MONOTONIC does not work on their
systems - I suspect it is available on x86 but perhaps not some
of the more uncommon architectures. We should fall back on
CLOCK_REALTIME in these cases.

Also, CLOCK_MONOTONIC_RAW seems even more monotonic, so we should use
that if it is available.

We now test different clock IDs during initialization to find the
best one that works.

14 years agoDarwin: handle overflows
Nathan Hjelm [Fri, 11 Sep 2009 17:00:29 +0000 (18:00 +0100)]
Darwin: handle overflows

14 years agov1.0.3 release
Daniel Drake [Thu, 27 Aug 2009 15:29:54 +0000 (21:14 +0545)]
v1.0.3 release

14 years agoDarwin: 64-bit type fixes
Toby Peterson [Sun, 23 Aug 2009 04:19:59 +0000 (10:04 +0545)]
Darwin: 64-bit type fixes

14 years agoDarwin: fix crash when reading descriptors after close
Nathan Hjelm [Sun, 23 Aug 2009 04:17:55 +0000 (10:02 +0545)]
Darwin: fix crash when reading descriptors after close

Fix a crash which occurs if the user does the following sequence on a
device: open, close, get_configuration_descriptor.

14 years agomove bug info to bug tracker
Daniel Drake [Sat, 1 Aug 2009 08:10:15 +0000 (13:55 +0545)]
move bug info to bug tracker

Protection needed: http://www.libusb.org/ticket/4
Losing data: fixed in previous commit

15 years agoLinux: try harder not to lose any data
Daniel Drake [Thu, 9 Jul 2009 21:09:04 +0000 (22:09 +0100)]
Linux: try harder not to lose any data

We would previously lose any data that was present on a cancelled URB.
Work harder to make sure this doesn't happen.

15 years agoAdd libusb_get_max_iso_packet_size()
Daniel Drake [Sun, 28 Jun 2009 18:49:10 +0000 (19:49 +0100)]
Add libusb_get_max_iso_packet_size()

As pointed out by Dennis Muhlestein, libusb_get_max_packet_size()
doesn't really do what the documentation might suggest because it
does not consider the number of transaction opportunities per
microframe.

Add a new function to do what is useful for isochronous I/O.

15 years agoLinux: fix sending of zero length bulk packets
Daniel Drake [Sat, 20 Jun 2009 21:33:21 +0000 (22:33 +0100)]
Linux: fix sending of zero length bulk packets

Note that there are is a kernel bug preventing this from working
properly at the moment, even after this fix.

15 years agoDarwin: Don't cancel transfers on timeout
Nathan Hjelm [Fri, 19 Jun 2009 21:18:44 +0000 (22:18 +0100)]
Darwin: Don't cancel transfers on timeout

...because the OS does this for us.

15 years agoDon't terminate enums with commas
Daniel Drake [Sun, 14 Jun 2009 18:23:21 +0000 (19:23 +0100)]
Don't terminate enums with commas

g++ -pedantic doesn't like this
Reported by Eberhard Mattes

15 years agov1.0.2 release
Daniel Drake [Sat, 13 Jun 2009 16:19:07 +0000 (17:19 +0100)]
v1.0.2 release

15 years agoLinux: fix config descriptor parsing on big-endian systems
Daniel Drake [Wed, 10 Jun 2009 20:42:05 +0000 (21:42 +0100)]
Linux: fix config descriptor parsing on big-endian systems

Multi-byte fields in the configuration descriptors that come back from
usbfs are always in bus endian format.

Thanks to Joe Jezak for help investigating and fixing this.

15 years agoDarwin: improve handling of disconnected devices
Nathan Hjelm [Sun, 7 Jun 2009 21:29:35 +0000 (22:29 +0100)]
Darwin: improve handling of disconnected devices

15 years agoDarwin: fix parsing of config descriptors
Nathan Hjelm [Sun, 7 Jun 2009 21:26:37 +0000 (22:26 +0100)]
Darwin: fix parsing of config descriptors

This was a confusion between configuration numbers and zero-based
configuration indexes.