在利用 Congatec 的定制平台上SA5模块和一个附加的CS4207 HDA 编解码器我正在尝试使用编解码器数字 SPDIF 输入和输出。 HDA 设计复制自 Congatec'S康加-SEVAL评估板。
SPDIF 输出(连接到放大器)开箱即用 - 这里没有问题。
但 SPDIF 输入(需要记录信号)让我有些头疼。
在测试过程中我使用的是 Xubuntu 20.04
Linux Test-01 5.4.0-48-generic #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
稍后我们将在 buildroot 中实现这些功能。
到目前为止我做了什么
通过使用hda_analysisr.py我可以看到 SPDIF 输入小部件默认处于禁用状态。手动启用它们对结果没有影响:
# Node 0x07 SPDIF Reciver Input Converter - Enable
hda-verb /dev/snd/hwC0D0 0x07 0x70d 0x01
# Node 0x0f SPDIF Reciver Input Pin - Enable
hda-verb /dev/snd/hwC0D0 0x0f 0x707 0x20
当我向 SPDIF 输入提供信号时,hda_analysisr 显示有效标志和信号的控制字内容。所以我认为来源很好。
通过手动启用 CS4207 的“SPDIF RX 到 TX1 环通”功能:
# Enable Rx to Tx1 Loopthru
hda-verb /dev/snd/hwC0D0 0x11 0x0500 0x01 && hda-verb /dev/snd/hwC0D0 0x11 0x0400 0x402a
我也能听到从连接到 SPDIF 输出的扬声器输入 SPDIF 输入的信号。
-> 所以我的结论是硬件部分应该没问题。
在 ALSA 方面,我认为存在配置问题,因为未列出 IEC958 数字捕获设备。但这是我无法理解的部分。有如此多的配置路径(/usr/share/pulseaudio/alsa-mixer/
/etc/alsa/conf.d/
/usr/share/alsa/
),甚至更多带有占位符的配置模板似乎被其他东西填充了。但我没有找到一种方法来找出有效使用的配置。
在 ALSA 文档中也找不到任何提示。
输出aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CS4207 Analog [CS4207 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: CS4207 Digital [CS4207 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
Subdevices: 1/1
Subdevice #0: subdevice #0
输出arecord -l
(此处未列出数字输入):
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CS4207 Analog [CS4207 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
输出pacmd list-cards
:
1 card(s) available.
index: 0
name: <alsa_card.pci-0000_00_0e.0>
driver: <module-alsa-card.c>
owner module: 7
properties:
alsa.card = "0"
alsa.card_name = "HDA Intel PCH"
alsa.long_card_name = "HDA Intel PCH at 0x91410000 irq 143"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:0e.0"
sysfs.path = "/devices/pci0000:00/0000:00:0e.0/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "5a98"
device.product.name = "Celeron N3350/Pentium N4200/Atom E3900 Series Audio Cluster"
device.form_factor = "internal"
device.string = "0"
device.description = "Built-in Audio"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
profiles:
input:analog-stereo: Analog Stereo Input (priority 65, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6500, available: unknown)
output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6565, available: unknown)
output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)
output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output + Analog Stereo Input (priority 5565, available: unknown)
output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5900, available: no)
output:hdmi-stereo+input:analog-stereo: Digital Stereo (HDMI) Output + Analog Stereo Input (priority 5965, available: no)
output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 800, available: no)
output:hdmi-surround+input:analog-stereo: Digital Surround 5.1 (HDMI) Output + Analog Stereo Input (priority 865, available: no)
output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 800, available: no)
output:hdmi-surround71+input:analog-stereo: Digital Surround 7.1 (HDMI) Output + Analog Stereo Input (priority 865, available: no)
output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5700, available: no)
output:hdmi-stereo-extra1+input:analog-stereo: Digital Stereo (HDMI 2) Output + Analog Stereo Input (priority 5765, available: no)
output:hdmi-surround-extra1: Digital Surround 5.1 (HDMI 2) Output (priority 600, available: no)
output:hdmi-surround-extra1+input:analog-stereo: Digital Surround 5.1 (HDMI 2) Output + Analog Stereo Input (priority 665, available: no)
output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output (priority 600, available: no)
output:hdmi-surround71-extra1+input:analog-stereo: Digital Surround 7.1 (HDMI 2) Output + Analog Stereo Input (priority 665, available: no)
output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 5700, available: no)
output:hdmi-stereo-extra2+input:analog-stereo: Digital Stereo (HDMI 3) Output + Analog Stereo Input (priority 5765, available: no)
output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority 600, available: no)
output:hdmi-surround-extra2+input:analog-stereo: Digital Surround 5.1 (HDMI 3) Output + Analog Stereo Input (priority 665, available: no)
output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (priority 600, available: no)
output:hdmi-surround71-extra2+input:analog-stereo: Digital Surround 7.1 (HDMI 3) Output + Analog Stereo Input (priority 665, available: no)
output:hdmi-stereo-extra3: Digital Stereo (HDMI 4) Output (priority 5700, available: no)
output:hdmi-stereo-extra3+input:analog-stereo: Digital Stereo (HDMI 4) Output + Analog Stereo Input (priority 5765, available: no)
output:hdmi-surround-extra3: Digital Surround 5.1 (HDMI 4) Output (priority 600, available: no)
output:hdmi-surround-extra3+input:analog-stereo: Digital Surround 5.1 (HDMI 4) Output + Analog Stereo Input (priority 665, available: no)
output:hdmi-surround71-extra3: Digital Surround 7.1 (HDMI 4) Output (priority 600, available: no)
output:hdmi-surround71-extra3+input:analog-stereo: Digital Surround 7.1 (HDMI 4) Output + Analog Stereo Input (priority 665, available: no)
output:hdmi-stereo-extra4: Digital Stereo (HDMI 5) Output (priority 5700, available: no)
output:hdmi-stereo-extra4+input:analog-stereo: Digital Stereo (HDMI 5) Output + Analog Stereo Input (priority 5765, available: no)
output:hdmi-surround-extra4: Digital Surround 5.1 (HDMI 5) Output (priority 600, available: no)
output:hdmi-surround-extra4+input:analog-stereo: Digital Surround 5.1 (HDMI 5) Output + Analog Stereo Input (priority 665, available: no)
output:hdmi-surround71-extra4: Digital Surround 7.1 (HDMI 5) Output (priority 600, available: no)
output:hdmi-surround71-extra4+input:analog-stereo: Digital Surround 7.1 (HDMI 5) Output + Analog Stereo Input (priority 665, available: no)
off: Off (priority 0, available: unknown)
active profile: <output:analog-stereo+input:analog-stereo>
sinks:
alsa_output.pci-0000_00_0e.0.analog-stereo/#0: Built-in Audio Analog Stereo
sources:
alsa_output.pci-0000_00_0e.0.analog-stereo.monitor/#0: Monitor of Built-in Audio Analog Stereo
alsa_input.pci-0000_00_0e.0.analog-stereo/#1: Built-in Audio Analog Stereo
ports:
analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: no)
properties:
device.icon_name = "audio-input-microphone"
analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: yes)
properties:
analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: no)
properties:
analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-speakers"
analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: no)
properties:
device.icon_name = "audio-headphones"
iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
properties:
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
hdmi-output-3: HDMI / DisplayPort 4 (priority 5600, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
hdmi-output-4: HDMI / DisplayPort 5 (priority 5500, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
另一件引起我注意的事情是评论/usr/share/pulseaudio/alsa-mixer/paths/analog-input.conf.common
; We explicitly don't want to wrap the following sources:
;
; CD
[...]
; Digital/SPDIF
现在怎么办
那么有没有一种简单的方法可以简单地启用IEC958捕获设备呢?
在哪里或如何获取当前有效的 alsa 配置进行修改?
--> 参见这个答案
编辑
CS4207 编解码器的 SPDIF-In 功能在内核 3.5 和 3.8 之间丢失。在那段时间里进行了重大重构patch_cirrus.c发生。
因此,即使我将 IEC958 输入的 ALSA 控件(从内核 3.5 的默认配置复制)添加到当前内核的配置中:
control.67 {
iface MIXER
name 'IEC958 Capture Switch'
value false
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.68 {
iface MIXER
name 'IEC958 Capture Default'
value '0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access read
type IEC958
count 1
}
}
我得到的回报:
Found hardware: "HDA-Intel" "Cirrus Logic CS4207" "HDA:10134207,10134207,00100302 HDA:8086280a,80860101,00100000" "0x8086" "0x7270"
Hardware is initialized using a generic method
alsactl: set_control:1325: failed to obtain info for control #67 (No such file or directory)
alsactl: set_control:1325: failed to obtain info for control #68 (No such file or directory)
所以看来 hda 驱动程序不向系统提供 SPDIF 输入。因此,问题不再与 ALSA 配置有关,而是与 hda 驱动程序相关。
答案1
有关其他(ALSA 无关)问题,请参阅原始帖子中的编辑
回答有关 ALSA 配置的原始问题:
看来这alsa-info
也是最好的地方。
根据该脚本,您可以通过以下方式保存当前有效的 ALSA 配置:
alsactl -f /tmp/alsa-config.txt store
之后可以在文件中更改配置(在本例中/tmp/alsa-config.txt
)并且可以通过以下方式恢复配置
alsactl -f /tmp/alsa-config.txt restore
当前有效的 ALSA 配置默认存储在
/var/lib/alsa/asound.state
答案2
使 SPDIF-In 可用
主要问题是snd_hda框架目前只支持1个数字输入引脚CS4207 有 3 个。
在解析编解码器引脚期间,所有三个都通过循环,最后一个获胜并呈现给 ALSA。技巧是没有任何配置连接的引脚在循环中被跳过。
通常引脚配置由 BIOS 设置。由于我们在此设置中不控制 BIOS,所以这不是一个选项。
另一种替代方法是使用补丁文件设置引脚配置(如所述这里在该部分早期修补)。
为此,我需要引脚节点 ID在这种情况下0x0E
,并0x12
读取其当前的引脚配置:
# hda-verb /dev/snd/hwC0D0 0x0e GET_CONFIG_DEFAULT 0x00
nid = 0xe, verb = 0xf1c, param = 0x0
value = 0xb7d6003e
# hda-verb /dev/snd/hwC0D0 0x12 GET_CONFIG_DEFAULT 0x00
nid = 0x12, verb = 0xf1c, param = 0x0
value = 0xb7d6005e
选择
# cat /sys/class/sound/hwC0D0/init_pin_configs
0x09 0x022140f0
0x0a 0x010140f0
0x0b 0x901700f0
0x0c 0x01813051
0x0d 0x01a19031
0x0e 0xb7d6003e
0x0f 0x02c4e0f0
0x10 0x014460f0
0x12 0xb7d6005e
0x15 0x014510f0
然后将配置中的前 2 位更改为“无连接”( 01
)。配置位的含义记录在HDA 规范 7.3.3.31 配置默认值。
所以0x0e 0xb7d6003e
->0x0e 0x77d6003e
和0x12 0xb7d6005e
-> 0x12 0xb7d6005e
。
/lib/firmware/patch_cs4207
使用这些值可以创建具有以下内容的补丁文件:
[codec]
0x10134207 0x10134207 0
[pincfg]
0x0e 0x77d6003e
0x12 0x77d6005e
在 [codec] 下需要列出供应商 ID、子系统 ID 和地址。
之后需要通过snd_hda_intel加载补丁文件。为此,需要将以下行添加到/etc/modprobe.d/alsa-base.conf
:
options snd-hda-intel patch=patch_cs4207
重新启动后,无需进一步调整 ALSA,SPDIF-In 即可被识别:
# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CS4207 Analog [CS4207 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: CS4207 Digital [CS4207 Digital]
Subdevices: 0/1
Subdevice #0: subdevice #0