Realtek的ALC260音频codec芯片的引脚复用设置(pincfg)

目录

1 简介

2 硬件信息

3 pin Configuration

3.1 数据格式

3.2 实际数据示例

4 修改默认的pin Configuration

4.1 临时修改(重启后无效)

4.2 永久修改

4.1.1 参考资料

4.1.2 获取codec的vendor_id 和 subsystem_id

4.1.3 使用新的pin Configuration

4.1.4 新建文件test_patch,内容如下

4.1.5 修改内核启动参数 并重启系统

5 其他信息

5.1 通过dmesg信息查看codec的初始化信息

5.2 查看系统初始化时使用的pin Configuration(/sys/class/sound/hwC0D0/init_pin_configs)


1 简介

        Realtek的ALCxxx 系列的codec芯片的音频通道(pin)大多是双向的,也就是说,既可以作为音频输入,也可以作为音频输出。

        linux内核中会为常见的ALCxxx 系列的codec芯片设置一个默认配置,默认配置中会指定codec芯片的音频通道的方向。但是有时候,硬件设计和内核中的默认配置会不同,比如,硬件设计的某个音频通道是作为扬声器(output)的,但是内核中的默认配置是麦克风(input)。这个时候,我们可以通过驱动自带的自定义配置接口(snd_hda_intel.patch=xxx)来更正默认配置。

2 硬件信息

        以ALC260为例,其功能框图如下:

图中标注“In/Out”的通道表示 既可以作为音频输入,也可以作为音频输出。

3 pin Configuration

3.1 数据格式

每一组音频通道都有一个对应32bits的pin configuration。分析linux5.4.18的内核代码可知32bits的configuration定义如下:

位域名称不同值的含义参考代码(sound/pci/hda/hda_proc.c)
[31:30]

PORT_CONN

0x00: Jack
0x01: N/A
0x02: Fixed
0x03: Both
print_pin_caps()
[29:24]

LOCATION

0x00: N/A
0x01: Rear
0x02: Front
0x03: Left
0x04: Right
0x05: Top
0x06: Botton
0x07: Rear Panel
0x08: Drive Bar
0x17: Riser
0x18: HDMI
0x19: ATAPI
0x37: Mobile-In
0x38: Mobile-Out
get_jack_location()
[23:20]

DEVICE

0x00: Line Out
0x01: Speaker
0x02: HP Out
0x03: CD
0x04: SPDIF Out
0x05: Digital Out
0x06: Modem Line
0x07: Modem Hand
0x08: Line In
0x09: Aux
0x0a: Mic
0x0b: Telephony
0x0c: SPDIF In
0x0d: Digital In
0x0e: Reserved
0x0f: Other
get_jack_type()
[19:16]

CONN_TYPE

0x00: Unknown
0x01: 1/8
0x02: 1/4
0x03: ATAPI
0x04: RCA
0x05: Optical
0x06: Digital
0x07: Analog
0x08: DIN
0x09: XLR
0x0a: RJ11
0x0b: Comb
0x0c: NULL
0x0d: NULL
0x0e: NULL
0x0f: Other
get_jack_connection()
[15:12]

COLOR

0x00: Unknown
0x01: Black
0x02: Grey
0x03: Blue
0x04: Green
0x05: Red
0x06: Orange
0x07: Yellow
0x08: Purple
0x09: Pink
0x0a: NULL
0x0b: NULL
0x0c: NULL
0x0d: NULL
0x0e: White
0x0f: Other
get_jack_color()
[11:8]

MISC

0x01: Misc = NO_PRESENCEprint_pin_caps()
[7:4]

DEF_ASSOC

print_pin_caps()
[3:0]

SEQUENCE

print_pin_caps()

3.2 实际数据示例

# cat /proc/asound/card0/codec#0
Codec: Realtek ALC257
......
Node 0x12 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00000020: IN
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE

  Pin-ctls: 0x00:
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Node 0x13 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00000020: IN
  Pin Default 0x40000000: [N/A] Line Out at Ext N/A
    Conn = Unknown, Color = Unknown
    DefAssociation = 0x0, Sequence = 0x0

  Pin-ctls: 0x00:
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Node 0x14 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Control: name="Speaker Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x80 0x80]
  Pincap 0x00010014: OUT EAPD Detect
  EAPD 0x2: EAPD
  Pin Default 0x90170110: [Fixed] Speaker at Int N/A
    Conn = Analog, Color = Unknown
    DefAssociation = 0x1, Sequence = 0x0
    Misc = NO_PRESENCE

  Pin-ctls: 0x40: OUT
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 1
     0x02
 

4 修改默认的pin Configuration

4.1 临时修改(重启后无效)

例如将 nid=0x15 的音频接口配置为 0x0201e010
        echo 0x15 0x0201e010 > /sys/class/sound/hwC0D0/user_pin_configs
        echo 1 > /sys/class/sound/hwC0D0/reconfig

4.2 永久修改

4.1.1 参考资料

Documentation/sound/hd-audio/notes.rst

Early Patching
--------------
When ``CONFIG_SND_HDA_PATCH_LOADER=y`` is set, you can pass a "patch"
as a firmware file for modifying the HD-audio setup before
initializing the codec.  This can work basically like the
reconfiguration via sysfs in the above, but it does it before the
first codec configuration.

A patch file is a plain text file which looks like below:

::

    [codec]
    0x12345678 0xabcd1234 2

    [model]
    auto

    [pincfg]
    0x12 0x411111f0

    [verb]
    0x20 0x500 0x03
    0x20 0x400 0xff

    [hint]
    jack_detect = no

The file needs to have a line ``[codec]``.  The next line should contain
three numbers indicating the codec vendor-id (0x12345678 in the 
example), the codec subsystem-id (0xabcd1234) and the address (2) of
the codec.  The rest patch entries are applied to this specified codec
until another codec entry is given.  Passing 0 or a negative number to
the first or the second value will make the check of the corresponding
field be skipped.  It'll be useful for really broken devices that don't
initialize SSID properly.

The ``[model]`` line allows to change the model name of the each codec.
In the example above, it will be changed to model=auto.
Note that this overrides the module option.

After the ``[pincfg]`` line, the contents are parsed as the initial
default pin-configurations just like ``user_pin_configs`` sysfs above.
The values can be shown in user_pin_configs sysfs file, too.

Similarly, the lines after ``[verb]`` are parsed as ``init_verbs``
sysfs entries, and the lines after ``[hint]`` are parsed as ``hints``
sysfs entries, respectively.

4.1.2 获取codec的vendor_id 和 subsystem_id

# cat /sys/class/sound/hwC0D0/vendor_id
0x10ec0260
# cat /sys/class/sound/hwC0D0/subsystem_id
0x2600000

4.1.3 使用新的pin Configuration

例如现在需要设置NID是0x0f和 0x15的音频通道都是输出,可以选择下面的Configuration

        0x0f 0x02214000
        0x15 0x90130110

4.1.4 新建文件test_patch,内容如下

[codec]
0x10ec0260 0x2600000 0

[model]
auto

[pincfg]
0x0f 0x02214000
0x15 0x90130110

[hint]
jack_detect = no

然后将文件test_patch放到系统的/lib/firmware/目录下。

4.1.5 修改内核启动参数 并重启系统

添加启动参数:snd_hda_intel.patch=test_patch

然后重启系统。

5 其他信息

5.1 通过dmesg信息查看codec的初始化信息

例如:

[   25.861010] sof-audio-pci-intel-tgl 0000:00:1f.3: ASoC: Parent card not yet available, widget card binding deferred
[   25.895469] snd_hda_codec_realtek ehdaudio0D0: autoconfig for ALC257: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[   25.895473] snd_hda_codec_realtek ehdaudio0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   25.895474] snd_hda_codec_realtek ehdaudio0D0:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[   25.895476] snd_hda_codec_realtek ehdaudio0D0:    mono: mono_out=0x0
[   25.895476] snd_hda_codec_realtek ehdaudio0D0:    inputs:
[   25.895477] snd_hda_codec_realtek ehdaudio0D0:      Mic=0x19
[   25.950004] snd_hda_codec_realtek ehdaudio0D0: ASoC: sink widget AIF1TX overwritten

5.2 查看系统初始化时使用的pin Configuration(/sys/class/sound/hwC0D0/init_pin_configs)

# cat /sys/class/sound/hwC0D0/init_pin_configs
0x12 0x411111f0
0x13 0x40000000
0x14 0x90170110
0x18 0x411111f0
0x19 0x04a11030
0x1a 0x411111f0
0x1b 0x411111f0
0x1d 0x40661b45
0x1e 0x411111f0
0x21 0x0421101f

参考资源链接:[Realtek ALC5672音频CODEC规格书:集成语音DSP与移动设备优化](https://wenku.csdn.net/doc/646f09c1d12cbe7ec3f18f1f?utm_source=wenku_answer2doc_content) 集成ALC5672音频CODEC至移动设备以实现低功耗高性能的音频处理,首先需要了解其技术规格和工作原理。ALC5672是一款专为移动设备设计的音频CODEC,它集成了高性能的第二代语音DSP以及SoundRealTM后处理技术,通过双I2S接口与外部音频设备连接,支持多通道音频格式,并且优化了功耗管理以延长电池寿命。 要实现高效集成,首先应详细阅读《Realtek ALC5672音频CODEC规格书:集成语音DSP与移动设备优化》。手册中详细介绍了ALC5672的规格参数、接口定义和使用指南,这是集成工作的基础。根据规格书,你需要确定CODEC的配置参数,如采样率、位深、通道配置等,以符合移动设备的具体需求。 接着,设计电路时应考虑CODEC与移动设备处理器的连接方式,如何利用I2S接口进行音频数据传输。需要在硬件设计中确保电源和地线布局合理,以减少噪声干扰并提高音频质量。同时,还应设计相应的软件驱动程序,以控制ALC5672的工作状态和音频处理参数。 在软件层面,利用ALC5672的DSP功能,可以对音频信号进行实时处理,包括音量控制、均衡器设置、动态范围压缩等。SoundRealTM后处理技术可以进一步提升音频输出的质量,通过消除噪声和回声,增强声音的清晰度和空间感。 最后,进行实际测试验证是不可忽略的步骤。通过测试,可以评估CODEC在移动设备上的性能表现,确保音频输出达到预期的质量标准,同时验证功耗是否符合设计要求。 综上所述,集成ALC5672音频CODEC至移动设备需要全面考虑硬件设计、软件编程以及性能测试等多方面的因素。参考《Realtek ALC5672音频CODEC规格书:集成语音DSP与移动设备优化》能够为你提供详尽的技术支持和指南,帮助你更有效地完成集成工作。 参考资源链接:[Realtek ALC5672音频CODEC规格书:集成语音DSP与移动设备优化](https://wenku.csdn.net/doc/646f09c1d12cbe7ec3f18f1f?utm_source=wenku_answer2doc_content)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值