1
0
Fork 0
forked from len0rd/rockbox

Sansa Connect: Fix power off panic screen

Queue power off requests because power_off() can be called within tick
context that must not acquire mutex.

Change-Id: I6f1a8f81d15518876cd03556118fc9eb37b8175f
This commit is contained in:
Tomasz Moń 2021-07-04 13:08:42 +02:00
parent e11fa5f74e
commit 89d3ca77b6
No known key found for this signature in database
GPG key ID: 92BA8820D4D517C8
2 changed files with 10 additions and 2 deletions

View file

@ -110,6 +110,7 @@ static struct mutex avr_mtx;
/* AVR thread events */
#define INPUT_INTERRUPT 1
#define MONOTIME_OFFSET_UPDATE 2
#define POWER_OFF_REQUEST 3
static int btn = 0;
static bool hold_switch;
static bool input_interrupt_pending;
@ -584,7 +585,10 @@ static void avr_hid_sys_ctrl(uint8_t parameter)
void avr_hid_power_off(void)
{
avr_hid_sys_ctrl(SYS_CTRL_POWEROFF);
/* Do not execute command directly here because we can get called inside
* tick task context that must not acquire mutex.
*/
queue_post(&avr_queue, POWER_OFF_REQUEST, 0);
}
static bool avr_state_changed(void)
@ -747,6 +751,11 @@ void avr_thread(void)
{
monotime_offset_update_pending = true;
}
else if (ev.id == POWER_OFF_REQUEST)
{
avr_hid_reset_codec();
avr_hid_sys_ctrl(SYS_CTRL_POWEROFF);
}
input_interrupt_pending = false;
if (avr_state_changed())

View file

@ -70,7 +70,6 @@ void power_off(void)
/* Disable GIO0 and GIO2 interrupts */
IO_INTC_EINT1 &= ~(INTR_EINT1_EXT2 | INTR_EINT1_EXT0);
avr_hid_reset_codec();
avr_hid_power_off();
}