diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/powermgmt.h | 1 | ||||
-rw-r--r-- | firmware/powermgmt.c | 17 |
2 files changed, 12 insertions, 6 deletions
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 29ef9eba95..e32867a188 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h | |||
@@ -130,5 +130,6 @@ int get_sleep_timer(void); | |||
130 | void set_car_adapter_mode(bool setting); | 130 | void set_car_adapter_mode(bool setting); |
131 | void reset_poweroff_timer(void); | 131 | void reset_poweroff_timer(void); |
132 | void shutdown_hw(void); | 132 | void shutdown_hw(void); |
133 | void sys_poweroff(bool halt); | ||
133 | 134 | ||
134 | #endif | 135 | #endif |
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 @@ | |||
44 | #ifdef HAVE_UDA1380 | 44 | #ifdef HAVE_UDA1380 |
45 | #include "uda1380.h" | 45 | #include "uda1380.h" |
46 | #endif | 46 | #endif |
47 | #include "logf.h" | ||
47 | 48 | ||
48 | /* | 49 | /* |
49 | * Define DEBUG_FILE to create a csv (spreadsheet) with battery information | 50 | * Define DEBUG_FILE to create a csv (spreadsheet) with battery information |
@@ -389,7 +390,7 @@ static void handle_auto_poweroff(void) | |||
389 | if(TIME_AFTER(current_tick, last_event_tick + timeout) && | 390 | if(TIME_AFTER(current_tick, last_event_tick + timeout) && |
390 | TIME_AFTER(current_tick, last_disk_activity + timeout)) | 391 | TIME_AFTER(current_tick, last_disk_activity + timeout)) |
391 | { | 392 | { |
392 | shutdown_hw(); | 393 | sys_poweroff(true); |
393 | } | 394 | } |
394 | } | 395 | } |
395 | else | 396 | else |
@@ -412,11 +413,7 @@ static void handle_auto_poweroff(void) | |||
412 | #endif | 413 | #endif |
413 | { | 414 | { |
414 | DEBUGF("Sleep timer timeout. Shutting off...\n"); | 415 | DEBUGF("Sleep timer timeout. Shutting off...\n"); |
415 | /* Make sure that the disk isn't spinning when | 416 | sys_poweroff(true); |
416 | we cut the power */ | ||
417 | while(ata_disk_is_active()) | ||
418 | sleep(HZ); | ||
419 | shutdown_hw(); | ||
420 | } | 417 | } |
421 | } | 418 | } |
422 | } | 419 | } |
@@ -877,6 +874,14 @@ void powermgmt_init(void) | |||
877 | 874 | ||
878 | #endif /* SIMULATOR */ | 875 | #endif /* SIMULATOR */ |
879 | 876 | ||
877 | void sys_poweroff(bool halt) | ||
878 | { | ||
879 | logf("sys_poweroff(%d)", halt); | ||
880 | queue_post(&button_queue, SYS_POWEROFF, NULL); | ||
881 | while(halt) | ||
882 | yield(); | ||
883 | } | ||
884 | |||
880 | /* Various hardware housekeeping tasks relating to shutting down the jukebox */ | 885 | /* Various hardware housekeeping tasks relating to shutting down the jukebox */ |
881 | void shutdown_hw(void) | 886 | void shutdown_hw(void) |
882 | { | 887 | { |