On 2015-03-26 09:29, Jie, Yang wrote:
Thank you so much, David!
So, I summarized as below table:
I've added how I see them with the new API, see below for further comments:
Jack Type kctls/switches name detection description
Headphone Headphone Jack HP plugged in/unplugged
SND_JACK_HEADPHONE
Mic Mic Jack Mic plugged in/unplugged
SND_JACK_MICROPHONE
Headset Headphone Jack Nothing plugged in: ""Headphone Jack"" = false, ""Headset Mic Jack"" = false Headset Mic Jack" Headphones plugged in: ""Headphone Jack"" = true, ""Headset Mic Jack"" = false Headset plugged in: ""Headphone Jack"" = true, ""Headset Mic Jack"" = true Mic plugged in: ""Headphone Jack"" = true ""Headset Mic Jack"" = false(should not plugged in Mic, detect wrongly)" independent switches
SND_JACK_HEADSET
"Mic plugged in" case is irrelevant - not supported by hw
Headset Mic Headphone Jack Nothing plugged in: ""Headphone Jack"" = false, ""Headset Mic Phantom Jack"" = false Headset Mic Phantom Jack Headphones plugged in: ""Headphone Jack"" = true, ""Headset Mic Phantom Jack"" = false? Headset plugged in: ""Headphone Jack"" = false, ""Headset Mic Phantom Jack"" = true ? Mic plugged in: ""Headphone Jack"" = true, ""Headset Mic Phantom Jack"" = false(should not plugged in Mic, detect wrongly)" one hw switch only
SND_JACK_HEADPHONE, the "Headset Mic Phantom Jack" is created manually
Headphone Mic Headphone Mic Jack Nothing plugged in: ""Headphone Mic Jack"" = false Headphones plugged in: ""Headphone Mic Jack"" = true Mic plugged in: ""Headphone Mic Jack"" = true Headset plugged in: ""Headphone Mic Jack"" = true?" one hw switch
SND_JACK_HEADPHONE (probably)
Headset Headphone Mic Headphone Mic Jack Nothing plugged in: ""Headphone Mic Jack"" = false, ""Headset Mic Phantom Jack"" = false Headset Mic Phantom Jack Headphones plugged in: ""Headphone Mic Jack"" = true, ""Headset Mic Phantom Jack"" = false Headset plugged in: ""Headphone Mic Jack"" = false, ""Headset Mic Phantom Jack"" = true ? Mic plugged in: ""Headphone Mic Jack"" = true, ""Headset Mic Phantom Jack"" = false" one hw switch only
SND_JACK_HEADPHONE (probably), the "Headset Mic Phantom Jack" is created manually
Headphone Mic Headset Headphone Mic Jack Nothing plugged in: ""Headphone Mic Jack"" = false, ""Headset Mic Jack"" = false Headset Mic Jack Headphones plugged in: ""Headphone Mic Jack"" = true, ""Headset Mic Jack"" = false Headset plugged in: ""Headphone Mic Jack"" = true, ""Headset Mic Jack"" = true Mic plugged in: ""Headphone Mic Jack"" = true, ""Headset Mic Jack"" = false one switch for hp/mic and the other for the headset mic
SND_JACK_HEADSET (probably)
so, we may need extend snd_jack_types enum, by adding types: Headset Mic, Headphone Mic, Headset Headphone Mic, Headphone Mic Headset.
enum snd_jack_types { SND_JACK_HEADPHONE = 0x0001, SND_JACK_MICROPHONE = 0x0002, SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE, SND_JACK_LINEOUT = 0x0004, SND_JACK_MECHANICAL = 0x0008, /* If detected separately */ SND_JACK_VIDEOOUT = 0x0010, SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT, SND_JACK_LINEIN = 0x0020,
SND_JACK_HEADSET_MIC = 0x0040, /* one hw switch only */ SND_JACK_HEADPHONE_MIC = 0x0080, /* one hw switch only, headphone, or mic */ SND_JACK_HEADSET_ HEADPHONE_MIC = 0x0100, /* one hw switch only, headset, headphone, or mic*/ SND_JACK_ HEADPHONE_HEADSET_ MIC = 0x0200, /* headset, headphone, or mic; one switch for hp/mic and the other for the headset mic */
This seems overly complex. I don't think we really need to add all of that.
First, for the phantom jacks. We'll need phantom jacks not only for "Headset Mic Phantom Jack" but also for "Internal Speaker Phantom Jack" and "Internal Mic Phantom Jack", and probably some others as well. So that means that the HDA driver needs to still create some kctls using the current kctl API instead of your new unified API.
A phantom jack is merely a marker to userspace indicating what hardware is present. It always returns "plugged in" when trying to read it.
With the phantom jacks dealt with separately, the question remains about the Headphone Mic stuff. If the name remains the way it is, maybe all we need is a SND_JACK_HEADPHONE (or SND_JACK_HEADSET) jack with the "Headphone Mic Jack" name and then userspace would know that this jack could potentially accomodate a microphone too. Otherwise we might need to add a SND_JACK_HEADPHONE_OR_MIC constant, but I prefer that the names are kept properly, because there might be other relevant info added to the name too (e g "Front Headphone Jack" instead of "Headphone Jack").