Audio crackle through headphones

A solution to this problem was found by Robert Joynt in a comment to this alsa-driver bug report. Here is a copy of the instructions:

Install alsa-tools if not installed:

sudo apt install alsa-tools

Create and save a script in /usr/local/bin:

#!/bin/bash 
hda-verb /dev/snd/hwC0D0 0x20 SET_COEF_INDEX 0x67 
hda-verb /dev/snd/hwC0D0 0x20 SET_PROC_COEF 0x3000

Run the script as root in a terminal to immediately fix the problem.

To run the script on startup, use cron with the @reboot command:

sudo crontab -e

and then add line in crontab:

@reboot [full path to script]

To run script on resume from suspend, copy the script to /lib/systemd/system-sleep

For more technical details regarding this fix, see https://bugzilla.kernel.org/show_bug.cgi?id=195457


This issue is still present for me in Ubuntu 20.04.1, on a a HP Pavilion 15-cw1905nz, and there is good indication that it is not a Ubuntu specific bug.

robertjjoynt's fix worked for me, but only after I changed the sound card from hwC0D0 to hwC1D0. So my script goes:

#!/bin/bash 
hda-verb /dev/snd/hwC1D0 0x20 SET_COEF_INDEX 0x67 
hda-verb /dev/snd/hwC1D0 0x20 SET_PROC_COEF 0x3000

You may have to tweak it a bit: if the above script doesn't work, try to replace "hwC1D0" with some other device (listed in /dev/snd/) until it works.

If it still doesn't work, then maybe the particular coeffs you need to change are not the same. There's an answer by Frédéric Pierret on bugzilla detailing how all of this works. My ears are eternally grateful to both him and Robert.