diff options
Diffstat (limited to 'firmware/powermgmt.c')
-rw-r--r-- | firmware/powermgmt.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 2cafd4b759..c33ad387ae 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -823,7 +823,7 @@ void powermgmt_init(void) | |||
823 | } | 823 | } |
824 | 824 | ||
825 | /* Various hardware housekeeping tasks relating to shutting down the player */ | 825 | /* Various hardware housekeeping tasks relating to shutting down the player */ |
826 | void shutdown_hw(void) | 826 | void shutdown_hw(enum shutdown_type sd_type) |
827 | { | 827 | { |
828 | charging_algorithm_close(); | 828 | charging_algorithm_close(); |
829 | audio_stop(); | 829 | audio_stop(); |
@@ -863,7 +863,17 @@ void shutdown_hw(void) | |||
863 | eeprom chips are quite slow and might be still writing the last | 863 | eeprom chips are quite slow and might be still writing the last |
864 | byte. */ | 864 | byte. */ |
865 | sleep(HZ/4); | 865 | sleep(HZ/4); |
866 | power_off(); | 866 | |
867 | switch (sd_type) { | ||
868 | case SHUTDOWN_POWER_OFF: | ||
869 | default: | ||
870 | power_off(); | ||
871 | break; | ||
872 | |||
873 | case SHUTDOWN_REBOOT: | ||
874 | system_reboot(); | ||
875 | break; | ||
876 | } | ||
867 | } | 877 | } |
868 | 878 | ||
869 | void set_poweroff_timeout(int timeout) | 879 | void set_poweroff_timeout(int timeout) |
@@ -878,10 +888,9 @@ void reset_poweroff_timer(void) | |||
878 | set_sleep_timer(sleeptimer_duration); | 888 | set_sleep_timer(sleeptimer_duration); |
879 | } | 889 | } |
880 | 890 | ||
881 | void sys_poweroff(void) | ||
882 | { | ||
883 | #ifndef BOOTLOADER | 891 | #ifndef BOOTLOADER |
884 | logf("sys_poweroff()"); | 892 | static void sys_shutdown_common(void) |
893 | { | ||
885 | /* If the main thread fails to shut down the system, we will force a | 894 | /* If the main thread fails to shut down the system, we will force a |
886 | power off after an 20 second timeout - 28 seconds if recording */ | 895 | power off after an 20 second timeout - 28 seconds if recording */ |
887 | if (shutdown_timeout == 0) { | 896 | if (shutdown_timeout == 0) { |
@@ -899,9 +908,26 @@ void sys_poweroff(void) | |||
899 | shutdown_timeout += HZ*20; | 908 | shutdown_timeout += HZ*20; |
900 | #endif | 909 | #endif |
901 | } | 910 | } |
911 | } | ||
912 | #endif /* BOOTLOADER */ | ||
902 | 913 | ||
914 | void sys_poweroff(void) | ||
915 | { | ||
916 | #ifndef BOOTLOADER | ||
917 | logf("sys_poweroff()"); | ||
918 | sys_shutdown_common(); | ||
903 | queue_broadcast(SYS_POWEROFF, 0); | 919 | queue_broadcast(SYS_POWEROFF, 0); |
904 | #endif /* BOOTLOADER */ | 920 | #endif |
921 | } | ||
922 | |||
923 | /* not to be confused with system_reboot... :( */ | ||
924 | void sys_reboot(void) | ||
925 | { | ||
926 | #ifndef BOOTLOADER | ||
927 | logf("sys_reboot()"); | ||
928 | sys_shutdown_common(); | ||
929 | queue_broadcast(SYS_REBOOT, 0); | ||
930 | #endif | ||
905 | } | 931 | } |
906 | 932 | ||
907 | void cancel_shutdown(void) | 933 | void cancel_shutdown(void) |