Setup laptop jack for speakers/microphone

I have a laptop (Thinkpad L460) with a jack port that can take both input audio and output audio.
TL.DR.: I'm trying to setup a jack port that can take headphones and/or microphone, so I can use an external analog Jack mic to record.

The card is recognized as:
pcm0: <Realtek ALC293 (Analog 2.0+HP/2.0)> at nid 20,21 and 26 on hdaa0
where 20 are speakers, 21 headphones and 26 mic.

I setup output audio this way so I can mute speakers on headphone plug:
hint.hdaa.0.nid21.config="as=1 seq=15 device=Headphones conn=Jack"
and I added this line to sysctl.conf in order to allow polling:
dev.hdac.0.polling=1

At this point if I read sndstat it looks like this:
Code:
cat /dev/sndstat                                                                          
Installed devices:
pcm0: <Realtek ALC293 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Realtek ALC293 (Internal Analog Mic)> (rec)
pcm2: <Intel Skylake (HDMI/DP 8ch)> (play)
No devices installed from userspace.

And some sysctl logs reveal more info:
Code:
sysctl -a | grep hda | grep Mic
dev.hdaa.0.nid26_original: 0x03a11020 as=2 seq=0 device=Mic conn=Jack ctype=1/8 loc=Left color=Black misc=0
dev.hdaa.0.nid26_config: 0x03a1102e as=2 seq=0 device=Mic conn=Jack ctype=1/8 loc=Left color=Black misc=0
dev.hdaa.0.nid26: pin: Mic (Black Jack)
dev.hdaa.0.nid18_original: 0x90a60130 as=3 seq=0 device=Mic conn=Fixed ctype=Digital loc=Internal color=Unknown misc=1
dev.hdaa.0.nid18_config: 0x90a60130 as=3 seq=0 device=Mic conn=Fixed ctype=Digital loc=Internal color=Unknown misc=1
dev.hdaa.0.nid18: pin: Mic (Fixed)

sysctl -a | grep hda | grep Speaker                                                        
dev.hdaa.0.nid20_original: 0x90170110 as=1 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
dev.hdaa.0.nid20_config: 0x90170110 as=1 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
dev.hdaa.0.nid20: pin: Speaker (Fixed)

sysctl -a | grep hda | grep Headphone                                                      
dev.hdaa.0.nid21_original: 0x03211040 as=4 seq=0 device=Headphones conn=Jack ctype=1/8 loc=Left color=Black misc=0
dev.hdaa.0.nid21_config: 0x0321101f as=1 seq=15 device=Headphones conn=Jack ctype=1/8 loc=Left color=Black misc=0
dev.hdaa.0.nid21: pin: Headphones (Black Jack)


I have an external jack microphone that I'd want to use to record voice. I read a bit about snd_hda() and search in formus and ended up adding this hint to the nid26:
hint.hdaa.0.nid26.config="as=3 seq=14 device=Mic conn=Jack ctype=1/8 loc=Left color=Black misc=8"

I tried using seq=15 but it doesn't work either.
Using as=1 removes speakers from pcm0 in sndstat.

With the hint applied, sndstat looks like this:
Code:
cat /dev/sndstat                                                                           
Installed devices:
pcm0: <Realtek ALC293 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Intel Skylake (HDMI/DP 8ch)> (play)
No devices installed from userspace.

So internal mic seems to be missing (I don't really care at all about internal tho).

Checking mixer0, the output is this:
Code:
mixer -f /dev/mixer                                                                        
Mixer vol      is currently set to  50:50
Mixer pcm      is currently set to 100:100
Mixer speaker  is currently set to  59:59
Mixer mic      is currently set to  67:67
Mixer mix      is currently set to  37:37
Mixer rec      is currently set to  37:37
Mixer igain    is currently set to   0:0
Mixer ogain    is currently set to 100:100
Mixer monitor  is currently set to  67:67
Recording source: mic

I tried changing Recording source to monitor but no luck.
Increasing Mixer igain adds a lot of white noise and the spectrum seems to be taking sound from my voice but I cannot verify it at all.

Any thoughts on how to setup a Jack port that can take both mic and headphones?
 
I have not fiddled with polling and my knowledge about it does not go beyond this quote from snd_hda(4):
dev.pcm.%d.polling

Enables polling mode. In this mode the
driver operates by querying the device
state on timer ticks using callout(9)
instead of interrupts. Polling is dis-
abled by default. Do not enable it un-
less you are facing weird interrupt
problems or if the device cannot gener-
ate interrupts at all.

Your initial
Code:
hint.hdaa.0.nid21.config="as=1 seq=15 device=Headphones conn=Jack"
assigns your headphones to pcm1 and by default, FreeBSD uses pcm0. The handbook section on sound describes how to change the default from pcm0 -> pcm1 which can be done to test your mic. Using pcm1, you will loose the working input/outputs in pcm0. snd_hda(4) describes how to reassign a nwid to a different grouping. as=1 -> as=0 will put that nwid into pcm0.

Code:
hint.hdaa.0.nid26.config="as=3 seq=14 device=Mic conn=Jack ctype=1/8 loc=Left color=Black misc=8"
->
Code:
hint.hdaa.0.nid26.config="as=0 seq=14 device=Mic conn=Jack ctype=1/8 loc=Left color=Black misc=8"

You may want to put the headphone nwid into as=0 also.

There is also a way to use 2 or more pcm groups at the cost of increased cpu cycles and memory.
 
Back
Top