diff options
author | Tomasz Moń <desowin@gmail.com> | 2021-07-04 13:08:42 +0200 |
---|---|---|
committer | Tomasz Moń <desowin@gmail.com> | 2021-07-04 13:08:42 +0200 |
commit | 89d3ca77b6ffd0ad499d91e8c66100f6d852e358 (patch) | |
tree | db11bdda5c1020c77b8cc2ac64ab1f0e53b1c377 /firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c | |
parent | e11fa5f74eb49b10ebefbe8882bb50186dffb2a4 (diff) |
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
Diffstat (limited to 'firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c')
-rw-r--r-- | firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c index a4efe0962a..a8e0d5eb5e 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c @@ -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()) |