Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions skeleton/SYSTEM/tg5040/bin/suspend
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
set -euo pipefail
exec 0<&-

wpa_running=
hciattach_running=
bluetoothd_running=
# wpa_running=
# hciattach_running=
# bluetoothd_running=

asound_state_dir=/tmp/asound-suspend
# asound_state_dir=/tmp/asound-suspend

before() {
>&2 echo "Preparing for suspend..."
# /mnt/SDCARD/Emus/tg5040/PORTS.pak/bin/i2cset -yfr 6 0x34 0x25 0x21

for f in $(find /sys/devices/platform/soc/7081400.s_twi/i2c-6/6-0034/ -name wakeup); do
echo "Disabling wakeup in $f"
echo disabled > "$f"
Expand Down Expand Up @@ -47,10 +47,10 @@ after() {
>&2 echo "Resumed from suspend."

for f in $(find /sys/devices/platform/soc/7081400.s_twi/i2c-6/6-0034/ -name wakeup); do
echo "Disabling wakeup in $f"
echo "Enabling wakeup in $f"
echo enabled > "$f"
done
# /mnt/SDCARD/Emus/tg5040/PORTS.pak/bin/i2cset -yfr 6 0x34 0x25 0x20

# >&2 echo "Restoring mixer state..."
# alsactl --file "$asound_state_dir/asound.state.post" store || true
# alsactl --file "$asound_state_dir/asound.state.pre" restore || true
Expand Down
16 changes: 16 additions & 0 deletions workspace/all/common/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2854,6 +2854,22 @@ static void PWR_exitSleep(void) {
PLAT_enableBacklight(1);
SetVolume(GetVolume());
}
// reinitialize audio after sleep otherwise it doesnt come back on sometimes
LOG_info("Reinitialize audio after sleep\n");
SDL_CloseAudio();

SDL_AudioSpec spec_in;
SDL_AudioSpec spec_out;

spec_in.freq = PLAT_pickSampleRate(snd.sample_rate_in, MAX_SAMPLE_RATE);
spec_in.format = AUDIO_S16;
spec_in.channels = 2;
spec_in.samples = SAMPLES;
spec_in.callback = SND_audioCallback;

if (SDL_OpenAudio(&spec_in, &spec_out)<0) LOG_info("SDL_OpenAudio error: %s\n", SDL_GetError());
snd.sample_rate_out = spec_out.freq;

SDL_PauseAudio(0);

sync();
Expand Down
2 changes: 0 additions & 2 deletions workspace/all/minarch/minarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -4804,15 +4804,13 @@ void Menu_quit(void) {
SDL_FreeSurface(menu.overlay);
}
void Menu_beforeSleep() {
LOG_info("beforeSleep\n");
SRAM_write();
RTC_write();
State_autosave();
putFile(AUTO_RESUME_PATH, game.path + strlen(SDCARD_PATH));
PWR_setCPUSpeed(CPU_SPEED_MENU);
}
void Menu_afterSleep() {
LOG_info("beforeSleep\n");
unlink(AUTO_RESUME_PATH);
setOverclock(overclock);
}
Expand Down