summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorNikesh Oswal <noswal@nvidia.com>2012-06-29 16:26:33 +0530
committerRohan Somvanshi <rsomvanshi@nvidia.com>2012-07-12 08:32:28 -0700
commit328ca1a833b594b574b9f4f82a25ba8613bad3e5 (patch)
treefdd0ee0b539347315e4037f915b7161eb3e2bdb2 /sound/soc
parent8f751e925da2510ded1003976186a379853b134e (diff)
asoc: codecs: max98088: Headset Detection
Add code for headset detection according to that state transitions mentioned for JKSNS field in the max98088 codec datasheet Bug: 110529 Bug: 1008246 Signed-off-by: Nikesh Oswal <noswal@nvidia.com> Reviewed-on: http://git-master/r/112127 (cherry picked from commit 12a2259e0e9cf7da4bf64bad2a97c32cec41477c) Change-Id: I7d45b210dd02f181e71a08d9b3de7cff109dd88b Reviewed-on: http://git-master/r/114445 Reviewed-by: Automatic_Commit_Validation_User Tested-by: Nikesh Oswal <noswal@nvidia.com> Reviewed-by: Scott Peterson <speterson@nvidia.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/max98088.c29
-rw-r--r--sound/soc/codecs/max98088.h5
2 files changed, 26 insertions, 8 deletions
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index e2ad10d2deaa..b2b31f912b74 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -57,6 +57,8 @@ struct max98088_priv {
unsigned int extmic_mode;
int irq;
struct snd_soc_jack *headset_jack;
+ unsigned int jk_sns;
+ int jack_report;
};
static const u8 max98088_reg[M98088_REG_CNT] = {
@@ -1968,19 +1970,28 @@ static void max98088_handle_pdata(struct snd_soc_codec *codec)
int max98088_report_jack(struct snd_soc_codec *codec)
{
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
- unsigned int value;
- int jack_report = 0;
+ unsigned int jk_sns_curr;
+ int jack_report_curr = 0;
/* Read the Jack Status Register*/
- value = snd_soc_read(codec, M98088_REG_02_JACK_STAUS);
+ jk_sns_curr = (snd_soc_read(codec, M98088_REG_02_JACK_STAUS))
+ & (M98088_JKSNS_7 | M98088_JKSNS_6);
+
+ if (max98088->jk_sns == M98088_NONE && jk_sns_curr == M98088_HP)
+ jack_report_curr = SND_JACK_HEADPHONE;
+ else if (max98088->jk_sns == M98088_NONE && jk_sns_curr == M98088_HS)
+ jack_report_curr = SND_JACK_HEADSET;
+ else if ((max98088->jk_sns == M98088_HP || max98088->jk_sns == M98088_HS)
+ && jk_sns_curr == M98088_NONE)
+ jack_report_curr = 0;
+ else
+ jack_report_curr = max98088->jack_report;
- if ((value & M98088_JKSNS_7) == 0)
- jack_report |= SND_JACK_HEADPHONE;
- if (value & M98088_JKSNS_6)
- jack_report |= SND_JACK_MICROPHONE;
+ max98088->jack_report = jack_report_curr;
+ max98088->jk_sns = jk_sns_curr;
snd_soc_jack_report(max98088->headset_jack,
- jack_report, SND_JACK_HEADSET);
+ jack_report_curr, SND_JACK_HEADSET);
return 0;
}
@@ -2001,6 +2012,8 @@ int max98088_headset_detect(struct snd_soc_codec *codec,
{
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
max98088->headset_jack = jack;
+ max98088->jk_sns = M98088_NONE;
+ max98088->jack_report = 0;
if (max98088->irq) {
if (type & SND_JACK_HEADSET) {
diff --git a/sound/soc/codecs/max98088.h b/sound/soc/codecs/max98088.h
index cf4b04d2d07a..81ccf4b4caee 100644
--- a/sound/soc/codecs/max98088.h
+++ b/sound/soc/codecs/max98088.h
@@ -222,6 +222,11 @@
#define M98088_BYTE1(w) ((w >> 8) & 0xff)
#define M98088_BYTE0(w) (w & 0xff)
+/* HeadPhone and HeadSet detection Bitmasks */
+#define M98088_HP 0
+#define M98088_HS M98088_JKSNS_6
+#define M98088_NONE (M98088_JKSNS_7 | M98088_JKSNS_6)
+
int max98088_headset_detect(struct snd_soc_codec *codec,
struct snd_soc_jack *jack, enum snd_jack_types type);