summaryrefslogtreecommitdiffstats
path: root/firmware/usb.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-29 00:22:42 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-29 00:22:42 +0000
commit088aaac9851d2529be2f4d2e0b301ed01b91a344 (patch)
treeb30b2d2c1cd5bb1df9867e8177453b809f26228c /firmware/usb.c
parent8855ac48db48425abac0998564fbd57148c7966b (diff)
downloadrockbox-088aaac9851d2529be2f4d2e0b301ed01b91a344.tar.gz
rockbox-088aaac9851d2529be2f4d2e0b301ed01b91a344.tar.bz2
rockbox-088aaac9851d2529be2f4d2e0b301ed01b91a344.zip
USB: Thread must remember that a host has been detected since the POWERED state is ambiguous when waiting for host. Storage access is not yet actually exclusive if not USB_INSERTED. usb_start_monitoring seems better posting USB_UNPOWERED only if USB_EXTRACTED, interpreting POWERED/INSERTED as POWERED.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29153 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usb.c')
-rw-r--r--firmware/usb.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/firmware/usb.c b/firmware/usb.c
index 91c620fdc0..13f66159ac 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -373,6 +373,9 @@ static void usb_thread(void) NORETURN_ATTR;
#endif
static void usb_thread(void)
{
+#ifdef USB_DELAYED_INSERT
+ bool host_detected = false;
+#endif
int num_acks_to_expect = 0;
long last_broadcast_tick = current_tick;
struct queue_event ev;
@@ -395,6 +398,11 @@ static void usb_thread(void)
#ifdef USB_DELAYED_INSERT
if(usb_state != USB_POWERED)
break;
+
+ if (host_detected)
+ break; /* Drivers configured but we're still USB_POWERED */
+
+ host_detected = true;
#else /* !USB_DELAYED_INSERT */
if(usb_state != USB_EXTRACTED)
break;
@@ -490,6 +498,9 @@ static void usb_thread(void)
/* Ok to broadcast disconnect now */
usb_configure_drivers(USB_EXTRACTED);
+#ifdef USB_DELAYED_INSERT
+ host_detected = false;
+#endif
break;
/* USB_UNPOWERED: USB_EXTRACTED: */
@@ -566,7 +577,7 @@ void usb_start_monitoring(void)
* before or during boot. */
#ifdef USB_DELAYED_INSERT
/* Filter the status - USB_INSERTED may happen later */
- status = (status == USB_INSERTED) ? USB_POWERED : USB_UNPOWERED;
+ status = (status == USB_EXTRACTED) ? USB_UNPOWERED : USB_POWERED;
#endif
usb_status_event(status);
@@ -749,7 +760,8 @@ bool usb_inserted(void)
#ifdef HAVE_USBSTACK
bool usb_exclusive_storage(void)
{
- return exclusive_storage_access;
+ /* Storage isn't actually exclusive until slave mode has been entered */
+ return exclusive_storage_access && usb_state == USB_INSERTED;
}
#endif /* HAVE_USBSTACK */