Ubuntu 18-04 - no HDMI audio with AMD Radeon HD 7870

I'm running Ubuntu 18.04 on a Gigabyte 78LMT-USB3 (gen 6) motherboard. Using HDMI audio via my graphics card is not working at all. Sound via headphones is working fine.

Here is my alsa report: http://www.alsa-project.org/db/?f=317bebb3e63a8726494c1637432903834c7c128c

Any ideas why I can't get any audio via my graphics card?


You may need to add kernel parameters to /etc/default/grub.

sudo nano /etc/default/grub

Look for GRUB_CMDLINE_LINUX_DEFAULT and add amdgpu.dc=1 (or, if it doesn't work, radeon.audio=1). Then update grub and reboot:

sudo update-grub

Then look at the last tab in pavucontrol for a profile that includes HDMI output.


My HDMI Audio (AMD HD 4850) has disappeared after installing new kernel on Ubuntu 18.10. Restart system with previous kernel version helped to solve the issue:

  • kernel 4.18.0-21-generic: HDMI Audio is not working
  • kernel 4.18.0-20-generic: HDMI Audio is working

All Kernels starting from 4.15.0-51, 4.18.0-21 and 5.0.0-16 are affected.

See details in this bug (comment #27): https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1834771


Update 8/21 This has become a longterm bug documented in this bug report (post 53 refers back to this answer).

First check that the kernel can control the audio hardware:

cat /proc/asound/cards

There should be at least one "HDMI" entry in the left column. If not, no HDMI audio is possible until the kernel can see and control the audio hardware. (Searches like 'alsa kernel config' may be helpful, returning pages such as this.) Otherwise, this workaround should fix HDMI sound in pulseaudio systems (if nothing else is broken).

Paste in terminal:

mkdir -p $HOME/bin
echo '#!/bin/bash

# Temporary workaround to restore HDMI audio until kernel is fixed
#       ref. https://askubuntu.com/a/1207919/165265
#
a=$(aplay -l | grep HDMI)
c=${a#*card }; card=${c:0:1}
d=${a%:*}; dev=${d: -1}

s=$(pacmd stat | grep sink)
[[ ${s: -4} == _${card}_${dev} ]] || {
pulseaudio --kill
rm $HOME/.config/pulse/*
sleep 2
wait
pulseaudio --start
pacmd load-module module-alsa-sink device=hw:$card,$dev
pacmd set-default-sink alsa_output.hw_${card}_${dev}
pacmd set-sink-volume alsa_output.hw_${card}_${dev} 35000
}
exit 0
' > $HOME/bin/fixHDMIaudio
chmod +x $HOME/bin/fixHDMIaudio
echo
cat $HOME/bin/fixHDMIaudio

Call with:

$HOME/bin/fixHDMIaudio &

The program checks whether HDMI audio is selected and if not, tries to activate the first HDMI device, 'HDMI 0'. Nothing is done if HDMI audio is already in use.

Note some sound cards may list multiple HDMI devices for a single port. In this case, it will be necessary to try each manually, see the last part of post 74 in the above-referenced bug report.

To auto-run after boot, the call can be added to Startup Applications or a startup script. Manually, it can be clicked from a launcher in the GUI or keyed at the CLI.

Some distros may intermittently revert to the no-HDMI-audio state after resuming from suspend. In this condition, the above workaround may not be able to restore HDMI audio until after a reboot.

Also note the known bug in the current release of Firefox (FF) that resets the application's volume to zero when the media play position is zero. So either don't use FF for testing, or be ready to increase volume in Sound Settings for every test.

In pre-20.04 releases, it was observed that sometimes HDMI audio would refuse to activate without an audio stream playing. If trouble getting HDMI audio, try playing a tune (in a media player, that is) before calling this program.

On first run, it may be necessary to select HDMI Audio on the Output Devices tab of Pulse Audio Volume Control (sudo apt install pavucontrol). The Configuration tab may continue to show the HDMI port as 'unplugged'. That's related to the bug this workaround exists for (!) and can be ignored.

Volume is set at 70% (35000); edit as desired.

Credit and thanks to bassmanitram on github and others on launchpad and here.