Message ID | 20221214123743.3713843-4-lukma@denx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp195683wrn; Wed, 14 Dec 2022 04:46:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf7T+1fsfV+7QwWBdmntBbjkCEo2GhYDEVCpbM1Od9cFkQeTFagxdxL3b7AsoJdMu6n4nB76 X-Received: by 2002:a05:6a20:d398:b0:af:70f0:8a74 with SMTP id iq24-20020a056a20d39800b000af70f08a74mr2234373pzb.36.1671022019587; Wed, 14 Dec 2022 04:46:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671022019; cv=none; d=google.com; s=arc-20160816; b=vvujggAnaSGqsyix7BpLmpZyjYXNQUQJM3T4/gQuVMk0RL1MG3GCC3GEECuUpMtmyH /KtD6JgbL3yz9LwqvC/Mgg1me38UORpzU0bk2oT/Mwikxkau+/ekj+zyvGFfxNi+w5kX jURNiSOjyeJ8OVHQjo07cTs9hzouzrGDesewdKkcvopiLfh7RJi1Rm5Y67be33gspS08 aMOR/AGXFrFACyM1lCxSVd/7V4NI6bwcv9IT7sRZA3zRJuHc5HiAV0/brsTkuskhg6UX UhawkvzilpvGhTu3+7Mtd8bezBBuGJa4MEdEjR8Z+mUt4cGyyiXv/uv9hxLsgma+WcHX 5gGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Jupxi3YTw8zb2A9Zvbmvr72UlqBukNaZRCAsj7GqjU=; b=oyr7mag+gy/eLK0/B89PcGmkdrcBtTysF4eZt+meK6QJDeIVVeI64+0vDDIo8Vr08B dYDWrLUIp/lX3ZX5iHvA4SbXczL+VYmgiOesxhhAoWQc2BoMYeCzXXiUWBLpv4spLAp4 ZX0fxpF6gWcx04nsb67bgSTK1CpBnOlu2yPNnhoZigNBCrxE4lITl6H8MpQuVE33nV5T PJz7JQQCFJWWRRSgDixBhNBQiLjWAlKdlPvIDnuBtJCuGHXWuVXq3f62JdMtAXM5+X/u 8htDWIHcwVzEbkkYr7huxAqBLuubVJgLxnO6CeGJv5Qk9BxKPK1JYXW+STtUPU9JxpL2 QNmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=o5UgHlc7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 196-20020a6306cd000000b004705618bd69si15801419pgg.343.2022.12.14.04.46.44; Wed, 14 Dec 2022 04:46:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=o5UgHlc7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237962AbiLNMjz (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Wed, 14 Dec 2022 07:39:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238283AbiLNMj0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 14 Dec 2022 07:39:26 -0500 Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F8CB21E00 for <linux-kernel@vger.kernel.org>; Wed, 14 Dec 2022 04:38:08 -0800 (PST) Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 28B5E85165; Wed, 14 Dec 2022 13:38:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1671021486; bh=6Jupxi3YTw8zb2A9Zvbmvr72UlqBukNaZRCAsj7GqjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5UgHlc7BdfCg9o2XR7gT44W6Ksgs3OtjVtv8ynu0m10B2QzPRU+PC/kEWRkvFPfP acl5roqWq/GsUSGan5B3XwKx/OYt2Pt7chpee0qctOneZIh2EKdT+8t3H0H3cIIbfj 25DbmW865Sa3PAJ0S+ZrifUDk0UBtKfpQpMuY6+Dw277FYYfsYVpyqohBIR2f9CNsY MGUkEtxm5m/RVsyl4t9dyespT3Zmwpcur3weMXvUgq9H6DbcZs0hwVb/zKcYtK+WdD JEob0lISivpColvXh/iz+g3tB/r/AOcxp82bZgDE+fL9AJQsqO0bQe6xNT3fMlgCd1 p0QRaC44qiFAA== 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 Message-Id: <20221214123743.3713843-4-lukma@denx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221214123743.3713843-1-lukma@denx.de> References: <20221214123743.3713843-1-lukma@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752193584769020115?= X-GMAIL-MSGID: =?utf-8?q?1752193584769020115?= |
Series |
ASoC: Fixes for WM8940 codec
|
|
Commit Message
Lukasz Majewski
Dec. 14, 2022, 12:37 p.m. UTC
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(-)
Comments
On Wed, Dec 14, 2022 at 01:37:42PM +0100, Lukasz Majewski wrote: > 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> > --- > + 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; This bit is also controlled by the "Speaker Playback Switch" so you probably need some locking between them to stop them clobbering each other. Thanks, Charles
On Wed, Dec 14, 2022 at 01:37:42PM +0100, Lukasz Majewski wrote: > 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. > @@ -465,9 +465,18 @@ static int wm8940_mute(struct snd_soc_dai *dai, int mute, int direction) > { > + 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); In addition to the issue Charles raised this is simply not what the mute callback should do, the mute callback should specifically mute the digital input (with the goal of masking any glitching on there while clocks are started/stopped). Looking at the driver the device supports analogue bypass paths to the speaker - these will be broken by your patch so if you genuinely need some workaround in this area I'd be looking at the Speaker Mixer PCM Playback Switch rather than muting the speaker as a whole. If the device just can't cope without an input then ignore_mdown_time might be what you're looking for, it looks like the device doesn't have any lengthy sleeps in the power up/down paths so that should be fine so long as it doesn't pop/click. I'd also check there's not some other system configuration issue here which is more obvious when the input from the DAC stops getting input, check that you don't see similar issues when silence is played for example. It might be worth checking that none of the analogue bypass paths are enabled.
Hi Mark, > On Wed, Dec 14, 2022 at 01:37:42PM +0100, Lukasz Majewski wrote: > > 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. > > > @@ -465,9 +465,18 @@ static int wm8940_mute(struct snd_soc_dai > > *dai, int mute, int direction) { > > > + 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); > > In addition to the issue Charles raised this is simply not what the > mute callback should do, the mute callback should specifically mute > the digital input (with the goal of masking any glitching on there > while clocks are started/stopped). Ok > Looking at the driver the device > supports analogue bypass paths to the speaker - these will be broken > by your patch I was not aware about this side effect. I just wanted to be sure that the speaker is muted. > so if you genuinely need some workaround in this area > I'd be looking at the Speaker Mixer PCM Playback Switch rather than > muting the speaker as a whole. I would be more than happy if I could use for example the 'amixer' command to setup the audio correctly without this patch. For example - on this system - before I run any speaker test I need to call: amixer -d set 'Speaker Mixer PCM',0 on to unmute the system. > If the device just can't cope without > an input then ignore_mdown_time might be what you're looking for, it > looks like the device doesn't have any lengthy sleeps in the power > up/down paths so that should be fine so long as it doesn't pop/click. > Ok. I will check this as well. > I'd also check there's not some other system configuration issue here > which is more obvious when the input from the DAC stops getting input, > check that you don't see similar issues when silence is played for > example. It might be worth checking that none of the analogue bypass > paths are enabled. Thanks for your hints. I will investigate it further. It looks like this patch is some kind of a hack, to fix my system configuration and shall be dropped in v2. Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Hi Mark, > Hi Mark, > > > On Wed, Dec 14, 2022 at 01:37:42PM +0100, Lukasz Majewski wrote: > > > 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. > > > > > @@ -465,9 +465,18 @@ static int wm8940_mute(struct snd_soc_dai > > > *dai, int mute, int direction) { > > > > > + 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); > > > > In addition to the issue Charles raised this is simply not what the > > mute callback should do, the mute callback should specifically mute > > the digital input (with the goal of masking any glitching on there > > while clocks are started/stopped). > > Ok > > > Looking at the driver the device > > supports analogue bypass paths to the speaker - these will be broken > > by your patch > > I was not aware about this side effect. I just wanted to be sure that > the speaker is muted. > > > so if you genuinely need some workaround in this area > > I'd be looking at the Speaker Mixer PCM Playback Switch rather than > > muting the speaker as a whole. > > I would be more than happy if I could use for example the 'amixer' > command to setup the audio correctly without this patch. > > For example - on this system - before I run any speaker test I need to > call: amixer -d set 'Speaker Mixer PCM',0 on > > to unmute the system. > This patch steamed from 4.4 Linux. On the newer Linux version the "distortion" problem is not present anymore. I will drop this patch. > > If the device just can't cope without > > an input then ignore_mdown_time might be what you're looking for, it > > looks like the device doesn't have any lengthy sleeps in the power > > up/down paths so that should be fine so long as it doesn't > > pop/click. > > Ok. I will check this as well. > > > I'd also check there's not some other system configuration issue > > here which is more obvious when the input from the DAC stops > > getting input, check that you don't see similar issues when silence > > is played for example. It might be worth checking that none of the > > analogue bypass paths are enabled. > > Thanks for your hints. I will investigate it further. > > It looks like this patch is some kind of a hack, to fix my system > configuration and shall be dropped in v2. > > > Best regards, > > Lukasz Majewski > > -- > > DENX Software Engineering GmbH, Managing Director: Wolfgang Denk > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: > lukma@denx.de Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
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 */