On Fri, Jan 28, 2011 at 10:39:39PM +0530, Harsha Priya wrote:
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.
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) or for 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/s...
It's quite hard coded in code terms but it covers things like the debounce.