No Audio Over HDMI on NVIDIA GeForce GTX 1050 Ti

Many thanks to Rudi Daemen. The audio problem on my GTX 1060 was solved by his solution. You can try his solution:

  1. Create file /etc/systemd/system/fix-hdmi-audio.service

    [Unit]
    Description=nVidia HDMI Audio Fixer
    Before=systemd-logind.service display-manager.service
    After=module-init-tools.service
    
    [Service]
    Type=oneshot
    ExecStart=/usr/local/bin/fix-hdmi-audio.sh
    
    [Install]
    WantedBy=multi-user.target
    
  2. Create file /usr/local/bin/fix-hdmi-audio.sh

    #!/bin/sh
    setpci -s 01:00.0 0x488.l=0x2000000:0x2000000
    rmmod nvidia-uvm nvidia-drm nvidia-modeset nvidia
    sh -c 'echo 1 > /sys/bus/pci/devices/0000:01:00.0/remove'
    sh -c 'echo 1 > /sys/bus/pci/devices/0000:00:01.0/rescan'
    modprobe nvidia nvidia-modeset nvidia-drm nvidia-uvm
    

    and set it to runnable: chmod +x /usr/local/bin/fix-hdmi-audio.sh

  3. Enable the service: systemctl enable fix-hdmi-audio.service

  4. Install apt install pavucontrol then start "PulseAudio Volume Control". In "Configuration" tab, you can see only "Internal Audio".

  5. Reboot. Plug HDMI and play some music. Start "PulseAudio Volume Control". In "Configuration" tab, you should see "Internal Audio" and "HDA NVidia".
    In "Playback" tab, there is a button on the right side of your music player. You can choose "Internal Audio" or "HDA NVidia". Choose "HDA NVidia".

Note

After rebooting, you can see

01:00.1 Audio device: NVIDIA Corporation Device 10f1 (rev a1)

in the outputs of lscpi.


Note this is for a GTX 970M but applies to 1060 and others.

The problem for me with the setpci route is multiple screen resets as lightdm is reloaded. Perhaps because I have three monitors:

  • 50" TV attached via built-in HDMI hardwired to nVidia card
  • 17" internal display driven by Intel iGPU
  • 32" TV attached via Thunderbolt and driven by Intel iGPU

The larger problem is complexity of setting up systemd and bash scripts.

The c language, kernel based solution found on this link: https://bugs.freedesktop.org/show_bug.cgi?id=75985#c33 is far superior. I've included the bulk of the link below with some modifications to my platform.


My system specs:

i7-6700HQ + GTX 970M
Linux kernel version: 4.13.0-26-generic
Nvidia driver Version: 384.130
OS: Ubuntu 16.04.5 LTS

I can confirm that kernel module, posted by Maik Freudenberg [Comment 27], is working fine on my system. Thank you for the fix. The HDMI audio device now works as it should.

I download and extracted the file nvhda.tar.xz. I created the directory ~/nVidia for extraction.

Run commands in terminal:

cd ~/nVidia
make
sudo make install
echo nvhda | sudo tee -a /etc/initramfs-tools/modules
echo "options nvhda load_state=1" | sudo tee /etc/modprobe.d/nvhda.conf
sudo update-initramfs -u # This updated newest kernel 4.15.0-26
sudo update-initramfs -u -k `uname -r` # Update booted 4.13.0-36
reboot

With this fix, I did not notice any problems with power management or system stability. HDMI audio works at system startup, after resume from sleep, after plugging/unplugging HDMI cable.