Solved Getting sound to automatically switch to laptop headphone jack? (X1 Carbon 6th Gen ThinkPad Realtek ALC285)

I haven't been able to find a clear guide on this.

Currently, when I plug in headphones, the speakers cut out. So it's obviously detecting it but no sound in headphones. Can't see any way to raise the volume on the headphones.
 
Sound in FreeBSD is complex.
See https://forums.freebsd.org/threads/no-audio-on-my-system.57473/post-327863
pcm(4) and mixer(8)

One other possibility is that newer laptops (is that what your using?) have combined the headphone and mic into a single 4 pin jack. Older 3 pin headphones will mute but not align the contacts for sound.

If you have further questions it would help to know your hardware. Hopefully, someone has worked this out. If not, then a listing of the sound pins will be needed.
 
This is quite confusing. Would love it if someone could add a How-To guide on this.
 
I managed to get my sound working thanks to contributions made by shepper in multiple threads. Have you doublechecked that the headphones and speakers are in the same association? I guess they could be because the sound gets muted but you can always go with dmesg | grep hda to find out.

Example from my laptop:
Code:
hdaa0: Patched pins configuration:
hdaa0: nid   0x    as seq device       conn  jack    loc        color   misc
hdaa0: 22 0221101f 1  15 Headphones    Jack  1/8     Front      Black   0
hdaa0: 23 02a19020 2  0  Mic           Jack  1/8     Front      Pink    0
hdaa0: 24 400001f0 15 0  Line-out      None  Unknown 0x00       Unknown 1 DISA
hdaa0: 25 400001f0 15 0  Line-out      None  Unknown 0x00       Unknown 1 DISA
hdaa0: 26 92170110 1  0  Speaker       Fixed Analog  0x12       Unknown 1
hdaa0: 27 400001f0 15 0  Line-out      None  Unknown 0x00       Unknown 1 DISA
hdaa0: 28 224511f0 15 0  SPDIF-out     Jack  Optical Ext-Front  Black   1
hdaa0: 29 95a7112e 2  14 Mic           Fixed Analog  0x15       Black   1

And "as" you can see they have the same association with "as" (1).
If they are not in the same association then you fix it by adding the correct line to /boot/device.hints
where you put information about sound driver, nid, as, seq, device: as found in snd_hda(4).

Line in my /boot/device.hints is hint.hdaa.0.nid22.config="as=1 seq=15". This sets the headphones to be associated with the speakers on my laptop.
^^^
Make sure to put correct hinting corresponding to your devices and system. Hope this is the case and you became somewhat helped by this.
 
I managed to get my sound working thanks to contributions made by shepper in multiple threads. Have you doublechecked that the headphones and speakers are in the same association? I guess they could be because the sound gets muted but you can always go with dmesg | grep hda to find out.

Example from my laptop:
Code:
hdaa0: Patched pins configuration:
hdaa0: nid   0x    as seq device       conn  jack    loc        color   misc
hdaa0: 22 0221101f 1  15 Headphones    Jack  1/8     Front      Black   0
hdaa0: 23 02a19020 2  0  Mic           Jack  1/8     Front      Pink    0
hdaa0: 24 400001f0 15 0  Line-out      None  Unknown 0x00       Unknown 1 DISA
hdaa0: 25 400001f0 15 0  Line-out      None  Unknown 0x00       Unknown 1 DISA
hdaa0: 26 92170110 1  0  Speaker       Fixed Analog  0x12       Unknown 1
hdaa0: 27 400001f0 15 0  Line-out      None  Unknown 0x00       Unknown 1 DISA
hdaa0: 28 224511f0 15 0  SPDIF-out     Jack  Optical Ext-Front  Black   1
hdaa0: 29 95a7112e 2  14 Mic           Fixed Analog  0x15       Black   1

And "as" you can see they have the same association with "as" (1).
If they are not in the same association then you fix it by adding the correct line to /boot/device.hints
where you put information about sound driver, nid, as, seq, device: as found in snd_hda(4).

Line in my /boot/device.hints is hint.hdaa.0.nid22.config="as=1 seq=15". This sets the headphones to be associated with the speakers on my laptop.
^^^
Make sure to put correct hinting corresponding to your devices and system. Hope this is the case and you became somewhat helped by this.

This is my verbose boot output:

Code:
hdaa0: Patching widget caps nid=29 0x00400400 -> 0x00700400
hdaa0: Patched pins configuration:
hdaa0: nid 0x as seq device conn jack loc color misc
hdaa0: 18 90a60130 3 0 Mic Fixed Digital Internal Unknown 1
hdaa0: 19 40000000 0 0 Line-out None Unknown 0x00 Unknown 0 DISA
hdaa0: 20 90170110 1 0 Speaker Fixed Analog Internal Unknown 1
hdaa0: 22 411111f0 15 0 Speaker None 1/8 Rear Black 1 DISA
hdaa0: 23 411111f0 15 0 Speaker None 1/8 Rear Black 1 DISA
hdaa0: 24 411111f0 15 0 Speaker None 1/8 Rear Black 1 DISA
hdaa0: 25 04a11040 4 0 Mic Jack 1/8 Right Black 0
hdaa0: 26 411111f0 15 0 Speaker None 1/8 Rear Black 1 DISA
hdaa0: 27 411111f0 15 0 Speaker None 1/8 Rear Black 1 DISA
hdaa0: 30 411111f0 15 0 Speaker None 1/8 Rear Black 1 DISA
hdaa0: 33 04211020 2 0 Headphones Jack 1/8 Right Black 0
hdaa0: 4 associations found:

It looks like "as" is 1 for Internal Speaker and 2 for Headphones Jack. Is that correct?
 
Code:
hdaa0: 20 90170110 1 0 Speaker Fixed Analog Internal Unknown 1
This should be your internal speaker that is wired to nid 20. The default association is AS=1.

Code:
hdaa0: 33 04211020 2 0 Headphones Jack 1/8 Right Black 0
This should be a 1/8 inch jack on the Right side of your laptop that is wired to nid 33. For nid33 the default association is AS=2

If you reassign nid33 to be in the same association as nid20 (AS=1) and give it a sequence of 15 (seq=15), when headphones are plugged into the jack, the lower output nid (nid20) should mute. There are a number of examples of the actual syntax that can be found by searching the forum or you can modify michael_hackson's example by changing nid22 to nid20 nid33.
 
Last edited:
Code:
hdaa0: 20 90170110 1 0 Speaker Fixed Analog Internal Unknown 1
This should be your internal speaker that is wired to nid 20. The AS=1.

Code:
hdaa0: 33 04211020 2 0 Headphones Jack 1/8 Right Black 0
This should be a 1/8 inch jack on the Right side of your laptop that is wired to nid 33.

If you assign nid 33 to be in the same association as nid20 (AS=1) and give it a sequence of 15 (seq=15), when headphones are plugged into the jack, the lower output nid (20) should mute. There are a number of examples of the actual syntax that can be found by searching the forum or you can modify michael_hackson example by changing nid22 to nid20.

This worked. Just had to give Headphones Jack the same "as" (1) as the Internal Speaker.

Thanks.
 
i-bsd
You can help future users by posting the make/model of laptop. Future users who search the web and this forum using "make/model + FreeBSD + sound" should find your fix.

Sure. X1 Carbon 6th Gen ThinkPad. Realtek ALC285.

Add this line to /boot/device.hints:

Code:
hint.hdaa.0.nid33.config="as=1 seq=15"

Reboot.
 
Can someone explain why the following in /boot/device.hints works:
Code:
hint.hdaa.0.nid33.config="as=1 seq=15"
But sysctl dev.hdaa.0.nid33_config="as=1 seq=15 does not?
 
But sysctl dev.hdaa.0.nid33_config="as=1 seq=15 does not?

The sysctl(8) program allows you to set values used by the kernel (in some cases). It can be done permanently via /etc/sysctl.conf.

On the other hand the boot loader(8) reads /boot/loader.rc and also device.hints(5) during initial startup and then boots the kernel if it is not interrupted.

But you can edit /boot/loader.conf and /boot/device.hints with the sysrc command using the -f flag and the filename.
 
Can someone explain why the following in /boot/device.hints works:
Code:
hint.hdaa.0.nid33.config="as=1 seq=15"
But sysctl dev.hdaa.0.nid33_config="as=1 seq=15 does not?

In case of "Intel High Definition Audio" changing the audio configuration during runtime using sysctrl works if you do it right. As per manpage you have to commit your change:

dev.hdaa.%d.reconfig Setting this to a non-zero value makes driver to destroy existing pcm devices and process new pins configuration set via dev.hdaa.%d.nid%d_config.

Example:
Code:
sysctl dev.hdaa.0.reconfig=1
sysctl dev.hdaa.1.reconfig=1

I highly recommend to read snd_hda(). It's not FreeBSD which is complex when it comes to sound. It's the audio chipsets which become more and more complex! In the old days you usually had one stereo output and one microphone or line input. Today you have multichannel output and input and they are (in case of Intel HD Audio) reconfigurable in software to meet different situations (e.g. 5.1, 7.1 and so on). Also todays audio jacks could be used as input or output depending on your software configuration. Beside this you might have multiple sound cards inside your computer. One dedicated sound card and one within your GPU. In case of my Lenovo X230 there is a dedicated audio chip (Realtek ALC269) and another sound card within the GPU(?) for HDMI, both implementing a Intel HD Audio. Would be interesting how the default setting looks like when running a recent Linux distribution. In Windows it might be no problem, because you install a specific driver from the vendor (Lenovo) which gives a reasonable default setting because the driver sticks to a particular hardware model (or line).
 
Hi,

let me confirm next code for /boot/device.hints works well for my Thinkpad X1 Carbon 5gen, type 20HR:
Code:
hint.hdaa.0.nid22.config="as=1 seq=15"
Thanks.
 
I ran into a problem like this when I was running, ahem, Debian "Stretch" GNU/Linux and I found a very useful tool in the alsa-tools pkg on that OS it is called hdajackretask located here: alsa-tools git repository it seems to be able to understand the details of how the pin out is done and present it in a graphical way that (at least on the advanced page) make sense to those of us who have a bit of difficulty picking out all that is there. I used it to correctly label/identify an output pin that I was using for my side speakers - it creates a boot time script that sounds like it does the equivalent to the lines in the /boot/device.hints but for that other Os.

Sadly I see that that part of the alsa code is not in /usr/ports/audio but I can not see whether that is because it does things that only makes sense on a Linux system or because no one interested enough has looked at it. I would love to get more than a single pair of speakers working...
 
I have a RealTek ALC1200 (7.1 Audio + 2.0 HP) on-board apparently and the analogue outputs are on the third audio device behind the HDMI audio from my NVidia graphics card and the RealTek units own digital(optical) output. I am not running FreeBSD at this precise moment but I have tracked down the configuration file that hdajackretask is using and it contains the following:

INI:
[codec]
0x10ec0888 0x1025014e 0


[pincfg]
0x11 0x411111f0
0x14 0x01014010
0x15 0x01011012
0x16 0x01016011
0x17 0x01014013
0x18 0x01a19840
0x19 0x02a19841
0x1a 0x411111f0
0x1b 0x0221401f
0x1c 0x0181304f
0x1d 0x411111f0
0x1e 0x014b1130
0x1f 0x411111f0

Next time I boot FreeBSD I will look to seeing if I can get those into the setup with some dev.hdaa.2.nidXX magic.

My main issue is that on the other OS I can audio out of all of the 7.1 outputs and mixer controls show all of them whereas on FreeBSD I only see a stereo output that only comes out of the Front (L/R) outputs and not to any other - given that the Front outputs are a pair of weedy speakers built into my primary monitor and the Side outputs are fed to a pair of amplified speakers positioned either side of my desk you can see why I am keen to get audio routed to them as well!

For the record I am a University Graduate with a degree in Electrical and Electronic Engineering - so I do have some idea of what is going on with the internal (and highly flexible I must admit) audio processing in the Intel HDA device...!
 
Ah, there is one difference in my FreeBSD setup which is that 0x17 which is nid23 is 0x01012014 under FreeBSD instead of 0x01014013, I am just tweaking my /boot/device.hints to see whether that makes any difference. To be honest I am not sure that this will fix things as that will only affect what will become the green Line-out 3.5mm socket on the back of the PC carries (as sequence 3 in association 1) - whilst that correction to the assignment is probably useful it isn't obvious that the other outputs will sudden become active as part of a 7.1 group...
 
Hi SlySven .
Im by far not a sound expert and the FreeBSD sound system remains substantially obscure to me.
Afa I am aware the snd_hda(4) driver enables 2.0 sound by default. For surround sound you need to configure more channels.
I also have a ALC1200 and thats how it looks actually with 4 channels:
Code:
# cat /dev/sndstat
FreeBSD Audio Driver (64bit 2009061500/amd64)
Installed devices:
pcm0: <ATI R6xx (HDMI)> on hdaa0  (1p:1v/0r:0v)
pcm1: <Realtek ALC1200 (Analog 7.1+HP/2.0)> on hdaa1  (1p:4v/1r:4v) default
pcm2: <Realtek ALC1200 (Rear Digital)> on hdaa1  (1p:1v/0r:0v)
pcm3: <Realtek ALC1200 (Onboard Digital)> on hdaa1  (1p:1v/0r:0v)
pcm4: <Realtek ALC1200 (Front Analog Mic)> on hdaa1  (0p:0v/1r:1v)
No devices installed from userspace.
You can configure your default device and your desired number of channels in /etc/sysctl.conf, e.g. if you need totally 6 channels for surround sound:
Code:
hw.snd.default_unit=4            # use the number of your default device
hw.snd.verbose=1
dev.pcm.4.play.vchanformat=s16le:5.1
dev.pcm.4.play.vchans=6            # number of virtual channels
dev.pcm.4.eq_preamp=+5
After a reboot you check your sound devices with cat /dev/sndstat.
To check your channels you can use speaker-test from the audio/alsa-utils package/port. If something went wrong play around with the nids of your external speakers.
 
When we are talking about virtual channels on a pcm device I am still not entirely clear whether we are talking about:
  • the division of an audio stream into the needed channels for each audio output (or input for recording obviously) - e.g. the front-left, front-right ... sub-woofer (err, Low-Frequency Environment - LFE)
  • the ability to have an individual group of those that an application can pump audio out to (or suck in) in the belief that it is the only thing "doing" audio {even though a cunning stunt is being performed upon such applications and in fact, for outputs, they are being combined and then put out to the actual hardware.]
As it happens I think 🤯 the dev.pcm.?.play.vchans=? setting is for the latter - and the dev.pcm.?.play.vchanformat=s16le:?.? is the former - but then, "I think rain is wet so who am I to say?"

I have made some headway in that I realised that I had puspulseaudio(1) installed and it was forcing everything to be stereo by virtual of the following defaults in /usr/local/etc/pulse/daemon.conf:
Code:
; default-sample-channels = 2
; default-channel-map = front-left,front-right
and changing them to (my current arrangement):
Code:
default-sample-channels = 4
default-channel-map = front-left,front-right,rear-left,rear-right

As I only need pulseaudio for audio from a mozilla type web browser I am considered dropping it and recompiling one of them to not use it - at least at run time.

As it happens I can now get surround (more than two channel) audio playback over the four speakers but I see that there does not seem to be a mixer control that allows me to tweak the four channel levels individually - the mixer(1) utility only handles one (mono) or two (left:right) and alsamixer(1) is only showing a master control for the PCM channel (with again only a left:right split) on my Debian GNU/Linux OS the same (7.1) hardware device is split into Front, Centre, Side, Rear and LFE - i.e. into controls for each audio channel...
 
Sound is one of the few things I think OpenBSD does better than FreeBSD. OpenBSD recognized and set up correctly my crummy Realtek soundcard out of the box, including the super buggy audio jack (which works like crap even under Windows); to get it working on FreeBSD I had to do the usual modifications on loader.conf, plus rebuilding the kernel with a patch in order to stop headphones from spitting out horrible, creaky noises... Which is definitely not super user friendly (I still prefer and use FreeBSD though).
 
Back
Top