forked from len0rd/rockbox
The power thread now monitors the shutdown process and forces a poweroff if it takes more than 8 seconds.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7517 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
74353a7fe4
commit
91216a5edc
5 changed files with 26 additions and 16 deletions
|
|
@ -299,7 +299,7 @@ bool info_menu(void)
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
static bool do_shutdown(void)
|
static bool do_shutdown(void)
|
||||||
{
|
{
|
||||||
sys_poweroff(false);
|
sys_poweroff();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1259,7 +1259,7 @@ bool shutdown_screen(void)
|
||||||
switch(button)
|
switch(button)
|
||||||
{
|
{
|
||||||
case BUTTON_OFF:
|
case BUTTON_OFF:
|
||||||
sys_poweroff(false);
|
sys_poweroff();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,9 @@ static void button_tick(void)
|
||||||
#endif
|
#endif
|
||||||
repeat_count > POWEROFF_COUNT)
|
repeat_count > POWEROFF_COUNT)
|
||||||
{
|
{
|
||||||
queue_post(&button_queue, SYS_POWEROFF, NULL);
|
/* Tell the main thread that it's time to
|
||||||
|
power off */
|
||||||
|
sys_poweroff();
|
||||||
|
|
||||||
/* Safety net for players without hardware
|
/* Safety net for players without hardware
|
||||||
poweroff */
|
poweroff */
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,6 @@ int get_sleep_timer(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 shutdown_hw(void);
|
void shutdown_hw(void);
|
||||||
void sys_poweroff(bool halt);
|
void sys_poweroff(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ static int wrcount;
|
||||||
#define DEBUG_STACK 0
|
#define DEBUG_STACK 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int shutdown_timeout = 0;
|
||||||
|
|
||||||
#ifdef SIMULATOR /***********************************************************/
|
#ifdef SIMULATOR /***********************************************************/
|
||||||
|
|
||||||
int battery_level(void)
|
int battery_level(void)
|
||||||
|
|
@ -392,7 +394,7 @@ static void handle_auto_poweroff(void)
|
||||||
if(TIME_AFTER(current_tick, last_event_tick + timeout) &&
|
if(TIME_AFTER(current_tick, last_event_tick + timeout) &&
|
||||||
TIME_AFTER(current_tick, last_disk_activity + timeout))
|
TIME_AFTER(current_tick, last_disk_activity + timeout))
|
||||||
{
|
{
|
||||||
sys_poweroff(true);
|
sys_poweroff();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -415,7 +417,7 @@ static void handle_auto_poweroff(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
DEBUGF("Sleep timer timeout. Shutting off...\n");
|
DEBUGF("Sleep timer timeout. Shutting off...\n");
|
||||||
sys_poweroff(true);
|
sys_poweroff();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -524,6 +526,14 @@ static void power_thread_sleep(int ticks)
|
||||||
sleep(small_ticks);
|
sleep(small_ticks);
|
||||||
ticks -= small_ticks;
|
ticks -= small_ticks;
|
||||||
|
|
||||||
|
/* If the power off timeout expires, the main thread has failed
|
||||||
|
to shut down the system, and we need to force a power off */
|
||||||
|
if(shutdown_timeout) {
|
||||||
|
shutdown_timeout -= small_ticks;
|
||||||
|
if(shutdown_timeout <= 0)
|
||||||
|
power_off();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ALARM_MOD
|
#ifdef HAVE_ALARM_MOD
|
||||||
power_thread_rtc_process();
|
power_thread_rtc_process();
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -568,9 +578,6 @@ static void power_thread(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
short *phps, *phpd; /* power history rotation pointers */
|
short *phps, *phpd; /* power history rotation pointers */
|
||||||
#if CONFIG_BATTERY == BATT_LIION2200
|
|
||||||
int charging_current;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_CHARGE_CTRL
|
#ifdef HAVE_CHARGE_CTRL
|
||||||
unsigned int target_voltage; /* desired topoff/trickle voltage level */
|
unsigned int target_voltage; /* desired topoff/trickle voltage level */
|
||||||
int charge_max_time_now = 0; /* max. charging duration, calculated at
|
int charge_max_time_now = 0; /* max. charging duration, calculated at
|
||||||
|
|
@ -606,11 +613,10 @@ static void power_thread(void)
|
||||||
tells us the charging current from the LTC1734. When DC is
|
tells us the charging current from the LTC1734. When DC is
|
||||||
connected (either via the external adapter, or via USB), we try
|
connected (either via the external adapter, or via USB), we try
|
||||||
to determine if it is actively charging or only maintaining the
|
to determine if it is actively charging or only maintaining the
|
||||||
charge. My tests show that ADC readings is below about 0x80 means
|
charge. My tests show that ADC readings below about 0x80 means
|
||||||
that the LTC1734 is only maintaining the charge. */
|
that the LTC1734 is only maintaining the charge. */
|
||||||
if(charger_inserted()) {
|
if(charger_inserted()) {
|
||||||
charging_current = adc_read(ADC_EXT_POWER);
|
if(adc_read(ADC_EXT_POWER) < 0x80) {
|
||||||
if(charging_current < 0x80) {
|
|
||||||
charge_state = TRICKLE;
|
charge_state = TRICKLE;
|
||||||
} else {
|
} else {
|
||||||
charge_state = CHARGING;
|
charge_state = CHARGING;
|
||||||
|
|
@ -878,12 +884,14 @@ void powermgmt_init(void)
|
||||||
|
|
||||||
#endif /* SIMULATOR */
|
#endif /* SIMULATOR */
|
||||||
|
|
||||||
void sys_poweroff(bool halt)
|
void sys_poweroff(void)
|
||||||
{
|
{
|
||||||
logf("sys_poweroff(%d)", halt);
|
logf("sys_poweroff()");
|
||||||
|
/* If the main thread fails to shut down the system, we will force a
|
||||||
|
power off after an 8 second timeout */
|
||||||
|
shutdown_timeout = HZ*8;
|
||||||
|
|
||||||
queue_post(&button_queue, SYS_POWEROFF, NULL);
|
queue_post(&button_queue, SYS_POWEROFF, NULL);
|
||||||
while(halt)
|
|
||||||
yield();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Various hardware housekeeping tasks relating to shutting down the jukebox */
|
/* Various hardware housekeeping tasks relating to shutting down the jukebox */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue