The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Vincent Knecht <vincent.knecht@mailoo.org>
To: stephan@gerhold.net, lgirdwood@gmail.com, broonie@kernel.org,
	robh+dt@kernel.org, perex@perex.cz, tiwai@suse.com
Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht,
	Vincent Knecht <vincent.knecht@mailoo.org>
Subject: [PATCH v1 1/4] ASoC: codecs: tfa989x: Add switch to allow disabling amplifier
Date: Sun, 24 Oct 2021 10:58:37 +0200	[thread overview]
Message-ID: <20211024085840.1536438-2-vincent.knecht@mailoo.org> (raw)
In-Reply-To: <20211024085840.1536438-1-vincent.knecht@mailoo.org>

From: Stephan Gerhold <stephan@gerhold.net>

In some configurations it may be necessary to explicitly disable
the amplifier with an ALSA mixer. An example for this is a stereo
setup with two TFA989X. If only one of them should be used (e.g.
to use it as an earpiece) the other one must be explicitly disabled.

Add a virtual "Amp Switch" to implement that. There is no register
for this (SND_SOC_NOPM) so it only prevents DAPM from activating
the amplifier. Also it is inverted (= enabled by default) for
compatibility with devices that do not need this functionality.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
---
 sound/soc/codecs/tfa989x.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c
index 643b45188b6f..1ae47d4f1ca7 100644
--- a/sound/soc/codecs/tfa989x.c
+++ b/sound/soc/codecs/tfa989x.c
@@ -77,13 +77,16 @@ static const struct regmap_config tfa989x_regmap = {
 
 static const char * const chsa_text[] = { "Left", "Right", /* "DSP" */ };
 static SOC_ENUM_SINGLE_DECL(chsa_enum, TFA989X_I2SREG, TFA989X_I2SREG_CHSA, chsa_text);
-static const struct snd_kcontrol_new chsa_mux = SOC_DAPM_ENUM("Amp Input", chsa_enum);
+static const struct snd_kcontrol_new
+	chsa_mux = SOC_DAPM_ENUM("Amp Input", chsa_enum),
+	amp_switch = SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 1);
 
 static const struct snd_soc_dapm_widget tfa989x_dapm_widgets[] = {
 	SND_SOC_DAPM_OUTPUT("OUT"),
 	SND_SOC_DAPM_SUPPLY("POWER", TFA989X_SYS_CTRL, TFA989X_SYS_CTRL_PWDN, 1, NULL, 0),
 	SND_SOC_DAPM_OUT_DRV("AMPE", TFA989X_SYS_CTRL, TFA989X_SYS_CTRL_AMPE, 0, NULL, 0),
 
+	SND_SOC_DAPM_SWITCH("Amp", SND_SOC_NOPM, 0, 0, &amp_switch),
 	SND_SOC_DAPM_MUX("Amp Input", SND_SOC_NOPM, 0, 0, &chsa_mux),
 	SND_SOC_DAPM_AIF_IN("AIFINL", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
 	SND_SOC_DAPM_AIF_IN("AIFINR", "HiFi Playback", 1, SND_SOC_NOPM, 0, 0),
@@ -92,7 +95,8 @@ static const struct snd_soc_dapm_widget tfa989x_dapm_widgets[] = {
 static const struct snd_soc_dapm_route tfa989x_dapm_routes[] = {
 	{"OUT", NULL, "AMPE"},
 	{"AMPE", NULL, "POWER"},
-	{"AMPE", NULL, "Amp Input"},
+	{"AMPE", NULL, "Amp"},
+	{"Amp", "Switch", "Amp Input"},
 	{"Amp Input", "Left", "AIFINL"},
 	{"Amp Input", "Right", "AIFINR"},
 };
-- 
2.31.1




  reply	other threads:[~2021-10-24  9:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-24  8:58 [PATCH v1 0/4] Add tfa9897 speaker/receiver modes switching Vincent Knecht
2021-10-24  8:58 ` Vincent Knecht [this message]
2021-10-25 10:52   ` [PATCH v1 1/4] ASoC: codecs: tfa989x: Add switch to allow disabling amplifier Mark Brown
2021-10-28  7:22     ` Stephan Gerhold
2021-10-24  8:58 ` [PATCH v1 2/4] ASoC: codecs: tfa989x: Add support for tfa9897 RCV bit Vincent Knecht
2021-10-24  8:58 ` [PATCH v1 3/4] ASoC: dt-bindings: nxp, tfa989x: Add rcv-gpios property for tfa9897 Vincent Knecht
2021-10-29  2:13   ` Rob Herring
2021-10-31  9:35     ` Vincent Knecht
2021-10-24  8:58 ` [PATCH v1 4/4] ASoC: codecs: tfa989x: Add support for tfa9897 optional rcv-gpios Vincent Knecht
2021-10-29 15:20 ` (subset) [PATCH v1 0/4] Add tfa9897 speaker/receiver modes switching 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=20211024085840.1536438-2-vincent.knecht@mailoo.org \
    --to=vincent.knecht@mailoo.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=stephan@gerhold.net \
    --cc=tiwai@suse.com \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /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