Optimus 系统上的 HDMI 音频

Optimus 系统上的 HDMI 音频

我有一台华硕 G46vw(规格如下),运行的是 Ubuntu 14.04 build 05/05/14,这台笔记本电脑有英特尔卡和独立 660M。我很高兴 HDMI 能与 Optimus 配合使用。但还有一件事让我抓狂。HDMI 音频。

我尝试用 Google 搜索这个问题,我很擅长通过阅读论坛来自己解决问题,但到目前为止我还没有找到答案。Pulseaudio 没有列出我的 HDMI 输出。也许我需要更新 Pulse Audio?下面是更多信息。

播放硬件设备列表

# 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

答案1

我设法在配备“NVIDIA Corporation GF116M [GeForce GT 555M/635M]”GPU 的笔记本电脑上使用 nvidia 驱动程序和 nvidia-prime 实现了 HDMI 音频输出。这个过程相当复杂,每次重启后你都必须执行它。我编写了一个脚本,尽可能地自动化这个过程。它的注释解释了它的作用。(编辑: 如果您不喜欢运行脚本,您也可以按照此处描述的步骤进行操作: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

答案2

好的,因此以下内容适用于 nvidia-384 专有驱动程序,该驱动程序与 nvidia-prime 一起安装在 Ubuntu Gnome 16.04.3 上。理论上,它应该适用于所有 Nvidia optimus 芯片组。

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

这将仅显示 VGA 控制器,而不显示音频芯片。要启用音频芯片,请执行以下命令。

$ 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

这次它还会显示音频芯片。例如对我来说,最后一个命令显示:

01:00.0 VGA 兼容控制器:NVIDIA Corporation GK107GLM [Quadro K1100M] (rev a1) 01:00.1 音频设备:NVIDIA Corporation GK107 HDMI 音频控制器 (rev a1)

现在您需要设置环境并加载 Nvidia 驱动程序。为此,请退出 root shell,将 nvidia 设置为主要设备并重新启动显示管理器,即

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

登录后,驱动程序会向 Alsa 注册音频控制器,因此您现在可以在声音设置中选择 HDMI 音频。希望这对某些人有所帮助。

相关内容