public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Charles Keepax <ckeepax@opensource.cirrus.com>,
	Stephen Kitt <steve@sk2.org>
Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org, Lukasz Majewski <lukma@denx.de>
Subject: [PATCH 3/4] ASoC: wm8940: Mute also the speaker output
Date: Wed, 14 Dec 2022 13:37:42 +0100	[thread overview]
Message-ID: <20221214123743.3713843-4-lukma@denx.de> (raw)
In-Reply-To: <20221214123743.3713843-1-lukma@denx.de>

Without this change the BTL speaker produces some
"distortion" noise when test program
(speaker-test -t waw) is ended with ctrl+c.

As our design uses speaker outputs to drive BTL speaker,
it was necessary to also mute the speaker via the codec
internal WM8940_SPKVOL register with setting
WM8940_SPKMUTE bit.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
 sound/soc/codecs/wm8940.c | 11 ++++++++++-
 sound/soc/codecs/wm8940.h |  3 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c
index 094e74905df9..13cb57210b4b 100644
--- a/sound/soc/codecs/wm8940.c
+++ b/sound/soc/codecs/wm8940.c
@@ -465,9 +465,18 @@ static int wm8940_mute(struct snd_soc_dai *dai, int mute, int direction)
 {
 	struct snd_soc_component *component = dai->component;
 	u16 mute_reg = snd_soc_component_read(component, WM8940_DAC) & 0xffbf;
+	u16 spkvol_reg = snd_soc_component_read(component, WM8940_SPKVOL);
+	int ret;
 
-	if (mute)
+	spkvol_reg &= ~WM8940_SPKMUTE;
+	if (mute) {
 		mute_reg |= 0x40;
+		spkvol_reg |= WM8940_SPKMUTE;
+	}
+
+	ret = snd_soc_component_write(component, WM8940_SPKVOL, spkvol_reg);
+	if (ret)
+		return ret;
 
 	return snd_soc_component_write(component, WM8940_DAC, mute_reg);
 }
diff --git a/sound/soc/codecs/wm8940.h b/sound/soc/codecs/wm8940.h
index 0d4f53ada2e6..eb051ed29bb8 100644
--- a/sound/soc/codecs/wm8940.h
+++ b/sound/soc/codecs/wm8940.h
@@ -95,5 +95,8 @@ struct wm8940_setup_data {
 #define WM8940_OPCLKDIV_3 2
 #define WM8940_OPCLKDIV_4 3
 
+/* Bit definitions */
+#define WM8940_SPKMUTE BIT(6)
+
 #endif /* _WM8940_H */
 
-- 
2.20.1


  parent reply	other threads:[~2022-12-14 12:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 12:37 [PATCH 0/4] ASoC: Fixes for WM8940 codec Lukasz Majewski
2022-12-14 12:37 ` [PATCH 1/4] ASoC: wm8940: Remove warning when no plat data present Lukasz Majewski
2022-12-14 13:10   ` Charles Keepax
2022-12-14 12:37 ` [PATCH 2/4] ASoC: wm8940: Rewrite code to set proper clocks Lukasz Majewski
2022-12-14 13:31   ` Charles Keepax
2022-12-14 21:01     ` Lukasz Majewski
2022-12-14 13:56   ` Mark Brown
2022-12-14 21:10     ` Lukasz Majewski
2022-12-14 12:37 ` Lukasz Majewski [this message]
2022-12-14 13:09   ` [PATCH 3/4] ASoC: wm8940: Mute also the speaker output Charles Keepax
2022-12-14 14:19   ` Mark Brown
2022-12-14 20:55     ` Lukasz Majewski
2022-12-15  8:53       ` Lukasz Majewski
2022-12-14 12:37 ` [PATCH 4/4] ASoC: wm8940: Read chip ID when wm8940 codec probing Lukasz Majewski
2022-12-14 13:10   ` Charles Keepax
2022-12-15  9:36 ` [PATCH v2 1/3] ASoC: wm8940: Remove warning when no plat data present Lukasz Majewski
2022-12-15  9:36   ` [PATCH v2 2/3] ASoC: wm8940: Rewrite code to set proper clocks Lukasz Majewski
2022-12-15 10:13     ` Charles Keepax
2022-12-15  9:36   ` [PATCH v2 3/3] ASoC: wm8940: Read chip ID when wm8940 codec probing Lukasz Majewski
2022-12-15 11:08   ` [PATCH v2 1/3] ASoC: wm8940: Remove warning when no plat data present Mark Brown
2022-12-15 13:59     ` Lukasz Majewski
2022-12-27 11:57 ` (subset) [PATCH 0/4] ASoC: Fixes for WM8940 codec Mark Brown
2022-12-27 11:57 ` 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=20221214123743.3713843-4-lukma@denx.de \
    --to=lukma@denx.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=steve@sk2.org \
    --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