# Unable to get headphones to work



## elgrande (May 3, 2021)

Hello all,

I am struggling to get the headphones to work on my XMG Neo 17 (2021) running FreeBSD 13.
Internal speakers work fine.

Here is my info from the pindump:

```
root@elxmgbsdo:~ # sysctl dev.hdac.1.pindump=1
dev.hdac.1.pindump: 0 -> 0
root@elxmgbsdo:~ # dmesg | grep -E "^hdaa1:"
hdaa1: <Realtek ALC1220 Audio Function Group> at nid 1 on hdacc1
hdaa1: Dumping AFG pins:
hdaa1: nid   0x    as seq device       conn  jack    loc        color   misc
hdaa1: 18 90a60130 3  0  Mic           Fixed Digital Internal   Unknown 1
hdaa1:     Caps: IN                 
hdaa1: 20 40000000 0  0  Line-out      None  Unknown 0x00       Unknown 0 DISA
hdaa1:     Caps:    OUT HP EAPD      Sense: 0x00000000 (disconnected)
hdaa1: 21 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa1:     Caps: IN OUT              Sense: 0x00000000 (disconnected)
hdaa1: 22 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa1:     Caps: IN OUT              Sense: 0x00000000 (disconnected)
hdaa1: 23 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa1:     Caps: IN OUT              Sense: 0x00000000 (disconnected)
hdaa1: 24 04a11040 4  0  Mic           Jack  1/8     Right      Black   0
hdaa1:     Caps: IN OUT         VREF Sense: 0x00000000 (disconnected)
hdaa1: 25 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa1:     Caps: IN OUT HP      VREF Sense: 0x00000000 (disconnected)
hdaa1: 26 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa1:     Caps: IN OUT         VREF Sense: 0x00000000 (disconnected)
hdaa1: 27 90170110 1  0  Speaker       Fixed Analog  Internal   Unknown 1
hdaa1:     Caps: IN OUT HP EAPD VREF Sense: 0x00000000 (disconnected)
hdaa1: 30 04451120 2  0  SPDIF-out     Jack  Optical Right      Black   1
hdaa1:     Caps:    OUT             
hdaa1: NumGPIO=8 NumGPO=0 NumGPI=0 GPIWake=0 GPIUnsol=1
hdaa1:  GPIO0: disabled
hdaa1:  GPIO1: disabled
hdaa1:  GPIO2: disabled
hdaa1:  GPIO3: disabled
hdaa1:  GPIO4: disabled
hdaa1:  GPIO5: disabled
hdaa1:  GPIO6: disabled
hdaa1:  GPIO7: disabled
root@elxmgbsdo:~ #
```

The only little success I could achieve was routing the headphone audio to the mic jack using the following in /boot/device.hints:

```
hint.hdaa.1.nid24.config="as=1 seq=15 device=Headphones conn=Jack"
```

If I do this, it is detected once I plug a phone and I hear the (distorted) audio on my headphones. But using the mic jack is obviously not the way it is meant to be and works only really distorted.
It simply is the wrong plug, I need to route to the headphones plug.
But from my pin config I cannot find out which nid it is, and I already tried some of them without success.

Any ideas would be really appreciated.


----------



## astyle (May 5, 2021)

pindump??? That part looks a little strange to me. I just made a post in another thread here, and I think it will help you, as well. But thing is, try `# cat /dev/sndstat` and take a look there.

As an aside, going by your post, FreeBSD 13 seems to install just fine on a Cezanne Zen 3 chipset??? You got lucky, those things are only now appearing in US! FreeBSD normally lags behind on hardware support, so this is a major plus!


----------



## elgrande (May 6, 2021)

Maybe I was giving too less basic details.

My first try was of course trying all devices from /dev/sndstat, but none of the outputs to headphone audio.


```
root@elxmgbsdo:~ # cat /dev/sndstat
Installed devices:
pcm0: <NVIDIA (0x009e) (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA (0x009e) (HDMI/DP 8ch)> (play)
pcm2: <NVIDIA (0x009e) (HDMI/DP 8ch)> (play)
pcm3: <Realtek ALC1220 (Internal Analog)> (play/rec) default
pcm4: <Realtek ALC1220 (Right Digital)> (play)
pcm5: <Realtek ALC1220 (Right Analog Mic)> (rec)
pcm6: <USB audio> (rec)
No devices installed from userspace.
root@elxmgbsdo:~ #
```

This device (Realtek ALC1220) is using snd_hda driver, where it may occur that you have to adjust the pin config. That is why I included the pindump.
Basically I was just following https://www.freebsd.org/cgi/man.cgi?snd_hda and trying to find out which is the current route for the headphones. But strangely there is no headphones jack detected.


----------



## astyle (May 6, 2021)

elgrande said:


> ```
> root@elxmgbsdo:~ # cat /dev/sndstat
> Installed devices:
> pcm0: <NVIDIA (0x009e) (HDMI/DP 8ch)> (play)
> ...


There we go. The default sound routing is to pcm3. It's labeled 'Internal Analog'. Your laptop should have just one headphone jack (not mic). It's FreeBSD sees it as pcm4. That's the one you need. Run `# sysctl hw.snd.default_unit=4`, plug cans in, and listen as much as you want.

To make it persist across reboots, do this: Make this change permanent by adding the following line to /etc/sysctl.conf: `hw.snd.default_unit=4`

I didn't do strange stuff like pindump or boot.device.hints. I do hope this post helps you, though.


----------



## elgrande (May 6, 2021)

I tried that before.
As I said I tried each and every pcm device, also pcm4.
I know it can be that simple, unfortunately it is not in my case.


----------



## astyle (May 6, 2021)

I think this is at least in part because you tried messing with other settings before. That kind of thing happened to me, as well - I tried modifying settings in weird places for Wayland, and now it's difficult to remember EVERYTHING I tried, so that it can be put back to defaults. As a result of messing around in obscure places, official instructions don't give me results. My suggestion would be to just re-install everything from scratch, and follow official instructions (rather than random bits of seemingly helpful info) that I pointed to. You do have very new hardware, 13-RELEASE is still very fresh, so just try from scratch again.


----------



## elgrande (May 6, 2021)

I actually tried switching default unit to pcm4 at very first on a fresh install.
Believe me it just does not work for my alc1220 chip.
/dev/sndstat also thinks this is a digital out, I am trying to use a analog plug though.
I am into FreeBSD since version 5 or 6 and kinda know what I am doing.
I appreciate you trying to help me, but this device is strange.
BTW I even cannot get proper audio under Ubuntu, which I tried for testing.
It is not urgent anymore anyhow since I found an old usb dac in the basement which works, so I have a workaround.
Nevertheless it would be interesting how to get the builtin audio jack to work, but I doubt it can be done without patching the driver on code level.
Cheers


----------

