Commit Graph

42 Commits

Author SHA1 Message Date
Philip P. Moltmann 9879bb2ba2 usb-bulk-transfer: Clarify sign-iy-ness of param
Parameter is implicily converted to unsigned when assigned to the struct,
so make sure users are aware of this.

Test: compiled
Change-Id: I25ca6b24591497aa4e7ce8db262ce1099c2b7b09
2016-09-21 15:51:35 +00:00
Elliott Hughes e0a7c773ed Move libusbhost's headers into libusbhost.
Change-Id: Ic5ff65bd6456ea3cc92e0c8f9d7a6f499e58dbfc
2016-09-16 10:43:56 -07:00
Keun-young Park f6411fa1ec libusbhost: add usb_device_reset
bug: 26404209
Change-Id: I8f307d6683afe70fe334746f5be2856b79782493
2016-01-13 16:01:42 -08:00
Mike Lockwood 0dd1aab7b5 libusbhost: Fix problem reading USB string descriptors on some quirky devices
Some devices fail to send USB string descriptors if you attempt to read more
than 255 bytes

Bug: 21871761
Change-Id: Id5b8865179f80523f0ad5b6028d49dd99db2b36b
2015-06-18 13:38:31 -07:00
Mike Lockwood f68600abfc libusbhost: Add usb_device_get_version()
Change-Id: If2161178e9fe94a94faf01c102ef64f2a72d093b
2015-04-29 13:04:10 -07:00
Badhri Jagan Sridharan 754358aa80 am 0d8943c2: am e4c5b614: Merge "libusbhost: Fix IOCTL call during usb_request_cancel"
* commit '0d8943c252a21390c63a16ae0f9f1459c3212163':
  libusbhost: Fix IOCTL call during usb_request_cancel
2014-08-12 21:05:43 +00:00
Badhri Jagan Sridharan ef4087bf2b libusbhost: Fix IOCTL call during usb_request_cancel
USBDEVFS_DISCARDURB IOCTL call expects a pointer to the
the urb structure to be passed from userspace. LibusbHost
instead sends usbdevfs_urb**. Change this to usbdevfs_urb*.

Fixes Issue: https://code.google.com/p/android/issues/detail?id=74530

Change-Id: Ifb8a13857e1a9f62536f2a07c0965e9c419b7d4c
2014-08-07 14:58:31 -07:00
Mark Salyzyn 4c61e36731 am 5cdb3f92: am 6b5f4c34: am 0c7e5cda: Merge "libusbhost: Turn on -Werror"
* commit '5cdb3f92c3f307d3d348a5a7247d052af6804740':
  libusbhost: Turn on -Werror
2014-05-22 19:21:07 +00:00
Mark Salyzyn 03b876953a libusbhost: Turn on -Werror
Change-Id: Ia765b56197c28d6cde633db9c429001993f75f17
2014-05-21 12:58:38 -07:00
JP Abgrall 585ca2a3de am 0a90004b: am cae898ac: am 3754791d: Merge "libusbhost: Fix issue of multiple inotify event at same time."
* commit '0a90004be8aba909391b25643ba943db76660fe4':
  libusbhost: Fix issue of multiple inotify event at same time.
2014-05-01 23:16:12 +00:00
Bo Huang 3c1d7b34c1 libusbhost: Fix issue of multiple inotify event at same time.
libusbhost can handle multiple inotify events at same time on Kit kat.
In original implementation, the function-level ret is assigned with
length of read and used for while loop.
if want to add a new watch for subdirectory,inotify_add_watch will
update the function-level ret with watch descriptor.
It impact on while loop to do exit.

Add local result to avoid it.

Change-Id: I101041ccfd54eaac14969a45e90ab2e49bdff578
Signed-off-by: Bo Huang <bo.b.huang@intel.com>
2014-04-25 13:56:38 +08:00
Colin Cross de864c2f7d am 74a41f5a: am b659ffd7: am deb3eecd: Merge "Fix the definition of LOCAL_PATH in libusbhost/Android.mk"
* commit '74a41f5adf10fcd6211d2933ada30fe08cd894c5':
  Fix the definition of LOCAL_PATH in libusbhost/Android.mk
2014-02-22 08:28:52 +00:00
Kévin PETIT 14893ec272 Fix the definition of LOCAL_PATH in libusbhost/Android.mk
Change-Id: I870cac2f0e26644e4456743209aa45644d7e494b
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
2014-02-12 16:28:11 +00:00
Mike Lockwood d2e798b530 libusbhost: Add usb_device_set_configuration and usb_device_set_interface
usb_device_set_configuration is to support devices with multiple configurations
usb_device_set_interface supports switching between interfaces with alternate settings

Also moved zero string index checking to usb_device_get_string

Change-Id: I34610b25f135894a0cf752a33e5738d4314d7122
2014-01-13 09:54:13 -08:00
Ziv Hendel 8cc80fc894 libusbhost: It's no longer assumed that "bus/usb" exists once "bus" was created
On some devices there is a slight delay between the creation of "/dev/bus"
and "/dev/bus/usb". Previously, the code assumed that both are created in the
same time which caused "watch_existing_subdirs" to fail and libusbhost to stop
working until the device is rebooted. The fix will setup an inotify event on the
creation of the "bus/usb" so it will not be missed once it's created.

Change-Id: I17f06dd167e61573307425e48898e12ebc954093
2013-08-26 14:56:39 -07:00
Ziv Hendel a306ced1ac libusbhost: It's no longer assumed that "bus/usb" exists once "bus" was created
On some devices there is a slight delay between the creation of "/dev/bus"
and "/dev/bus/usb". Previously, the code assumed that both are created in the
same time which caused "watch_existing_subdirs" to fail and libusbhost to stop
working until the device is rebooted. The fix will setup an inotify event on the
creation of the "bus/usb" so it will not be missed once it's created.

Change-Id: I17f06dd167e61573307425e48898e12ebc954093
2013-08-20 17:51:13 -07:00
Ziv Hendel f75ea8d082 Properly handle cases of multiple inotify events
Bug: 8469799
Change-Id: Ie10242dd05becd142cc84651d5e5795e4c02270d
Signed-off-by: Igor Murashkin <iam@google.com>
Signed-off-by: Adam Hampson <ahampson@google.com>
2013-03-25 14:12:18 -07:00
Guillaume Ranquet 08c119910a libusbhost: generates a static library
due to limitations of the droidboot OS used for POS,
there's a need for a static libusbhost library.

this permits to include libusbhost in droidboot

Change-Id: I0f0c07817ad19b773b466b69fd6e997877d41b34
Signed-off-by: Guillaume Ranquet <guillaumex.ranquet@intel.com>
2012-12-10 11:12:44 +01:00
Guillaume Ranquet dea46b6657 libusbhost: permits client polling on inotify wd
Modify libusbhost to expose the inotify watch descriptor to clients

This modification permits clients to add the watch descriptor to
their polling loop so that they don't have to use a dedicated
thread only for libusbhost.

Change-Id: I615bfcd56beab978135034b228d4d93337351eab
Signed-off-by: Guillaume Ranquet <guillaumex.ranquet@intel.com>
Signed-off-by: Luc Piguet-Lacroix <lucx.piguet-lacroix@intel.com>
2012-12-10 11:12:35 +01:00
Benoit Goby f4de078388 libusbhost: Fix USB device discovery on boot
On some devices, /dev/bus/usb does not exist on boot, it is only created
when the otg port is in host mode. Use inotify to detect when /dev/bus/usb
is created and then start watching subdirectories.

Change-Id: Ic1472a5ea7a7118cdbb560cc7071ade9bcee753a
2012-08-02 12:20:25 -07:00
Benoit Goby 6cc883ca09 libusbhost: Fix possible missed "device added" notification
When a new bus is added, check for existing devices in the bus
directory, since devices may have been added before calling
inotify_add_watch.

Also add missing inotify_rm_watch calls.

Change-Id: Ie69fc995a3e8b18431099b252be86f0054fe5531
2012-08-02 12:19:30 -07:00
Steve Block 8d66c49258 Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE
Bug: 5449033
Change-Id: I9244d927f14c750cd359ebffb1fc1c355a755d5a
2012-01-03 22:32:30 +00:00
Mike Lockwood c4c00d8e6a libusbhost: Limit bulk transfer requests to 16384 bytes
Otherwise the kernel will return an EINVAL error

Change-Id: I906472a4128eb26c5be7865142bc4a52464cf5f8
Bug: 4065217

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-12 14:06:49 -05:00
Mike Lockwood b5d68a3c28 libusbhost: Save endpoint ID in usb_request struct
Change-Id: I2cf189cee67c2efbcf919c8bae1447a6cb112f02
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-02-14 08:05:40 -05:00
Mike Lockwood 120b57a3d9 libusbhost: Add call for synchronous bulk transfers
Also clean up and add timeout to control request transfer

Change-Id: Ibc2d8ac64d0fa90e0a23e6225ce2c49b23bb0d97
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-01-27 16:21:56 -08:00
Mike Lockwood ec9e7b1c18 libusbhost: Add usb_device_connect_kernel_driver()
This can be used to ask the kernel to disconnect its driver for a device
so usb_device_claim_interface() can claim it instead.

Also increased size of descriptor buffer and added some debugging logs

Change-Id: I4945196d957fb8493716eb9b7e5463c06b168ef1
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-01-22 14:10:04 -08:00
Mike Lockwood e533c5f100 libusbhost: Support for multiple pending requests on a single endpoint
Add new usb_request struct to replace usb_endpoint, which is no longer needed.

Change-Id: Ia3637b3431a3597caced41bfec677ef0b044a453
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-01-06 09:21:13 -05:00
Mike Lockwood 7d700f8bdc libusbhost: Add usb_device_get_name_from_unique_id()
This allows converting from unique IDs to USB device names

Change-Id: I8e3b300790c01383aed8e3d4f547b54bcb7c2cd4
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-12-29 09:27:16 -05:00
Mike Lockwood 123538954b Change libusbhost from static to shared library
Change-Id: I0c16cc4536c4ab700c33433c8a6323ade7cfc95d
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-12-29 08:33:24 -05:00
Mike Lockwood 93aff72d9b libusbhost: Fix breakage due to not storing dev_name in struct usb_device
Change-Id: Iefac9b31f900edb2dbd594f9eff9113b2038757d
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-12-15 12:58:04 -08:00
Mike Lockwood 50372073d2 libusbhost: Add accessor for the USB device descriptor
Change-Id: Ic3a54e2a06f3b4fa72f99b64025a911fbf525daf
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-12-13 19:08:27 -08:00
Mike Lockwood cd185f23cc libusbhost: Add support for creating a usb_device struct from an existing fd
We will use this for sharing USB file descriptors across address spaces via Binder

Change-Id: Iadbd3e0a4178f79d1d778fdfd5175f6fe0e2aaf5
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-12-13 19:08:14 -08:00
Mike Lockwood 07eb4af174 libusbhost: add usb_device_get_unique_id_from_name()
Change-Id: Idce54fc26d0432d4dc46f605623c4960c0e8690f
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-07-27 19:05:33 -04:00
Mike Lockwood 1b7d991b43 libusbhost: Add usb_device_send_control for sending raw commands on endpoint 0.
Change-Id: If883f2690c4031b9ba4d5cf943b5bf5c13193bce
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-07-24 13:57:57 -04:00
Mike Lockwood e8849d190a libusbhost: Fix deadlock on devices without USB host support.
Change-Id: Ic91f99d1169fcdc00474dd6a870eb7e614128bc2
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-07-20 16:31:42 -04:00
Mike Lockwood a805519cee libusbhost: Add callback to usb_host_run to notify when initial device discovery is done
This can be used to eliminate race conditions in clients that operate immediately
on the currently connected device list.

Signed-off-by: Mike Lockwood <lockwood@android.com>

Change-Id: I14954b9fcc84239950ead6bdc1a0a888882c2226
2010-07-20 09:50:56 -04:00
Mike Lockwood 7a96ba436c 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>
2010-07-01 11:33:41 -04:00
Mike Lockwood e15af09876 libusbhost: Use logcat for debugging when building device library.
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-06-10 10:22:38 -04:00
Mike Lockwood 203f102028 libusbhost: Added usb_device_get_unique_id
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-06-01 22:18:04 -04:00
Mike Lockwood 6ac3aa1574 libusbhost: Remove global data to allow multiple instances in the same process.
Change-Id: I977145f44131ec8b588dd274e0afbc563f3aa4c0
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-05-25 08:20:32 -04:00
Mike Lockwood 5e567cb34b libusbhost: add usb_endpoint_get_device()
Change-Id: Ibe4ce0551faca5d2d8bec0fbd21315a393b9f208
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-05-12 08:53:49 -04:00
Mike Lockwood 30ff2c70ce libusbhost: new library for Linux USB host support.
Supports access to Linux usbdevfs on both device and Linux host.

Change-Id: Ie88a5193be3ee715792b10b34b3da32ffc4ca57b
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-05-10 11:37:26 -04:00