summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/misc.c15
-rw-r--r--firmware/export/powermgmt.h1
-rw-r--r--firmware/powermgmt.c19
3 files changed, 20 insertions, 15 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 9e7e3948c8..67fe2688b4 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -35,6 +35,7 @@
35#include "ata.h" 35#include "ata.h"
36#include "kernel.h" 36#include "kernel.h"
37#include "power.h" 37#include "power.h"
38#include "powermgmt.h"
38#include "backlight.h" 39#include "backlight.h"
39#ifdef HAVE_MMC 40#ifdef HAVE_MMC
40#include "ata_mmc.h" 41#include "ata_mmc.h"
@@ -232,19 +233,7 @@ bool clean_shutdown(void)
232 { 233 {
233 lcd_clear_display(); 234 lcd_clear_display();
234 splash(0, true, str(LANG_SHUTTINGDOWN)); 235 splash(0, true, str(LANG_SHUTTINGDOWN));
235 mpeg_stop(); 236 shutdown_hw();
236 ata_flush();
237 ata_spindown(1);
238 while(ata_disk_is_active())
239 sleep(HZ/10);
240
241 mp3_shutdown();
242#if CONFIG_KEYPAD == ONDIO_PAD
243 backlight_off();
244 sleep(1);
245 lcd_set_contrast(0);
246#endif
247 power_off();
248 } 237 }
249#endif 238#endif
250 return false; 239 return false;
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index ce006e9145..922630097a 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -120,5 +120,6 @@ void set_sleep_timer(int seconds);
120int get_sleep_timer(void); 120int get_sleep_timer(void);
121void set_car_adapter_mode(bool setting); 121void set_car_adapter_mode(bool setting);
122void reset_poweroff_timer(void); 122void reset_poweroff_timer(void);
123void shutdown_hw(void);
123 124
124#endif 125#endif
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index cb9fb53fcb..91b09aa555 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -351,7 +351,7 @@ static void handle_auto_poweroff(void)
351 TIME_AFTER(current_tick, last_disk_activity + timeout) && 351 TIME_AFTER(current_tick, last_disk_activity + timeout) &&
352 TIME_AFTER(current_tick, last_charge_time + timeout)) 352 TIME_AFTER(current_tick, last_charge_time + timeout))
353 { 353 {
354 power_off(); 354 shutdown_hw();
355 } 355 }
356 } 356 }
357 else 357 else
@@ -375,7 +375,7 @@ static void handle_auto_poweroff(void)
375 we cut the power */ 375 we cut the power */
376 while(ata_disk_is_active()) 376 while(ata_disk_is_active())
377 sleep(HZ); 377 sleep(HZ);
378 power_off(); 378 shutdown_hw();
379 } 379 }
380 } 380 }
381 } 381 }
@@ -874,3 +874,18 @@ void powermgmt_init(void)
874 874
875#endif /* SIMULATOR */ 875#endif /* SIMULATOR */
876 876
877void shutdown_hw(void) {
878 mpeg_stop();
879 ata_flush();
880 ata_spindown(1);
881 while(ata_disk_is_active())
882 sleep(HZ/10);
883
884 mp3_shutdown();
885#if CONFIG_KEYPAD == ONDIO_PAD
886 backlight_off();
887 sleep(1);
888 lcd_set_contrast(0);
889#endif
890 power_off();
891}