alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Harsha Priya <priya.harsha@intel.com>
To: alsa-devel@alsa-project.org
Cc: Harsha Priya <priya.harsha@intel.com>,
	Vinod Koul <vinod.koul@intel.com>,
	broonie@opensource.wolfsonmicro.com, lrg@slimlogic.co.uk
Subject: [PATCH 1/3] ASoC: soc_jack - add function to determine jack type
Date: Fri, 28 Jan 2011 22:39:39 +0530	[thread overview]
Message-ID: <1296234579-6622-1-git-send-email-priya.harsha@intel.com> (raw)

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)
-- 
1.7.3.4

             reply	other threads:[~2011-01-28 16:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-28 17:09 Harsha Priya [this message]
2011-01-31 12:06 ` [PATCH 1/3] ASoC: soc_jack - add function to determine jack type Liam Girdwood
2011-01-31 12:08 ` Mark Brown
2011-02-01 13:19   ` Harsha, Priya
2011-02-01 13:22     ` Mark Brown
2011-02-01 13:35       ` Harsha, Priya
2011-02-01 13:43         ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1296234579-6622-1-git-send-email-priya.harsha@intel.com \
    --to=priya.harsha@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lrg@slimlogic.co.uk \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).