This patch adds a helper function that determines the jack type 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
Signed-off-by: Harsha Priya priya.harsha@intel.com Signed-off-by: Vinod Koul vinod.koul@intel.com --- include/sound/soc.h | 15 +++++++++++++++ sound/soc/soc-jack.c | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 7ecdaef..afe98eb 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -246,6 +246,19 @@ typedef int (*hw_write_t)(void *,const char* ,int);
extern struct snd_ac97_bus_ops soc_ac97_ops;
+enum soc_mic_bias_zones { + /* mic bias volutage range for Headphones*/ + SND_SOC_JACK_HP_START = 0, + SND_SOC_JACK_HP_END = 400, + /* mic bias volutage range for American Headset*/ + SND_SOC_JACK_AM_HS_START = 400, + SND_SOC_JACK_AM_HS_END = 650, + /* mic bias volutage range for Headset*/ + SND_SOC_JACK_HS_START = 650, + SND_SOC_JACK_HS_END = 2000, + SND_SOC_UNDEFINED, +}; + enum snd_soc_control_type { SND_SOC_CUSTOM, SND_SOC_I2C, @@ -307,6 +320,8 @@ void snd_soc_jack_notifier_register(struct snd_soc_jack *jack, struct notifier_block *nb); void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, struct notifier_block *nb); +int snd_soc_jack_get_type(int mic_bias); + #ifdef CONFIG_GPIOLIB int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, struct snd_soc_jack_gpio *gpios); diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index ac5a5bc..462965a 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -186,6 +186,24 @@ void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, } EXPORT_SYMBOL_GPL(snd_soc_jack_notifier_unregister);
+/** + * snd_soc_jack_get_type - Based on the mic bias value, this function returns + * the type of jack + * + * @mic_bias: mic bias value detected + * + * Based on the mic bias value passed, this function helps identify + * the type of jack as either SND_JACK_HEADSET or SND_JACK_HEADPHONE. + */ +int snd_soc_jack_get_type(int mic_bias) +{ + if (mic_bias >= SND_SOC_JACK_HP_START && mic_bias < SND_SOC_JACK_HS_END) + return SND_JACK_HEADSET; + else + return SND_JACK_HEADPHONE; +} +EXPORT_SYMBOL_GPL(snd_soc_jack_get_type); + #ifdef CONFIG_GPIOLIB /* gpio detect */ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)