Linux – Headphone jack stops working after suspend / reboot

alsaaudioheadphoneslinux

I had this really annoying problem, where the headphone jack would work fine after a cold start. But after suspending or cold rebooting (restart the computer without completely shutting it down) the headphone jack would stop working.

The system detects, when headphones are being plugged in and out, but there is just no sound coming out of the headphones anymore.

I am experiencing this only under Ubuntu 14.04 (under my Windows partition it works fine) on a XMG A305 Laptop. It seems like this problem is related to the drivers used with my soundcard (Card: HDA Intel PCH, Chip: VIA VT1802) or the interaction between different drivers.

Also, there have been several other people experiencing this on other machines:
Bugreport for Clevo Laptop

Best Answer

After searching for quite a while, I have come up with a solution that works well for me and might help you too:

The code is mostly taken from here.

Get the code

There exists a python script that can reactivate the headphone jack. This code is taken from ektor5 on GitHub. You need to download the script, place it somewhere where your system finds it and make it executable. You can do all this with this line:

sudo wget https://raw.githubusercontent.com/ektor5/init-headphone/master/init-headphone -O /usr/local/sbin/init-headphone && sudo chmod +x /usr/local/sbin/init-headphone

Install dependencies

The init-headphone script needs dependencies that can be installed with:

sudo apt-get install python-smbus

Add grub flag

Also, your kernel has to be started with an additional flag enabled. You can do this by editing the file ''/etc/default/grub''. Alter this line

GRUB_CMDLINE_LINUX=""

to this

GRUB_CMDLINE_LINUX="acpi_enforce_resources=lax"

After that run

sudo update-grub

Load modules at start up

Additionally, the script needs to modules to be loaded. Namely ´i2c_dev´ and ´i2c_i801´. These can be loaded at runtime with

modprobe i2c_dev
modprobe i2c_i801

You can now test whether it works, by running ´sudo init-headphone´.

To automatically load the modules on startup, add the following lines to ''/etc/modules'':

i2c_dev
i2c_i801

Create startup script

Last of all, we want the script to run automatically, when our computer reboots or returns from suspension. To do so, place the following script in ´/etc/pm/sleep.d/´.

sudo gedit /etc/pm/sleep.d/init-headphone

Add the following lines

#!/bin/sh

if [ ! -x /usr/local/sbin/init-headphone ]; then
    exit 0
fi

case $1 in
     resume|thaw)
        /usr/local/sbin/init-headphone
       ;;
esac

And don't forget to make the file executable

sudo chmod +x /etc/pm/sleep.d/init-headphone

I hope this helps, let me know if you have any problems.

cbandera

Related Question