Ubuntu – No sound after sleep – Ubuntu 20.04

alsasoundspeakerssuspend

I have a Xioami notebook pro laptop on Ubuntu 20.04 (same issue on 18.04).

After the laptop goes in sleep/hibernate mode, there is no sound that comes out of the speakers. The system settings (settings>sounds) are detecting music is being played and the headphones are working fine after sleep. The issue is only related to the speakers integrated in the laptop. As a quick fix, I need to reboot to have the speakers to work again.

I have tried the options below without success:

  1. Open alsamixer and do not see any "muted speaker"
  2. Enter in the terminal: sudo alsa force-reload
  3. Set up the script that reload alsa after sleep as indicated on the Ubuntu help page
  4. pavucontrol is also install on my laptop
  5. Tried to kill and restart pulseaudio

Let me know if you have any ideas to fix the issue.
I believe it is driver related, but I'm not sure how to resolve this.


Please find below the information mentioned on the hardware.

aplay -l:

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC256 Analog [ALC256 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

cat /proc/asound/cards:

 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xb4214000 irq 147

lspci -nnk | grep -A2 Audio:

00:1f.3 Audio device [0403]: Intel Corporation Device [8086:02c8]
    Subsystem: Xiaomi Device [1d72:1905]
    Kernel driver in use: snd_hda_intel

pacmd list-cards:

1 card(s) available.
    index: 0
    name: <alsa_card.pci-0000_00_1f.3>
    driver: <module-alsa-card.c>
    owner module: 7
    properties:
        alsa.card = "0"
        alsa.card_name = "HDA Intel PCH"
        alsa.long_card_name = "HDA Intel PCH at 0xb4214000 irq 147"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:00:1f.3"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "02c8"
        device.form_factor = "internal"
        device.string = "0"
        device.description = "Built-in Audio"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"

Thanks.

Best Answer

I have a success story (thank to Night Str)!

The same hardware. The same situation after sleep mode. First of all get root privileges:

$ sudo su -

Than discover your devices:

# lspci -vvv
...
00:1f.3 Audio device: Intel Corporation Device 02c8 (prog-if 80)
        Subsystem: Xiaomi Device 1963
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 32, Cache Line Size: 64 bytes
        Interrupt: pin A routed to IRQ 148
        Region 0: Memory at c4214000 (64-bit, non-prefetchable) [size=16K]
        Region 4: Memory at c4000000 (64-bit, non-prefetchable) [size=1M]
        Capabilities: <access denied>
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel, snd_sof_pci
...

So, my device id is 00:1f.3. Let`s check it:

# ls /sys/bus/pci/devices/ | grep 00:1f.3
0000:00:1f.3

Here is the trick:

# echo 1 > /sys/bus/pci/devices/0000:00:1f.3/remove
# echo 1 > /sys/bus/pci/rescan

The first command disconnects the driver from the device and detaches the device from the tree. The driver (snd_hda_intel) is not unloaded, just disconnected. The second command rescans pci devices.

As result, sound appears back.

Related Question