Some notes on audio in Linux

For a little while I used the model=dell-headset-multi solution from this post to get the headset mic working. But having “Headset Mic” and “Headphone Mic” devices, only one of which worked, annoyed me. So I read some docs and played around with hdajackretask and came up with something that seems to work somewhat better.

  1. First, make sure your kernel is compiled with CONFIG_SND_HDA_PATCH_LOADER=y.
  2. Create a patch file in /lib/firmware/hda-audio-patch.fw (the exact filename doesn’t matter), with contents
    [codec]
    0x10ec0295 0xf1110001 0
    
    [pincfg]
    0x19 0x03a1112c
    
  3. Create a file in /etc/modprobe.d/hda-audio-patch.conf (again, the specific filename doesn’t matter) with contents
    # Patch the sound card.
    # https://01.org/linuxgraphics/gfx-docs/drm/sound/hd-audio/notes.html
    #
    # Note this refers to /lib/firmware/hda-audio-patch.fw.
    options snd-hda-intel patch=hda-audio-patch.fw
    
    If you didn’t name the file in step 2 hda-audio-patch.fw, change the references in there of course.

When you reboot (or unload and reload the snd-hda-intel kernel module), you should see lines in the kernel logs like

snd_hda_intel 0000:00:1f.3: Applying patch firmware 'hda-audio-patch.fw'
snd_hda_intel 0000:00:1f.3: firmware: direct-loading firmware hda-audio-patch.fw

and your mixer should then show controls for both “Internal Mic” and “Mic”.

I also found a few other things:

  • If you add a line 0x1b 0x908001f0 to that hda-audio-patch.fw file, you’ll get a “Line” input alongside “Internal Mic” and “Mic”. This is something of a loopback, it lets you record the audio as it’s being output.
  • While BIOS can beep through the sound card, probably via a hardware pin, it doesn’t seem that there’s a “beep generator audio widget” on the Realtek ALC295 codec for Linux to use. Or if there is, it needs some magic (that no one seems to know about) to make it show up.
5 Likes

Hello, I have been having issues accessing the microphone on Arch Linux. I have booted into a live ISO of Ubuntu 21.04, on which the microphone worked. So I know it isn’t a hardware issue. I found this post, and tried it, but the microphone still isn’t showing up in pavucontrol. I do however see the kernel loading it (I think). After reloading the kernel module snd_hda_intel, I get this output in dmesg

[  690.834133] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040380
[  690.834343] snd_hda_intel 0000:00:1f.3: Applying patch firmware 'hda-audio-patch.fw'
[  690.834416] snd_hda_intel 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[  690.860298] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC295: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[  690.860302] snd_hda_codec_realtek hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[  690.860303] snd_hda_codec_realtek hdaudioC0D0:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[  690.860304] snd_hda_codec_realtek hdaudioC0D0:    mono: mono_out=0x0
[  690.860304] snd_hda_codec_realtek hdaudioC0D0:    inputs:
[  690.860305] snd_hda_codec_realtek hdaudioC0D0:      Mic=0x19
[  690.860305] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12
[  690.927329] input: HDA Intel PCH Front Headphone as /devices/pci0000:00/0000:00:1f.3/sound/card0/input27
[  690.927365] input: HDA Intel PCH HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input28
[  690.927393] input: HDA Intel PCH HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input29
[  690.927422] input: HDA Intel PCH HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input30
[  690.927445] input: HDA Intel PCH HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input31
[  690.927470] input: HDA Intel PCH HDMI/DP,pcm=10 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input32
[  690.927504] input: HDA Intel PCH HDMI/DP,pcm=11 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input33
[  690.927539] input: HDA Intel PCH HDMI/DP,pcm=12 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input34
[  690.927575] input: HDA Intel PCH HDMI/DP,pcm=13 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input35
[  690.927608] input: HDA Intel PCH HDMI/DP,pcm=14 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input36
[  690.927632] input: HDA Intel PCH HDMI/DP,pcm=15 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input37
[  690.927659] input: HDA Intel PCH HDMI/DP,pcm=16 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input38
[  690.927683] input: HDA Intel PCH HDMI/DP,pcm=17 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input39

It has the line of it applying the patch, but doesn’t have it direct-loading it. The devices seem to be in dmesg, but show up in neither pavucontrol or in pacmd list-sources.

Thoughts?

@Seth_Gower Looks like the kernel is seeing it. The different loading message may be due to a different kernel version, or Debian (which I use) may have patched it for some reason.

You might start by tracking down where exactly it’s getting lost.

  • On my Debian system with kernel 5.14.9, I have a file /proc/asound/card0/codec#0 where I can see Node 0x12 is associated with “Internal Mic Boost Volume” and Node 0x19 is associated with “Mic Boost Volume”
  • Then I see amixer includes both “Simple mixer control ‘Mic’,0” and “Simple mixer control ‘Internal Mic’,0”. Similarly, I find Mic and Internal Mic in alsamixer.

I don’t use pulseaudio so I don’t know how you’d see what that’s doing with it.

@Brad_J thanks for the update. It seems that it may be a Pulse problem. It shows up in /proc/asound/card0/codec#0 as

Node 0x12 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
  Control: name="Internal Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00000020: IN
  Pin Default 0x90a60130: [Fixed] Mic at Int N/A
    Conn = Digital, Color = Unknown
    DefAssociation = 0x3, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x20: IN
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0

and

Node 0x19 [Pin Complex] wcaps 0x40048b: Stereo Amp-In
  Control: name="Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00003724: IN Detect
    Vref caps: HIZ 50 GRD 80 100
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x24: IN VREF_80
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0

so same as you. And it also shows up in amixer

Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 62265 [95%] [off]
  Front Right: Playback 62265 [95%] [off]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 65536 [100%] [on]
  Front Right: Capture 65536 [100%] [on]

So time to figure out how to debug pulseaudio

Thanks!

Turns out I was wrong about that. It does have a beep generator “hidden” on nid 0x01.

What it doesn’t have is a way to control it via the HDA mixers, so Linux refuses to use it. The only way to make it work is apparently to set a secret register that makes it replace the (seemingly unused on Framework) 0x1a input, exactly as described in Realtek PC Beep Hidden Register — The Linux Kernel documentation.