GTX 1060 - No Audio over HDMI - Only HDA Intel detected - Azalia

For some reason, a lot of recent laptops are set up to boot with the GPU’s PCI audio function disabled. I haven’t done much investigation, but you can turn on the audio function and make the kernel see it by setting the appropriate PCI configuration bit and then telling the kernel to rescan the PCI bus on the PCI bridge the GPU is connected to.

Unfortunately, the kernel won’t see the audio function unless you remove the graphics function first, which temporarily breaks the console. Because of that, it works best if you write a script to do it so you don’t have to SSH into the system or try to type the commands into the console blind. Obviously, you have to stop the X server first so that you can unload the NVIDIA drivers.

For example, on my system, the GPU is at 01:00.0 and its parent PCI bridge is 00:01.0. So the script I use is:

setpci -s 01:00.0 0x488.l=0x2000000:0x2000000
rmmod nvidia-drm nvidia-modeset nvidia
echo 1 > /sys/bus/pci/devices/0000:01:00.0/remove
echo 1 > /sys/bus/pci/devices/0000:00:01.0/rescan
modprobe nvidia-drm
xinit -- -retro

You can figure out your PCI topology with “lspci -t” but interpreting the results is pretty tricky.