# [ThinkPad X230] No sound on headphones



## sickboy (Dec 20, 2013)

Hi there,

I'm running FreeBSD 9.2-RELEASE on a ThinkPad X230. Sound works so far, but I can't hear anything on headphones.

`dmesg -a`:

```
hdacc0: <Realtek ALC269 HDA CODEC> at cad 0 on hdac0
hdaa0: <Realtek ALC269 Audio Function Group> at nid 1 on hdacc0
pcm0: <Realtek ALC269 (Analog)> at nid 20 and 24 on hdaa0
pcm1: <Realtek ALC269 (Analog)> at nid 21 and 18 on hdaa0
hdacc1: <Intel Panther Point HDA CODEC> at cad 3 on hdac0
hdaa1: <Intel Panther Point Audio Function Group> at nid 1 on hdacc1
pcm2: <Intel Panther Point (HDMI/DP 8ch)> at nid 5 on hdaa1
pcm3: <Intel Panther Point (HDMI/DP 8ch)> at nid 6 on hdaa1
pcm4: <Intel Panther Point (HDMI/DP 8ch)> at nid 7 on hdaa1
```

Advice, anyone?


----------



## suhijo (Dec 21, 2013)

Can you post the output of the next command please?  `cat /dev/sndstat`


----------



## sickboy (Dec 21, 2013)

No problem.


```
> cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
Installed devices:
pcm0: <Realtek ALC269 (Analog)> (play/rec) default
pcm1: <Realtek ALC269 (Analog)> (play/rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <Intel Panther Point (HDMI/DP 8ch)> (play)
```

BTW: I can switch to headphones when I set `sysctl hw.snd.default_unit=1`. Is it possible to do so automatically?


----------



## suhijo (Dec 21, 2013)

As I thought, the default output is

```
pcm0
```
so, execute this `sysctl hw.snd.default_unit=1`  and see if it works.


----------



## sickboy (Dec 21, 2013)

Yes, it does.


----------



## suhijo (Dec 21, 2013)

Well, you can execute that command every time you want to listen through the headphones or simply make it default by adding 


```
hw.snd.default_unit=1
```
to the file etc/sysctl.conf.


----------



## sickboy (Dec 21, 2013)

But then headphone output is the default. Doesn't the system detect whether headphones are plugged in or not?


----------



## suhijo (Dec 21, 2013)

This is not automatic in FreeBSD.


----------



## jrm@ (Dec 21, 2013)

I had the same problems with my X220 and my friend's T530.  Things are a little more complicated because Lenovo switched to one jack for both external microphone and speakers (headphones).

I thought this was fixed later in 9-STABLE, but I still have the following in /boot/loader.conf, which might work for you.

```
# Out : speaker + headphones
hint.hdac.0.cad0.nid25.config="as=1 seq=15"
# In : mic + external mic
hint.hdac.0.cad0.nid35.config="as=2"
hint.hdac.0.cad0.nid27.config="as=2 seq=15"
```

I also have the following in /etc/sysctl.conf

```
hw.snd.default_auto=1
hw.snd.default_unit=0
```


----------



## kpa (Dec 21, 2013)

suhijo said:
			
		

> This is not automatic in FreeBSD.



It's not automatic but the sound driver can be configured to switch the main speakers off when the headphones are plugged in. See example 2 in the  snd_hda(4) manual page.


----------



## sickboy (Dec 22, 2013)

jrm said:
			
		

> I had the same problems with my X220 and my friend's T530.  Things are a little more complicated because Lenovo switched to one jack for both external mic and speakers (headphones).


Unfortunately, it doesn't work either. I still have to switch manually.


----------



## Grance (Dec 23, 2013)

This is not automatic in FreeBSD.


----------



## pkubaj (Dec 26, 2013)

Well, it is automatic for me. I had an opposite problem once (speakers not working, sound only via headphones). Then I found some thread by accident on this forum (I don't remember which one) which required adding something to /boot/device.hints. From the looks of the file I think it was 

```
hint.hdac.0.cad0.nid31.config="as=2 seq=0 device=Speaker"
hint.hdac.0.cad0.nid25.config="as=2 seq=15 device=Headphones"
```


----------



## jrm@ (Dec 27, 2013)

It's always been automatic for me as well until the Lenovo X220 and T530.  The answer is likely in snd_hda(4).  You could also try the freebsd-multimedia@freebsd.org mailing list.


----------



## sickboy (Jan 5, 2014)

After some confusion concerning the right settings for nid, as, and seq, as stated in snd_hda(), I've found the correct hints:

```
hint.hdaa.0.nid20.config="as=1 seq=0 device=Speaker"
hint.hdaa.0.nid21.config="as=1 seq=15 device=Headphones"
```

Thank you all for helping me.


----------



## emmex (Apr 15, 2014)

sickboy said:
			
		

> After some confusion concerning the right settings for nid, as, and seq, as stated in snd_hda(), I've found the correct hints:
> 
> ```
> hint.hdaa.0.nid20.config="as=1 seq=0 device=Speaker"
> ...



Thanks to you @sickboy. This works in my Samsung ATIV BOOK 2 model NP270E5E-K02IT too.


----------

