[alsa-devel] How to handle jack detection through gpios

Hans de Goede hdegoede at redhat.com
Fri Nov 3 13:09:37 CET 2017


Hi,

On 03-11-17 12:24, Mark Brown wrote:
> On Fri, Nov 03, 2017 at 09:41:29AM +0100, Hans de Goede wrote:
> 
>> So I was wondering if there is a way to have a headphone
>> switch without tying it to a card, while userspace will
>> still know what to do ?
> 
> You can make a GPIO input device but obviously can't have anything
> reporting through the sound card interface without a sound card.

Ok, so I could make the driver generate evdev events
of type EV_SW with code SW_HEADPHONE_INSERT. Does userspace
do anything useful with this like automatically switching
between headphones and speakers as a headphone-jack which
is part of the sound card would do ?

If not, then is there a way to get a list of registered
soundcards from a driver, then pick one of the cards
based on some heuristics and then do the snd_soc_card_jack_new,
etc. on the picked card?

I assume that the approach from:
https://github.com/me176c-dev/kernel_asus_me176c/commit/498116d7e7b4718fa0655c4879e59a163b1dd85b

Where the struct snd_soc_card byt_rt5640_card is made
non-static and exported is not acceptable ?

Regards,

Hans


More information about the Alsa-devel mailing list