From 5c73e34d2d81545f59c5c664da3475251a5ac3c6 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Tue, 8 Mar 2011 19:33:30 +0000 Subject: [PATCH] Bring idle poweroff to RaaA and the sim git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29543 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/powermgmt.h | 2 +- firmware/powermgmt.c | 33 +++++++++++----------- firmware/target/hosted/android/powermgmt-android.c | 4 --- firmware/target/hosted/maemo/maemo-thread.c | 10 ------- firmware/target/hosted/powermgmt.c | 2 +- uisimulator/common/powermgmt-sim.c | 9 ------ 6 files changed, 18 insertions(+), 42 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 */ void set_sleep_timer(int seconds); int get_sleep_timer(void); -void handle_sleep_timer(void); +void handle_auto_poweroff(void); void set_car_adapter_mode(bool setting); void reset_poweroff_timer(void); 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; static int shutdown_timeout = 0; -static void handle_auto_poweroff(void); +void handle_auto_poweroff(void); static int poweroff_timeout = 0; -static long last_event_tick; +static long last_event_tick = 0; #if (CONFIG_PLATFORM & PLATFORM_NATIVE) /* @@ -134,11 +134,6 @@ void battery_read_info(int *voltage, int *level) *level = voltage_to_battery_level(millivolts); } -void reset_poweroff_timer(void) -{ - last_event_tick = current_tick; -} - #if BATTERY_TYPES_COUNT > 1 void set_battery_type(int type) { @@ -204,11 +199,6 @@ bool battery_level_safe(void) #endif } -void set_poweroff_timeout(int timeout) -{ - poweroff_timeout = timeout; -} - /* look into the percent_to_volt_* table and get a realistic battery level */ static int voltage_to_percent(int voltage, const short* table) { @@ -712,6 +702,16 @@ void shutdown_hw(void) } #endif /* PLATFORM_NATIVE */ +void set_poweroff_timeout(int timeout) +{ + poweroff_timeout = timeout; +} + +void reset_poweroff_timer(void) +{ + last_event_tick = current_tick; +} + void sys_poweroff(void) { #ifndef BOOTLOADER @@ -790,7 +790,7 @@ int get_sleep_timer(void) return 0; } -void handle_sleep_timer(void) +static void handle_sleep_timer(void) { if (!sleeptimer_active) return; @@ -817,7 +817,6 @@ void handle_sleep_timer(void) } } - /* * We shut off in the following cases: * 1) The unit is idle, not playing music @@ -830,7 +829,7 @@ void handle_sleep_timer(void) * 3) We are recording, or recording with pause * 4) The radio is playing */ -static void handle_auto_poweroff(void) +void handle_auto_poweroff(void) { long timeout = poweroff_timeout*60*HZ; int audio_stat = audio_status(); @@ -846,7 +845,7 @@ static void handle_auto_poweroff(void) } #endif -#ifndef APPLICATION +#if !(CONFIG_PLATFORM & PLATFORM_HOSTED) if (!shutdown_timeout && query_force_shutdown()) { backlight_on(); sys_poweroff(); @@ -863,7 +862,7 @@ static void handle_auto_poweroff(void) !sleeptimer_active))) { if (TIME_AFTER(tick, last_event_tick + timeout) -#ifndef APPLICATION +#if !(CONFIG_PLATFORM & PLATFORM_HOSTED) && TIME_AFTER(tick, storage_last_disk_activity() + timeout) #endif ) { 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) return 0; } -/* could be useful to stop the service after some time of inactivity */ -void reset_poweroff_timer(void) {} -void set_poweroff_timeout(int timeout) { (void)timeout; }; - /* should always be safe on android targets, the host shuts us down before */ bool battery_level_safe(void) { 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) { return battery_level() >= 5; } - -/** Rockbox stubs */ -void set_poweroff_timeout(int timeout) -{ - (void)timeout; -} - -void reset_poweroff_timer(void) -{ -} 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) /* Sleep two seconds */ sleep(HZ*2); - handle_sleep_timer(); + handle_auto_poweroff(); } } /* power_thread */ diff --git a/uisimulator/common/powermgmt-sim.c b/uisimulator/common/powermgmt-sim.c index 14054dca1d..e747d7d782 100644 --- a/uisimulator/common/powermgmt-sim.c +++ b/uisimulator/common/powermgmt-sim.c @@ -118,11 +118,6 @@ bool battery_level_safe(void) return battery_level() >= 10; } -void set_poweroff_timeout(int timeout) -{ - (void)timeout; -} - void set_battery_capacity(int capacity) { (void)capacity; @@ -148,7 +143,3 @@ void lineout_set(bool enable) (void)enable; } #endif - -void reset_poweroff_timer(void) -{ -} -- 2.11.4.GIT