From d9f7ac24f42e62a314ed76768597859a6a229743 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Wed, 8 Nov 2006 02:23:01 +0000 Subject: [PATCH] fix booboo in ata.c (SYS_POWEROFF falling into SYS_USB_CONNECTED) enable ata_idle callbacks in ata_mmc.c (calls the callbacks after 10s of real inactivity) fix builds git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11462 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps.c | 5 +++-- apps/playback.c | 4 +++- firmware/SOURCES | 2 +- firmware/drivers/ata.c | 2 ++ firmware/drivers/ata_mmc.c | 18 ++++++++++++++++++ firmware/export/ata_idle_notify.h | 3 +-- 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index a9ceae822e..115e9f7441 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -57,6 +57,7 @@ #ifdef HAVE_LCD_COLOR #include "backdrop.h" #endif +#include "ata_idle_notify.h" #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" @@ -140,7 +141,7 @@ long gui_wps_show(void) if (wps_state.paused) { settings_save(); #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) - ata_flush(); + call_ata_idle_notifys(false); #endif } } @@ -254,7 +255,7 @@ long gui_wps_show(void) audio_pause(); settings_save(); #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) - ata_flush(); /* make sure resume info is saved */ + call_ata_idle_notifys(false); /* make sure resume info is saved */ #endif } break; diff --git a/apps/playback.c b/apps/playback.c index c0558ed737..f1589ac22e 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -2780,8 +2780,10 @@ static void audio_fill_file_buffer( audio_generate_postbuffer_events(); filling = false; } - +#ifndef SIMULATOR ata_sleep(); +#endif + } static void audio_rebuffer(void) diff --git a/firmware/SOURCES b/firmware/SOURCES index df38169be3..9077d71afa 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -101,7 +101,6 @@ drivers/lcd-h300.c drivers/power.c #endif drivers/led.c -ata_idle_notify.c #ifndef SIMULATOR #ifndef TARGET_TREE drivers/adc.c @@ -117,6 +116,7 @@ drivers/ata.c #endif #endif #endif +ata_idle_notify.c drivers/button.c drivers/dac.c drivers/fat.c diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 9e20bfb87d..7dcc049b64 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -1375,6 +1375,8 @@ static void ata_thread(void) queue_wait(&ata_queue, &ev); switch ( ev.id ) { case SYS_POWEROFF: + call_ata_idle_notifys(false); + break; case SYS_USB_CONNECTED: call_ata_idle_notifys(false); #ifndef USB_NONE diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 64a7ba4bfd..3b5510f43d 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c @@ -19,6 +19,7 @@ #include #include "ata.h" #include "ata_mmc.h" +#include "ata_idle_notify.h" #include "kernel.h" #include "thread.h" #include "led.h" @@ -979,12 +980,29 @@ void ata_spin(void) static void mmc_thread(void) { struct event ev; + static long last_seen_mtx_unlock = 0; while (1) { + while ( queue_empty( &mmc_queue ) ) { + 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 ) { + case SYS_POWEROFF: + call_ata_idle_notifys(false); + break; case SYS_USB_CONNECTED: + call_ata_idle_notifys(false); usb_acknowledge(SYS_USB_CONNECTED_ACK); /* Wait until the USB cable is extracted again */ usb_wait_for_disconnect(&mmc_queue); diff --git a/firmware/export/ata_idle_notify.h b/firmware/export/ata_idle_notify.h index 491a612bdd..0428f3f9a7 100644 --- a/firmware/export/ata_idle_notify.h +++ b/firmware/export/ata_idle_notify.h @@ -35,8 +35,7 @@ #endif #define USING_ATA_CALLBACK !defined(SIMULATOR) \ - && !defined(HAVE_FLASH_DISK) \ - && !defined(HAVE_MMC) + && !defined(HAVE_FLASH_DISK) #define MAX_ATA_CALLBACKS 5 typedef bool (*ata_idle_notify)(void);