alsa-mixer: Adding Jack of Front Headphone Front and Surround

Submitted by Hui Wang on Dec. 21, 2018, 3:05 a.m.

Details

Message ID 20181221030554.5354-1-hui.wang@canonical.com
State New
Headers show
Series "alsa-mixer: Adding Jack of Front Headphone Front and Surround" ( rev: 1 ) in PulseAudio

Not browsing as part of any series.

Commit Message

Hui Wang Dec. 21, 2018, 3:05 a.m.
We have 2 HP desktop models which have one front headphone Jack and
one front headset Jack, in the Linux kernel, these two jacks are
named "Front Headphone Front Jack" and "Front Headphone Surround
Jack", now adding them into the pathes conf file.

Without this change, if users plug a headset or headphone, the
path of headphone will not be activated, and users can't see
headphones from UI like gnome-control-center.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
For alsa-info.txt of one of machines, please access:
https://pastebin.ubuntu.com/p/CjCGySMpM5/

 .../alsa/mixer/paths/analog-input-headset-mic.conf        | 6 ++++++
 .../alsa/mixer/paths/analog-output-headphones.conf        | 6 ++++++
 .../alsa/mixer/paths/analog-output-speaker-always.conf    | 8 ++++++++
 src/modules/alsa/mixer/paths/analog-output-speaker.conf   | 8 ++++++++
 4 files changed, 28 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf b/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
index 579db6bb7..bc687b6e4 100644
--- a/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
+++ b/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
@@ -35,6 +35,12 @@  state.plugged = unknown
 [Jack Front Headphone]
 state.plugged = unknown
 
+[Jack Front Headphone Front]
+state.plugged = unknown
+
+[Jack Front Headphone Surround]
+state.plugged = unknown
+
 [Jack Headphone Mic]
 state.plugged = unknown
 
diff --git a/src/modules/alsa/mixer/paths/analog-output-headphones.conf b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
index d2147c50f..2d751607c 100644
--- a/src/modules/alsa/mixer/paths/analog-output-headphones.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
@@ -40,6 +40,12 @@  required-any = any
 state.plugged = unknown
 state.unplugged = unknown
 
+[Jack Front Headphone Front]
+required-any = any
+
+[Jack Front Headphone Surround]
+required-any = any
+
 [Jack Headphone]
 required-any = any
 
diff --git a/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf b/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
index 71f356dce..c9374e471 100644
--- a/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
@@ -33,6 +33,14 @@  state.unplugged = unknown
 state.plugged = no
 state.unplugged = unknown
 
+[Jack Front Headphone Front]
+state.plugged = no
+state.unplugged = unknown
+
+[Jack Front Headphone Surround]
+state.plugged = no
+state.unplugged = unknown
+
 [Jack Line Out]
 state.plugged = no
 state.unplugged = unknown
diff --git a/src/modules/alsa/mixer/paths/analog-output-speaker.conf b/src/modules/alsa/mixer/paths/analog-output-speaker.conf
index 9f4dac414..536630d0a 100644
--- a/src/modules/alsa/mixer/paths/analog-output-speaker.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-speaker.conf
@@ -36,6 +36,14 @@  state.unplugged = unknown
 state.plugged = no
 state.unplugged = unknown
 
+[Jack Front Headphone Front]
+state.plugged = no
+state.unplugged = unknown
+
+[Jack Front Headphone Surround]
+state.plugged = no
+state.unplugged = unknown
+
 [Jack Line Out]
 state.plugged = no
 state.unplugged = unknown

Comments

On Fri, 2018-12-21 at 11:05 +0800, Hui Wang wrote:
> We have 2 HP desktop models which have one front headphone Jack and
> one front headset Jack, in the Linux kernel, these two jacks are
> named "Front Headphone Front Jack" and "Front Headphone Surround
> Jack", now adding them into the pathes conf file.

How do the kcontrols map to physical connectors? Is there only one
physical connector or two? How do different kinds of devices
(headphones, headsets, stand-alone mics) change the state of the two
kcontrols?

I think at least the headset-mic path configuration in your patch is
incorrect, but I don't know how it should be configured before knowing
how the two kcontrols behave.

(A sidenote: it would be awesome to have some documentation that
explains what combinations of headphone/headset/mic jacks exist in the
wild and how those combinations map to physical connectors. The details
of the headphone/headset/mic jack detection mess are impossible to
remember.)

> Without this change, if users plug a headset or headphone, the
> path of headphone will not be activated, and users can't see
> headphones from UI like gnome-control-center.
> 
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
> For alsa-info.txt of one of machines, please access:
> https://pastebin.ubuntu.com/p/CjCGySMpM5/
> 
>  .../alsa/mixer/paths/analog-input-headset-mic.conf        | 6 ++++++
>  .../alsa/mixer/paths/analog-output-headphones.conf        | 6 ++++++
>  .../alsa/mixer/paths/analog-output-speaker-always.conf    | 8 ++++++++
>  src/modules/alsa/mixer/paths/analog-output-speaker.conf   | 8 ++++++++
>  4 files changed, 28 insertions(+)
> 
> diff --git a/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf b/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
> index 579db6bb7..bc687b6e4 100644
> --- a/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
> +++ b/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
> @@ -35,6 +35,12 @@ state.plugged = unknown
>  [Jack Front Headphone]
>  state.plugged = unknown
>  
> +[Jack Front Headphone Front]
> +state.plugged = unknown
> +
> +[Jack Front Headphone Surround]
> +state.plugged = unknown
> +
>  [Jack Headphone Mic]
>  state.plugged = unknown
>  
> diff --git a/src/modules/alsa/mixer/paths/analog-output-headphones.conf b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
> index d2147c50f..2d751607c 100644
> --- a/src/modules/alsa/mixer/paths/analog-output-headphones.conf
> +++ b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
> @@ -40,6 +40,12 @@ required-any = any
>  state.plugged = unknown
>  state.unplugged = unknown
>  
> +[Jack Front Headphone Front]
> +required-any = any
> +
> +[Jack Front Headphone Surround]
> +required-any = any
> +
>  [Jack Headphone]
>  required-any = any
>  
> diff --git a/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf b/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
> index 71f356dce..c9374e471 100644
> --- a/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
> +++ b/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
> @@ -33,6 +33,14 @@ state.unplugged = unknown
>  state.plugged = no
>  state.unplugged = unknown
>  
> +[Jack Front Headphone Front]
> +state.plugged = no
> +state.unplugged = unknown
> +
> +[Jack Front Headphone Surround]
> +state.plugged = no
> +state.unplugged = unknown
> +
>  [Jack Line Out]
>  state.plugged = no
>  state.unplugged = unknown
> diff --git a/src/modules/alsa/mixer/paths/analog-output-speaker.conf b/src/modules/alsa/mixer/paths/analog-output-speaker.conf
> index 9f4dac414..536630d0a 100644
> --- a/src/modules/alsa/mixer/paths/analog-output-speaker.conf
> +++ b/src/modules/alsa/mixer/paths/analog-output-speaker.conf
> @@ -36,6 +36,14 @@ state.unplugged = unknown
>  state.plugged = no
>  state.unplugged = unknown
>  
> +[Jack Front Headphone Front]
> +state.plugged = no
> +state.unplugged = unknown
> +
> +[Jack Front Headphone Surround]
> +state.plugged = no
> +state.unplugged = unknown
> +
>  [Jack Line Out]
>  state.plugged = no
>  state.unplugged = unknown
On 2018/12/31 下午9:46, Tanu Kaskinen wrote:
> On Fri, 2018-12-21 at 11:05 +0800, Hui Wang wrote:
>> We have 2 HP desktop models which have one front headphone Jack and
>> one front headset Jack, in the Linux kernel, these two jacks are
>> named "Front Headphone Front Jack" and "Front Headphone Surround
>> Jack", now adding them into the pathes conf file.
> How do the kcontrols map to physical connectors? Is there only one
> physical connector or two? How do different kinds of devices
> (headphones, headsets, stand-alone mics) change the state of the two
> kcontrols?
There are 2 physical connectors/jacks, one is the pure headphone jack, 
the other is the headset jack (headphone + mic).

For the headphone jack, the kcontrols are:  'Front Headphone Surround 
Jack' and 'Headphone Playback Volume' index 1

For the headset jack, the kcontrols are: 'Front Headphone Front Jack',  
'Headphone Playback Volume' index 0, 'Mic Jack' and 'Mic Boost Volume'

If we plug a headphone in either of the two jacks, the 'Surround Jack' 
or 'Front Jack' will be true. If we plug a headset in the headset jack, 
the 'Front Jack' and 'Mic Jack' will be true.

This is not the Dell machine, most Dell machines can't detect mic of 
headset, so we add headset-mic, headphone-mic for them.  This HP machine 
can detect mic of headset jack, and it doesn't support stand-alone mics too.


>
> I think at least the headset-mic path configuration in your patch is
> incorrect, but I don't know how it should be configured before knowing
> how the two kcontrols behave.

After reading your comments above,  I think you are right.  And I think 
I shouldn't touch analog-input-headset-mic.conf in the patch, since this 
is a HP machine, and the headset jack of this machine has capability to 
detect the mic on the headset and the kcontrols are "Mic Jack" and 
"Headphone Front Jack". It is different from the Dell machines.


> (A sidenote: it would be awesome to have some documentation that
> explains what combinations of headphone/headset/mic jacks exist in the
> wild and how those combinations map to physical connectors. The details
> of the headphone/headset/mic jack detection mess are impossible to
> remember.)
>
It is not easy to fully understand this part, need to study it bit by 
bit.  :-)


>> Without this change, if users plug a headset or headphone, the
>> path of headphone will not be activated, and users can't see
>> headphones from UI like gnome-control-center.
>>
>> Signed-off-by: Hui Wang <hui.wang@canonical.com>
>> ---
>> For alsa-info.txt of one of machines, please access:
>> https://pastebin.ubuntu.com/p/CjCGySMpM5/
>>
>>   .../alsa/mixer/paths/analog-input-headset-mic.conf        | 6 ++++++
>>   .../alsa/mixer/paths/analog-output-headphones.conf        | 6 ++++++
>>   .../alsa/mixer/paths/analog-output-speaker-always.conf    | 8 ++++++++
>>   src/modules/alsa/mixer/paths/analog-output-speaker.conf   | 8 ++++++++
>>   4 files changed, 28 insertions(+)
>>
>> diff --git a/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf b/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
>> index 579db6bb7..bc687b6e4 100644
>> --- a/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
>> +++ b/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
>> @@ -35,6 +35,12 @@ state.plugged = unknown
>>   [Jack Front Headphone]
>>   state.plugged = unknown
>>   
>> +[Jack Front Headphone Front]
>> +state.plugged = unknown
>> +
>> +[Jack Front Headphone Surround]
>> +state.plugged = unknown
>> +
>>   [Jack Headphone Mic]
>>   state.plugged = unknown
>>   
>> diff --git a/src/modules/alsa/mixer/paths/analog-output-headphones.conf b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
>> index d2147c50f..2d751607c 100644
>> --- a/src/modules/alsa/mixer/paths/analog-output-headphones.conf
>> +++ b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
>> @@ -40,6 +40,12 @@ required-any = any
>>   state.plugged = unknown
>>   state.unplugged = unknown
>>   
>> +[Jack Front Headphone Front]
>> +required-any = any
>> +
>> +[Jack Front Headphone Surround]
>> +required-any = any
>> +
>>   [Jack Headphone]
>>   required-any = any
>>   
>> diff --git a/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf b/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
>> index 71f356dce..c9374e471 100644
>> --- a/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
>> +++ b/src/modules/alsa/mixer/paths/analog-output-speaker-always.conf
>> @@ -33,6 +33,14 @@ state.unplugged = unknown
>>   state.plugged = no
>>   state.unplugged = unknown
>>   
>> +[Jack Front Headphone Front]
>> +state.plugged = no
>> +state.unplugged = unknown
>> +
>> +[Jack Front Headphone Surround]
>> +state.plugged = no
>> +state.unplugged = unknown
>> +
>>   [Jack Line Out]
>>   state.plugged = no
>>   state.unplugged = unknown
>> diff --git a/src/modules/alsa/mixer/paths/analog-output-speaker.conf b/src/modules/alsa/mixer/paths/analog-output-speaker.conf
>> index 9f4dac414..536630d0a 100644
>> --- a/src/modules/alsa/mixer/paths/analog-output-speaker.conf
>> +++ b/src/modules/alsa/mixer/paths/analog-output-speaker.conf
>> @@ -36,6 +36,14 @@ state.unplugged = unknown
>>   state.plugged = no
>>   state.unplugged = unknown
>>   
>> +[Jack Front Headphone Front]
>> +state.plugged = no
>> +state.unplugged = unknown
>> +
>> +[Jack Front Headphone Surround]
>> +state.plugged = no
>> +state.unplugged = unknown
>> +
>>   [Jack Line Out]
>>   state.plugged = no
>>   state.unplugged = unknown
On Wed, 2019-01-02 at 20:23 +0800, Hui Wang wrote:
> On 2018/12/31 下午9:46, Tanu Kaskinen wrote:
> > On Fri, 2018-12-21 at 11:05 +0800, Hui Wang wrote:
> > > We have 2 HP desktop models which have one front headphone Jack and
> > > one front headset Jack, in the Linux kernel, these two jacks are
> > > named "Front Headphone Front Jack" and "Front Headphone Surround
> > > Jack", now adding them into the pathes conf file.
> > How do the kcontrols map to physical connectors? Is there only one
> > physical connector or two? How do different kinds of devices
> > (headphones, headsets, stand-alone mics) change the state of the two
> > kcontrols?
> There are 2 physical connectors/jacks, one is the pure headphone jack, 
> the other is the headset jack (headphone + mic).
> 
> For the headphone jack, the kcontrols are:  'Front Headphone Surround 
> Jack' and 'Headphone Playback Volume' index 1
> 
> For the headset jack, the kcontrols are: 'Front Headphone Front Jack',  
> 'Headphone Playback Volume' index 0, 'Mic Jack' and 'Mic Boost Volume'

The jack kcontrol names are unfortunate. They don't really make sense.
"Surround" normally refers to particular channels in multichannel
setup, and similarly the second "Front" in "Front Headphone Front"
would normally refer to the front channels in multichannel setup. I'm
not familiar with the kernel driver code - in case you know better,
would it be feasible to get these jack kcontrols renamed? Or are we
doomed to live with nonsensical kcontrol names forever?

I'd like to change the jack kcontrols to simply "Front Headphone Jack"
(or even simpler "Headphone Jack", since the volume element doesn't use
the "Front" prefix either). The headphone jack would use index 1 like
is done with the volume element. Or alternatively use "Headphone2" with
the headphone volume and jack kcontrols (this would be easier to
support in PulseAudio).

PulseAudio doesn't currently support any mixer controls with non-zero
index, so currently the headphone output won't have hardware volume. If
you're interested in improving that, it should be relatively easy to
fix this shortcoming. We just need a new "index" option for the
[Element] sections in the configuration files, and alsa-mixer.c then
needs to use that index instead of hardcoding the index to 0 like it
does now. We probably need also a new "alsa-name" option for the
[Element] sections, because there's probably need to have two [Element]
sections in one configuration file with the same alsa name but
different identifier. Like this:

[Element Headphone_1]
alsa-name = Headphone
volume = ...
mute = ...

[Element Headphone_2]
alsa-name = Headphone
volume = ...
mute = ...


> If we plug a headphone in either of the two jacks, the 'Surround Jack' 
> or 'Front Jack' will be true. If we plug a headset in the headset jack, 
> the 'Front Jack' and 'Mic Jack' will be true.
> 
> This is not the Dell machine, most Dell machines can't detect mic of 
> headset, so we add headset-mic, headphone-mic for them.  This HP machine 
> can detect mic of headset jack, and it doesn't support stand-alone mics too.
> 
> 
> > I think at least the headset-mic path configuration in your patch is
> > incorrect, but I don't know how it should be configured before knowing
> > how the two kcontrols behave.
> 
> After reading your comments above,  I think you are right.  And I think 
> I shouldn't touch analog-input-headset-mic.conf in the patch, since this 
> is a HP machine, and the headset jack of this machine has capability to 
> detect the mic on the headset and the kcontrols are "Mic Jack" and 
> "Headphone Front Jack". It is different from the Dell machines.

Yes, it seems that headset-mic can be left alone.

Since there are two physical connectors, I don't think we can use
analog-output-headphone for both. With your original patch, if you plug
in headphones to the headphone connector, PulseAudio will enable the
analog-output-headphone port. PulseAudio will also think that the port
has hardware volume, because the "Headphone" volume element exists, but
PulseAudio will only control the element with index 0, which has no
effect on the headphone output - it only affects the headset output. We
should assign the "Front Headphone Surround" jack to the analog-output-
headphone-2 path. That way volume control works with both connectors.