Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mark Brown <broonie@kernel.org>, Bard Liao <bardliao@realtek.com>,
	Oder Chiou <oder_chiou@realtek.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.com>
Subject: [PATCH 2/6] ASoC: rt5645: add micbias power control select.
Date: Tue,  2 Jan 2018 19:53:10 +0100	[thread overview]
Message-ID: <20180102185314.17189-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20180102185314.17189-1-hdegoede@redhat.com>

From: Bard Liao <bardliao@realtek.com>

We need to set a corresponding control bit before powering micbias up.

Signed-off-by: Bard Liao <bardliao@realtek.com>
[hdegoede@redhat.com: Remove 2 unused variable declarations]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 sound/soc/codecs/rt5645.c | 56 +++++++++++++++++++++++++++++++++++++++++++++--
 sound/soc/codecs/rt5645.h |  6 +++++
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index b69c57709d8b..2e495d61b55e 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -1943,6 +1943,56 @@ static int rt5650_hp_event(struct snd_soc_dapm_widget *w,
 	return 0;
 }
 
+static int rt5645_set_micbias1_event(struct snd_soc_dapm_widget *w,
+		struct snd_kcontrol *k, int  event)
+{
+	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		snd_soc_update_bits(codec, RT5645_GEN_CTRL2,
+			RT5645_MICBIAS1_POW_CTRL_SEL_MASK,
+			RT5645_MICBIAS1_POW_CTRL_SEL_M);
+		break;
+
+	case SND_SOC_DAPM_POST_PMD:
+		snd_soc_update_bits(codec, RT5645_GEN_CTRL2,
+			RT5645_MICBIAS1_POW_CTRL_SEL_MASK,
+			RT5645_MICBIAS1_POW_CTRL_SEL_A);
+		break;
+
+	default:
+		return 0;
+	}
+
+	return 0;
+}
+
+static int rt5645_set_micbias2_event(struct snd_soc_dapm_widget *w,
+		struct snd_kcontrol *k, int  event)
+{
+	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		snd_soc_update_bits(codec, RT5645_GEN_CTRL2,
+			RT5645_MICBIAS2_POW_CTRL_SEL_MASK,
+			RT5645_MICBIAS2_POW_CTRL_SEL_M);
+		break;
+
+	case SND_SOC_DAPM_POST_PMD:
+		snd_soc_update_bits(codec, RT5645_GEN_CTRL2,
+			RT5645_MICBIAS2_POW_CTRL_SEL_MASK,
+			RT5645_MICBIAS2_POW_CTRL_SEL_A);
+		break;
+
+	default:
+		return 0;
+	}
+
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
 	SND_SOC_DAPM_SUPPLY("LDO2", RT5645_PWR_MIXER,
 		RT5645_PWR_LDO2_BIT, 0, NULL, 0),
@@ -1981,9 +2031,11 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
 	/* Input Side */
 	/* micbias */
 	SND_SOC_DAPM_SUPPLY("micbias1", RT5645_PWR_ANLG2,
-			RT5645_PWR_MB1_BIT, 0, NULL, 0),
+			RT5645_PWR_MB1_BIT, 0, rt5645_set_micbias1_event,
+			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
 	SND_SOC_DAPM_SUPPLY("micbias2", RT5645_PWR_ANLG2,
-			RT5645_PWR_MB2_BIT, 0, NULL, 0),
+			RT5645_PWR_MB2_BIT, 0, rt5645_set_micbias2_event,
+			SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
 	/* Input Lines */
 	SND_SOC_DAPM_INPUT("DMIC L1"),
 	SND_SOC_DAPM_INPUT("DMIC R1"),
diff --git a/sound/soc/codecs/rt5645.h b/sound/soc/codecs/rt5645.h
index cfc5f97549eb..940325b28c29 100644
--- a/sound/soc/codecs/rt5645.h
+++ b/sound/soc/codecs/rt5645.h
@@ -2117,6 +2117,12 @@ enum {
 #define RT5645_RXDC_SRC_STO			(0x0 << 7)
 #define RT5645_RXDC_SRC_MONO			(0x1 << 7)
 #define RT5645_RXDC_SRC_SFT			(7)
+#define RT5645_MICBIAS1_POW_CTRL_SEL_MASK	(0x1 << 5)
+#define RT5645_MICBIAS1_POW_CTRL_SEL_A		(0x0 << 5)
+#define RT5645_MICBIAS1_POW_CTRL_SEL_M		(0x1 << 5)
+#define RT5645_MICBIAS2_POW_CTRL_SEL_MASK	(0x1 << 4)
+#define RT5645_MICBIAS2_POW_CTRL_SEL_A		(0x0 << 4)
+#define RT5645_MICBIAS2_POW_CTRL_SEL_M		(0x1 << 4)
 #define RT5645_RXDP2_SEL_MASK			(0x1 << 3)
 #define RT5645_RXDP2_SEL_IF2			(0x0 << 3)
 #define RT5645_RXDP2_SEL_ADC			(0x1 << 3)
-- 
2.14.3

  parent reply	other threads:[~2018-01-02 18:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-02 18:53 [PATCH 0/6] ASoC: rt5645: Analog microphone fixes Hans de Goede
2018-01-02 18:53 ` [PATCH 1/6] ASoC: rt5645: change micbias widget type to supply Hans de Goede
2018-01-03 10:50   ` Mark Brown
2018-01-03 11:01     ` Hans de Goede
2018-01-03 11:28       ` Mark Brown
2018-01-03 11:32         ` Hans de Goede
2018-01-03 11:36           ` Mark Brown
2018-01-03 12:45     ` Bard Liao
     [not found]     ` <ABFD875FF5FB574BA706497D987D48D702756F3C@RTITMBSV02.realtek.com.tw>
2018-01-04 10:53       ` Mark Brown
     [not found]         ` <ABFD875FF5FB574BA706497D987D48D7027574B8@RTITMBSV02.realtek.com.tw>
2018-01-04 12:01           ` Mark Brown
     [not found]             ` <ABFD875FF5FB574BA706497D987D48D702757599@RTITMBSV02.realtek.com.tw>
2018-01-04 12:41               ` Mark Brown
2018-01-02 18:53 ` Hans de Goede [this message]
2018-01-04 12:37   ` Applied "ASoC: rt5645: add micbias power control select." to the asoc tree Mark Brown
2018-01-02 18:53 ` [PATCH 3/6] ASoC: rt5645: set in2_diff flag for GPD win and pocket devices Hans de Goede
2018-01-03 12:13   ` Applied "ASoC: rt5645: set in2_diff flag for GPD win and pocket devices" to the asoc tree Mark Brown
2018-01-02 18:53 ` [PATCH 4/6] ASoC: rt5645: cleanup DMI matching code Hans de Goede
2018-01-03 12:12   ` Applied "ASoC: rt5645: cleanup DMI matching code" to the asoc tree Mark Brown
2018-01-02 18:53 ` [PATCH 5/6] ASoC: rt5645: add platform data for the Teclast X80 Pro tablet Hans de Goede
2018-01-03 12:12   ` Applied "ASoC: rt5645: add platform data for the Teclast X80 Pro tablet" to the asoc tree Mark Brown
2018-01-02 18:53 ` [PATCH 6/6] ASoC: Intel: cht_bsw_rt5645: Analog Mic support Hans de Goede
2018-01-03 12:12   ` Applied "ASoC: Intel: cht_bsw_rt5645: Analog Mic support" to the asoc tree Mark Brown
2018-01-02 18:56 ` [PATCH 0/6] ASoC: rt5645: Analog microphone fixes Hans de Goede

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=20180102185314.17189-3-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bardliao@realtek.com \
    --cc=broonie@kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=tiwai@suse.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