17

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.

Zanna
  • 69,223
  • 56
  • 216
  • 327
Victor Blanchier
  • 173
  • 1
  • 1
  • 5

5 Answers5

16

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.

GHopper
  • 386
  • 1
  • 3
  • 9
  • this worked for me as well- thank you so much - will look at making it in a script! – Victor Blanchier Dec 14 '20 at 06:58
  • 2
    here is the script, which does magic automatically: https://github.com/GHopperMSK/configs/blob/master/bin/restart-sound – GHopper Jan 07 '21 at 06:32
  • says permission denied error for me..even after i do sudo su - – abhigyan nayak Apr 06 '21 at 12:11
  • @abhigyannayak I had the same problem. What I did was editing these files on vim: `sudo vi /sys/bus/pci/devices/0000:00:1f.3/remove`, then add "1" to the file content and save. And then, do the same with `/sys/bus/pci/rescan` – Guilherme Garnier May 18 '21 at 16:24
  • I found the core cause.. this citrix workspace creates some issues, not sure what it does iternally.. do you also have similar software installed in your system? – abhigyan nayak May 21 '21 at 19:46
  • permission defined even with sudo. Editing fiels also want help, newly made files a read only in memory files. – simar May 15 '23 at 17:16
10

i have same problem. And i find a solution, but it dosn't work in kde i don't known why.

Solution:

echo 1 > /sys/bus/pci/devices/<device_address>/remove
sleep 1
echo 1 > /sys/bus/pci/rescan

To search the device address: lspci | grep Audio

Update:

Solution to apply commands after wakeup:

You can create new file: /lib/systemd/system-sleep/99_restart_sound and insert the following source code:

#!/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

The file must be executable:

sudo chmod +x /lib/systemd/system-sleep/99_restart_sound
Jan S.
  • 3
  • 2
Night Str
  • 101
  • 1
  • 5
  • 1
    Welcome to [Ask Ubuntu](https://askubuntu.com/), how does this answer the question when you say it didn't work. –  Nov 18 '20 at 08:28
  • I testing in Kde and Gnome. So it's work fine for gnome but not for kde. – Night Str Dec 03 '20 at 12:06
  • I am on debian (ubuntu) and it works fine with out the "sleep 1" - trying to understand the reason for adding it – Victor Blanchier Dec 23 '20 at 17:10
  • Good also looping with multiple devices https://gist.github.com/muka/d5492a25252a5edf332934201705dfe7 – lcapra Feb 13 '23 at 19:05
8

type this command:

pulseaudio -k

each time your computer out of sleep.

could be related to this bug: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1888598

Le Gluon du Net
  • 196
  • 3
  • 6
2

This command worked for me
amixer -q -D pulse sset Master toggle

Seems it mutes then unmutes the master audio device

0

After figuring out all the audio device IDs from lspci -vvv (please replace device id according in the below mentioned commands) :

sudo echo 1 |sudo tee /sys/bus/pci/devices/0000:00:03.0/remove
sudo echo 1 |sudo tee /sys/bus/pci/devices/0000:03:00.0/remove
sudo echo 1 |sudo tee /sys/bus/pci/devices/0000:00:1b.0/remove
sleep 10
sudo echo 1 |sudo tee /sys/bus/pci/rescan
sleep 10
pulseaudio --kill; pulseaudio --start
Greenonline
  • 2,030
  • 8
  • 20
  • 27