[alsa-devel] [PATCH 1/3] ASoC: soc_jack - add function to determine jack type

Harsha, Priya priya.harsha at intel.com
Tue Feb 1 14:19:11 CET 2011

>> given the mic bias value. For any codec that would give
>> the mic bias value on a jack insertion, this function would
>> return the type of jack based on mic bias range
>I think this is too minimal as an API for this.  There's two things I'm
>missing here.  The major one is that there's no handling of debounce -
>jack insertion is a very slow and very analogue process relative to CPUs
>so taking a single reading is likely to give false measurements.
I believe this should be part of codec driver that would make sure that it has
determined the right adc value and then call the function to find the jack type. 
In the sn95031 codec, this is handled in hardware with programmable debounce
values. The default value  takes care of ensuring that the adc value is read is for
right jack event.
Later, I will add a kcontrol for the same to enable programming it.
>The other is that there's no facility for either scaling the voltages
>with micbias (obviously the specific voltages read are going to vary
>depending on what the micbias voltage on a given system is) 
I can add a field "system_micbias" field and the ranges fields to snd_soc_jack
structure. The machine driver can set these details when it creates a jack. The
new API can give the jack or button type based on this range. This way its
scalable. Will this help? Let us know, if there is a better way

>adding other things that can be detected.  For example, some systems
>have buttons on their headset which pull micbias to ground via varying
>resistances with individual buttons being detected by measuring the
>different voltages resulting from the different resistances.
>It'd be worth taking a look at the sec_jack stuff that Samsung have used
>in at least some of their Android devices:
>  http://android.git.kernel.org/?p=kernel/samsung.git;a=blob;f=include/linux/sec_jack.h
>It's quite hard coded in code terms but it covers things like the
Thanks for the link.


More information about the Alsa-devel mailing list