summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2008-10-02 20:51:14 +0000
committerFrank Gevaerts <frank@gevaerts.be>2008-10-02 20:51:14 +0000
commitfcdffd68afdc0718910702fa1bb71b5ffc7a6d1c (patch)
tree20377cdf9bc521492a55446f1fb6ec88c3de9c6b /firmware
parent6d5b54081a9420456fa47e103d13472f9285faf7 (diff)
downloadrockbox-fcdffd68afdc0718910702fa1bb71b5ffc7a6d1c.tar.gz
rockbox-fcdffd68afdc0718910702fa1bb71b5ffc7a6d1c.zip
Accept FS#8943, allow disk spindown during USB connection for software usb
Implementation by Linus Nielsen Feltzing git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18685 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/ata.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 55e4892b24..ca523d126f 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -884,6 +884,9 @@ static void ata_thread(void)
static long last_sleep = 0;
struct queue_event ev;
static long last_seen_mtx_unlock = 0;
+#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
+ static bool usb_mode = false;
+#endif
while (1) {
queue_wait_w_tmo(&ata_queue, &ev, HZ/2);
@@ -898,7 +901,10 @@ static void ata_thread(void)
last_seen_mtx_unlock = current_tick;
if (TIME_AFTER(current_tick, last_seen_mtx_unlock+(HZ*2)))
{
- call_ata_idle_notifys(false);
+#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
+ if(!usb_mode)
+#endif
+ call_ata_idle_notifys(false);
last_seen_mtx_unlock = 0;
}
}
@@ -908,7 +914,10 @@ static void ata_thread(void)
TIME_AFTER( current_tick,
last_disk_activity + sleep_timeout ) )
{
- call_ata_idle_notifys(true);
+#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
+ if(!usb_mode)
+#endif
+ call_ata_idle_notifys(true);
ata_perform_sleep();
last_sleep = current_tick;
}
@@ -940,12 +949,28 @@ static void ata_thread(void)
DEBUGF("ata_thread got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
+#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
+ usb_mode = true;
+#else
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&ata_queue);
+#endif
+ break;
+
+#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
+ case SYS_USB_DISCONNECTED:
+ /* Tell the USB thread that we are ready again */
+ DEBUGF("ata_thread got SYS_USB_DISCONNECTED\n");
+ usb_acknowledge(SYS_USB_DISCONNECTED_ACK);
+ usb_mode = false;
break;
#endif
+#endif
case Q_SLEEP:
- call_ata_idle_notifys(false);
+#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
+ if(!usb_mode)
+#endif
+ call_ata_idle_notifys(false);
last_disk_activity = current_tick - sleep_timeout + (HZ/2);
break;