summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-11-08 07:32:53 +0000
committerJens Arnold <amiconn@rockbox.org>2006-11-08 07:32:53 +0000
commitaf2d91f629c66c6ba1c3d89f1e321be184b99312 (patch)
tree28301da0265592ba7be262c248ecdbc3042ac17b
parent92eff9d293dd358195839b9fa67ba6f05579400e (diff)
downloadrockbox-af2d91f629c66c6ba1c3d89f1e321be184b99312.tar.gz
rockbox-af2d91f629c66c6ba1c3d89f1e321be184b99312.zip
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
-rw-r--r--firmware/drivers/ata_mmc.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 3b5510f43d..0920ad730b 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -976,31 +976,19 @@ void ata_spin(void)
976{ 976{
977} 977}
978 978
979#ifdef HAVE_HOTSWAP
980static void mmc_thread(void) 979static void mmc_thread(void)
981{ 980{
982 struct event ev; 981 struct event ev;
983 static long last_seen_mtx_unlock = 0; 982 static long last_seen_mtx_unlock = 0;
984 983
985 while (1) { 984 while (1) {
986 while ( queue_empty( &mmc_queue ) ) { 985 queue_wait_w_tmo(&mmc_queue, &ev, HZ);
987 if (!ata_disk_is_active())
988 {
989 if (!last_seen_mtx_unlock)
990 last_seen_mtx_unlock = current_tick;
991 if (TIME_AFTER(current_tick, last_seen_mtx_unlock+(HZ*10)))
992 {
993 call_ata_idle_notifys(false);
994 last_seen_mtx_unlock = 0;
995 }
996 }
997 }
998 queue_wait(&mmc_queue, &ev);
999 switch ( ev.id ) 986 switch ( ev.id )
1000 { 987 {
1001 case SYS_POWEROFF: 988 case SYS_POWEROFF:
1002 call_ata_idle_notifys(false); 989 call_ata_idle_notifys(false);
1003 break; 990 break;
991
1004 case SYS_USB_CONNECTED: 992 case SYS_USB_CONNECTED:
1005 call_ata_idle_notifys(false); 993 call_ata_idle_notifys(false);
1006 usb_acknowledge(SYS_USB_CONNECTED_ACK); 994 usb_acknowledge(SYS_USB_CONNECTED_ACK);
@@ -1008,6 +996,7 @@ static void mmc_thread(void)
1008 usb_wait_for_disconnect(&mmc_queue); 996 usb_wait_for_disconnect(&mmc_queue);
1009 break; 997 break;
1010 998
999#ifdef HAVE_HOTSWAP
1011 case SYS_MMC_INSERTED: 1000 case SYS_MMC_INSERTED:
1012 disk_mount(1); /* mount MMC */ 1001 disk_mount(1); /* mount MMC */
1013 queue_broadcast(SYS_FS_CHANGED, NULL); 1002 queue_broadcast(SYS_FS_CHANGED, NULL);
@@ -1017,15 +1006,30 @@ static void mmc_thread(void)
1017 disk_unmount(1); /* release "by force" */ 1006 disk_unmount(1); /* release "by force" */
1018 queue_broadcast(SYS_FS_CHANGED, NULL); 1007 queue_broadcast(SYS_FS_CHANGED, NULL);
1019 break; 1008 break;
1009#endif
1010
1011 default:
1012 if (!ata_disk_is_active())
1013 {
1014 if (!last_seen_mtx_unlock)
1015 last_seen_mtx_unlock = current_tick;
1016 if (TIME_AFTER(current_tick, last_seen_mtx_unlock+(HZ*10)))
1017 {
1018 call_ata_idle_notifys(false);
1019 last_seen_mtx_unlock = 0;
1020 }
1021 }
1022 break;
1020 } 1023 }
1021 } 1024 }
1022} 1025}
1023 1026
1027#ifdef HAVE_HOTSWAP
1024void mmc_enable_monitoring(bool on) 1028void mmc_enable_monitoring(bool on)
1025{ 1029{
1026 mmc_monitor_enabled = on; 1030 mmc_monitor_enabled = on;
1027} 1031}
1028#endif /* #ifdef HAVE_HOTSWAP */ 1032#endif
1029 1033
1030bool mmc_detect(void) 1034bool mmc_detect(void)
1031{ 1035{
@@ -1168,11 +1172,10 @@ int ata_init(void)
1168 { 1172 {
1169 if (!last_mmc_status) 1173 if (!last_mmc_status)
1170 mmc_status = MMC_UNTOUCHED; 1174 mmc_status = MMC_UNTOUCHED;
1171#ifdef HAVE_HOTSWAP 1175
1172 queue_init(&mmc_queue, true); 1176 queue_init(&mmc_queue, true);
1173 create_thread(mmc_thread, mmc_stack, 1177 create_thread(mmc_thread, mmc_stack,
1174 sizeof(mmc_stack), mmc_thread_name IF_PRIO(, PRIORITY_SYSTEM)); 1178 sizeof(mmc_stack), mmc_thread_name IF_PRIO(, PRIORITY_SYSTEM));
1175#endif
1176 tick_add_task(mmc_tick); 1179 tick_add_task(mmc_tick);
1177 initialized = true; 1180 initialized = true;
1178 } 1181 }