1
0
Fork 0
forked from len0rd/rockbox

Fix idle monitoring to not freeze the Ondio, and add it in a more elegant way. Fixed hotswap ifdefing.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11465 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2006-11-08 07:32:53 +00:00
parent 92eff9d293
commit af2d91f629

View file

@ -976,31 +976,19 @@ void ata_spin(void)
{ {
} }
#ifdef HAVE_HOTSWAP
static void mmc_thread(void) static void mmc_thread(void)
{ {
struct event ev; struct event ev;
static long last_seen_mtx_unlock = 0; static long last_seen_mtx_unlock = 0;
while (1) { while (1) {
while ( queue_empty( &mmc_queue ) ) { queue_wait_w_tmo(&mmc_queue, &ev, HZ);
if (!ata_disk_is_active())
{
if (!last_seen_mtx_unlock)
last_seen_mtx_unlock = current_tick;
if (TIME_AFTER(current_tick, last_seen_mtx_unlock+(HZ*10)))
{
call_ata_idle_notifys(false);
last_seen_mtx_unlock = 0;
}
}
}
queue_wait(&mmc_queue, &ev);
switch ( ev.id ) switch ( ev.id )
{ {
case SYS_POWEROFF: case SYS_POWEROFF:
call_ata_idle_notifys(false); call_ata_idle_notifys(false);
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
call_ata_idle_notifys(false); call_ata_idle_notifys(false);
usb_acknowledge(SYS_USB_CONNECTED_ACK); usb_acknowledge(SYS_USB_CONNECTED_ACK);
@ -1008,6 +996,7 @@ static void mmc_thread(void)
usb_wait_for_disconnect(&mmc_queue); usb_wait_for_disconnect(&mmc_queue);
break; break;
#ifdef HAVE_HOTSWAP
case SYS_MMC_INSERTED: case SYS_MMC_INSERTED:
disk_mount(1); /* mount MMC */ disk_mount(1); /* mount MMC */
queue_broadcast(SYS_FS_CHANGED, NULL); queue_broadcast(SYS_FS_CHANGED, NULL);
@ -1017,15 +1006,30 @@ static void mmc_thread(void)
disk_unmount(1); /* release "by force" */ disk_unmount(1); /* release "by force" */
queue_broadcast(SYS_FS_CHANGED, NULL); queue_broadcast(SYS_FS_CHANGED, NULL);
break; break;
#endif
default:
if (!ata_disk_is_active())
{
if (!last_seen_mtx_unlock)
last_seen_mtx_unlock = current_tick;
if (TIME_AFTER(current_tick, last_seen_mtx_unlock+(HZ*10)))
{
call_ata_idle_notifys(false);
last_seen_mtx_unlock = 0;
}
}
break;
} }
} }
} }
#ifdef HAVE_HOTSWAP
void mmc_enable_monitoring(bool on) void mmc_enable_monitoring(bool on)
{ {
mmc_monitor_enabled = on; mmc_monitor_enabled = on;
} }
#endif /* #ifdef HAVE_HOTSWAP */ #endif
bool mmc_detect(void) bool mmc_detect(void)
{ {
@ -1168,11 +1172,10 @@ int ata_init(void)
{ {
if (!last_mmc_status) if (!last_mmc_status)
mmc_status = MMC_UNTOUCHED; mmc_status = MMC_UNTOUCHED;
#ifdef HAVE_HOTSWAP
queue_init(&mmc_queue, true); queue_init(&mmc_queue, true);
create_thread(mmc_thread, mmc_stack, create_thread(mmc_thread, mmc_stack,
sizeof(mmc_stack), mmc_thread_name IF_PRIO(, PRIORITY_SYSTEM)); sizeof(mmc_stack), mmc_thread_name IF_PRIO(, PRIORITY_SYSTEM));
#endif
tick_add_task(mmc_tick); tick_add_task(mmc_tick);
initialized = true; initialized = true;
} }