Bug 80074 - Active port is not set when plugging in headphones in a lenovo Ultradock jack
Summary: Active port is not set when plugging in headphones in a lenovo Ultradock jack
Status: RESOLVED INVALID
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: alsa (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-16 04:22 UTC by Francois Marier
Modified: 2014-06-18 03:24 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Output of "pulseaudio -k && pulseaudio -vvv" (179.73 KB, text/plain)
2014-06-16 04:22 UTC, Francois Marier
Details
"cat /proc/asound/card1/codec#0" without headphones (11.17 KB, text/plain)
2014-06-16 04:24 UTC, Francois Marier
Details
"cat /proc/asound/card1/codec#0" with headphones in laptop jack (11.16 KB, text/plain)
2014-06-16 04:25 UTC, Francois Marier
Details
"cat /proc/asound/card1/codec#0" with headphones in dock jack (11.16 KB, text/plain)
2014-06-16 04:25 UTC, Francois Marier
Details
"pactl list sinks" without headphones (3.81 KB, text/plain)
2014-06-16 04:25 UTC, Francois Marier
Details
"pactl list sinks" with headphones in laptop jack (3.82 KB, text/plain)
2014-06-16 04:26 UTC, Francois Marier
Details
"pactl list sinks" with headphones in dock jack (3.81 KB, text/plain)
2014-06-16 04:26 UTC, Francois Marier
Details

Description Francois Marier 2014-06-16 04:22:55 UTC
Created attachment 101132 [details]
Output of "pulseaudio -k && pulseaudio -vvv"

If I plug headphones in the headphone jack of my laptop (T440p), the active port goes from analog-output-speaker to analog-output-headphones as expected.

However, if I use the headphone jack the dock, the active port stays as analog-output-speaker, instead of switching to analog-output.

I don't use Ubuntu, but I followed the instructions on https://wiki.ubuntu.com/ALSA/JackSense and as far as I can tell, the kernel can tell whether or not headphones are plugged in. Both on the laptop itself:

    $ diff -u codec.no_hp.txt codec.hp_laptop.txt
    --- codec.no_hp.txt	2014-06-16 16:03:58.036317735 +1200
    +++ codec.hp_laptop.txt	2014-06-16 16:04:34.399789974 +1200
    @@ -155,14 +155,14 @@
         Conn = Analog, Color = Unknown
         DefAssociation = 0x1, Sequence = 0x0
         Misc = NO_PRESENCE
    -  Pin-ctls: 0x40: OUT
    +  Pin-ctls: 0x00:
       Unsolicited: tag=00, enabled=0
       Power states:  D0 D1 D2 D3 EPSS
       Power: setting=D0, actual=D0

as well as on the dock:

    $ diff -u codec.no_hp.txt codec.hp_dock.txt
    --- codec.no_hp.txt	2014-06-16 16:03:58.036317735 +1200
    +++ codec.hp_dock.txt	2014-06-16 16:03:48.412457393 +1200
    @@ -162,7 +162,7 @@
         Conn = Analog, Color = Unknown
         DefAssociation = 0x1, Sequence = 0x0
         Misc = NO_PRESENCE
    -  Pin-ctls: 0x40: OUT
    +  Pin-ctls: 0x00:
       Unsolicited: tag=00, enabled=0
       Power states:  D0 D1 D2 D3 EPSS
       Power: setting=D0, actual=D0

However, pulseaudio only updates the active port when plugging into the laptop jack:

    $ diff -u sinks.no_hp.txt sinks.hp_laptop.txt
    --- sinks.no_hp.txt	2014-06-16 16:02:05.541949763 +1200
    +++ sinks.hp_laptop.txt	2014-06-16 16:00:21.983451258 +1200
    @@ -104,8 +104,8 @@
     		device.icon_name = "audio-card-pci"
     	Ports:
     		analog-output: Analog Output (priority: 9900)
    -		analog-output-speaker: Speakers (priority: 10000)
    -		analog-output-headphones: Headphones (priority: 9000, not available)
    -	Active Port: analog-output-speaker
    +		analog-output-speaker: Speakers (priority: 10000, not available)
    +		analog-output-headphones: Headphones (priority: 9000, available)
    +	Active Port: analog-output-headphones
     	Formats:
     		pcm

and not on the dock:

    $ diff -u sinks.no_hp.txt sinks.hp_dock.txt
    $
Comment 1 Francois Marier 2014-06-16 04:24:46 UTC
Created attachment 101133 [details]
"cat /proc/asound/card1/codec#0" without headphones
Comment 2 Francois Marier 2014-06-16 04:25:11 UTC
Created attachment 101134 [details]
"cat /proc/asound/card1/codec#0" with headphones in laptop jack
Comment 3 Francois Marier 2014-06-16 04:25:31 UTC
Created attachment 101135 [details]
"cat /proc/asound/card1/codec#0" with headphones in dock jack
Comment 4 Francois Marier 2014-06-16 04:25:59 UTC
Created attachment 101136 [details]
"pactl list sinks" without headphones
Comment 5 Francois Marier 2014-06-16 04:26:19 UTC
Created attachment 101137 [details]
"pactl list sinks" with headphones in laptop jack
Comment 6 Francois Marier 2014-06-16 04:26:43 UTC
Created attachment 101138 [details]
"pactl list sinks" with headphones in dock jack
Comment 7 Raymond 2014-06-16 05:05:02 UTC
try hda-jack-sense-test -a 
to find out the node of dock headphone
when you plug dock headphone
Comment 8 Francois Marier 2014-06-16 06:49:23 UTC
Raymond, I'm assuming you mean the tool that's available at https://launchpad.net/~diwic/+archive/hda/+packages in the snd-hda-tools package.

I grabbed version 0.20130207+saucy1 and unfortunately it returned this error on my Debian jessie box:

    Traceback (most recent call last):
      File "/usr/bin/hda-jack-sense-test", line 47, in <module>
        codec = HDACodec(cardindex, codecindex)
      File "/usr/share/snd-hda-tools/hda_codec.py", line 1036, in __init__
       self.parse_proc()
      File "/usr/share/snd-hda-tools/hda_codec.py", line 1135, in parse_proc
        self.proc_codec = HDACodecProc(self.card, self.device, file)
      File "/usr/share/snd-hda-tools/hda_proc.py", line 479, in __init__
        self.parse(proc_file)
      File "/usr/share/snd-hda-tools/hda_proc.py", line 677, in parse
        node.add_digital(line[11:]) 
      File "/usr/share/snd-hda-tools/hda_proc.py", line 296, in add_digital
        self.wrongfile('unknown dig1 bit %s' % repr(b))
      File "/usr/share/snd-hda-tools/hda_proc.py", line 143, in wrongfile
        raise ValueError, "wrong proc file format (%s)" % msg
   ValueError: wrong proc file format (unknown dig1 bit 'KAE')

Perhaps my kernel (3.14-1-amd64) or alsa-base (1.0.25+3) is more recent than the one in Ubuntu saucy? Is there a more recent version of that script somewhere?
Comment 9 Raymond 2014-06-16 16:00:16 UTC
http://git.alsa-project.org/?p=alsa-tools.git;a=blob;f=hda-verb/README;hb=HEAD

you can use

 hda-verb  GET_PIN_SENSE

for all connected and unconnected pin complex

the return value 0x80000000 indicate the Jack is detected
Comment 10 Francois Marier 2014-06-17 00:07:49 UTC
Thanks Raymond. I installed alsa-tools 1.0.27-3 and ran the following:

    sudo hda-verb /dev/snd/hwC1D0 0x0 GET_PIN_SENSE 0

but I'm not sure that's what you wanted because I just took a wild guess for the "nid". It's described in the README you pointed to as "widget NID" but I have no idea what that means or how to look it up.

If I run any of the following:

    sudo hda-verb /dev/snd/hwC1D0 0x0 GET_PIN_SENSE
    sudo hda-verb /dev/snd/hwC1D0 GET_PIN_SENSE
    sudo hda-verb GET_PIN_SENSE

I get the "usage" output:

    usage: hda-verb [option] hwdep-device nid verb param
       -l      List known verbs and parameters
       -L      List known verbs and parameters (one per line)

suggesting that hda-verb needs all four parameters to be supplied on the command line.
Comment 11 Francois Marier 2014-06-17 00:33:17 UTC
Nevermind my last comment, I figured out that the "widget NID" are the node IDs displayed in the output "cat /proc/asound/card1/codec#0".

So looking at these three pin complexes:

    Node 0x14 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
      Control: name="Speaker Playback Switch", index=0, device=0
        ControlAmp: chs=3, dir=Out, idx=0, ofs=0
      Control: name="Speaker Phantom Jack", index=0, device=0
      Pin Default 0x90170110: [Fixed] Speaker at Int N/A
        Conn = Analog, Color = Unknown
        DefAssociation = 0x1, Sequence = 0x0
        Misc = NO_PRESENCE
    Node 0x15 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
      Control: name="Headphone Playback Switch", index=1, device=0
        ControlAmp: chs=3, dir=Out, idx=0, ofs=0
      Control: name="Headphone Jack", index=0, device=0
      Pin Default 0x0321101f: [Jack] HP Out at Ext Left
        Conn = 1/8, Color = Black
        DefAssociation = 0x1, Sequence = 0xf
    Node 0x16 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
      Control: name="Headphone Playback Switch", index=0, device=0
        ControlAmp: chs=3, dir=Out, idx=0, ofs=0
      Control: name="Dock Headphone Jack", index=0, device=0
      Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
        Conn = 1/8, Color = Black
        DefAssociation = 0xf, Sequence = 0x0
        Misc = NO_PRESENCE

I see that hda-verb returns these values for GET_PIN_SENSE when nothing is connected:

    nid = 0x14, verb = 0xf09, param = 0x0
    value = 0x0
    nid = 0x15, verb = 0xf09, param = 0x0
    value = 0x0
    nid = 0x16, verb = 0xf09, param = 0x0
    value = 0x0

these values when headphones are connected to the laptop jack:

    nid = 0x14, verb = 0xf09, param = 0x0
    value = 0x0
    nid = 0x15, verb = 0xf09, param = 0x0
    value = 0x80000000
    nid = 0x16, verb = 0xf09, param = 0x0
    value = 0x0

and these values when headphones are connected to the dock jack:

    nid = 0x14, verb = 0xf09, param = 0x0
    value = 0x0
    nid = 0x15, verb = 0xf09, param = 0x0
    value = 0x0
    nid = 0x16, verb = 0xf09, param = 0x0
    value = 0x80000000

So it does look like the two jacks correctly detect the presence of headphones.
Comment 12 Raymond 2014-06-17 04:55:58 UTC
you most like need to check those unconnected pin complex [N/A] for the missing dock headphone which pincap support OUT
Comment 13 Raymond 2014-06-17 04:58:12 UTC
use hda-Jack-retask to retask it as dock headphone when the unconnected pin complex response to get pin sense
Comment 14 Francois Marier 2014-06-17 10:42:57 UTC
This is starting to feel like it's not a pulseaudio bug after all and that maybe I should be filing this elsewhere?

I've looked at all of the pin complexes and the only one that responds to the dock headphone jack is 0x16.

One thing I should have probably mentioned when we started talking about pins is that I had to apply the patch for the T440 described here:

  https://github.com/leoluk/thinkpad-stuff/wiki/Haswell-ThinkPad-problems#linux-docking-station-audio-compatibility

Looking at that though, it seems slightly different from the one which has been committed to the kernel sound subsystem:

  https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/sound/pci/hda/patch_realtek.c#n4711
Comment 15 Francois Marier 2014-06-17 11:17:36 UTC
Actually, it looks like the pins were not configured correctly and that this wiki was wrong.

Using the pincfg from the kernel, everything works fine.

Thanks for all of your help, I would have never figured this out all by myself!
Comment 16 Raymond 2014-06-18 03:24:55 UTC
hese values when headphones are connected to the laptop jack:

    nid = 0x14, verb = 0xf09, param = 0x0
    value = 0x0
    nid = 0x15, verb = 0xf09, param = 0x0
    value = 0x80000000
    nid = 0x16, verb = 0xf09, param = 0x0
    value = 0x0

and these values when headphones are connected to the dock jack:

    nid = 0x14, verb = 0xf09, param = 0x0
    value = 0x0
    nid = 0x15, verb = 0xf09, param = 0x0
    value = 0x0
    nid = 0x16, verb = 0xf09, param = 0x0
    value = 0x80000000

if detection of two headphone jacks are correct, 
you have to check the availablility of speaker 

since pulseaudio need to check status of both jacks to determine the status of speaker

the speaker is muted when either jack is plugged but unmuted when both jacks are unplugged

http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.