diff options
author | Thomas Jarosch <tomj@simonv.com> | 2011-03-08 19:33:30 +0000 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2011-03-08 19:33:30 +0000 |
commit | 5c73e34d2d81545f59c5c664da3475251a5ac3c6 (patch) | |
tree | 3fc1be9423deaaa5e6e97c54fd4eaf0ec878cc33 /firmware | |
parent | 2ebe370ca1e4b5297cc1240b3b11e15ff168a184 (diff) | |
download | rockbox-5c73e34d2d81545f59c5c664da3475251a5ac3c6.tar.gz rockbox-5c73e34d2d81545f59c5c664da3475251a5ac3c6.zip |
Bring idle poweroff to RaaA and the sim
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29543 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/powermgmt.h | 2 | ||||
-rw-r--r-- | firmware/powermgmt.c | 33 | ||||
-rw-r--r-- | firmware/target/hosted/android/powermgmt-android.c | 4 | ||||
-rw-r--r-- | firmware/target/hosted/maemo/maemo-thread.c | 10 | ||||
-rw-r--r-- | firmware/target/hosted/powermgmt.c | 2 |
5 files changed, 18 insertions, 33 deletions
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 1194432830..808c8586d8 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h | |||
@@ -164,7 +164,7 @@ void set_battery_type(int type); /* set local battery type */ | |||
164 | 164 | ||
165 | void set_sleep_timer(int seconds); | 165 | void set_sleep_timer(int seconds); |
166 | int get_sleep_timer(void); | 166 | int get_sleep_timer(void); |
167 | void handle_sleep_timer(void); | 167 | void handle_auto_poweroff(void); |
168 | void set_car_adapter_mode(bool setting); | 168 | void set_car_adapter_mode(bool setting); |
169 | void reset_poweroff_timer(void); | 169 | void reset_poweroff_timer(void); |
170 | void cancel_shutdown(void); | 170 | void cancel_shutdown(void); |
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index b1a08bff29..d9014dc047 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -81,9 +81,9 @@ enum charge_state_type charge_state = DISCHARGING; | |||
81 | 81 | ||
82 | static int shutdown_timeout = 0; | 82 | static int shutdown_timeout = 0; |
83 | 83 | ||
84 | static void handle_auto_poweroff(void); | 84 | void handle_auto_poweroff(void); |
85 | static int poweroff_timeout = 0; | 85 | static int poweroff_timeout = 0; |
86 | static long last_event_tick; | 86 | static long last_event_tick = 0; |
87 | 87 | ||
88 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 88 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
89 | /* | 89 | /* |
@@ -134,11 +134,6 @@ void battery_read_info(int *voltage, int *level) | |||
134 | *level = voltage_to_battery_level(millivolts); | 134 | *level = voltage_to_battery_level(millivolts); |
135 | } | 135 | } |
136 | 136 | ||
137 | void reset_poweroff_timer(void) | ||
138 | { | ||
139 | last_event_tick = current_tick; | ||
140 | } | ||
141 | |||
142 | #if BATTERY_TYPES_COUNT > 1 | 137 | #if BATTERY_TYPES_COUNT > 1 |
143 | void set_battery_type(int type) | 138 | void set_battery_type(int type) |
144 | { | 139 | { |
@@ -204,11 +199,6 @@ bool battery_level_safe(void) | |||
204 | #endif | 199 | #endif |
205 | } | 200 | } |
206 | 201 | ||
207 | void set_poweroff_timeout(int timeout) | ||
208 | { | ||
209 | poweroff_timeout = timeout; | ||
210 | } | ||
211 | |||
212 | /* look into the percent_to_volt_* table and get a realistic battery level */ | 202 | /* look into the percent_to_volt_* table and get a realistic battery level */ |
213 | static int voltage_to_percent(int voltage, const short* table) | 203 | static int voltage_to_percent(int voltage, const short* table) |
214 | { | 204 | { |
@@ -712,6 +702,16 @@ void shutdown_hw(void) | |||
712 | } | 702 | } |
713 | #endif /* PLATFORM_NATIVE */ | 703 | #endif /* PLATFORM_NATIVE */ |
714 | 704 | ||
705 | void set_poweroff_timeout(int timeout) | ||
706 | { | ||
707 | poweroff_timeout = timeout; | ||
708 | } | ||
709 | |||
710 | void reset_poweroff_timer(void) | ||
711 | { | ||
712 | last_event_tick = current_tick; | ||
713 | } | ||
714 | |||
715 | void sys_poweroff(void) | 715 | void sys_poweroff(void) |
716 | { | 716 | { |
717 | #ifndef BOOTLOADER | 717 | #ifndef BOOTLOADER |
@@ -790,7 +790,7 @@ int get_sleep_timer(void) | |||
790 | return 0; | 790 | return 0; |
791 | } | 791 | } |
792 | 792 | ||
793 | void handle_sleep_timer(void) | 793 | static void handle_sleep_timer(void) |
794 | { | 794 | { |
795 | if (!sleeptimer_active) | 795 | if (!sleeptimer_active) |
796 | return; | 796 | return; |
@@ -817,7 +817,6 @@ void handle_sleep_timer(void) | |||
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
820 | |||
821 | /* | 820 | /* |
822 | * We shut off in the following cases: | 821 | * We shut off in the following cases: |
823 | * 1) The unit is idle, not playing music | 822 | * 1) The unit is idle, not playing music |
@@ -830,7 +829,7 @@ void handle_sleep_timer(void) | |||
830 | * 3) We are recording, or recording with pause | 829 | * 3) We are recording, or recording with pause |
831 | * 4) The radio is playing | 830 | * 4) The radio is playing |
832 | */ | 831 | */ |
833 | static void handle_auto_poweroff(void) | 832 | void handle_auto_poweroff(void) |
834 | { | 833 | { |
835 | long timeout = poweroff_timeout*60*HZ; | 834 | long timeout = poweroff_timeout*60*HZ; |
836 | int audio_stat = audio_status(); | 835 | int audio_stat = audio_status(); |
@@ -846,7 +845,7 @@ static void handle_auto_poweroff(void) | |||
846 | } | 845 | } |
847 | #endif | 846 | #endif |
848 | 847 | ||
849 | #ifndef APPLICATION | 848 | #if !(CONFIG_PLATFORM & PLATFORM_HOSTED) |
850 | if (!shutdown_timeout && query_force_shutdown()) { | 849 | if (!shutdown_timeout && query_force_shutdown()) { |
851 | backlight_on(); | 850 | backlight_on(); |
852 | sys_poweroff(); | 851 | sys_poweroff(); |
@@ -863,7 +862,7 @@ static void handle_auto_poweroff(void) | |||
863 | !sleeptimer_active))) { | 862 | !sleeptimer_active))) { |
864 | 863 | ||
865 | if (TIME_AFTER(tick, last_event_tick + timeout) | 864 | if (TIME_AFTER(tick, last_event_tick + timeout) |
866 | #ifndef APPLICATION | 865 | #if !(CONFIG_PLATFORM & PLATFORM_HOSTED) |
867 | && TIME_AFTER(tick, storage_last_disk_activity() + timeout) | 866 | && TIME_AFTER(tick, storage_last_disk_activity() + timeout) |
868 | #endif | 867 | #endif |
869 | ) { | 868 | ) { |
diff --git a/firmware/target/hosted/android/powermgmt-android.c b/firmware/target/hosted/android/powermgmt-android.c index e5e8344315..d23fece39a 100644 --- a/firmware/target/hosted/android/powermgmt-android.c +++ b/firmware/target/hosted/android/powermgmt-android.c | |||
@@ -58,10 +58,6 @@ int battery_time(void) | |||
58 | return 0; | 58 | return 0; |
59 | } | 59 | } |
60 | 60 | ||
61 | /* could be useful to stop the service after some time of inactivity */ | ||
62 | void reset_poweroff_timer(void) {} | ||
63 | void set_poweroff_timeout(int timeout) { (void)timeout; }; | ||
64 | |||
65 | /* should always be safe on android targets, the host shuts us down before */ | 61 | /* should always be safe on android targets, the host shuts us down before */ |
66 | bool battery_level_safe(void) | 62 | bool battery_level_safe(void) |
67 | { | 63 | { |
diff --git a/firmware/target/hosted/maemo/maemo-thread.c b/firmware/target/hosted/maemo/maemo-thread.c index 8300c8f0b6..a32a563459 100644 --- a/firmware/target/hosted/maemo/maemo-thread.c +++ b/firmware/target/hosted/maemo/maemo-thread.c | |||
@@ -200,13 +200,3 @@ bool battery_level_safe(void) | |||
200 | { | 200 | { |
201 | return battery_level() >= 5; | 201 | return battery_level() >= 5; |
202 | } | 202 | } |
203 | |||
204 | /** Rockbox stubs */ | ||
205 | void set_poweroff_timeout(int timeout) | ||
206 | { | ||
207 | (void)timeout; | ||
208 | } | ||
209 | |||
210 | void reset_poweroff_timer(void) | ||
211 | { | ||
212 | } | ||
diff --git a/firmware/target/hosted/powermgmt.c b/firmware/target/hosted/powermgmt.c index d4103a0c00..bf05e5ff19 100644 --- a/firmware/target/hosted/powermgmt.c +++ b/firmware/target/hosted/powermgmt.c | |||
@@ -44,7 +44,7 @@ static void power_thread(void) | |||
44 | /* Sleep two seconds */ | 44 | /* Sleep two seconds */ |
45 | sleep(HZ*2); | 45 | sleep(HZ*2); |
46 | 46 | ||
47 | handle_sleep_timer(); | 47 | handle_auto_poweroff(); |
48 | } | 48 | } |
49 | } /* power_thread */ | 49 | } /* power_thread */ |
50 | 50 | ||