From: "Koul, Vinod" <vinod.koul@intel.com>
To: alsa-devel@alsa-project.org
Cc: Vinod Koul <vinod.koul@intel.com>,
broonie@opensource.wolfsonmicro.com,
Harsha Priya <priya.harsha@intel.com>,
lrg@slimlogic.co.uk
Subject: [PATCH 1/3] ASoC: sn95031: Add jack support in the codec
Date: Wed, 9 Feb 2011 14:42:25 +0530 [thread overview]
Message-ID: <1297242747-18632-2-git-send-email-vinod.koul@intel.com> (raw)
In-Reply-To: <1297242747-18632-1-git-send-email-vinod.koul@intel.com>
From: Vinod Koul <vinod.koul@intel.com>
This patch adds support for jack detection and reporting in the codec
It however is not fully functional as it doesn't measure adc to figure
out what got inserted which will be added later
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Harsha Priya <priya.harsha@intel.com>
---
sound/soc/codecs/sn95031.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
sound/soc/codecs/sn95031.h | 10 +++++++
2 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c
index 40e285d..3cd812d 100644
--- a/sound/soc/codecs/sn95031.c
+++ b/sound/soc/codecs/sn95031.c
@@ -34,6 +34,7 @@
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include <sound/tlv.h>
+#include <sound/jack.h>
#include "sn95031.h"
#define SN95031_RATES (SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100)
@@ -649,6 +650,62 @@ struct snd_soc_dai_driver sn95031_dais[] = {
},
};
+void disable_jack_btn(struct snd_soc_codec *codec)
+{
+ snd_soc_write(codec, SN95031_BTNCTRL2, 0x00);
+}
+EXPORT_SYMBOL_GPL(disable_jack_btn);
+
+static inline void enable_jack_btn(struct snd_soc_codec *codec)
+{
+ snd_soc_write(codec, SN95031_BTNCTRL1, 0x77);
+ snd_soc_write(codec, SN95031_BTNCTRL2, 0x01);
+}
+
+static int sn95031_get_headset_state(struct snd_soc_jack *mfld_jack)
+{
+ /* Defaulting to HEADSET for now.
+ * will change after adding soc-jack detection apis */
+ int jack_type = SND_JACK_HEADSET;
+
+ pr_debug("jack type detected = %d\n", jack_type);
+ if (jack_type == SND_JACK_HEADSET)
+ enable_jack_btn(mfld_jack->codec);
+ return jack_type;
+}
+
+void sn95031_jack_detection(struct mfld_jack_data *jack_data)
+{
+ unsigned int status;
+ unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET;
+
+ pr_debug("interrupt id read in sram = 0x%x\n", jack_data->intr_id);
+ if (jack_data->intr_id & 0x1) {
+ pr_debug("short_push detected\n");
+ status = SND_JACK_HEADSET | SND_JACK_BTN_0;
+ } else if (jack_data->intr_id & 0x2) {
+ pr_debug("long_push detected\n");
+ status = SND_JACK_HEADSET | SND_JACK_BTN_1;
+ } else if (jack_data->intr_id & 0x4) {
+ pr_debug("headset or headphones inserted\n");
+ status = sn95031_get_headset_state(jack_data->mfld_jack);
+ } else if (jack_data->intr_id & 0x8) {
+ pr_debug("headset or headphones removed\n");
+ status = 0;
+ disable_jack_btn(jack_data->mfld_jack->codec);
+ } else {
+ pr_err("unidentified interrupt\n");
+ return;
+ }
+
+ snd_soc_jack_report(jack_data->mfld_jack, status, mask);
+ /*button pressed and released so we send explicit button release */
+ if ((status & SND_JACK_BTN_0) | (status & SND_JACK_BTN_1))
+ snd_soc_jack_report(jack_data->mfld_jack,
+ SND_JACK_HEADSET, mask);
+}
+EXPORT_SYMBOL_GPL(sn95031_jack_detection);
+
/* codec registration */
static int sn95031_codec_probe(struct snd_soc_codec *codec)
{
diff --git a/sound/soc/codecs/sn95031.h b/sound/soc/codecs/sn95031.h
index e2b17d9..3d6f9bb 100644
--- a/sound/soc/codecs/sn95031.h
+++ b/sound/soc/codecs/sn95031.h
@@ -96,4 +96,14 @@
#define SN95031_SSR5 0x384
#define SN95031_SSR6 0x385
+#define SN95031_AUDIO_GPIO_CTRL 0x070
+struct mfld_jack_data {
+ int intr_id;
+ int micbias_vol;
+ struct snd_soc_jack *mfld_jack;
+};
+
+extern void sn95031_jack_detection(struct mfld_jack_data *jack_data);
+
+extern void disable_jack_btn(struct snd_soc_codec *codec);
#endif
--
1.7.2.3
next prev parent reply other threads:[~2011-02-09 9:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-09 9:12 [PATCH 0/3] add support for jack detection in mid-x86 Koul, Vinod
2011-02-09 9:12 ` Koul, Vinod [this message]
2011-02-09 12:11 ` [PATCH 1/3] ASoC: sn95031: Add jack support in the codec Mark Brown
2011-02-09 13:06 ` Koul, Vinod
2011-02-09 13:07 ` Mark Brown
2011-02-09 9:12 ` [PATCH 2/3] ASoC: mfld_machine: Add support for jack detection Koul, Vinod
2011-02-09 13:55 ` Mark Brown
2011-02-09 14:38 ` Koul, Vinod
2011-02-09 14:39 ` Mark Brown
2011-02-09 14:53 ` Koul, Vinod
2011-02-09 9:12 ` [PATCH 3/3] ASoC: sn95031: Add support for reading mic bias Koul, Vinod
2011-02-09 15:06 ` Mark Brown
2011-02-09 15:09 ` Koul, Vinod
-- strict thread matches above, loose matches on Subject: below --
2011-02-09 16:14 [PATCH 0/3] add support for jack detection in mid-x86 Koul, Vinod
2011-02-09 16:14 ` [PATCH 1/3] ASoC: sn95031: Add jack support in the codec Koul, Vinod
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=1297242747-18632-2-git-send-email-vinod.koul@intel.com \
--to=vinod.koul@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lrg@slimlogic.co.uk \
--cc=priya.harsha@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).