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
This commit is contained in:
Frank Gevaerts 2008-10-02 20:51:14 +00:00
parent 6d5b54081a
commit fcdffd68af

View file

@ -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,6 +901,9 @@ static void ata_thread(void)
last_seen_mtx_unlock = current_tick;
if (TIME_AFTER(current_tick, last_seen_mtx_unlock+(HZ*2)))
{
#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
if(!usb_mode)
#endif
call_ata_idle_notifys(false);
last_seen_mtx_unlock = 0;
}
@ -908,6 +914,9 @@ static void ata_thread(void)
TIME_AFTER( current_tick,
last_disk_activity + sleep_timeout ) )
{
#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,11 +949,27 @@ 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:
#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;