diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2013-05-22 02:04:29 -0400 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2013-05-22 02:28:31 -0400 |
| commit | 7738660effc7fcb4eb70a8b408b28af7c682e547 (patch) | |
| tree | 89077bf56b445f1356763c0c1403335215a892bd | |
| parent | 39946a56d8e4c4edda8a7be22bd65a00f0bd1b2f (diff) | |
| download | rockbox-7738660effc7fcb4eb70a8b408b28af7c682e547.zip rockbox-7738660effc7fcb4eb70a8b408b28af7c682e547.tar.gz rockbox-7738660effc7fcb4eb70a8b408b28af7c682e547.tar.bz2 rockbox-7738660effc7fcb4eb70a8b408b28af7c682e547.tar.xz | |
USB: Detect charging-only mode upon cable insert, not host detect.
Letting go of the button before the host is detected allows storage mode
to be entered even though a button was down when plugging. Sometimes the
host would try several times and the button would have to be held down
for several seconds to avoid a storage connection.
The adjustment wasn't made when switching to setup request host
detection.
Change-Id: Iab3bced5bfb1478d4d9a7baab2a2a1144afaf437
| -rw-r--r-- | firmware/usb.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/firmware/usb.c b/firmware/usb.c index d749e1e..a7b19eb 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -84,6 +84,9 @@ static bool usb_hid = true; static bool usb_host_present = false; static int usb_num_acks_to_expect = 0; static long usb_last_broadcast_tick = 0; +#ifdef HAVE_USB_POWER +static bool usb_charging_only = false; +#endif #if defined(USB_FIREWIRE_HANDLING) \ || (defined(HAVE_USBSTACK) && !defined(USE_ROCKBOX_USB)) @@ -127,13 +130,15 @@ static inline bool usb_do_screendump(void) #endif /* HAVE_LCD_BITMAP */ /* Power (charging-only) button */ -static inline bool usb_power_button(void) +static inline void usb_detect_charging_only(bool detect) { #ifdef HAVE_USB_POWER - return (button_status() & ~USBPOWER_BTN_IGNORE); -#else - return false; + if (detect) + detect = button_status() & ~USBPOWER_BTN_IGNORE; + + usb_charging_only = detect; #endif + (void)detect; } #ifdef USB_FIREWIRE_HANDLING @@ -375,12 +380,14 @@ static void usb_set_host_present(bool present) return; } - if(usb_power_button()) +#ifdef HAVE_USB_POWER + if (usb_charging_only) { /* Only charging is desired */ usb_configure_drivers(USB_POWERED); return; } +#endif if(!usb_configure_drivers(USB_INSERTED)) return; /* Exclusive storage access not required */ @@ -470,6 +477,8 @@ static void NORETURN_ATTR usb_thread(void) usb_state = USB_POWERED; usb_stack_enable(true); + usb_detect_charging_only(true); + #ifndef USB_DETECT_BY_REQUEST usb_set_host_present(true); #endif @@ -496,6 +505,7 @@ static void NORETURN_ATTR usb_thread(void) usb_state = USB_EXTRACTED; + usb_detect_charging_only(false); usb_set_host_present(false); break; /* USB_EXTRACTED: */ |