diff options
author | Nathan Hjelm <hjelmn@me.com> | 2012-11-29 14:23:26 -0700 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-05-15 17:28:06 +0200 |
commit | 7801ff94fa6e49fe98433eccc7f2e461590a6f7c (patch) | |
tree | 7d75d9c8f40471b45bbd77e8352ff602d5497c6f /libusb/libusbi.h | |
parent | 29480089519f0b52da7697c34a3bbb67d3e74a3f (diff) | |
download | android_external_libusbx-7801ff94fa6e49fe98433eccc7f2e461590a6f7c.tar.gz android_external_libusbx-7801ff94fa6e49fe98433eccc7f2e461590a6f7c.tar.bz2 android_external_libusbx-7801ff94fa6e49fe98433eccc7f2e461590a6f7c.zip |
Add hotplug support.
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>
Diffstat (limited to 'libusb/libusbi.h')
-rw-r--r-- | libusb/libusbi.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libusb/libusbi.h b/libusb/libusbi.h index b0cc53e..1b59175 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -224,6 +224,11 @@ struct libusb_context { struct list_head open_devs; usbi_mutex_t open_devs_lock; + /* A list of registered hotplug callbacks */ + struct list_head hotplug_cbs; + usbi_mutex_t hotplug_cbs_lock; + int hotplug_pipe[2]; + /* this is a list of in-flight transfer handles, sorted by timeout * expiration. URBs to timeout the soonest are placed at the beginning of * the list, URBs that will time out later are placed after, and urbs with @@ -290,6 +295,7 @@ struct libusb_device { unsigned long session_data; struct libusb_device_descriptor device_descriptor; + int attached; unsigned char os_priv[0]; }; @@ -401,6 +407,9 @@ int usbi_device_cache_descriptor(libusb_device *dev); int usbi_get_config_index_by_value(struct libusb_device *dev, uint8_t bConfigurationValue, int *idx); +void usbi_connect_device (struct libusb_device *dev); +void usbi_disconnect_device (struct libusb_device *dev); + /* Internal abstraction for poll (needs struct usbi_transfer on Windows) */ #if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) #include <unistd.h> |