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

7,693

Solution 1

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

Solution 2

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.

Solution 3

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.

Share:
7,693

Related videos on Youtube

Jamesking56
Author by

Jamesking56

Updated on September 18, 2022

Comments

  • Jamesking56
    Jamesking56 over 1 year

    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?

    • WinEunuuchs2Unix
      WinEunuuchs2Unix about 6 years
      Something like a nVidia GTX 970M to a GTX 1060?
    • Jamesking56
      Jamesking56 about 6 years
      No its an AMD Radeon HD 7870 graphics card. I'm plugged into the HDMI port on it. Got display all fine just no audio, audio works via headphones though
    • WinEunuuchs2Unix
      WinEunuuchs2Unix about 6 years
      Good to know as I have nVidia which has different solutions.
  • Jamesking56
    Jamesking56 about 6 years
    It says that they are all unplugged
  • xiota
    xiota about 6 years
    I assume you've checked cables and made sure all devices are turned on? ... try running pulseaudio -k ; sleep 1 ; if ! pgrep pulseaudio ; then pulseaudio -D ; fi ... then try pavucontrol again?
  • Jamesking56
    Jamesking56 about 6 years
    Cables are fine, your command showed a couple of numbers but pavucontrol still shows all HDMI stereo unplugged
  • Jamesking56
    Jamesking56 about 6 years
    didn't use Ubuntu, 18.04 is first version
  • xiota
    xiota about 6 years
    What happens if you select HDMI anyway, even though it says unplugged?
  • Jamesking56
    Jamesking56 about 6 years
    Still no audio through HDMI...
  • xiota
    xiota about 6 years
    Have you tried the solution here: askubuntu.com/q/67113/567307 ; Also this page may have info that will help: manerosss.wordpress.com/2018/01/09/mesa-displayport-hdmi-aud‌​io
  • xealits
    xealits over 3 years
    on ubuntu 20.04, this made "HD-Audio Generic" appear in the sound settings, and on "test sound" pavucontrol does show some output there, but still no sound out of the speakers. This was about my tenth hack attempting to fix this, so I decided to test the monitor speakers, if they work at all. Connected it to a Macbook and everything got recognized and worked immediately -- no further comments...
  • u2n
    u2n over 3 years
    @xealits, with sound settings not open, after running the program (in terminal or by shortcut), did u try then opening sound settings? This is a squirrely bug that sometimes just takes that odd click. Also running u20.04 and find I still need to use this, but much less often than w/ 18.04. You might also try pasting the first three lines and verify the correct values are being used. There's almost no way for this not to work since it forces pulse to use the correct source/sink.