alsa: Jack detection kcontrol implementation

Support the new jack detection interface implemented in Linux 3.3
(and Ubuntu's 3.2 kernel).

Jacks are probed and detected using the snd_hctl_* commands, which
means we need to listen to them using fdlists. As this detection
needs to be active even if there is currently no sink for the jack,
so this polling is done on the card level.

Also add configuration support in paths, like this:
[Jack Headphone]
required-any = any

...where 'Jack Headphone' should match 'Headphone Jack' as given by
ALSA (as seen in e g 'amixer controls').
"Required", "required-any" and "required-absent" is supported. Using
required-any, one can have several ports even though there is no
other indication in the mixer that this path exists.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
David Henningsson 2012-02-23 07:17:02 +01:00 committed by Arun Raghavan
parent 74e01ad616
commit dedf1340c6
14 changed files with 464 additions and 105 deletions

View file

@ -22,6 +22,9 @@
priority = 78
name = analog-input-microphone-dock
[Jack Dock Mic]
required-any = any
[Element Dock Mic Boost]
required-any = any
switch = select

View file

@ -22,6 +22,9 @@
priority = 85
name = analog-input-microphone-front
[Jack Front Mic]
required-any = any
[Element Front Mic Boost]
required-any = any
switch = select

View file

@ -21,6 +21,9 @@
[General]
priority = 81
[Jack Line]
required-any = any
[Element Capture]
switch = mute
volume = merge

View file

@ -22,6 +22,9 @@
priority = 87
name = analog-input-microphone
[Jack Mic]
required-any = any
[Element Mic Boost]
required-any = any
switch = select

View file

@ -22,6 +22,9 @@
priority = 82
name = analog-input-microphone-rear
[Jack Rear Mic]
required-any = any
[Element Rear Mic Boost]
required-any = any
switch = select

View file

@ -22,6 +22,9 @@
priority = 90
name = analog-output-headphones
[Jack Headphone]
required-any = any
[Element Hardware Master]
switch = mute
volume = merge
@ -39,7 +42,7 @@ switch = off
volume = off
[Element Headphone]
required = any
required-any = any
switch = mute
volume = merge
override-map.1 = all

View file

@ -70,7 +70,7 @@
; [Element ...] # For each element that we shall control
; required = ignore | switch | volume | enumeration | any # If set, require this element to be of this kind and available,
; # otherwise don't consider this path valid for the card
; required-any = ignore | switch | volume | enumeration | any # If set, at least one of the elements with required-any in this
; required-any = ignore | switch | volume | enumeration | any # If set, at least one of the elements or jacks with required-any in this
; # path must be present, otherwise this path is invalid for the card
; required-absent = ignore | switch | volume # If set, require this element to not be of this kind and not
; # available, otherwise don't consider this path valid for the card
@ -100,6 +100,12 @@
; # channel mask. A channel mask may either be the name of a single channel, or the words "all-left",
; # "all-right", "all-center", "all-front", "all-rear", and "all" to encode a specific subset of
; # channels in a mask
; [Jack ...] # For each jack that we will use for jack detection
; # The name 'Jack Foo' must match ALSA's 'Foo Jack' control.
; required = ignore | any # If not set to ignore, make the path invalid if this jack control is not present.
; required-absent = ignore | any # If not set to ignore, make the path invalid if this jack control is present.
; required-any = ignore | any # If not set to ignore, make the path invalid if no jack controls and no elements with
; # the required-any are present.
[Element PCM]
switch = mute