platform/upstream/libusb.git
16 years agov0.9.2 release
Daniel Drake [Sat, 19 Jul 2008 22:51:28 +0000 (17:51 -0500)]
v0.9.2 release

16 years agoLinux: fix sysfs directory handling
Daniel Drake [Wed, 16 Jul 2008 14:22:12 +0000 (09:22 -0500)]
Linux: fix sysfs directory handling

The length of the directory name varies, e.g. when you have nested hubs.
Use dynamic allocation to be able to deal with any length of name.

16 years agoLinux: correct usage of MAX_PATH
David Engraf [Wed, 16 Jul 2008 14:16:38 +0000 (09:16 -0500)]
Linux: correct usage of MAX_PATH

Thanks to clarification from Artem Egorkine, MAX_PATH already includes
space for the trailing NULL.

16 years agoLinux: fix bulk/iso transfer double-cancellation
Daniel Drake [Wed, 9 Jul 2008 02:15:54 +0000 (21:15 -0500)]
Linux: fix bulk/iso transfer double-cancellation

Reset counters to 0 so that it's possible to cancel a transfer twice
without breaking things. Not sure that I want to support this properly,
but this makes it work at least.

16 years agov0.9.1 release
Daniel Drake [Sun, 29 Jun 2008 02:28:44 +0000 (21:28 -0500)]
v0.9.1 release

16 years agoAdd missing GET_CONTEXT()
Daniel Drake [Sun, 29 Jun 2008 02:24:49 +0000 (21:24 -0500)]
Add missing GET_CONTEXT()

16 years agoLinux: Compatibility with new sysfs descriptors file
Daniel Drake [Sun, 29 Jun 2008 02:18:41 +0000 (21:18 -0500)]
Linux: Compatibility with new sysfs descriptors file

As of 2.6.26, the descriptors file now includes all descriptors, not
just the active one.

16 years agoAllow user data pointer to be passed through pollfd notification API
Daniel Drake [Fri, 27 Jun 2008 03:47:05 +0000 (22:47 -0500)]
Allow user data pointer to be passed through pollfd notification API

16 years agoIntroduce contexts to the API
Daniel Drake [Wed, 25 Jun 2008 04:01:51 +0000 (23:01 -0500)]
Introduce contexts to the API

Suggested by David Zeuthen. This allows multiple libraries in the same
process to independently use libusb without interfering.

16 years agoRevert "Temporary workaround for event handling serialization issue"
Daniel Drake [Wed, 25 Jun 2008 02:31:13 +0000 (21:31 -0500)]
Revert "Temporary workaround for event handling serialization issue"

This reverts commit 2d3a1111caff40ebb87983c861ff548cdc9e5946.
This was based on the assumption that dying threads would automatically
release mutexes, which is not the case.

16 years agoOverflow handling
Daniel Drake [Sat, 21 Jun 2008 04:04:53 +0000 (23:04 -0500)]
Overflow handling

16 years agoa fix for SIGSEGV in handle_bulk_completion()
Artem Egorkine [Tue, 17 Jun 2008 23:27:38 +0000 (18:27 -0500)]
a fix for SIGSEGV in handle_bulk_completion()

We cannot dereference tpriv after calling
usbi_handle_transfer_cancellation() because that function may invoke
the user-supplied callback which may free the transfer.

16 years agoRefine configuration selection again
Daniel Drake [Tue, 17 Jun 2008 03:50:50 +0000 (22:50 -0500)]
Refine configuration selection again

At Alan Stern's suggestion, just offer the bare "set configuration" and
"get configuration" functionality, and let applications worry about the
specific race conditions and unusual situations.

16 years agodocs update
Daniel Drake [Sun, 15 Jun 2008 20:29:38 +0000 (15:29 -0500)]
docs update

Add a THANKS file, make copyright notices easily accessible, update TODO

16 years agoround up poll timeout
Daniel Drake [Sun, 15 Jun 2008 20:23:29 +0000 (15:23 -0500)]
round up poll timeout

Pointed out by Richard Röjfors, otherwise we end up busy-looping with
a poll() timeout of 0.

16 years agofix doc about libusb_open()
Felipe Balbi [Sun, 8 Jun 2008 09:34:48 +0000 (12:34 +0300)]
fix doc about libusb_open()

libusb_open() returns int instead of libusb_device_handle.

Signed-off-by: Felipe Balbi <me@felipebalbi.com>
[dsd: small correction]

16 years agoTemporary workaround for event handling serialization issue
Daniel Drake [Thu, 29 May 2008 16:26:26 +0000 (17:26 +0100)]
Temporary workaround for event handling serialization issue

Ludovic Rousseau pointed out that libusb_unlock_events() is not called
when a thread gets terminated with a signal, meaning that event waiters
will not be woken up in this case.

Add a temporary hack to libusb_event_handler_active() so that at least
the other threads will realise on the next iteration of their event
handling loop.

The real fix will likely involve reworking most of this.

16 years agoRefine libusb_set_configuration() semantics
Daniel Drake [Thu, 29 May 2008 11:35:01 +0000 (12:35 +0100)]
Refine libusb_set_configuration() semantics

Applications will generally want to set a configuration before claiming
interfaces. The problem is that the interface may already be set, and
someone else may have claimed an interface (meaning that all calls to
set_configuration will fail, even if it's for the same configuration).

There are now 2 options:
1. Use the new libusb_get_configuration() to determine active
   configuration before calling libusb_set_configuration()
2. Or just call libusb_set_configuration() as usual, which will do
   nothing if that configuration is already active.

16 years agov0.9.0 release
Daniel Drake [Sun, 25 May 2008 22:42:42 +0000 (23:42 +0100)]
v0.9.0 release

First libusb-1.0 beta release

16 years agoTake lock before raising event waiters condition
Daniel Drake [Sun, 25 May 2008 21:59:09 +0000 (22:59 +0100)]
Take lock before raising event waiters condition

This avoids a race between the user checking for active event handler
and then blocking on the condition variable

16 years agoImplement serialization of event handlers
Daniel Drake [Fri, 23 May 2008 14:57:07 +0000 (15:57 +0100)]
Implement serialization of event handlers

Now offers a mechanism to wait for events while another thread is
doing the event handling. Complicates things for MT async apps, but
then again it's a bit of a tricky combination to start with.

16 years agoallow LIBUSB_DEBUG env var to control message verbosity at runtime
Daniel Drake [Sat, 24 May 2008 20:28:31 +0000 (21:28 +0100)]
allow LIBUSB_DEBUG env var to control message verbosity at runtime

Based on ideas from Ludovic Rousseau

16 years agodon't print messages by default
Daniel Drake [Fri, 23 May 2008 14:58:11 +0000 (15:58 +0100)]
don't print messages by default

Add libusb_set_debug() API to set message verbosity.

Ludovic Rousseau pointed out that applications may close stdout/stderr
descriptors, which might then be reused.

16 years agoFix memory leak in libusb_control_transfer
Daniel Drake [Mon, 19 May 2008 14:43:27 +0000 (15:43 +0100)]
Fix memory leak in libusb_control_transfer

Pointed out by David Engraf: we weren't freeing the transfer buffer

16 years agoLinux: fix handling of ioctl failure
David Engraf [Mon, 19 May 2008 14:16:32 +0000 (15:16 +0100)]
Linux: fix handling of ioctl failure

The return value of some ioctl commands in linux_usbfs.c are not
handeled correct. The ioctl function returns != 0 and errno is set with
the error code.

16 years agocritical memory leak in handle_events
David Engraf [Mon, 19 May 2008 14:13:38 +0000 (15:13 +0100)]
critical memory leak in handle_events

This patch closes a critical memory leak in handle_events. The fds
variable is malloced but never freed. When I'm calling
handle_events with a timeout of 0, my system runs out of memory after a
few seconds.

16 years agoMore informative libusb_open() return code
Daniel Drake [Fri, 16 May 2008 22:50:20 +0000 (23:50 +0100)]
More informative libusb_open() return code

Hopefully one of the last API tweaks...

16 years agoFix endianness with descriptor handling
Daniel Drake [Fri, 16 May 2008 21:37:56 +0000 (22:37 +0100)]
Fix endianness with descriptor handling

Alan Stern pointed out that usbfs gives host-endian data, but sysfs gives
bus-endian.

16 years agoBackend documentation for porting efforts
Daniel Drake [Mon, 12 May 2008 17:46:37 +0000 (18:46 +0100)]
Backend documentation for porting efforts

Hopefully comprehensive enough for people to get started.

16 years agoLinux: fix caching of guessed configuration
Daniel Drake [Mon, 12 May 2008 14:43:30 +0000 (15:43 +0100)]
Linux: fix caching of guessed configuration

Reported and tested by Xiaofan Chen

16 years agoLinux: fix bulk transfer early completion
Rob Walker [Sun, 11 May 2008 20:14:18 +0000 (21:14 +0100)]
Linux: fix bulk transfer early completion

We were forgetting about the remaining urbs when a non-final urb
completed early.

[dsd: some touchups and a warning message for a corner case that we don't handle]

16 years agoHandle hot-unplugging
Daniel Drake [Sun, 11 May 2008 19:31:58 +0000 (20:31 +0100)]
Handle hot-unplugging

This involved moving from select() to poll() because there is no way to
distinguish usbfs's POLLERR condition with select().

16 years agoDocumentation work
Daniel Drake [Sun, 11 May 2008 15:04:35 +0000 (16:04 +0100)]
Documentation work

16 years agoEndianness of control setup packets
Daniel Drake [Sun, 11 May 2008 14:36:24 +0000 (15:36 +0100)]
Endianness of control setup packets

Document behaviour where host-endian and bus-endian (little) should be
used respectively.

Also remove packed attribute from libusb_control_setup as all fields
are naturally aligned.

16 years agoDocument that releasing interface causes SET_INTERFACE control request
Daniel Drake [Sun, 11 May 2008 14:11:59 +0000 (15:11 +0100)]
Document that releasing interface causes SET_INTERFACE control request

16 years agoSupport unconfigured devices
Daniel Drake [Sat, 10 May 2008 20:45:42 +0000 (21:45 +0100)]
Support unconfigured devices

16 years agoLinux: fix caching of active configuration for non-sysfs
Daniel Drake [Sat, 10 May 2008 19:56:44 +0000 (20:56 +0100)]
Linux: fix caching of active configuration for non-sysfs

16 years agoFetch configurations by index (not value)
Daniel Drake [Sat, 10 May 2008 13:42:43 +0000 (14:42 +0100)]
Fetch configurations by index (not value)

Otherwise there is no way to know which values to look for.

16 years agoLinux: comprehensive sysfs vs usbfs access
Daniel Drake [Fri, 9 May 2008 23:12:53 +0000 (00:12 +0100)]
Linux: comprehensive sysfs vs usbfs access

Be more flexible when certain parts of sysfs are not available.

16 years agoLinux: no need to store usbfs node path
Daniel Drake [Fri, 9 May 2008 18:38:13 +0000 (19:38 +0100)]
Linux: no need to store usbfs node path

This can be computed from bus number and device address

16 years agoRework configuration handling
Daniel Drake [Fri, 9 May 2008 13:34:31 +0000 (14:34 +0100)]
Rework configuration handling

libusb no longer caches descriptors in libusb_device but backends are
intended to be able to provide copies from memory. In the common linux
case we can use sysfs.

16 years agolibusb_get_device_list() can return negative error code
Daniel Drake [Fri, 9 May 2008 13:36:14 +0000 (14:36 +0100)]
libusb_get_device_list() can return negative error code

16 years agoLinux: fix clear_halt implementation
Daniel Drake [Thu, 8 May 2008 22:09:21 +0000 (23:09 +0100)]
Linux: fix clear_halt implementation

The ioctl expects an integer.
Bug found with the assistance of Soumen Mondal

16 years agoDocumentation work
Daniel Drake [Thu, 8 May 2008 22:04:52 +0000 (23:04 +0100)]
Documentation work

Partially based on some libusb-devel discussions

16 years agoLinux: enumerate devices and descriptors from sysfs
Daniel Drake [Mon, 5 May 2008 21:57:48 +0000 (22:57 +0100)]
Linux: enumerate devices and descriptors from sysfs

Suggested by Alan Stern. This avoids waking up any suspended USB devices.
sysfs is not available on all systems, so the usbfs mechanism is still
in place as a fallback.

16 years agodocumentation touchups
Daniel Drake [Mon, 5 May 2008 20:34:31 +0000 (21:34 +0100)]
documentation touchups

16 years agomore error code sanitization
Daniel Drake [Mon, 5 May 2008 20:17:03 +0000 (21:17 +0100)]
more error code sanitization

16 years agoIsochronous transfer helper functions
Daniel Drake [Mon, 5 May 2008 19:57:43 +0000 (20:57 +0100)]
Isochronous transfer helper functions

16 years agofree open devices on exit
Daniel Drake [Mon, 5 May 2008 16:54:33 +0000 (17:54 +0100)]
free open devices on exit

16 years agomove descriptor parsing into main library
Daniel Drake [Mon, 5 May 2008 16:47:49 +0000 (17:47 +0100)]
move descriptor parsing into main library

OS modules now provide functionality for fetching device/config
descriptors

16 years agoDetect endpoint halts and unsupported control requests
Daniel Drake [Mon, 5 May 2008 15:22:33 +0000 (16:22 +0100)]
Detect endpoint halts and unsupported control requests

16 years agoLinux: fix logical URB allocation
Daniel Drake [Mon, 5 May 2008 00:00:31 +0000 (01:00 +0100)]
Linux: fix logical URB allocation

We were allocating the wrong number of URBs for transfers of size
multiples of 16k.

16 years agoadd functionality for querying and detaching kernel driver
Daniel Drake [Sun, 4 May 2008 15:51:23 +0000 (16:51 +0100)]
add functionality for querying and detaching kernel driver

16 years agoDescriptor reading functionality
Daniel Drake [Sun, 4 May 2008 15:20:46 +0000 (16:20 +0100)]
Descriptor reading functionality

16 years agosanitized error returns from synchronous I/O functions
Daniel Drake [Sun, 4 May 2008 13:22:16 +0000 (14:22 +0100)]
sanitized error returns from synchronous I/O functions

16 years agoimplement libusb_reset_device()
Daniel Drake [Sun, 4 May 2008 13:10:19 +0000 (14:10 +0100)]
implement libusb_reset_device()

16 years agoAdd functionality to clear endpoint halt conditions
Daniel Drake [Sun, 4 May 2008 12:46:41 +0000 (13:46 +0100)]
Add functionality to clear endpoint halt conditions

16 years agoFix libusb_get_device_list return value
Daniel Drake [Sat, 3 May 2008 23:51:59 +0000 (00:51 +0100)]
Fix libusb_get_device_list return value

It was documented to return the list length, but was returning 0.

16 years agoWell-defined error codes for some operations
Daniel Drake [Sat, 3 May 2008 15:50:58 +0000 (16:50 +0100)]
Well-defined error codes for some operations

Also renamed set_interface_altsetting to set_interface_alt_setting for
better consistency

16 years agoAdd libusb_set_configuration()
Daniel Drake [Sat, 3 May 2008 15:24:11 +0000 (16:24 +0100)]
Add libusb_set_configuration()

16 years agorename LIBUSB_ERROR_NOMEM to LIBUSB_ERROR_NO_MEM
Daniel Drake [Sat, 3 May 2008 14:40:23 +0000 (15:40 +0100)]
rename LIBUSB_ERROR_NOMEM to LIBUSB_ERROR_NO_MEM
improves consistency

16 years agoLinux: better EACCES handling
Daniel Drake [Sat, 3 May 2008 13:34:54 +0000 (14:34 +0100)]
Linux: better EACCES handling

16 years agoRename reference counting API
Daniel Drake [Sat, 3 May 2008 13:26:56 +0000 (14:26 +0100)]
Rename reference counting API

This improves consistency with the naming style of other functions

16 years agoLinux: use read-only access to enumerate devices and descriptors
Daniel Drake [Sat, 3 May 2008 13:24:40 +0000 (14:24 +0100)]
Linux: use read-only access to enumerate devices and descriptors

Write access is not needed until later.
Also fix handling of open() error code.

16 years agodocument pollfd notifiers
Daniel Drake [Fri, 2 May 2008 16:45:23 +0000 (17:45 +0100)]
document pollfd notifiers

16 years agoAllow multiple interfaces to be claimed
Daniel Drake [Fri, 2 May 2008 16:33:52 +0000 (17:33 +0100)]
Allow multiple interfaces to be claimed

16 years agoDocumentation improvements
Daniel Drake [Fri, 2 May 2008 15:55:36 +0000 (16:55 +0100)]
Documentation improvements

16 years agodetect short descriptor reads
Daniel Drake [Fri, 2 May 2008 11:55:34 +0000 (12:55 +0100)]
detect short descriptor reads

16 years agoremove "references" and "referenced by" listings in documentation
Daniel Drake [Fri, 2 May 2008 11:32:46 +0000 (12:32 +0100)]
remove "references" and "referenced by" listings in documentation

16 years agoUse typedef ptr types in parameters and return types
Daniel Drake [Fri, 2 May 2008 11:32:08 +0000 (12:32 +0100)]
Use typedef ptr types in parameters and return types

This is passed through to the docs

16 years agoExpose bus number and device address
Daniel Drake [Fri, 2 May 2008 11:28:31 +0000 (12:28 +0100)]
Expose bus number and device address

16 years agostandardised error codes
Daniel Drake [Tue, 29 Apr 2008 14:26:46 +0000 (15:26 +0100)]
standardised error codes

16 years agoFix descriptor handling memory leaks
Daniel Drake [Tue, 29 Apr 2008 12:34:26 +0000 (13:34 +0100)]
Fix descriptor handling memory leaks

16 years agoRename endpoint_type to transfer_type
Daniel Drake [Sun, 27 Apr 2008 22:50:01 +0000 (23:50 +0100)]
Rename endpoint_type to transfer_type

Matches the USB specs more closely

16 years agoRemove a FIXME comment
Daniel Drake [Sun, 27 Apr 2008 22:41:24 +0000 (23:41 +0100)]
Remove a FIXME comment

it can't.

16 years agoFix unlocked flying_transfers list access
Daniel Drake [Sun, 27 Apr 2008 22:30:34 +0000 (23:30 +0100)]
Fix unlocked flying_transfers list access

16 years agoRemove libusb_cancel_transfer_sync
Daniel Drake [Sun, 27 Apr 2008 22:27:04 +0000 (23:27 +0100)]
Remove libusb_cancel_transfer_sync

This wasn't a particularly nice API. Cancellation should be handled by
the completion handler.

16 years agoremove extra timeout check
Daniel Drake [Sun, 27 Apr 2008 18:56:02 +0000 (19:56 +0100)]
remove extra timeout check

If select() didn't timeout then don't check for more timeouts

16 years agoDocumentation touchups
Daniel Drake [Sun, 27 Apr 2008 18:53:51 +0000 (19:53 +0100)]
Documentation touchups

Detail that interrupt polling interval is fixed to endpoint bInterval,
and that data may be transferred even on a timeout condition.

16 years agoadd threaded example program
Daniel Drake [Sat, 19 Apr 2008 15:17:53 +0000 (16:17 +0100)]
add threaded example program

16 years agolibusb_device mutex protection
Daniel Drake [Fri, 18 Apr 2008 22:58:54 +0000 (23:58 +0100)]
libusb_device mutex protection

16 years agomutex protection for device and handle lists
Daniel Drake [Fri, 18 Apr 2008 22:42:40 +0000 (23:42 +0100)]
mutex protection for device and handle lists

16 years agolock flying_transfers during transfer removal
Daniel Drake [Fri, 18 Apr 2008 19:00:31 +0000 (20:00 +0100)]
lock flying_transfers during transfer removal

16 years agopollfds mutex protection
Daniel Drake [Fri, 18 Apr 2008 18:59:56 +0000 (19:59 +0100)]
pollfds mutex protection

16 years agoflying_transfers mutex protection
Daniel Drake [Thu, 17 Apr 2008 17:24:54 +0000 (18:24 +0100)]
flying_transfers mutex protection

This marks the beginnings of thread safety

16 years agoLinux: fix control transfer cancellation
Daniel Drake [Thu, 17 Apr 2008 16:44:28 +0000 (17:44 +0100)]
Linux: fix control transfer cancellation

16 years agoset correct endpoint type for isochronous transfers
Daniel Drake [Mon, 14 Apr 2008 19:03:27 +0000 (20:03 +0100)]
set correct endpoint type for isochronous transfers

Pointed out by Felix Domke

16 years agoLinux: fire multiple URBs at once for split transfers
Daniel Drake [Fri, 11 Apr 2008 20:40:07 +0000 (21:40 +0100)]
Linux: fire multiple URBs at once for split transfers

This results in a significant performance increase for bulk transfers
larger than 16kb, and fixes a bug where data would be spliced and mixed
between two simultaneously submitted transfers to the same endpoint.

It also allows isochronous transfers larger than 16kb to be submitted.

This commit also improves cancellation - the library now understands
what is going on.

16 years agoConstify some return data
Daniel Drake [Tue, 1 Apr 2008 22:28:32 +0000 (23:28 +0100)]
Constify some return data

Make it clear that apps should not mess with these structures

16 years agoRename libusb_poll() to libusb_handle_events()
Daniel Drake [Sun, 30 Mar 2008 21:19:00 +0000 (22:19 +0100)]
Rename libusb_poll() to libusb_handle_events()

16 years agoIsochronous endpoint I/O
Daniel Drake [Tue, 25 Mar 2008 16:24:30 +0000 (16:24 +0000)]
Isochronous endpoint I/O

Due to variable-sized structures, this involved changing allocation
mechanism. All transfers must now be allocated and freed through
libusb.

A synchronous function is missing, and I could do with writing a few
more helper functions to simplify things.

16 years agodistcheck fix for docs
Daniel Drake [Sun, 23 Mar 2008 21:17:32 +0000 (21:17 +0000)]
distcheck fix for docs

16 years agoSupport for changing altsetting
Daniel Drake [Sun, 23 Mar 2008 21:13:14 +0000 (21:13 +0000)]
Support for changing altsetting

Will probably be suject to later consideration w.r.t. claiming of endpoints

16 years agoit's called bmRequestType
Daniel Drake [Thu, 20 Mar 2008 21:10:01 +0000 (21:10 +0000)]
it's called bmRequestType

16 years agoSave transfer flags before invoking callback
Daniel Drake [Thu, 20 Mar 2008 21:07:00 +0000 (21:07 +0000)]
Save transfer flags before invoking callback

The callback may free the transfer, in which case we can't read the flags
after it has returned.

16 years agoAPI documentation
Daniel Drake [Sat, 15 Mar 2008 16:35:12 +0000 (16:35 +0000)]
API documentation

Hopefully mostly complete. Some constants were renamed and move into
enums.

16 years agoFix get_device_list for realloc case
Vasily Khoruzhick [Sat, 15 Mar 2008 11:50:53 +0000 (13:50 +0200)]
Fix get_device_list for realloc case

get_device_list can modify pointer passed to it with realloc, but this
case wasn't handled and caused crash on my machine. Fixed

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
16 years agoBeginnings of cross-platform abstraction
Daniel Drake [Thu, 13 Mar 2008 12:36:56 +0000 (12:36 +0000)]
Beginnings of cross-platform abstraction

This also includes a libusb_get_pollfds API change

16 years agoAdd transfer flags
Daniel Drake [Mon, 10 Mar 2008 18:38:15 +0000 (18:38 +0000)]
Add transfer flags

16 years agoSimplify libusb_fill_control_transfer()
Daniel Drake [Mon, 10 Mar 2008 11:32:15 +0000 (11:32 +0000)]
Simplify libusb_fill_control_transfer()

Transfer length can be inferred from the setup packet.