summaryrefslogtreecommitdiffstats
path: root/firmware/powermgmt.c
diff options
context:
space:
mode:
authorThomas Jarosch <tomj@simonv.com>2011-02-28 23:05:00 +0000
committerThomas Jarosch <tomj@simonv.com>2011-02-28 23:05:00 +0000
commit2647d11354d95bae15d3a119f482348775a77491 (patch)
tree59fc722a11eed0462af37b0a57e45cdbb88c1330 /firmware/powermgmt.c
parent3bcfd5c106e04a88d1c804eb410cbe641757ac53 (diff)
downloadrockbox-2647d11354d95bae15d3a119f482348775a77491.tar.gz
rockbox-2647d11354d95bae15d3a119f482348775a77491.tar.bz2
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
Diffstat (limited to 'firmware/powermgmt.c')
-rw-r--r--firmware/powermgmt.c94
1 files changed, 50 insertions, 44 deletions
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";
static int poweroff_timeout = 0;
static int powermgmt_est_runningtime_min = -1;
-static bool sleeptimer_active = false;
-static long sleeptimer_endtick;
-
static long last_event_tick;
static int voltage_to_battery_level(int battery_millivolts);
@@ -204,26 +201,6 @@ void set_poweroff_timeout(int timeout)
poweroff_timeout = timeout;
}
-void set_sleep_timer(int seconds)
-{
- if (seconds) {
- sleeptimer_active = true;
- sleeptimer_endtick = current_tick + seconds * HZ;
- }
- else {
- sleeptimer_active = false;
- sleeptimer_endtick = 0;
- }
-}
-
-int get_sleep_timer(void)
-{
- if (sleeptimer_active && (sleeptimer_endtick >= current_tick))
- return (sleeptimer_endtick - current_tick) / HZ;
- else
- return 0;
-}
-
/* look into the percent_to_volt_* table and get a realistic battery level */
static int voltage_to_percent(int voltage, const short* table)
{
@@ -350,27 +327,8 @@ static void handle_auto_poweroff(void)
TIME_AFTER(tick, storage_last_disk_activity() + timeout)) {
sys_poweroff();
}
- }
- else if (sleeptimer_active) {
- /* Handle sleeptimer */
- if (TIME_AFTER(tick, sleeptimer_endtick)) {
- audio_stop();
-
- if (usb_inserted()
-#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
- || charger_input_state != NO_CHARGER
-#endif
- ) {
- DEBUGF("Sleep timer timeout. Stopping...\n");
- set_sleep_timer(0);
- backlight_off(); /* Nighty, nighty... */
- }
- else {
- DEBUGF("Sleep timer timeout. Shutting off...\n");
- sys_poweroff();
- }
- }
- }
+ } else
+ handle_sleep_timer();
}
#ifdef CURRENT_NORMAL /*check that we have a current defined in a config file*/
@@ -853,3 +811,51 @@ void send_battery_level_event(void)
level++;
}
}
+
+static bool sleeptimer_active = false;
+static long sleeptimer_endtick;
+
+void set_sleep_timer(int seconds)
+{
+ if (seconds) {
+ sleeptimer_active = true;
+ sleeptimer_endtick = current_tick + seconds * HZ;
+ }
+ else {
+ sleeptimer_active = false;
+ sleeptimer_endtick = 0;
+ }
+}
+
+int get_sleep_timer(void)
+{
+ if (sleeptimer_active && (sleeptimer_endtick >= current_tick))
+ return (sleeptimer_endtick - current_tick) / HZ;
+ else
+ return 0;
+}
+
+void handle_sleep_timer(void)
+{
+ if (!sleeptimer_active)
+ return;
+
+ /* Handle sleeptimer */
+ if (TIME_AFTER(current_tick, sleeptimer_endtick)) {
+ audio_stop();
+
+ if (usb_inserted()
+#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
+ || charger_input_state != NO_CHARGER
+#endif
+ ) {
+ DEBUGF("Sleep timer timeout. Stopping...\n");
+ set_sleep_timer(0);
+ backlight_off(); /* Nighty, nighty... */
+ }
+ else {
+ DEBUGF("Sleep timer timeout. Shutting off...\n");
+ sys_poweroff();
+ }
+ }
+}