aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/android.c
Commit message (Collapse)AuthorAgeFilesLines
* usb: gadget: android: Fix product nameBenoit Goby2012-05-291-4/+1
| | | | | | | | Product names may contain spaces and scanf %s only matches the 1st word. Use strlcpy instead. Change-Id: Ie8703fea9775f7fc17fe615a42597ca3816d36b0 Signed-off-by: Benoit Goby <benoit@android.com>
* USB: gadget: f_audio_source: New gadget driver for audio outputMike Lockwood2012-05-161-0/+63
| | | | | | | This driver presents a standard USB audio class interface to the host and an ALSA PCM device to userspace Signed-off-by: Mike Lockwood <lockwood@google.com>
* USB: gadget: f_accessory: Add support for HID input devicesMike Lockwood2012-05-151-0/+5
| | | | Signed-off-by: Mike Lockwood <lockwood@google.com>
* usb: gadget: adb: Only enable the gadget when adbd is readyBenoit Goby2012-03-211-7/+111
| | | | | | | | | | | | | | | | | When adb is enabled, only connect the gadget when adbd is ready. If adbd dies or is restarted (e.g. "adb root"), the gadget is disconnected when the adb device is close, and it is re-connected once adb re-open the device. - Add callbacks to adb, similar to FunctionFs callbacks, to notify the gadget when the daemon is ready or closed. - Refcount calls to android_enable/android_disable to enable the gadget only once all the function daemons are ready. - Add enable/disble to android_usb_function to notify the function when it is added/removed from the list of enabled functions. Change-Id: Id54ff85aec9cf8715c94b4f9bd6137a79ad58bfc Signed-off-by: Benoit Goby <benoit@android.com>
* usb: gadget: android: Honor CONFIG_USB_GADGET_VBUS_DRAWScott Anderson2012-01-251-3/+0
| | | | | | | | | | | The maximum current draw was hard coded to 500 mA. composite.c has code that uses CONFIG_USB_GADGET_VBUS_DRAW to set the bMaxPower and to set whether or not the device is self-powered if they haven't been set. This change removes the code in android.c to allow composite.c to set them. Change-Id: I9db37922e91ee86e9e5c0e14519e119e5c41ca48 Signed-off-by: Scott Anderson <saa@google.com>
* usb: gadget: Fix usb string id allocationBenoit Goby2012-01-251-1/+0
| | | | | | | | | Don't reset next_string_id every time the gadget is enabled, this makes the next strings allocated overwrite strings allocated at probe time. Instead, fix rndis not to allocate new string ids on every config bind. Change-Id: Ied28ee416bb6f00c434c34176fe5b7f0dcb2b2d4 Signed-off-by: Benoit Goby <benoit@android.com>
* usb: gadget: android: Don't allow changing the functions list if enabledBenoit Goby2011-12-091-4/+24
| | | | | Change-Id: I3ad39b420ce79a8602a7eca1daac1f56b30bad5c Signed-off-by: Benoit Goby <benoit@android.com>
* usb: gadget: android: Cancel pending ctrlrequest before disablingBenoit Goby2011-11-291-0/+2
| | | | | | | | | | | | Make sure there is no pending ctrlrequest before removing the config. Otherwise the ctrlrequest complete callback could access structures after they have been freed. Unbind cancels pending transfers but not ep0 requests. Bug: 5513065 5440193 Change-Id: I063c22bf5d104a3d2df71cf622409459fac5f27a Signed-off-by: Benoit Goby <benoit@android.com>
* usb: gadget: android: Reset next_string_id before enableBenoit Goby2011-11-281-0/+1
| | | | | | | | | | Reset next_string_id to 0 before enabling the gadget driver. Otherwise, after a large number of enable/disable cycles, bind will fail because we cannot allocate new string ids. String ids cannot be larger than 254 per USB spec. Change-Id: I44f5fece45008b7a0a18c025d4eb5ce842585c28 Signed-off-by: Benoit Goby <benoit@android.com>
* usb: gadget: android: always update the sw_connected stateDima Zavin2011-09-141-5/+4
| | | | | | | | | | | | | If we go through connected->configured->disconnected cycle very quickly, it is possible that we may not generate a disconnect uevent to userspace. Connected+configured could have happened before the work item got executed, and thus would not have updated the sw_connected state. On the disconnect, it would have noticed that a config is no longer there but since sw_connected was still 0, it would not have sent the disconnect event. Change-Id: Id71175f784e3e1cf3f828bd8b24fceea1078a06b Signed-off-by: Dima Zavin <dima@android.com>
* usb: gadget: android: dump the uevents sent when changing statesDima Zavin2011-09-141-10/+12
| | | | | Change-Id: If5011e39f400b3aca036a890b8b932a7606a7ac2 Signed-off-by: Dima Zavin <dima@android.com>
* usb: gadget: android: follow proper order on disconnectDima Zavin2011-09-141-1/+7
| | | | | | | | | We should composite_disconnect *before* updating our internal state and sending uevent to userspace. Also, hold cdev->lock while updating internal state. Change-Id: If66a5a4f7d4a102a44aefc3ce4a154a5a1517dcf Signed-off-by: Dima Zavin <dima@android.com>
* USB: gadget: android: pass ctrl requests to accessory function when disabledMike Lockwood2011-09-071-2/+7
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* usb: gadget: android: Only call ctrlrequest callback on enabled functionsMike Lockwood2011-08-121-2/+1
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: Use "rndis%d" for RNDIS device name instead of "usb%d"Mike Lockwood2011-08-121-1/+1
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: f_mtp: Add PTP variant of MTP USB functionMike Lockwood2011-06-171-1/+26
| | | | | | | This is the same as MTP but with PTP interface descriptor. Also removed obsolete ioctl for switching between MTP and PTP mode Signed-off-by: Mike Lockwood <lockwood@android.com>
* usb: gadget: android: Update android gadget driverBenoit Goby2011-06-171-276/+875
| | | | | | | | | | | | | | | | | | | * Functions and the device descriptor are configured from user space: echo 0 > /sys/class/android_usb/android0/enable echo adb,acm > /sys/class/android_usb/android0/functions echo 2 > /sys/class/android_usb/android0/f_acm/instances echo 1 > /sys/class/android_usb/android0/enable * Driver does not require platform data anymore * Moved function initialization to android.c instead of each function file * Replaced switches by uevents Signed-off-by: Benoit Goby <benoit@android.com> Signed-off-by: Mike Lockwood <lockwood@android.com> Change-Id: If5ad9267c111ad0a442f0d87a0d31082dc5381b6
* USB: gadget: f_accessory: New gadget driver for android USB accesoriesMike Lockwood2011-06-171-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_accessory: Misc improvements and cleanup: - Add URI string - Replace type string with a description string - Add a control call to retrieve accessory protocol version (currently 1) - Driver read() and write() calls now fail after USB disconnect until driver file is closed and reopened. - Misc cleanup work Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_accessory: Clear accessory strings when USB is disconnected Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_accessory: Clear previous strings on ACCESSORY_GET_PROTOCOL Clearing strings on disconnect does not work since we may receive a disconnect on some devices when transitioning into accessory mode. We require an accessory to send ACCESSORY_GET_PROTOCOL before sending any strings, so any strings from a previous session will be cleared. Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_accessory: Clear disconnected flag when driver file is opened Fixes a race condition that can occur when entering accessory mode. Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_accessory: Add string for accessory's unique serial number Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_accessory: Set bNumEndpoints to correct value of 2 Change-Id: I24f4e36f196d45436e0573301500c3b93215953d Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: Fix problem switching vendor IDsMike Lockwood2011-06-141-1/+4
| | | | | | We need to update the vendor ID in the composite driver as well Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: Support switching vendor ID when configuration changesMike Lockwood2011-06-141-7/+25
| | | | | | | Based on the list of enabled USB functions, we can now switch the vendor ID as well as the product ID. Signed-off-by: Mike Lockwood <lockwood@android.com>
* usb: gadget: android: fix compilation on 2.6.37Dima Zavin2011-06-141-4/+2
| | | | | Change-Id: I9a99f007415c5be1bd1a86b138486eac51784e0d Signed-off-by: Dima Zavin <dima@android.com>
* USB: gadget: android Fix gadget descriptor compliance for IAD'sJohn Michelau2011-06-141-13/+43
| | | | | | | | | | | | | USB-IF core team mandates that composite devices containing IAD's must use bDeviceClass=0xEF, bDeviceSubClass=0x02, & bDeviceProtocol=0x01 instead of the usual 0x00 in all fields. This is not a problem currently on Linux hosts, but it is a problem when connecting to Windows hosts. Without this change the default Microsoft composite driver will not group interfaces properly, which is what allows child function drivers with IAD's to load correctly. Signed-off-by: Mike Lockwood <lockwood@android.com>
* usb: gadget: Fixed Android gadget function discovery & product matchingJohn Michelau2011-06-141-9/+56
| | | | | | | | - Don't bind until all required functions have registered - Consider multi-instance functions when matching products Change-Id: I6fa10567db71d49cd81968c01d75e326ff9a17c8 Signed-off-by: John Michelau <john.michelau@motorola.com>
* usb: gadget: android: Remove WAKEUP flag from bmAttributesBenoit Goby2011-06-141-3/+0
| | | | | | | | | Remove USB_CONFIG_ATT_WAKEUP from bmAttributes as we don't support remote wakeup. This fixes an issue with the USB 2.0 compliance test tool. Change-Id: Ic15e44710069f3f05ace6a82bbfa2b85a3649027 Signed-off-by: Benoit Goby <benoit@android.com>
* USB: gadget: android: Disable MTP when RNDIS function is enabled.Mike Lockwood2011-06-141-3/+3
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* drivers: usb: gadget: Fix section mismatch warningDmitry Shmidt2011-06-141-3/+3
| | | | Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
* USB: composite: Add usb_composite_force_reset utility to force enumerationMike Lockwood2011-06-141-9/+2
| | | | | | | | Use this rather than calling usb_gadget_disconnect and usb_gadget_connect directly to avoid sending USB disconnect events to userspace when resetting the bus. Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: Remove unused function android_usb_set_connected()Mike Lockwood2011-06-141-10/+0
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: composite: Add userspace notifications for USB state changesMike Lockwood2011-06-141-4/+4
| | | | | | | | | | | | Add switch to notify current USB configuration. This can be used to detect USB connect and disconnect events. Broadcast a change via the usb_composite class when a USB function is enabled or disabled. Rename usb_function.hidden to usb_function.disabled. Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: check for null _android_dev in android_register_function()Mike Lockwood2011-06-141-1/+1
| | | | | | | This fixes a load ordering issue that occurred if a function driver loads before the android gadget driver is initialized. Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: Disable UMS when RNDIS ethernet is active.Mike Lockwood2011-06-141-7/+20
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* Add USB_ANDROID_RNDIS_WCEIS option.Steve Kondik2011-06-141-0/+4
| | | | | Change-Id: I85973ebfcbfae6b401fb8b402842309c72655149 Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: Fix special case for RNDIS ethernet functionMike Lockwood2011-06-141-7/+12
| | | | | | | Only set device descriptor bDeviceClass field to USB_CLASS_COMM when the RNDIS function is actually enabled. Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: Specify USB_CLASS_COMM in device descriptor if using RNDISMike Lockwood2011-06-141-0/+7
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: android: Use composite class driver for enabling and disabling functionsMike Lockwood2011-06-141-0/+1
| | | | Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: android USB gadget improvements:Mike Lockwood2011-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | usb: gadget: f_mass_storage: use dev_set_name() Replacing strcpy() to device->bus_id which no longer exists in 2.6.32 Change-Id: Id978c881f457044c750bfd62f4c5bcc35bcd4fc5 Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_adb: Claim endpoints so they are not reused by another function. Change-Id: Ic9536cca800162e701c81cab36054f51ea759b72 Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_acm: Fix crashes in acm_set_alt() Change-Id: I91b761d392f8b1ca8784c69069b43e402b90d6a4 Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: f_acm: Include android code only if CONFIG_USB_ANDROID_ACM is set. Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: Android support for RNDIS serial ethernet function. Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: android: Add function name to android_register_function printk. Change-Id: I38bf79d9b544cdeaec9385f7482a131417fc4b23 Signed-off-by: Mike Lockwood <lockwood@android.com>
* USB: gadget: android: android USB gadget improvements:Krishna, Vamsi2011-06-141-84/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | USB: android gadget: add remote wakeup attribute to android function Add remote wakeup attribute to configuration descriptor of android function to advertise remote wakeup capability to host Acked-by: Allam, Suresh Reddy <sallam@qualcomm.com> Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: android: Allow functions to handle setup requests. Signed-off-by: Mike Lockwood <lockwood@android.com> Support for specifying the list of USB functions from platform data. The main android.c gadget driver no longer has hard coded references to the mass_storage and adb functions. Support for computing the product ID based on tables in platform data and the currently enabled functions. Moved the adb enable/disable logic from android.c to f_adb.c. Change-Id: I6259d3fb1473ed973f700e55d17744956f3527bb Signed-off-by: Mike Lockwood <lockwood@android.com>
* android_usb: Composite USB gadget driver for android.Mike Lockwood2011-06-141-0/+351
Change-Id: I4101540916b73a5f4e48684727ff782f98b969c7 Signed-off-by: Mike Lockwood <lockwood@android.com> USB: android gadget: add remote wakeup attribute to android function Add remote wakeup attribute to configuration descriptor of android function to advertise remote wakeup capability to host Acked-by: Allam, Suresh Reddy <sallam@qualcomm.com> Signed-off-by: Mike Lockwood <lockwood@android.com> usb gadget: link fixes for android composite gadget Signed-off-by: Mike Lockwood <lockwood@android.com> usb gadget: Fix null pointer errors in android composite driver Signed-off-by: Mike Lockwood <lockwood@android.com> usb: gadget: android: Allow usb charging to draw up to 500mA instead of 250. Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com> usb gadget: android: Add helper function for usb_gadget_connect and disconnect. Signed-off-by: Mike Lockwood <lockwood@android.com> drivers: usb: gadget: call switch_dev_unregister in mass storage unbind callback This fixes a problem unloading the android gadget driver when built as a module Signed-off-by: Mike Lockwood <lockwood@android.com> usb: gadget: android: Add dependency on switch driver. Signed-off-by: Mike Lockwood <lockwood@android.com> USB: gadget: android: Fix USB WHQL Certification Issues Submitted on behalf of RaviKumar Vembu <ravi.v@motorola.com> Signed-off-by: Jared Suttles <jared.suttles@motorola.com> Signed-off-by: Mike Lockwood <lockwood@android.com> drivers: usb: gadget: Add "usb_mass_storage" platform driver. This will be used for configuring vendor, product and release from board file. Submitted on behalf of RaviKumar Vembu <ravi.v@motorola.com> Signed-off-by: Jared Suttles <jared.suttles@motorola.com> Signed-off-by: Mike Lockwood <lockwood@android.com> drivers: usb: gadget: Use usb_mass_storage platform device as parent for lun If a platform device is specified for the f_mass_storage function, use it as the parent driver for the lun files in sysfs. This allows a platform independent file path for controlling USB mass storage from user space. Signed-off-by: Mike Lockwood <lockwood@android.com> drivers: usb: gadget: Add platform data struct for usb_mass_storage device Signed-off-by: Mike Lockwood <lockwood@android.com> usb: gadget: mass_storage: Fix Mass Storage Panic during PC reboot Submitted on behalf of RaviKumar Vembu <ravi.v@motorola.com> Signed-off-by: Jared Suttles <jared.suttles@motorola.com> Signed-off-by: Mike Lockwood <lockwood@android.com> usb: gadget: f_mass_storage: Handle setup request correctly Signed-off-by: Mike Lockwood <lockwood@android.com> usb: gadget: f_mass_storage: Clean up wakelocks on error paths Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com> Signed-off-by: Mike Lockwood <lockwood@android.com>