Bug 222636 - Headphones redirection for Lenovo T420s
Summary: Headphones redirection for Lenovo T420s
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Christos Margiolis
URL: https://www.freebsd.org/cgi/man.cgi?q...
Keywords: feature, needs-patch, needs-qa
Depends on:
Blocks:
 
Reported: 2017-09-27 09:08 UTC by Slawomir Wojciech Wojtczak
Modified: 2025-06-13 12:31 UTC (History)
4 users (show)

See Also:


Attachments
pciconf.out (4.24 KB, application/x-extension-out)
2025-05-19 10:14 UTC, Slawomir Wojciech Wojtczak
no flags Details
dmesg.out (22.10 KB, application/x-extension-out)
2025-05-19 10:14 UTC, Slawomir Wojciech Wojtczak
no flags Details
sysctl.out (27 bytes, application/x-extension-out)
2025-05-19 10:15 UTC, Slawomir Wojciech Wojtczak
no flags Details
dmesg.NEW.out (29.38 KB, application/x-extension-out)
2025-05-31 22:07 UTC, Slawomir Wojciech Wojtczak
no flags Details
t420s_patch (1.38 KB, patch)
2025-06-11 17:28 UTC, Christos Margiolis
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Slawomir Wojciech Wojtczak 2017-09-27 09:08:19 UTC
Same as here:
https://lists.freebsd.org/pipermail/freebsd-bugs/2013-March/052009.html

The headphone jack is 'deaf' on T420s while it works well on T520.

I had the same problem as X300 and as I see the thread from the link there is also an 'exception' for X300.

Regards,
vermaden
Comment 1 Slawomir Wojciech Wojtczak 2017-09-27 21:33:10 UTC
These lines in /boot/device.hints file solves the problem:

# SOUND ON HEADPHONES
hint.hdaa.0.nid31.config="as=1"
hint.hdaa.0.nid25.config="as=1 seq=15 device=Headphones mute=0 misc=0"
hint.hdaa.0.nid28.config="as=1 seq=15 device=Headphones mute=0 misc=0"

Here are devices details from 'sysctl -a | grep hda' command:

# dev.hdaa.0.nid31_original: 0x90170110 as=1 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
# dev.hdaa.0.nid31_config: 0x90170110 as=1 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
# dev.hdaa.0.nid31: pin: Speaker (Fixed)
#      Widget cap: 0x00400501 PWR STEREO
#     Association: 0 (0x0001)
#         Pin cap: 0x00000010 OUT
#      Pin config: 0x90170110 as=1 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
#     Pin control: 0x00000040 OUT
#     Connections: 2
#           + <- nid=16 [audio output] (selected)
#           + [DISABLED] <- nid=17 [audio output]
# 
# dev.hdaa.0.nid28_original: 0x6121401f as=1 seq=15 device=Headphones conn=None ctype=1/8 loc=Ext-Rear color=Green misc=0
# dev.hdaa.0.nid28_config: 0x6121401f as=1 seq=15 device=Headphones conn=None ctype=1/8 loc=Ext-Rear color=Green misc=0
# dev.hdaa.0.nid28: pin: Headphones (None) [DISABLED]
#      Widget cap: 0x00400581 PWR UNSOL STEREO
#         Pin cap: 0x00000014 PDC OUT
#      Pin config: 0x6121401f as=1 seq=15 device=Headphones conn=None ctype=1/8 loc=Ext-Rear color=Green misc=0
#     Pin control: 0x00000000
#     Connections: 2
#           + <- nid=16 [audio output] (selected)
#           + <- nid=17 [audio output]
# 
# dev.hdaa.0.nid25_original: 0x04211040 as=4 seq=0 device=Headphones conn=Jack ctype=1/8 loc=Right color=Black misc=0
# dev.hdaa.0.nid25_config: 0x04211040 as=4 seq=0 device=Headphones conn=Jack ctype=1/8 loc=Right color=Black misc=0
# dev.hdaa.0.nid25: pin: Headphones (Black Jack)
#      Widget cap: 0x00400581 PWR UNSOL STEREO
#     Association: 1 (0x0001)
#         Pin cap: 0x0000001c PDC HP OUT
#      Pin config: 0x04211040 as=4 seq=0 device=Headphones conn=Jack ctype=1/8 loc=Right color=Black misc=0
#     Pin control: 0x000000c0 HP OUT
#     Connections: 2
#           + [DISABLED] <- nid=16 [audio output]
#           + <- nid=17 [audio output] (selected)
Comment 2 Slawomir Wojciech Wojtczak 2018-05-24 08:44:55 UTC
Is it possible to add that information to FreeBSD tree so it does not have to be added at every install to /boot/device.hints file? Expecially when 11.2-BETA* is in the table?
Comment 3 Slawomir Wojciech Wojtczak 2019-10-14 13:13:08 UTC
Could you finally add/commit this 'quirk' please?

Its the same on 12.1-RC1.

These lines in /boot/device.hints fix the problem on ThinkPad T420s:

# SOUND ON HEADPHONES
hint.hdaa.0.nid31.config="as=1"
hint.hdaa.0.nid25.config="as=1 seq=15 device=Headphones mute=0 misc=0"
hint.hdaa.0.nid28.config="as=1 seq=15 device=Headphones mute=0 misc=0"

Regards.
Comment 4 Slawomir Wojciech Wojtczak 2020-10-28 19:16:35 UTC
Maybe its possible to add such quirk for 13-CURRENT now?
Comment 5 Slawomir Wojciech Wojtczak 2021-05-10 09:30:46 UTC
Maybe for 14-CURRENT now? :)
Comment 6 Slawomir Wojciech Wojtczak 2022-10-10 03:33:21 UTC
It also solves the same problem on Lenovo ThinkPad X220T (do not confuse with regular X220).
Comment 7 Graham Perrin freebsd_committer freebsd_triage 2022-12-05 04:06:37 UTC
Keyword: needs-patch

(In reply to Slawomir Wojciech Wojtczak from comment #3)

> These lines in /boot/device.hints …

Please, can you provide what's needed? A .patch or .diff as an attachment. Thanks. 

Seeking    hints   at <https://github.com/freebsd/freebsd-src/find/main>, I can't tell which file(s) should be patched.
Comment 8 Slawomir Wojciech Wojtczak 2022-12-05 15:50:22 UTC
(In reply to Graham Perrin from comment #7)

Sorry to disappoint - but I do not know what (and how) to patch this.

This is only thing I know it works - these lines in /boot/device.hints file:

# SOUND ON HEADPHONES T420s/X220T
hint.hdaa.0.nid31.config="as=1"
hint.hdaa.0.nid25.config="as=1 seq=15 device=Headphones mute=0 misc=0"
hint.hdaa.0.nid28.config="as=1 seq=15 device=Headphones mute=0 misc=0"

I do not know how to translate that into code ...

Regards.
Comment 9 Christos Margiolis freebsd_committer freebsd_triage 2025-04-29 22:42:21 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #8)
Is this still an issue in current versions of FreeBSD? That is, if you remove those hints, do things work fine?
Comment 10 Slawomir Wojciech Wojtczak 2025-04-29 23:13:11 UTC
(In reply to Christos Margiolis from comment #9)

The hints are still needed.
Comment 11 Christos Margiolis freebsd_committer freebsd_triage 2025-04-29 23:17:17 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #10)
Please attach the following things:
- pciconf -lv
- dmesg after booting _without_ the hints and then running "sysctl dev.hdac.0.pindump=1"
Comment 12 Slawomir Wojciech Wojtczak 2025-05-19 10:14:07 UTC
Sure. Adding.
Comment 13 Slawomir Wojciech Wojtczak 2025-05-19 10:14:34 UTC
Created attachment 260541 [details]
pciconf.out
Comment 14 Slawomir Wojciech Wojtczak 2025-05-19 10:14:54 UTC
Created attachment 260542 [details]
dmesg.out
Comment 15 Slawomir Wojciech Wojtczak 2025-05-19 10:15:15 UTC
Created attachment 260543 [details]
sysctl.out
Comment 16 Christos Margiolis freebsd_committer freebsd_triage 2025-05-21 19:52:40 UTC
dmesg should be run _after_ running "sysctl dev.hdac.0.pindump=1". Also please do not forget disabling all hints before rebooting.
Comment 17 Slawomir Wojciech Wojtczak 2025-05-31 22:06:57 UTC
(In reply to Christos Margiolis from comment #16)

Hi,

about that 'dev.hdac.0.pindump' ... I am not able to switch it into '1'.

# sysctl dev.hdac.0.pindump=1
dev.hdac.0.pindump: 0 -> 0

I even added it to loader.conf(8) but still the same:

# grep hdac /boot/loader.conf
  dev.hdac.0.pindump=1

I attach new dmesg(8) output after executing 'sysctl dev.hdac.0.pindump=1' command tho.

Regards,
ver
Comment 18 Slawomir Wojciech Wojtczak 2025-05-31 22:07:17 UTC
Created attachment 260846 [details]
dmesg.NEW.out
Comment 19 Christos Margiolis freebsd_committer freebsd_triage 2025-06-01 15:27:44 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #17)
This sysctl doesn't actually set anything to 1, it just triggers a pin dump which is visible in dmesg, including the one you shared now, if you look at the end of it.

So, as is expected, your device does need patching, but the patches it needs to work fully, are those that already exist [1] (also the link you shared in your first comment), not the ones you have. Can you please remove your patches from /boot/device.hints and simply run the existing ones?

[1] https://cgit.freebsd.org/src/commit/?id=156860b2b32cfd192528d405f9f4dff8071e6a3b
Comment 20 Slawomir Wojciech Wojtczak 2025-06-01 21:14:22 UTC
(In reply to Christos Margiolis from comment #19)

This patch is from 2013 and has 'MFC after: 1 month' - why it has not been merged?
Comment 21 Christos Margiolis freebsd_committer freebsd_triage 2025-06-01 21:57:27 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #20)
This patch has been MFC'd to branches as old as even stable/10. What version of FreeBSD are you running on that machine?
Comment 22 Slawomir Wojciech Wojtczak 2025-06-01 21:59:55 UTC
(In reply to Christos Margiolis from comment #21)

14.2 - I did not even checked if it works without these loader.conf(4) settings :D

I will check and let You know.
Comment 23 Christos Margiolis freebsd_committer freebsd_triage 2025-06-01 22:02:56 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #22)
Also make sure to remove the /boot/device.hints lines.
Comment 24 Slawomir Wojciech Wojtczak 2025-06-09 22:46:08 UTC
(In reply to Christos Margiolis from comment #23)

This commit - https://cgit.freebsd.org/src/commit/?id=156860b2b32cfd192528d405f9f4dff8071e6a3b - does not change anything.

T420s =/= T420

They are different laptops.

... and I have X220 and it works w/o a problem and not settings in /boot/device.hints needed.

So T420s still needs the settings I mentioned above in the /boot/device.hints file.

Regards,
ver
Comment 25 Christos Margiolis freebsd_committer freebsd_triage 2025-06-11 17:28:24 UTC
Created attachment 261178 [details]
t420s_patch

(In reply to Slawomir Wojciech Wojtczak from comment #24)
Oh. I thought you meant "T420s" as in "T420 models". My bad. This makes sense then.

Can you please apply the attached patch and let me know?

Also I see you mention the X220T in previous comments. Do you need the exact same quirks for it, as with T420s? If yes, please attach the X220T's "pciconf -lv" as well, so that I can see the device ID.
Comment 26 Slawomir Wojciech Wojtczak 2025-06-12 22:45:40 UTC
I applied the patch and after 'make buildkernel' and reboot everything works like a charm without any entries at /dev/device.hints file.
Comment 27 commit-hook freebsd_committer freebsd_triage 2025-06-12 23:03:03 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=84e73074412719ec83143fb514625c09d27f468c

commit 84e73074412719ec83143fb514625c09d27f468c
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-06-11 17:28:40 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-06-12 23:02:15 +0000

    snd_hda: Patch Lenovo T420s

    PR:             222636
    Tested by:      vermaden@interia.pl
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 day

 sys/dev/sound/pci/hda/hdaa_patches.c | 16 ++++++++++++++++
 sys/dev/sound/pci/hda/hdac.h         |  1 +
 2 files changed, 17 insertions(+)
Comment 28 Slawomir Wojciech Wojtczak 2025-06-12 23:04:49 UTC
Thank You for committing it - it was worth to wait 8 years for it :)
Comment 29 Christos Margiolis freebsd_committer freebsd_triage 2025-06-12 23:06:07 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #28)
Cheers! Sorry for not getting that fixed earlier. :-)
Comment 30 Slawomir Wojciech Wojtczak 2025-06-12 23:15:04 UTC
(In reply to Christos Margiolis from comment #29)

No problem mate - we all live our busy lives - I am glad that it is finally there - not for me - I know how to overcome this - but for people that will start with ThinkPad T420s with FreeBSD - and while its 14 years old laptop - its still more then needed to have a nice FreeBSD desktop/laptop experience.

Regards,
ver
Comment 31 Slawomir Wojciech Wojtczak 2025-06-12 23:15:52 UTC
.. and thank You for all the work You do - its really often 'unseen' but a really needed one.

Kudos mate.
Comment 32 Christos Margiolis freebsd_committer freebsd_triage 2025-06-13 12:28:48 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #31)
Thank you for the kind words! :-)
Comment 33 commit-hook freebsd_committer freebsd_triage 2025-06-13 12:31:01 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4027e17c179573c428143d3c3cb2aeef3f446b42

commit 4027e17c179573c428143d3c3cb2aeef3f446b42
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-06-11 17:28:40 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-06-13 12:30:22 +0000

    snd_hda: Patch Lenovo T420s

    PR:             222636
    Tested by:      vermaden@interia.pl
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 day

    (cherry picked from commit 84e73074412719ec83143fb514625c09d27f468c)

 sys/dev/sound/pci/hda/hdaa_patches.c | 16 ++++++++++++++++
 sys/dev/sound/pci/hda/hdac.h         |  1 +
 2 files changed, 17 insertions(+)