1
0
Fork 0
forked from len0rd/rockbox

Bring idle poweroff to RaaA and the sim

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29543 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Jarosch 2011-03-08 19:33:30 +00:00
parent 2ebe370ca1
commit 5c73e34d2d
6 changed files with 18 additions and 42 deletions

View file

@ -164,7 +164,7 @@ void set_battery_type(int type); /* set local battery type */
void set_sleep_timer(int seconds); void set_sleep_timer(int seconds);
int get_sleep_timer(void); int get_sleep_timer(void);
void handle_sleep_timer(void); void handle_auto_poweroff(void);
void set_car_adapter_mode(bool setting); void set_car_adapter_mode(bool setting);
void reset_poweroff_timer(void); void reset_poweroff_timer(void);
void cancel_shutdown(void); void cancel_shutdown(void);

View file

@ -81,9 +81,9 @@ enum charge_state_type charge_state = DISCHARGING;
static int shutdown_timeout = 0; static int shutdown_timeout = 0;
static void handle_auto_poweroff(void); void handle_auto_poweroff(void);
static int poweroff_timeout = 0; static int poweroff_timeout = 0;
static long last_event_tick; static long last_event_tick = 0;
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
/* /*
@ -134,11 +134,6 @@ void battery_read_info(int *voltage, int *level)
*level = voltage_to_battery_level(millivolts); *level = voltage_to_battery_level(millivolts);
} }
void reset_poweroff_timer(void)
{
last_event_tick = current_tick;
}
#if BATTERY_TYPES_COUNT > 1 #if BATTERY_TYPES_COUNT > 1
void set_battery_type(int type) void set_battery_type(int type)
{ {
@ -204,11 +199,6 @@ bool battery_level_safe(void)
#endif #endif
} }
void set_poweroff_timeout(int timeout)
{
poweroff_timeout = timeout;
}
/* look into the percent_to_volt_* table and get a realistic battery level */ /* look into the percent_to_volt_* table and get a realistic battery level */
static int voltage_to_percent(int voltage, const short* table) static int voltage_to_percent(int voltage, const short* table)
{ {
@ -712,6 +702,16 @@ void shutdown_hw(void)
} }
#endif /* PLATFORM_NATIVE */ #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) void sys_poweroff(void)
{ {
#ifndef BOOTLOADER #ifndef BOOTLOADER
@ -790,7 +790,7 @@ int get_sleep_timer(void)
return 0; return 0;
} }
void handle_sleep_timer(void) static void handle_sleep_timer(void)
{ {
if (!sleeptimer_active) if (!sleeptimer_active)
return; return;
@ -817,7 +817,6 @@ void handle_sleep_timer(void)
} }
} }
/* /*
* We shut off in the following cases: * We shut off in the following cases:
* 1) The unit is idle, not playing music * 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 * 3) We are recording, or recording with pause
* 4) The radio is playing * 4) The radio is playing
*/ */
static void handle_auto_poweroff(void) void handle_auto_poweroff(void)
{ {
long timeout = poweroff_timeout*60*HZ; long timeout = poweroff_timeout*60*HZ;
int audio_stat = audio_status(); int audio_stat = audio_status();
@ -846,7 +845,7 @@ static void handle_auto_poweroff(void)
} }
#endif #endif
#ifndef APPLICATION #if !(CONFIG_PLATFORM & PLATFORM_HOSTED)
if (!shutdown_timeout && query_force_shutdown()) { if (!shutdown_timeout && query_force_shutdown()) {
backlight_on(); backlight_on();
sys_poweroff(); sys_poweroff();
@ -863,7 +862,7 @@ static void handle_auto_poweroff(void)
!sleeptimer_active))) { !sleeptimer_active))) {
if (TIME_AFTER(tick, last_event_tick + timeout) if (TIME_AFTER(tick, last_event_tick + timeout)
#ifndef APPLICATION #if !(CONFIG_PLATFORM & PLATFORM_HOSTED)
&& TIME_AFTER(tick, storage_last_disk_activity() + timeout) && TIME_AFTER(tick, storage_last_disk_activity() + timeout)
#endif #endif
) { ) {

View file

@ -58,10 +58,6 @@ int battery_time(void)
return 0; 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 */ /* should always be safe on android targets, the host shuts us down before */
bool battery_level_safe(void) bool battery_level_safe(void)
{ {

View file

@ -200,13 +200,3 @@ bool battery_level_safe(void)
{ {
return battery_level() >= 5; return battery_level() >= 5;
} }
/** Rockbox stubs */
void set_poweroff_timeout(int timeout)
{
(void)timeout;
}
void reset_poweroff_timer(void)
{
}

View file

@ -44,7 +44,7 @@ static void power_thread(void)
/* Sleep two seconds */ /* Sleep two seconds */
sleep(HZ*2); sleep(HZ*2);
handle_sleep_timer(); handle_auto_poweroff();
} }
} /* power_thread */ } /* power_thread */

View file

@ -118,11 +118,6 @@ bool battery_level_safe(void)
return battery_level() >= 10; return battery_level() >= 10;
} }
void set_poweroff_timeout(int timeout)
{
(void)timeout;
}
void set_battery_capacity(int capacity) void set_battery_capacity(int capacity)
{ {
(void)capacity; (void)capacity;
@ -148,7 +143,3 @@ void lineout_set(bool enable)
(void)enable; (void)enable;
} }
#endif #endif
void reset_poweroff_timer(void)
{
}