From 6e80ac39a5a3e7091c14db19cac791c9ddb8849f Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 5 Jul 2005 00:03:18 +0000 Subject: New poweroff handling, using the SYS_POWEROFF event, allowing plugins to save their settings before powering off. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7019 a1c6a512-1295-4272-9138-f99709370657 --- firmware/powermgmt.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'firmware/powermgmt.c') diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 519785f9c6..fdc77f680b 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -44,6 +44,7 @@ #ifdef HAVE_UDA1380 #include "uda1380.h" #endif +#include "logf.h" /* * Define DEBUG_FILE to create a csv (spreadsheet) with battery information @@ -389,7 +390,7 @@ static void handle_auto_poweroff(void) if(TIME_AFTER(current_tick, last_event_tick + timeout) && TIME_AFTER(current_tick, last_disk_activity + timeout)) { - shutdown_hw(); + sys_poweroff(true); } } else @@ -412,11 +413,7 @@ static void handle_auto_poweroff(void) #endif { DEBUGF("Sleep timer timeout. Shutting off...\n"); - /* Make sure that the disk isn't spinning when - we cut the power */ - while(ata_disk_is_active()) - sleep(HZ); - shutdown_hw(); + sys_poweroff(true); } } } @@ -877,6 +874,14 @@ void powermgmt_init(void) #endif /* SIMULATOR */ +void sys_poweroff(bool halt) +{ + logf("sys_poweroff(%d)", halt); + queue_post(&button_queue, SYS_POWEROFF, NULL); + while(halt) + yield(); +} + /* Various hardware housekeeping tasks relating to shutting down the jukebox */ void shutdown_hw(void) { -- cgit v1.2.3