summaryrefslogtreecommitdiffstats
path: root/include/usbhost
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-07-01 11:33:41 -0400
committerMike Lockwood <lockwood@android.com>2010-07-01 11:33:41 -0400
commit7a96ba436c9a2bacc64e712bdb53bd7accc5c3a9 (patch)
treec21beaa4015313b25616db50d28c713425d9696d /include/usbhost
parent4272a7ad70721acd68cf9f73c0455bda3102c80f (diff)
downloadsystem_core-7a96ba436c9a2bacc64e712bdb53bd7accc5c3a9.zip
system_core-7a96ba436c9a2bacc64e712bdb53bd7accc5c3a9.tar.gz
system_core-7a96ba436c9a2bacc64e712bdb53bd7accc5c3a9.tar.bz2
libusbhost: The client is now responsible for creating the thread that monitors the bus
This is to allow using a thread that is capable of calling through JNI to Java code to report USB device attached/removed events. Change-Id: Ia58592607a2c1f4357b31072044f5db5617d7f5b Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'include/usbhost')
-rw-r--r--include/usbhost/usbhost.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/include/usbhost/usbhost.h b/include/usbhost/usbhost.h
index d67437b..c6a443c 100644
--- a/include/usbhost/usbhost.h
+++ b/include/usbhost/usbhost.h
@@ -23,6 +23,7 @@ extern "C" {
#include <stdint.h>
+struct usb_host_context;
struct usb_endpoint_descriptor;
struct usb_descriptor_iter {
@@ -31,18 +32,31 @@ struct usb_descriptor_iter {
unsigned char* curr_desc;
};
-/* callback for notification when new USB devices are attached */
-typedef void (* usb_device_added_cb)(const char *dev_name, void *client_data);
+/* Callback for notification when new USB devices are attached.
+ * Return true to exit from usb_host_run.
+ */
+typedef int (* usb_device_added_cb)(const char *dev_name, void *client_data);
+
+/* Callback for notification when USB devices are removed.
+ * Return true to exit from usb_host_run.
+ */
+typedef int (* usb_device_removed_cb)(const char *dev_name, void *client_data);
+
+/* Call this to initialize the USB host library. */
+struct usb_host_context *usb_host_init(void);
-/* callback for notification when USB devices are removed */
-typedef void (* usb_device_removed_cb)(const char *dev_name, void *client_data);
+/* Call this to cleanup the USB host library. */
+void usb_host_cleanup(struct usb_host_context *context);
-/* Call this to start monitoring the USB bus.
+/* Call this to monitor the USB bus for new and removed devices.
+ * This is intended to be called from a dedicated thread,
+ * as it will not return until one of the callbacks returns true.
* added_cb will be called immediately for each existing USB device,
* and subsequently each time a new device is added.
* removed_cb is called when USB devices are removed from the bus.
*/
-int usb_host_init(usb_device_added_cb added_cb,
+void usb_host_run(struct usb_host_context *context,
+ usb_device_added_cb added_cb,
usb_device_removed_cb removed_cb,
void *client_data);