diff --git a/skeleton/SYSTEM/tg5040/bin/suspend b/skeleton/SYSTEM/tg5040/bin/suspend index 10fcd34fe..a9fafa187 100755 --- a/skeleton/SYSTEM/tg5040/bin/suspend +++ b/skeleton/SYSTEM/tg5040/bin/suspend @@ -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" @@ -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 diff --git a/workspace/all/common/api.c b/workspace/all/common/api.c index 0a4ac041f..d40c6fd7e 100644 --- a/workspace/all/common/api.c +++ b/workspace/all/common/api.c @@ -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(); diff --git a/workspace/all/minarch/minarch.c b/workspace/all/minarch/minarch.c index 42e6c1ec7..323362e7d 100644 --- a/workspace/all/minarch/minarch.c +++ b/workspace/all/minarch/minarch.c @@ -4804,7 +4804,6 @@ void Menu_quit(void) { SDL_FreeSurface(menu.overlay); } void Menu_beforeSleep() { - LOG_info("beforeSleep\n"); SRAM_write(); RTC_write(); State_autosave(); @@ -4812,7 +4811,6 @@ void Menu_beforeSleep() { PWR_setCPUSpeed(CPU_SPEED_MENU); } void Menu_afterSleep() { - LOG_info("beforeSleep\n"); unlink(AUTO_RESUME_PATH); setOverclock(overclock); }