Bug 87002 - Headphones selected on first run while unplugged and other ports are available
Summary: Headphones selected on first run while unplugged and other ports are available
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: alsa (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-04 13:07 UTC by Mario Sanchez Prada
Modified: 2018-07-30 09:39 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Output of alsa-info.sh (26.12 KB, text/plain)
2014-12-04 13:07 UTC, Mario Sanchez Prada
Details
Output of pactl list (16.04 KB, text/plain)
2014-12-04 13:07 UTC, Mario Sanchez Prada
Details
Verbose output on the 1st run (no local configuration stored) (149.88 KB, text/plain)
2014-12-04 13:08 UTC, Mario Sanchez Prada
Details
Verbose output on the 2nd run (headphones unplugged but still selected) (147.09 KB, text/plain)
2014-12-04 13:08 UTC, Mario Sanchez Prada
Details

Description Mario Sanchez Prada 2014-12-04 13:07:13 UTC
Created attachment 110456 [details]
Output of alsa-info.sh

It seems that the patch for bug 73375 had a side effect that I think it might not be desirable in some cases. A short summary would be something like this:

The first time that pulseaudio is run for an user (no configuration previously stored), the headphones port of the analog output will be selected, even if the headphones are not plugged at all (hence the analog-output-headphones port is not available).

STEPS TO REPRODUCE:

  1. Power on the computer while connected to an audio capable device through HDMI (e.g. TV), no other possible output port available (e.g. no built-in speakers), and with headphones unplugged
  2. After logging in, remove any local configuration (e.g. rm -rf ~/.config/pulse)
  3. Kill PA, and let it restart: pulseaudio -k
  4. Try to play some sound, or just modify the volume up/down

EXPECTED OUTCOME:

As the only possible output port is the HDMI one, the hdmi-output port should be selected instead of the not-available headphones port.

ACTUAL OUTCOME:

The analog-output-headphones port gets selected, effectively making impossible to hear anything in a speaker-less computer even if connected to a TV through HDMI.


ADDITIONAL INFORMATION:

This is a particular problem in the hardware I'm using because I'm plugged to a TV through HDMI, which provides the only available output port at the time PA is run for the first time if no headphones are plugged. Thus, I think in this case it's very confusing that the headphones are selected even if not available, instead of the HDMI port.

I can fix this scenario I select the HDMI port manually, and that change will work across reboots. However, if I eventually plug the headphones, select them and then reboot, the headphones port will be selected again next time the user logs in, no matter they are still plugged or not (forcing to manually select HDMI again).

I've checked this with the latest code from the master branch and it's indeed an issue in there. Reverting the commit from bug 73375 gets rid of this problem, but then it gets other issues back that are probably worse.

Would it perhaps make sense perhaps to probe whether there's at least one available output port on other sinks before setting on the analog output during the first boot?

PS: Attaching the output of alsa-info.sh now. Will upload the output of pactl list and the verbose output of pulseaudio after filing the bug
Comment 1 Mario Sanchez Prada 2014-12-04 13:07:34 UTC
Created attachment 110457 [details]
Output of pactl list
Comment 2 Mario Sanchez Prada 2014-12-04 13:08:06 UTC
Created attachment 110458 [details]
Verbose output on the 1st run (no local configuration stored)
Comment 3 Mario Sanchez Prada 2014-12-04 13:08:38 UTC
Created attachment 110459 [details]
Verbose output on the 2nd run (headphones unplugged but still selected)
Comment 4 Raymond 2014-12-04 17:08:35 UTC
seem only one physical  jack 

is this jack support headset , headphone/mic ?

sys/class/sound/hwC0D0/init_pin_configs:
0x12 0x40000000
0x14 0x411111f0
0x17 0x411111f0
0x18 0x411111f0
0x19 0x411111f0
0x1a 0x411111f0
0x1b 0x411111f0
0x1d 0x40541a05
0x1e 0x411111f0
0x21 0x04211010

/sys/class/sound/hwC0D0/driver_pin_configs:
0x19 0x04a110f0


driver fixup pin 0x19

Node 0x21 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Control: name="Master Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Headphone Jack", index=0, device=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 0x04211010: [Jack] HP Out at Ext Right
    Conn = 1/8, Color = Black
    DefAssociation = 0x1, Sequence = 0x0
  Pin-ctls: 0xc0: OUT HP
  Unsolicited: tag=02, enabled=1
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 2
     0x0c* 0x0d
Comment 5 Raymond 2014-12-04 17:14:38 UTC
Simple mixer control 'Mic',0
  Capabilities: pvolume pswitch penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]


if the jack suport headphone or mic ? mic playback volume control is no use
Comment 6 Mario Sanchez Prada 2014-12-04 17:38:08 UTC
Thanks for taking a look to this, and the quick feedback

See my comments/answers inline below, hope they are helpful too

(In reply to Raymond from comment #4)
> seem only one physical  jack 
> 
> is this jack support headset , headphone/mic ?

It supports both headset and headphone/mic connectors.

> sys/class/sound/hwC0D0/init_pin_configs:
> 0x12 0x40000000
> 0x14 0x411111f0
> 0x17 0x411111f0
> 0x18 0x411111f0
> 0x19 0x411111f0
> 0x1a 0x411111f0
> 0x1b 0x411111f0
> 0x1d 0x40541a05
> 0x1e 0x411111f0
> 0x21 0x04211010
> 
> /sys/class/sound/hwC0D0/driver_pin_configs:
> 0x19 0x04a110f0
> 
> driver fixup pin 0x19
> 

Sorry, I'm new to the audio world, and I'm not sure I understand what you mean, or the relationship with the excerpt below (should it be the one for Node 0x19, perhaps?)

> Node 0x21 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
>   Control: name="Master Playback Switch", index=0, device=0
>     ControlAmp: chs=3, dir=Out, idx=0, ofs=0
>   Control: name="Headphone Jack", index=0, device=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 0x04211010: [Jack] HP Out at Ext Right
>     Conn = 1/8, Color = Black
>     DefAssociation = 0x1, Sequence = 0x0
>   Pin-ctls: 0xc0: OUT HP
>   Unsolicited: tag=02, enabled=1
>   Power states:  D0 D1 D2 D3 EPSS
>   Power: setting=D0, actual=D0
>   Connection: 2
>      0x0c* 0x0d

(In reply to Raymond from comment #5)
> Simple mixer control 'Mic',0
>   Capabilities: pvolume pswitch penum
>   Playback channels: Front Left - Front Right
>   Limits: Playback 0 - 31
>   Mono:
>   Front Left: Playback 0 [0%] [-34.50dB] [off]
>   Front Right: Playback 0 [0%] [-34.50dB] [off]
> 
> 
> if the jack suport headphone or mic ? mic playback volume control is no use

The jack supports both, but at the time I took this log I had a simple headset (no mic) connected
Comment 8 Raymond 2014-12-05 01:30:53 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/hda?id=73bdd597823e2231dc882577dbbaf8df92fe1775




+	[ALC283_FIXUP_BXBT2807_MIC] = {
+		.type = HDA_FIXUP_PINS,
+		.v.pins = (const struct hda_pintbl[]) {
+			{ 0x19, 0x04a110f0 },
+			{ },
+		},
+	},

the current implemenation use sequence number to identify headset mic and headphone mic but it still   use sequence number zero
Comment 10 Raymond 2014-12-05 01:46:44 UTC


In PulseAudio ports will show up with the following names:
   Headphones - analog-output-headphones
   Headset mic - analog-input-microphone-headset
   Jack in mic-in mode - analog-input-microphone

   However, since regular mics also show up as analog-input-microphone,
   we need to check for certain controls on alsa mixer level too, to know
   if we deal with a separate mic jack, or a multi-function jack with a 
   mic-in mode (also called "headphone mic"). 
   We check for the following names:

   Headphone Mic Jack - indicates headphone and mic-in mode share the same jack,
     i e, not two separate jacks. Hardware cannot distinguish between a
     headphone and a mic.
   Headset Mic Phantom Jack - indicates headset jack where hardware can not
     distinguish between headphones and headsets
   Headset Mic Jack - indicates headset jack where hardware can distinguish
     between headphones and headsets. There is no use popping up a dialog in
     this case, unless we already need to do this for the mic-in mode.

yours seem different from pa_backend.c

Node 0x19 [Pin Complex] wcaps 0x40048b: Stereo Amp-In
  Control: name="Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Mic Jack", index=0, device=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x2f, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00003724: IN Detect
    Vref caps: HIZ 50 GRD 80 100
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x24: IN VREF_80
  Unsolicited: tag=01, enabled=1
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Comment 11 Raymond 2014-12-05 03:22:12 UTC
Node 0x0b [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
  Control: name="Mic Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=1, ofs=0
  Control: name="Mic Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=1, ofs=0
  Control: name="Beep Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=4, ofs=0
  Control: name="Beep Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=4, ofs=0
  Amp-In caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1
  Amp-In vals:  [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80]
  Connection: 5
     0x18 0x19 0x1a 0x1b 0x1d


why did the driver create beep playback volume/switch when node 0x1d is [N/A]

Node 0x1d [Pin Complex] wcaps 0x400400: Mono
  Pincap 0x00000020: IN
  Pin Default 0x40541a05: [N/A] Digital Out at Ext N/A
    Conn = RCA, Color = Black
    DefAssociation = 0x0, Sequence = 0x5
  Pin-ctls: 0x20: IN
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Comment 12 Raymond 2014-12-05 07:03:22 UTC
Unsolicited: tag=02, enabled=1

Unsolicited: tag=01, enabled=1

it is strange to enable unsolicited event on two nodes when you only have one physical jack


try hda jack sense test
Comment 13 Mario Sanchez Prada 2014-12-05 11:23:38 UTC
Again, thanks a lot for your time. See my answers below, at least in the places where I could certainly provide one! :)

Feel free to ask me to conduct more experiments

(In reply to Raymond from comment #7)
> http://www.gigabyte.com/products/product-page.aspx?pid=5038
> 
> are yours revision 1.0 ?
>

Yes

> seem support headphone or mic 
> 
> the icon is not headset but
> 
> https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/
> pci/hda?id=9dc12862da9d56ef4da646ba540c4f58b78738fc

I just plugged a Philips SHE8005 Headset[1] (same jack combined) that I have, and I can confirm that is properly recognized as both and output and input device.


(In reply to Raymond from comment #8)
> https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/
> pci/hda?id=73bdd597823e2231dc882577dbbaf8df92fe1775
> 
> 
> 
> 
> +	[ALC283_FIXUP_BXBT2807_MIC] = {
> +		.type = HDA_FIXUP_PINS,
> +		.v.pins = (const struct hda_pintbl[]) {
> +			{ 0x19, 0x04a110f0 },
> +			{ },
> +		},
> +	},
> 
> the current implemenation use sequence number to identify headset mic and
> headphone mic but it still   use sequence number zero

Not sure what you mean here. I'm CCing my colleague Daniel Drake (author of the other kernel commit you pointed out), in case he can maybe comment on this 


(In reply to Raymond from comment #9)
> http://voices.canonical.com/david.henningsson/2014/03/07/headset-jacks-on-
> newer-laptops/
> 
> can your codec detect the jack type automatically or not ?

I'm using codec ALC283 and yes, the jack type seems to be automatically detected when plugging it


(In reply to Raymond from comment #10)
> 
> 
> In PulseAudio ports will show up with the following names:
>    Headphones - analog-output-headphones
>    Headset mic - analog-input-microphone-headset
>    Jack in mic-in mode - analog-input-microphone
> 
>    However, since regular mics also show up as analog-input-microphone,
>    we need to check for certain controls on alsa mixer level too, to know
>    if we deal with a separate mic jack, or a multi-function jack with a 
>    mic-in mode (also called "headphone mic"). 
>    We check for the following names:
> 
>    Headphone Mic Jack - indicates headphone and mic-in mode share the same
> jack,
>      i e, not two separate jacks. Hardware cannot distinguish between a
>      headphone and a mic.
>    Headset Mic Phantom Jack - indicates headset jack where hardware can not
>      distinguish between headphones and headsets
>    Headset Mic Jack - indicates headset jack where hardware can distinguish
>      between headphones and headsets. There is no use popping up a dialog in
>      this case, unless we already need to do this for the mic-in mode.

This is I can see from the verbose output of pulseaudio -vvvvv, when plugging that Philips headset:

   [pulseaudio] module-alsa-card.c: Jack 'Headphone Jack' is now plugged in
   [pulseaudio] module-alsa-card.c: Jack 'Mic Jack' is now plugged in


(In reply to Raymond from comment #11)
> Node 0x0b [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
>   Control: name="Mic Playback Volume", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=1, ofs=0
>   Control: name="Mic Playback Switch", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=1, ofs=0
>   Control: name="Beep Playback Volume", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=4, ofs=0
>   Control: name="Beep Playback Switch", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=4, ofs=0
>   Amp-In caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1
>   Amp-In vals:  [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80]
>   Connection: 5
>      0x18 0x19 0x1a 0x1b 0x1d
> 
> why did the driver create beep playback volume/switch when node 0x1d is [N/A]
> 

Can't really answer this question, sorry :(

> Node 0x1d [Pin Complex] wcaps 0x400400: Mono
>   Pincap 0x00000020: IN
>   Pin Default 0x40541a05: [N/A] Digital Out at Ext N/A
>     Conn = RCA, Color = Black
>     DefAssociation = 0x0, Sequence = 0x5
>   Pin-ctls: 0x20: IN
>   Power states:  D0 D1 D2 D3 EPSS
>   Power: setting=D0, actual=D0

(In reply to Raymond from comment #12)
> Unsolicited: tag=02, enabled=1
> 
> Unsolicited: tag=01, enabled=1
> 
> it is strange to enable unsolicited event on two nodes when you only have
> one physical jack
> 

Perhaps that's a mistake, I really don't know. Could you elaborate a bit more on that?

> try hda jack sense test

I did, see the output before and after unplugging the Philips headset:

    $ sudo hda-jack-sense-test 
    Pin 0x21 (Black HP Out): present = No

    $ sudo hda-jack-sense-test 
    Pin 0x21 (Black HP Out): present = Yes


[1] http://www.philips.co.uk/c-p/SHE8005_10/-/specifications
Comment 14 David Henningsson 2014-12-05 11:54:19 UTC
Ok, I've looked at this issue now. 

The startup order is something like:

1) module_alsa_card's init_jacks initializes port availability, and for every port, we get a callback to port_available_hook_callback. No action is done here due to the fix for bug 73375.

2) module_alsa_card's init_profile is called, which in turn creates sources and sinks. At this point, we don't switch profiles: our current profile is analog, we don't switch away from profiles when ports become unavailable.

The thing is, to solve this properly, we should need a callback *between* 1) and 2). We can't act on 1), because not all ports are guaranteed to have its availability set yet. But acting on 2) is too late, because then the profile is already set.
Comment 15 Mario Sanchez Prada 2014-12-05 12:14:59 UTC
(In reply to David Henningsson from comment #14)
> Ok, I've looked at this issue now. 
> 
> The startup order is something like:
> 
> 1) module_alsa_card's init_jacks initializes port availability, and for
> every port, we get a callback to port_available_hook_callback. No action is
> done here due to the fix for bug 73375.
> 
> 2) module_alsa_card's init_profile is called, which in turn creates sources
> and sinks. At this point, we don't switch profiles: our current profile is
> analog, we don't switch away from profiles when ports become unavailable.
> 
> The thing is, to solve this properly, we should need a callback *between* 1)
> and 2). We can't act on 1), because not all ports are guaranteed to have its
> availability set yet. But acting on 2) is too late, because then the profile
> is already set.

What about letting 1) and 2) to finish, as if everything went fine and then, as a last and desperate attempt to avoid having a profile with no ports available, check if there's a better option and switch profiles if needed?

That's the "hack" I've been experimenting with lately in this device (notice that we use PA 5.0, but an stable release, not the trunk), and so far seemed to work fine, although I'm not 100% it's a totally broken or not.

You can check it in this commit: https://github.com/mariospr/pulseaudio/commit/4d3fdd5bbe8bc003f98403188e38a02110ba4c91

Please let me know what you think

Thanks a lot for the feedback!
Comment 16 David Henningsson 2014-12-05 12:50:37 UTC
(In reply to Mario Sanchez Prada from comment #15)
> (In reply to David Henningsson from comment #14)
> > Ok, I've looked at this issue now. 
> > 
> > The startup order is something like:
> > 
> > 1) module_alsa_card's init_jacks initializes port availability, and for
> > every port, we get a callback to port_available_hook_callback. No action is
> > done here due to the fix for bug 73375.
> > 
> > 2) module_alsa_card's init_profile is called, which in turn creates sources
> > and sinks. At this point, we don't switch profiles: our current profile is
> > analog, we don't switch away from profiles when ports become unavailable.
> > 
> > The thing is, to solve this properly, we should need a callback *between* 1)
> > and 2). We can't act on 1), because not all ports are guaranteed to have its
> > availability set yet. But acting on 2) is too late, because then the profile
> > is already set.
> 
> What about letting 1) and 2) to finish, as if everything went fine and then,
> as a last and desperate attempt to avoid having a profile with no ports
> available, check if there's a better option and switch profiles if needed?
> 
> That's the "hack" I've been experimenting with lately in this device (notice
> that we use PA 5.0, but an stable release, not the trunk), and so far seemed
> to work fine, although I'm not 100% it's a totally broken or not.
> 
> You can check it in this commit:
> https://github.com/mariospr/pulseaudio/commit/
> 4d3fdd5bbe8bc003f98403188e38a02110ba4c91
> 
> Please let me know what you think
> 
> Thanks a lot for the feedback!

Well, it's a hack. And the hackier, the more likely we regress some other use case.

I'm more thinking that maybe one could initialize the port availability earlier, even before pa_card_new, using the pa_device_port_new_data_set_available function. Then we could act accordingly already in the callback in 1).
Comment 17 Mario Sanchez Prada 2014-12-05 13:11:58 UTC
(In reply to David Henningsson from comment #16)
> [...]
> Well, it's a hack. And the hackier, the more likely we regress some other
> use case.

Agreed. I never thought of that as a solution but more as an experiment, hopefully able to spark some discussion. Seems it worked, pretty nicely from that pov :)

Anyway, I'm building PA again enabling the unit tests, to at least check whether I'm regressing something obvious..

> I'm more thinking that maybe one could initialize the port availability
> earlier, even before pa_card_new, using the
> pa_device_port_new_data_set_available function. Then we could act
> accordingly already in the callback in 1).

If that was possible, I think it would be awesome, I think that could simplify things a lot. Still, if I understand things correctly, we still could not revert the patch for bug 73375, even if we do that, as the sinks/sources would not be initialized at that point, but in init_profile.

Does that make sense at all?
Comment 18 David Henningsson 2014-12-05 13:32:11 UTC
Rough outline of new suggested startup order:

 1) Above the add_profiles call in module-alsa-card.c, we should first start listening to mixer events (in order not to get a race condition).
 2) Update availability of all jacks. This might require some refactoring of code as the jacks do not have associated ports at that point.

 3) add_profiles ends up calling alsa-mixer.c:device_port_alsa_init. Here, add a call to pa_device_port_new_data_set_available() and fill it in accordingly. This will also require refactoring the jack availability to port availability logic into a separate function in alsa-mixer.c.

 4) We add a new hook in module-switch-on-port-available that listens to pa_card_new. From this hook, we switch the suggested profile in case the current profile has no available ports (and we find another profile that has).

Does that make sense? Anything (or all) of the above that you'd like to write yourself?
Comment 19 Raymond 2014-12-05 14:05:13 UTC
what happen when user just use vga and don`t use hdmi ?

user may plugged headphone after pulseaudio completely startup
Comment 20 Raymond 2014-12-05 16:35:32 UTC
> 
> What about letting 1) and 2) to finish, as if everything went fine and then,
> as a last and desperate attempt to avoid having a profile with no ports
> available, check if there's a better option and switch profiles if needed?
> 

the source already has a profile with no port available

Ports:
		analog-input-mic: Microphone (priority: 8700, not available)
	Active Port: analog-input-mic
	Formats:
		pcm
Comment 21 Mario Sanchez Prada 2014-12-05 18:47:27 UTC
(In reply to Raymond from comment #20)
> > 
> > What about letting 1) and 2) to finish, as if everything went fine and then,
> > as a last and desperate attempt to avoid having a profile with no ports
> > available, check if there's a better option and switch profiles if needed?
> > 
> 
> the source already has a profile with no port available
> 
> Ports:
> 		analog-input-mic: Microphone (priority: 8700, not available)
> 	Active Port: analog-input-mic
> 	Formats:
> 		pcm

Yes, and in that case my approach would be not to change a thing: only if you preselect a profile with no ports available when there are another profile with ports available.

But as David said, that's a hack and not the proper solution.
Comment 22 Mario Sanchez Prada 2014-12-05 19:09:10 UTC
(In reply to David Henningsson from comment #18)
> Rough outline of new suggested startup order:
> [...]

Thanks for this outline, David. At a first glance it all looks like it makes sense to me, but still my knowledge on this is quite limited, so it's hard to make an informed opinion now on whether it really makes sense or not, or whether there are things I could write myself or not.

What I can say now, however, is that I'll try to take a closer look to this suggestion (ideally next week) by trying to implement it myself. Once I devote some time to that, I should be able to know better what exactly I'll be able to tackle and what not, and then I will surely have more questions too.

Of course, feel free to point out/comment anything you want in the meanwhile. I'm sure that any extra info you, or anyone else, can provide on this will be very valuable to me.
Comment 23 Raymond 2014-12-06 02:56:00 UTC
did you find any of those message in system log when you use debug version of alsa driver ?


+	snd_printdd("Headset jack set to iPhone-style headset mode.\n");
+}
+

+/* 
+	snd_printdd("Headset jack set to Nokia-style headset mode.\n");
+}
+



+	snd_printdd("Headset jack detected iPhone-style headset: %s\n",
+		    is_ctia ? "yes" : "no");
+	spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
+}
+
Comment 24 Raymond 2014-12-06 03:39:06 UTC
(In reply to Mario Sanchez Prada from comment #21)
> (In reply to Raymond from comment #20)
> > > 
> > > What about letting 1) and 2) to finish, as if everything went fine and then,
> > > as a last and desperate attempt to avoid having a profile with no ports
> > > available, check if there's a better option and switch profiles if needed?
> > > 
> > 
> > the source already has a profile with no port available
> > 
> > Ports:
> > 		analog-input-mic: Microphone (priority: 8700, not available)
> > 	Active Port: analog-input-mic
> > 	Formats:
> > 		pcm
> 
> Yes, and in that case my approach would be not to change a thing: only if
> you preselect a profile with no ports available when there are another
> profile with ports available.
> 
> But as David said, that's a hack and not the proper solution.

it contradict the logic of module-switch-on-port-available which switch to other available /unknown port when active port is unavailable

when pulseaudio cannot find valid profile of the sound card, auto null is automically selected when there is no sound card available
Comment 25 Mario Sanchez Prada 2014-12-08 15:41:10 UTC
(In reply to Raymond from comment #23)
> did you find any of those message in system log when you use debug version
> of alsa driver ?

I don't think I was running the debug version of the driver, nor I'm sure how I can do that. Would you mind sharing a few tips on how to do it so?

I've checked http://www.alsa-project.org/main/index.php/Help_To_Debug and a few more places, but still is not clear to me.
Comment 26 Raymond 2014-12-09 05:22:24 UTC
it is strange that mixer output different from codec info

neither alsactl init nor pulseaudio turn this switch on


Simple mixer control 'IEC958',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]


Node 0x04 [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
  Control: name="HDMI/DP,pcm=3 Jack", index=0, device=0
  Control: name="IEC958 Playback Con Mask", index=0, device=0
  Control: name="IEC958 Playback Pro Mask", index=0, device=0
  Control: name="IEC958 Playback Default", index=0, device=0
  Control: name="IEC958 Playback Switch", index=0, device=0
  Control: name="ELD", index=0, device=3
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x00 0x00]
  Pincap 0x09000094: OUT Detect HBR HDMI DP
  Pin Default 0x18560010: [Jack] Digital Out at Int HDMI
    Conn = Digital, Color = Unknown
    DefAssociation = 0x1, Sequence = 0x0
  Pin-ctls: 0x40: OUT
  Unsolicited: tag=01, enabled=1
  Power states:  D0 D3
  Power: setting=D0, actual=D0
  Connection: 2
     0x02* 0x03
Comment 27 Raymond 2014-12-09 05:37:22 UTC
http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths/iec958-stereo-output.conf

[Element IEC958]
switch = mute

it is an element in iec958  conf but your barebone only have hdmi device and no digital device

those hdmi-output conf does not has this element 

http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths
Comment 28 Raymond 2014-12-10 13:21:43 UTC
it bug of pulseaudio if those iec958 playback is mute switch of hdmi 

restore card device expect to restore volume/mute but pulseaudio did not save any info into the databse


D: [pulseaudio] alsa-mixer.c: Probing path 'hdmi-output-0'
D: [pulseaudio] alsa-mixer.c: Probe of jack 'HDMI/DP,pcm=3 Jack' succeeded (found!)
D: [pulseaudio] alsa-mixer.c: Available mixer paths (after tidying):
D: [pulseaudio] alsa-mixer.c: Path Set 0x83a26a0, direction=1
D: [pulseaudio] alsa-mixer.c: Path hdmi-output-0 (HDMI / DisplayPort), direction=1, priority=59, probed=yes, supported=yes, has_mute=no, has_volume=no, has_dB=no, min_volume=0, max_volume=0, min_dB=inf, max_dB=-inf
D: [pulseaudio] alsa-mixer.c: Jack HDMI/DP,pcm=3, alsa_name='HDMI/DP,pcm=3 Jack', detection possible
Comment 29 Mario Sanchez Prada 2015-03-20 16:40:28 UTC
(In reply to Mario Sanchez Prada from comment #22)
> Thanks for this outline, David. At a first glance it all looks like it makes
> sense to me, but still my knowledge on this is quite limited, so it's hard
> to make an informed opinion now on whether it really makes sense or not, or
> whether there are things I could write myself or not.
> 
> What I can say now, however, is that I'll try to take a closer look to this
> suggestion (ideally next week) by trying to implement it myself. Once I
> devote some time to that, I should be able to know better what exactly I'll
> be able to tackle and what not, and then I will surely have more questions
> too.

I'm so sorry for having taken so long to finally get back to this, but the last months it was nearly impossible to me to devote time to sit down and work on upstreaming this patch.

Fortunately, Arun lend me a hand during the Gstreamer hackfest and I'm happy to say that I have a version of the patch that I hope will be on the right path. Just sent it to the mailing list for review now:

http://lists.freedesktop.org/archives/pulseaudio-discuss/2015-March/023420.html

The idea implemented is based on David's suggestion from comment #18 after "digesting" it with the help of Arun, but perhaps with a few twists I found as needed while writing the actual patch. Hope it looks ok anyway, though :)
Comment 30 Raymond 2015-03-21 08:37:32 UTC
seem driver bug 

only HP pin but no speaker


!Sysfs Files
!!-----------

/sys/class/sound/hwC0D0/init_pin_configs:
0x12 0x40000000
0x14 0x411111f0
0x17 0x411111f0
0x18 0x411111f0
0x19 0x411111f0
0x1a 0x411111f0
0x1b 0x411111f0
0x1d 0x40541a05
0x1e 0x411111f0
0x21 0x04211010

/sys/class/sound/hwC0D0/driver_pin_configs:
0x19 0x04a110f0
Comment 31 GitLab Migration User 2018-07-30 09:39:41 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/79.


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.