2

I have an Asus G46vw (specs below) running Ubuntu 14.04 build 05/05/14 and this laptop has Intel Card and a discrete 660M. I am very excited to have HDMI working with Optimus. But I have one last thing that is driving me nuts. Audio over HDMI.

I have tried googled the crap out of this issue and I am pretty good at figuring things out for myself through forum reading but I have had no luck so far. Pulseaudio does not list my HDMI output. Maybe I need to update Pulse Audio? Below is more info.

List of PLAYBACK Hardware Devices

# aplay -l
card 0: PCH [HDA Intel PCH], device 0: VT1802 Analog [VT1802 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: VT1802 Digital [VT1802 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 2: VT1802 Alt Analog [VT1802 Alt Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


# cat /proc/asound/cards 
 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf7a10000 irq 46
ChrisR.
  • 527
  • 4
  • 7
Sandman007
  • 65
  • 1
  • 2
  • 8
  • Are you using Optimus (through bumblebee)? Do you have the proprietary Nvidia drivers installed? – ChrisR. Apr 06 '14 at 18:04
  • I'm sorry. I forgot to mention that I am using the latest Nvidia-Prime package. 0.5 I believe. Yes I have the propriety Nvidia drivers installed as well. – Sandman007 Apr 06 '14 at 18:26
  • I would try some of the answers over in this question :http://askubuntu.com/questions/309293/no-sound-through-hdmi-cable-nvidia and see if they work. – ChrisR. Apr 06 '14 at 18:56
  • Thanks, Chris. I have actually already seen this thread before I had posted and they did not work for me. The only one I did not try was the GRUB_CMDLINE_LINUX="radeon.audio=1" line as I have an Nvidia card. – Sandman007 Apr 06 '14 at 19:46
  • Yeah don't. That is passing a kernel param that you do not even have the module for. Did you check in the volume settings to see if your HDMI port is listed, but just turned off?

    If that does not work, the only thing I can think of is to try bumblebee-nvidia instead of nvidia-prime.

    – ChrisR. Apr 06 '14 at 23:38
  • Yea HDMI isn't listed there. I'll pass on bumblebee. I have used it in the past. no HDMI audio support and I actually get better performance with Nvidia-Prime package. – Sandman007 Apr 07 '14 at 02:47
  • Well, that exhausts my knowledge on the subject. When I use bumblebee-nvidia (bumblebee with proprietary drivers), my devices are listed as Intel HDMI (and etc). I have only tested them once and they worked. *shrug – ChrisR. Apr 07 '14 at 07:43
  • ok I guess Ill test teh bumblebee package again, it has been a while. I'll post back as soon as I get it set up. – Sandman007 Apr 07 '14 at 15:52
  • No go on the Bumblebee package :/. Going back to Nvidia-prime – Sandman007 Apr 08 '14 at 00:48
  • any other ideas? – Sandman007 Apr 08 '14 at 18:47
  • The only thing I have seen to get the nvidia driver to push sound over HDMI is to use bumblebee-nvidia and optirun , which should make the HDMI sound option pop up in pulse. It also depends on setup. My laptop has the Nvidia GPU wired into the Intel GPU, so the Intel GPU controls all interfaces, but uses the Nvidia GPU when needed (or I make it). – ChrisR. Apr 09 '14 at 07:47
  • If anyone stumbles over this thread, I had a similar issue and there is a fix for this: https://devtalk.nvidia.com/default/topic/1024022/linux/gtx-1060-no-audio-over-hdmi-only-hda-intel-detected-azalia/2 – Liechtenschwein Jan 07 '18 at 21:29

2 Answers2

4

I managed to get HDMI audio output working on my laptop with "NVIDIA Corporation GF116M [GeForce GT 555M/635M]" GPU, using the nvidia driver and nvidia-prime. The process is rather convoluted and you have to perform it after every reboot. I've written a script that automates the process as much as possible. Its comments explain what it does. (Edit: If you don't like running the script, you can also follow the procedure described here: https://askubuntu.com/a/660910/73753)

#!/bin/bash

# Check if we are executing as root
if [ $UID != 0 ]; then
    echo "This script must be run as root."; exit
fi

# The nvidia driver cannot be loaded while we are configuring the GPU.
# Check whether the nvidia kernel is loaded:
if grep nvidia /proc/modules; then
    # It is. Check if we have HDMI audio
    if lspci | grep 01:00.1; then
        # Yes, so we are already done.
        echo "The following list should contain HDMI audio devices"
        aplay -l
        alsa reload
        echo "--> You are done!"; exit
    else
        # No, disable output through nvidia:
        prime-select intel
        echo "Please reboot. Afterwards rerun this script."; exit
    fi
fi

# Make sure that the GPU is powered
if ! lspci -H1 | grep 01:00.0; then
    if ! grep OFF /proc/acpi/bbswitch; then
        echo "ERROR: GPU is listed in lspci -H1, but bbswitch thinks it is off"; exit 1
    fi
    # Turn on the discrete GPU (to get it listed in `lspci -H1`)
    echo ON > /proc/acpi/bbswitch
    if ! grep ON /proc/acpi/bbswitch; then
        echo "ERROR: Failed to turn on the GPU"; exit 1
    fi
fi

# Check if the GPU's audio chip is powered
if ! lspci -H1 | grep 01:00.1; then
    echo "Suspend the pc and resume it again. This will turn on the audio chip on the discrete GPU. Afterwards rerun this script."; exit
fi

# The output of 'lscpi -H1' should now contain 2 lines similar to:
# 01:00.0 VGA compatible controller: NVIDIA Corporation GF116M [GeForce GT 555M/635M] (rev a1)
# 01:00.1 Audio device: NVIDIA Corporation GF116 High Definition Audio Controller (rev a1)

# Now we need to rescan for the GPU such that the audio chip is found as well
if lspci | grep 01:00.0; then
    # Now we 'unmount' the GPU
    # the nvidia driver is not loaded, otherwise this step would eventualy cause your computer to freeze/hang
    echo 1 > /sys/bus/pci/devices/0000\:01\:00.0/remove
    # Wait a bit
    sleep 1
    # Check if this succeeded
    if ! lspci | grep 01:00.0; then
        echo "ERROR: Failed to remove the GPU (or so it seems, you can try again)"; exit 1
    fi
fi

if ! lspci | grep 01:00.0; then
    # Rescan
    echo 1 > /sys/bus/pci/rescan
    if ! lspci | grep 01:00.1; then
        echo "ERROR: Rescan did not find the audio chip"; exit 1
    fi

    # The output of 'lspci' should now contain 2 lines similar to:
    # 01:00.0 VGA compatible controller: NVIDIA Corporation GF116M [GeForce GT 555M/635M] (rev a1)
    # 01:00.1 Audio device: NVIDIA Corporation GF116 High Definition Audio Controller (rev a1)

    # Now we are ready to restart X11 using the nvidia driver
    prime-select nvidia
    echo "Please log out and in again. Afterwards rerun this script."; exit
fi

echo "ERROR: Something went wrong"; exit 1
bcmpinc
  • 269
  • 2
  • 8
  • This works great. How did you figure out to suspend and restart?! Anyway, I needed one final step to get the HDMI audio output to show up in "Sound Settings". https://wiki.archlinux.org/index.php/PulseAudio/Examples#HDMI_output_configuration – cxrodgers Oct 10 '16 at 00:04
  • Either by accident or it was a lucky guess. It makes sense though, as it basically runs ACPI code to turn the GPU off and on again. Once I noticed that it made 01:00.1 appear in the lspci output, I still needed to figure out how to make it appear without loading the nvidia driver first. I guess I spent 10 hours on trial and error until I ended up with this. Unfortunately, a few months later I did a distribution upgrade and it stopped working. – bcmpinc Oct 10 '16 at 00:32
  • Any new solution on this ? The script no longer works on Ubuntu 16.04 – Carlos Ferreira Mar 21 '17 at 17:37
  • I used the script on Ubuntu 16.04 and after it asked me to log out and log in I did the log out and the laptop crashed. :-( – zeehio May 01 '17 at 16:57
0

OK, so the following works for nvidia-384 proprietary driver, installed with nvidia-prime on Ubuntu Gnome 16.04.3. Theoratically it should work for all Nvidia optimus chipsets.

$ sudo prime-select intel
$ sudo reboot
// After the reboot and login
$ sudo lspci -H1 | grep -i nvidia

This would show you only the VGA controller, not the audio chip. To enable the audio chip, execute the following commands.

$ sudo su
# setpci -s 01:00.0 0x488.l=0x2000000:0x2000000
# echo 1 > /sys/bus/pci/devices/0000\:01\:00.0/remove
// where 0000:01:00.0 is your VGA device in sysfs PCI heirarchy.
# echo "1" > /sys/bus/pci/rescan
# lspci -H1 | grep -i nvidia

This time it would show you the audio chip as well. e.g. for me, the last command shows:

01:00.0 VGA compatible controller: NVIDIA Corporation GK107GLM [Quadro K1100M] (rev a1) 01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1)

Now you need to get the environment setup and load Nvidia drivers. For that purpose, exit root shell, set nvidia as prime device and restart the display manager i.e.

# exit
$ sudo prime-select nvidia
$ sudo service gdm restart

After login, the driver registers the audio controller with Alsa and hence you can select HDMI audio in sound settings now. Hope this helps someone.

  • I'm quite busy with stuff, otherwise this could have been easily scripted to dynamically apply to any optimus system. – 3uphoric Mar 09 '18 at 04:51
  • Found a probably better solution, but haven't tried this yet... haven't had success unloading nvidia modules in the past: https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1377653/comments/19 – 3uphoric Mar 09 '18 at 05:04