Bug 195161 - No Jack sound on Lenovo dock with a T470 connected
Summary: No Jack sound on Lenovo dock with a T470 connected
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: Intel Linux
: P1 high
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-30 17:10 UTC by Dieter Mummenschanz
Modified: 2018-04-19 14:05 UTC (History)
21 users (show)

See Also:
Kernel Version: 4.11-rc, 4.12, 4.13-rc, 4.14, 4.15-rc
Tree: Mainline
Regression: No


Attachments
alsa-info.sh dump (41.44 KB, text/plain)
2017-03-30 17:10 UTC, Dieter Mummenschanz
Details
Output of alsa-info on X270 (37.21 KB, text/plain)
2017-04-10 06:20 UTC, Max Deineko
Details
alsa-info.sh output on ThinkPad T470s in Dock - kernel 4.11.1 (53.10 KB, text/plain)
2017-05-22 07:43 UTC, Michael Groh
Details
Thinkpad T570, before pin reconfig (43.38 KB, text/plain)
2017-06-27 12:22 UTC, Tim Ruffing
Details
Thinkpad T570, after pin reconfig (45.44 KB, text/plain)
2017-06-27 12:22 UTC, Tim Ruffing
Details
Test fix for resume issue (730 bytes, patch)
2018-02-25 20:29 UTC, Takashi Iwai
Details | Diff

Description Dieter Mummenschanz 2017-03-30 17:10:37 UTC
Created attachment 255643 [details]
alsa-info.sh dump

Hello,

I'm unable to get sound via the jack headphone connection on my lenovo dock when a t470 is connected. Some years ago I've experienced a similar issue with a t440p connected to the same docking station. Back then a patch helped to activate the jack sound over the docking station:

[codec]
0x10ec0292 0x17aa220e 0

[pincfg]
0x16 0x21211010
0x19 0x21a11010

So I've tried to match codec and pincfg to my t470 without success unfortunately:

[codec]
0x10ec0298 0x17aa2245 0

[pincfg]
0x17 0x21211010
0x19 0x21a11010

alsa-info.sh attached.

Any ideas / pathces I can test?
Comment 1 Max Deineko 2017-04-10 06:20:28 UTC
Created attachment 255801 [details]
Output of alsa-info on X270

Also experiencing this on an X270 with ultradock.
Comment 2 Max Deineko 2017-04-10 06:22:06 UTC
Sorry, forgot to mention: running 4.10.8.
Comment 3 Dieter Mummenschanz 2017-04-10 09:25:34 UTC
Waiting for rescue to arrive I did some research on my alsa configuration and found out that there is no pin configuration supplied from the Laptop BIOS that connects to the Docking Headphone Jack.

The hdajacksensetest tool only shows this when the Laptop is docked and a Headphone is pluged in:
Pin 0x18 (Black Mic, Left side): present = No
Pin 0x21 (Black Headphone, Left side): present = No

So I did some patching using a early firmware load patch floating around the web targeting the same docking station for my older T440p laptop:
echo 0x17 0x21211010 > /sys/class/sound/hwC0D0/user_pin_configs 
echo 1 > /sys/class/sound/hwC0D0/reconfig

Now my Docking Station Headphone Jack is being detected! :)

With the Headphone Connected:
Pin 0x17 (Black Headphone, Docking station, Rear side): present = Yes
Pin 0x18 (Black Mic, Left side): present = No
Pin 0x21 (Black Headphone, Left side): present = No

And disconnected:
Pin 0x17 (Black Headphone, Docking station, Rear side): present = No
Pin 0x18 (Black Mic, Left side): present = No
Pin 0x21 (Black Headphone, Left side): present = No

However there is STILL no sound even after unmuting everything in alsamixer!
I'm pretty sure 0x17 is the right pincfg but I'm not sure about 0x21211010 and how I obtain such an address for my laptop.

Could someone please help me out here or give me a hint?

Here is a alsa-info.sh dump when the Laptop is not connected to the Dock:
https://pastebin.com/eTNnfnzL

And here when the Laptop is connected to the Dock (No changes):
https://pastebin.com/ySBsKUeH

And here after setting the pin config 0x17 0x21211010:
https://pastebin.com/xmDfsNtQ

I'm sure I'm very close. But something is still missing. Any help is much apprechiated!

Thanks in advance
Dieter
Comment 4 Michael Groh 2017-05-22 07:43:52 UTC
Created attachment 256653 [details]
alsa-info.sh output on ThinkPad T470s in Dock - kernel 4.11.1

Hello everyone,

i have the same Problem: The Headphone-Jack on the ThinkPad Ultra Dock is not working. I am running Linux 4.11.1 on a ThinkPad T470s, the attached file has been generated with the alsa-info.sh script while the external Speakers were plugged into the Headphone-Jack on the Dock.

I have been playing around with the reconfiguration of the pins ( with the hdajackretask tool) but so far have not been able to get output on the external speakers. I fear that Lenovo tried to create something clever - as i am not able to get the internal speakers to output sound as soon as something is plugged into the headphone jack on the laptop itself.

If there is anything to do that helps to debug this issue, i would be glad to help.

Thanks in advance for the help, and thanks in general for creating and keeping alive the linux kernel ;)
Michael
Comment 5 Tim Ruffing 2017-06-27 12:21:33 UTC
I have the same issue on a T570 incl. the behavior described  in comment 3.

> uname -sr
Linux 4.11.6-3-ARCH
Comment 6 Tim Ruffing 2017-06-27 12:22:40 UTC
Created attachment 257197 [details]
Thinkpad T570, before pin reconfig
Comment 7 Tim Ruffing 2017-06-27 12:22:58 UTC
Created attachment 257199 [details]
Thinkpad T570, after pin reconfig
Comment 8 Takashi Iwai 2017-06-27 12:39:59 UTC
So the situation is same on both T470 and T570, where the sound doesn't come out even after you set up the pin NID 0x17 to 0x21211010, right?

Could you try to pass model=nofixup so that it skips the other Thinkpad quirks (e.g. for LED)?
Comment 9 Tim Ruffing 2017-06-27 12:50:27 UTC
(In reply to Takashi Iwai from comment #8)
> So the situation is same on both T470 and T570, where the sound doesn't come
> out even after you set up the pin NID 0x17 to 0x21211010, right?
Exactly.

> 
> Could you try to pass model=nofixup so that it skips the other Thinkpad
> quirks (e.g. for LED)?
It does not change anything. I also tried tpt460, tpt440-dock and thinkpad already, both with and without the pin config. No success.
Comment 10 Takashi Iwai 2017-06-27 13:08:18 UTC
The pincfg override is mostly mandatory without doubt, so you need to keep the pincfg.

Just to be sure, try model=generic as well.  I don't think this matters, but let's check the all possibilities.

BTW, when you test with different model options, be sure the mixer setup before the actual sound test.  The mixer elements may change depending on the parser and its setup, thus some new mixer element might be muted as default.
Comment 11 Tim Ruffing 2017-06-27 14:03:02 UTC
No, model=generic does not work either. 

A weird thing in alsamixer is that "Headphone 1" (which appears after pincfg) has only a mute toggle but no volume bar.
Comment 12 Takashi Iwai 2017-06-27 14:13:57 UTC
(In reply to Tim Ruffing from comment #11)
> A weird thing in alsamixer is that "Headphone 1" (which appears after
> pincfg) has only a mute toggle but no volume bar.

This is correct behavior.  The pin widget node has only the mute bit, and the volume is controlled in DAC node that is shared by both headphone jacks.

BTW, does the built-in headphone jack work?  If yes, what if you plug both the built-in and dock headphone jacks at the same time?
Comment 13 Tim Ruffing 2017-06-27 15:24:49 UTC
(In reply to Takashi Iwai from comment #12)

> BTW, does the built-in headphone jack work?  If yes, what if you plug both
> the built-in and dock headphone jacks at the same time?

Yes, the built-in jacks. It makes no difference whether it's plugged or not.

Built-in plugged, dock plugged: sound from built-in, no sound from dock
Built-in not plugged, dock plugged: no sound 

Detection works: Headphones are detected if either the built-in or the dock jack are plugged (or both).
Comment 14 Tim Ruffing 2017-06-27 23:31:34 UTC
(In reply to Tim Ruffing from comment #13)
> Yes, the built-in jacks.
"The built-in jack works", of course...

Is there anything else I could test?
Comment 15 Dieter Mummenschanz 2017-07-04 07:39:05 UTC
Update: No changes with Kernel 4.12
Comment 16 Michael Groh 2017-09-04 06:53:59 UTC
(In reply to Takashi Iwai from comment #12)
> 
> BTW, does the built-in headphone jack work?  If yes, what if you plug both
> the built-in and dock headphone jacks at the same time?

With the 4.13 Kernel, when using both the dock and the headphone jack on the laptop, only the headphone jack is working. And there is still no sound with only the dock plugged in.

Is there anything more we can test?

Thanks for your help,
Michael
Comment 17 Simon Sapin 2017-10-20 22:02:08 UTC
Same issue on kernel 4.13.7 with a Thinkpad T570. When connecting to the Ultra Dock’s jack output the built-in speakers mute, but no audio is sent to that jack.

On a previous laptop Thinkpad T450s with the same Ultra Dock, I could get audio from the dock’s jack output. (Though I sometimes had to disconnect that jack and connect it again to get it recognized when resuming from suspend-to-RAM.)
Comment 18 Simon Sapin 2017-10-22 10:25:34 UTC
For future readers who like me are new to all this and try to debug this: https://www.kernel.org/doc/html/latest/sound/hd-audio/notes.html#hd-audio-reconfiguration has documentation on messing with HDA config without rebooting.

Writing to the '/sys/class/sound/hwC0D0/reconfig' file may fail with an error message like "Device is busy" if pulseaudio is running. On Archlinux with GNOME, I’ve had to:

* Run 'systemctl --user mask pulseaudio.socket'
* Run 'pulseaudio --kill'
* Run 'machinectl shell gdm@'
  - In the newly opened subshell, run 'pulseaudio --kill'
  - Exit that subshell with CTRL-D or 'exit'

Then when I’m done messing with config:

* 'pulseaudio --start'
* 'systemctl --user unmask pulseaudio.socket'

(In reply to Dieter Mummenschanz from comment #3)
> The hdajacksensetest tool only shows this when the Laptop is docked and a
> Headphone is pluged in:
> Pin 0x18 (Black Mic, Left side): present = No
> Pin 0x21 (Black Headphone, Left side): present = No
> 
> So I did some patching using a early firmware load patch floating around the
> web targeting the same docking station for my older T440p laptop:
> echo 0x17 0x21211010 > /sys/class/sound/hwC0D0/user_pin_configs 
> echo 1 > /sys/class/sound/hwC0D0/reconfig
> 
> Now my Docking Station Headphone Jack is being detected! :)
> 
> With the Headphone Connected:
> Pin 0x17 (Black Headphone, Docking station, Rear side): present = Yes
> Pin 0x18 (Black Mic, Left side): present = No
> Pin 0x21 (Black Headphone, Left side): present = No
> 
> And disconnected:
> Pin 0x17 (Black Headphone, Docking station, Rear side): present = No
> Pin 0x18 (Black Mic, Left side): present = No
> Pin 0x21 (Black Headphone, Left side): present = No
> 
> However there is STILL no sound even after unmuting everything in alsamixer!


I’ve managed to reproduce this result, but I don’t know if it’s significant. `hdajacksensetest --help` documents this option:

    -a, --allpins         try all pins, even those who (probably) does not have a physical jack

Running with this option, without any user_pin_configs, and with a jack connected to the dock, I get:

    Pin 0x12 (Internal Mic): present = No
    Pin 0x13 (Not connected): present = No
    Pin 0x14 (Internal Speaker): present = No
    Pin 0x17 (Not connected): present = Yes
    Pin 0x18 (Black Mic, Left side): present = No
    Pin 0x19 (Not connected): present = No
    Pin 0x1a (Not connected): present = No
    Pin 0x1d (Not connected): present = No
    Pin 0x1e (Not connected): present = No
    Pin 0x1f (Not connected): present = No
    Pin 0x21 (Black Headphone, Left side): present = No

That Yes for pin 0x17 becomes No when I disconnect the physical jack.

So it looks like jack sensing works correctly regardless of user_pin_configs (all that does is make hdajacksensetest without -a not skip that pin because it assumes there’s nothing there), what’s missing is somehow routing audio to that output.


> I'm pretty sure 0x17 is the right pincfg but I'm not sure about 0x21211010
> and how I obtain such an address for my laptop.

For what it’s worth, I believe 0x21211010 is not an address but a bit-field. The hdajackretask tool gives a GUI for picking and setting these values. If you select "Advanced override" you can see the components. A pin config says things like "This is a jack connector, 3.5mm, black, located at the rear of a dock, for headphones" etc. This file:

http://git.alsa-project.org/?p=alsa-tools.git;a=blob;f=hdajackretask/sysfs-pin-configs.c

contains bit masks and offsets that indicate which component is what.
Comment 19 Jaroslav Kysela 2017-11-16 10:04:11 UTC
Could you try to play with the 0x17 config 0x21211010 and GPIO pins - for example using HDA Analyzer ?

https://www.alsa-project.org/main/index.php/HDA_Analyzer

The GPIO might control an amplifier or something else on the analog path in the docking station..
Comment 20 Tim Ruffing 2017-11-16 20:52:11 UTC
# uname -sr
Linux 4.13.12-1-ARCH

Now things are different (maybe due to the new kernel?).

 - pulseaudio -k
 - echo 0x17 0x21211010 > /sys/class/sound/hwC0D0/user_pin_configs
 - echo 1 > /sys/class/sound/hwC0D0/reconfig
 - pulseaudio spawns again


Results:
 - sound over speaker works initially
 - connect headphones to jack on laptop -> no sound at all
 - connect headphones to jack on dock -> no sound at all
 - unplug headphones again -> no sound at all (not even on speaker!)
 - sensing does not work anymore: pavucontrol shows me whatever was sensed before the reconfig, but it does not change anymore when I plug or unplug the headphones
 - pulseaudio shows me a new audio profile with 4.0 surround instead of stereo. It does not have headphones as output, only speakers.

Trying more:
 - select the new profile -> still no sound
 - select stereo again -> at least speakers work again
 - sensing still does not work, I need to restart to get that working again

I tried to play around with GPIO but nothing happened -- but maybe this observation is useless before the other issue has been sorted.

Info for 0x17:

Node 0x17 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Control: name="Headphone Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=1, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals: [0x00 0x00]
  Pincap 0x0001001c: OUT HP EAPD Detect
  EAPD 0x2: EAPD
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0xc0: OUT HP
  Unsolicited: tag=0x01, enabled=1
  Power: setting=D3, actual=D3
  Connection: 3
     0x0c 0x0d* 0x06
Comment 21 Markus Zimmermann 2018-01-18 14:37:49 UTC
I have the same problem with a Thinkpad T470s on an Ultra Dock 90W using OpenSUSE Tumbleweed 20180116 with Kernel 4.14.13. Anything I can provide to help debug this problem?
Comment 22 Dieter Mummenschanz 2018-02-07 15:42:33 UTC
The issue has FINALLY been fixed with this commit:

https://cgit.freedesktop.org/drm-tip/commit/?id=61fcf8ece9b6b09450250c4ca40cc3b81a96a68d

I confirm the headphone jack now works with my T470 attached to the my ultra dock!
Comment 23 Vít Ondruch 2018-02-19 10:47:36 UTC
Does this work for anybody? Trying the patch, now just PA crashes, but still no sound :/

https://bugzilla.redhat.com/show_bug.cgi?id=1543326
Comment 24 Vít Ondruch 2018-02-19 16:18:36 UTC
Nevermind, as it turns out, it did not work due to my previous attempts fixing this issue. Removing all the modprobes, the sound output via my dock works now. Thx for fixing this and sorry for the noise.
Comment 25 em_prv 2018-02-23 08:11:32 UTC
The patch is in kernel changelog 4.15.5
https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.15.5
Comment 26 Felixoid 2018-02-23 13:24:40 UTC
Updated from https://www.archlinux.org/packages/testing/x86_64/linux/
It works like magic.
T740p and thinkpad ultradoc 40a2
Comment 27 Simon Sapin 2018-02-25 12:05:14 UTC
This seemed fixed after rebooting into 4.15.5 on Archlinux, but after a suspend-to-ram/resume cycle I’m back to the previous situation where hdajacksensetest does detect when a jack is connected to the dock’s output but no audio comes out form there. (There’s a new entry though: Pin 0x19 (Black Mic, Docking station, Rear side): present = No)
Comment 28 Takashi Iwai 2018-02-25 20:29:20 UTC
(In reply to simon-bugzilla-kernel from comment #27)
> This seemed fixed after rebooting into 4.15.5 on Archlinux, but after a
> suspend-to-ram/resume cycle I’m back to the previous situation where
> hdajacksensetest does detect when a jack is connected to the dock’s output
> but no audio comes out form there. (There’s a new entry though: Pin 0x19
> (Black Mic, Docking station, Rear side): present = No)

As a blind shot: does the patch below change the behavior?
Comment 29 Takashi Iwai 2018-02-25 20:29:55 UTC
Created attachment 274455 [details]
Test fix for resume issue
Comment 30 Simon Sapin 2018-02-26 10:51:10 UTC
This additional patch does work for me after suspend/resume. Thanks for your quick response!
Comment 31 Takashi Iwai 2018-02-26 14:43:04 UTC
Thanks for testing.  I'll submit and merge the additional fix to upstream.
Comment 32 Felixoid 2018-03-01 09:32:13 UTC
Could you say please since which version it will be in upstream?
```uname -r
4.15.6-1-ARCH```
Seems resume wasn't fixed
Comment 33 Simon Sapin 2018-03-01 14:52:33 UTC
Felixoid, the initial patch is in 4.15.5 and worked for me as long as I did not suspend.

The second patch attached here (which as far as I know is not upstream yet) improves things, but I sometimes still need remove/reconnect the jack to the dock in order for it to be detected. I’m not quite sure of the exact conditions, but I’ve seen it happen after a reboot (while leaving laptop and jack on the dock), and another time after suspend-to-RAM, moving to a different dock (but same model), then resume.
Comment 34 Simon Sapin 2018-03-12 16:42:46 UTC
(In reply to Takashi Iwai from comment #31)
> Thanks for testing.  I'll submit and merge the additional fix to upstream.

This is part of 4.15.9, isn’t it?
Comment 35 em_prv 2018-03-12 16:44:47 UTC
It's part of the 4.15.8 kernel which I installed today on arch linux. check the changelog:
https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.15.8

Note You need to log in before you can comment on or make changes to this bug.