diff options
author | Thomas Jarosch <tomj@simonv.com> | 2011-02-28 23:05:00 +0000 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2011-02-28 23:05:00 +0000 |
commit | 2647d11354d95bae15d3a119f482348775a77491 (patch) | |
tree | 59fc722a11eed0462af37b0a57e45cdbb88c1330 | |
parent | 3bcfd5c106e04a88d1c804eb410cbe641757ac53 (diff) | |
download | rockbox-2647d11354d95bae15d3a119f482348775a77491.tar.gz rockbox-2647d11354d95bae15d3a119f482348775a77491.zip |
Move sleep timer code outside of PLATFORM_NATIVE ifdef so RaaA can access it
Also remove redundant RaaA stubs for it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29467 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/export/powermgmt.h | 1 | ||||
-rw-r--r-- | firmware/powermgmt.c | 94 | ||||
-rw-r--r-- | firmware/target/hosted/android/powermgmt-android.c | 11 | ||||
-rw-r--r-- | uisimulator/common/stubs.c | 11 |
4 files changed, 51 insertions, 66 deletions
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 983825052e..b22518f07d 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h | |||
@@ -164,6 +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 set_car_adapter_mode(bool setting); | 168 | void set_car_adapter_mode(bool setting); |
168 | void reset_poweroff_timer(void); | 169 | void reset_poweroff_timer(void); |
169 | void cancel_shutdown(void); | 170 | void cancel_shutdown(void); |
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index f7aa4baf07..5ca698f46e 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -106,9 +106,6 @@ static const char power_thread_name[] = "power"; | |||
106 | static int poweroff_timeout = 0; | 106 | static int poweroff_timeout = 0; |
107 | static int powermgmt_est_runningtime_min = -1; | 107 | static int powermgmt_est_runningtime_min = -1; |
108 | 108 | ||
109 | static bool sleeptimer_active = false; | ||
110 | static long sleeptimer_endtick; | ||
111 | |||
112 | static long last_event_tick; | 109 | static long last_event_tick; |
113 | 110 | ||
114 | static int voltage_to_battery_level(int battery_millivolts); | 111 | static int voltage_to_battery_level(int battery_millivolts); |
@@ -204,26 +201,6 @@ void set_poweroff_timeout(int timeout) | |||
204 | poweroff_timeout = timeout; | 201 | poweroff_timeout = timeout; |
205 | } | 202 | } |
206 | 203 | ||
207 | void set_sleep_timer(int seconds) | ||
208 | { | ||
209 | if (seconds) { | ||
210 | sleeptimer_active = true; | ||
211 | sleeptimer_endtick = current_tick + seconds * HZ; | ||
212 | } | ||
213 | else { | ||
214 | sleeptimer_active = false; | ||
215 | sleeptimer_endtick = 0; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | int get_sleep_timer(void) | ||
220 | { | ||
221 | if (sleeptimer_active && (sleeptimer_endtick >= current_tick)) | ||
222 | return (sleeptimer_endtick - current_tick) / HZ; | ||
223 | else | ||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | /* look into the percent_to_volt_* table and get a realistic battery level */ | 204 | /* look into the percent_to_volt_* table and get a realistic battery level */ |
228 | static int voltage_to_percent(int voltage, const short* table) | 205 | static int voltage_to_percent(int voltage, const short* table) |
229 | { | 206 | { |
@@ -350,27 +327,8 @@ static void handle_auto_poweroff(void) | |||
350 | TIME_AFTER(tick, storage_last_disk_activity() + timeout)) { | 327 | TIME_AFTER(tick, storage_last_disk_activity() + timeout)) { |
351 | sys_poweroff(); | 328 | sys_poweroff(); |
352 | } | 329 | } |
353 | } | 330 | } else |
354 | else if (sleeptimer_active) { | 331 | handle_sleep_timer(); |
355 | /* Handle sleeptimer */ | ||
356 | if (TIME_AFTER(tick, sleeptimer_endtick)) { | ||
357 | audio_stop(); | ||
358 | |||
359 | if (usb_inserted() | ||
360 | #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) | ||
361 | || charger_input_state != NO_CHARGER | ||
362 | #endif | ||
363 | ) { | ||
364 | DEBUGF("Sleep timer timeout. Stopping...\n"); | ||
365 | set_sleep_timer(0); | ||
366 | backlight_off(); /* Nighty, nighty... */ | ||
367 | } | ||
368 | else { | ||
369 | DEBUGF("Sleep timer timeout. Shutting off...\n"); | ||
370 | sys_poweroff(); | ||
371 | } | ||
372 | } | ||
373 | } | ||
374 | } | 332 | } |
375 | 333 | ||
376 | #ifdef CURRENT_NORMAL /*check that we have a current defined in a config file*/ | 334 | #ifdef CURRENT_NORMAL /*check that we have a current defined in a config file*/ |
@@ -853,3 +811,51 @@ void send_battery_level_event(void) | |||
853 | level++; | 811 | level++; |
854 | } | 812 | } |
855 | } | 813 | } |
814 | |||
815 | static bool sleeptimer_active = false; | ||
816 | static long sleeptimer_endtick; | ||
817 | |||
818 | void set_sleep_timer(int seconds) | ||
819 | { | ||
820 | if (seconds) { | ||
821 | sleeptimer_active = true; | ||
822 | sleeptimer_endtick = current_tick + seconds * HZ; | ||
823 | } | ||
824 | else { | ||
825 | sleeptimer_active = false; | ||
826 | sleeptimer_endtick = 0; | ||
827 | } | ||
828 | } | ||
829 | |||
830 | int get_sleep_timer(void) | ||
831 | { | ||
832 | if (sleeptimer_active && (sleeptimer_endtick >= current_tick)) | ||
833 | return (sleeptimer_endtick - current_tick) / HZ; | ||
834 | else | ||
835 | return 0; | ||
836 | } | ||
837 | |||
838 | void handle_sleep_timer(void) | ||
839 | { | ||
840 | if (!sleeptimer_active) | ||
841 | return; | ||
842 | |||
843 | /* Handle sleeptimer */ | ||
844 | if (TIME_AFTER(current_tick, sleeptimer_endtick)) { | ||
845 | audio_stop(); | ||
846 | |||
847 | if (usb_inserted() | ||
848 | #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) | ||
849 | || charger_input_state != NO_CHARGER | ||
850 | #endif | ||
851 | ) { | ||
852 | DEBUGF("Sleep timer timeout. Stopping...\n"); | ||
853 | set_sleep_timer(0); | ||
854 | backlight_off(); /* Nighty, nighty... */ | ||
855 | } | ||
856 | else { | ||
857 | DEBUGF("Sleep timer timeout. Shutting off...\n"); | ||
858 | sys_poweroff(); | ||
859 | } | ||
860 | } | ||
861 | } | ||
diff --git a/firmware/target/hosted/android/powermgmt-android.c b/firmware/target/hosted/android/powermgmt-android.c index 6dc7c8c814..e5e8344315 100644 --- a/firmware/target/hosted/android/powermgmt-android.c +++ b/firmware/target/hosted/android/powermgmt-android.c | |||
@@ -73,14 +73,3 @@ unsigned battery_voltage(void) | |||
73 | { | 73 | { |
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | |||
77 | static int sleeptime; | ||
78 | void set_sleep_timer(int seconds) | ||
79 | { | ||
80 | sleeptime = seconds; | ||
81 | } | ||
82 | |||
83 | int get_sleep_timer(void) | ||
84 | { | ||
85 | return sleeptime; | ||
86 | } | ||
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index e0372d2683..024afab14f 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c | |||
@@ -385,17 +385,6 @@ void mpeg_set_pitch(int pitch) | |||
385 | (void)pitch; | 385 | (void)pitch; |
386 | } | 386 | } |
387 | 387 | ||
388 | static int sleeptime; | ||
389 | void set_sleep_timer(int seconds) | ||
390 | { | ||
391 | sleeptime = seconds; | ||
392 | } | ||
393 | |||
394 | int get_sleep_timer(void) | ||
395 | { | ||
396 | return sleeptime; | ||
397 | } | ||
398 | |||
399 | #ifdef HAVE_LCD_CHARCELLS | 388 | #ifdef HAVE_LCD_CHARCELLS |
400 | void lcd_clearrect (int x, int y, int nx, int ny) | 389 | void lcd_clearrect (int x, int y, int nx, int ny) |
401 | { | 390 | { |