Speakers stop working after sleep

Hi,

I’ve been reading through the forum and saw a similar subject (cannot link it it seems), but the solutions given in it were not working for me.

I have a Xiaomi notebook laptop, and every time I wake it up from sleep, the speakers are not working anymore and I need to reboot it. Also only the speakers are not working, when i try plugin in my earbuds, everything works just fine.

I tried re-scanning like in shared thread :

$ sudo su -
$ echo 1 > /sys/bus/pci/devices/0000:00:1f.3/remove
$ echo 1 > /sys/bus/pci/rescan

And it only works if something plugged in the jack port (my earbuds for example), otherwise the speakers don’t start working again.

Hardware info (sorry for the french !) :

$ aplay -l

**** Liste des périphériques matériels PLAYBACK ****
carte 0 : PCH [HDA Intel PCH], périphérique 0 : ALC256 Analog [ALC256 Analog]
  Sous-périphériques : 0/1
  Sous-périphérique #0 : subdevice #0
carte 0 : PCH [HDA Intel PCH], périphérique 3 : HDMI 0 [HDMI 0]
  Sous-périphériques : 1/1
  Sous-périphérique #0 : subdevice #0
carte 0 : PCH [HDA Intel PCH], périphérique 7 : HDMI 1 [HDMI 1]
  Sous-périphériques : 1/1
  Sous-périphérique #0 : subdevice #0
carte 0 : PCH [HDA Intel PCH], périphérique 8 : HDMI 2 [HDMI 2]
  Sous-périphériques : 1/1
  Sous-périphérique #0 : subdevice #0
carte 0 : PCH [HDA Intel PCH], périphérique 9 : HDMI 3 [HDMI 3]
  Sous-périphériques : 1/1
  Sous-périphérique #0 : subdevice #0
carte 0 : PCH [HDA Intel PCH], périphérique 10 : HDMI 4 [HDMI 4]
  Sous-périphériques : 1/1
  Sous-périphérique #0 : subdevice #0
$ cat /proc/asound/cards
0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0x9f804000 irq 147

And like in the previously mentioned subject I tried these commands :

systemctl --user disable --now pipewire.socket
systemctl --user disable --now pipewire.service
systemctl --user restart pulseaudio.service

and adding this script in /lib/systemd/system-sleep/99_restart_sound :

#!/bin/sh
  
case "$1" in
    post)
        DEVICE_ID=`lspci -D |grep Audio|awk '{print $1}'`
        echo 1 > /sys/bus/pci/devices/${DEVICE_ID}/remove
        sleep 1
        echo 1 > /sys/bus/pci/rescan
esac

with :

sudo chmod +x /lib/systemd/system-sleep/99_restart_sound

But nothing worked so far, still no sound in my laptop’s speakers after waking up from sleep.