From patchwork Mon Jun 6 15:44:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 12870605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AF09C43334 for ; Mon, 6 Jun 2022 15:46:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EBFFE192C; Mon, 6 Jun 2022 17:45:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EBFFE192C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654530366; bh=nXIf4LCHcs+ke0Z4yb3lxqEx9Iiwj8A274WRvZbmJQc=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=V6EMW6Pg8iatuMkzh5Ug9ejJ0B9zmXu73yQGvszvokV1HswTRNIQ5dXorJt90ViD7 Y+BhoUwURkDSl4W83rMv47FQENuccBBox5WMsCv5mkZENyPvizneWl8Wg6qJ4V1koZ +PFD2lgwGI6UwHnRfIHcUvTV6P4+VBM585BOMYqI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8BC89F801D8; Mon, 6 Jun 2022 17:45:15 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2E28BF80423; Mon, 6 Jun 2022 17:45:14 +0200 (CEST) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 011A6F80116 for ; Mon, 6 Jun 2022 17:45:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 011A6F80116 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="EldHzQj9" 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 8D66D83AF6; Mon, 6 Jun 2022 17:45:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1654530306; bh=AqZOOnLJGuceB2TSU+9Eh0CvtWhy1P7vm+Mht3l7hBE=; h=From:To:Cc:Subject:Date:From; b=EldHzQj9W37KS4B3Zp8Zck7vsRweKlwHZBqX5t6x/0i2aE2k/IrYCAjxSSBNUMM5N IowMxYrBgfQKidisX14n1e1fCmxLgt7gHyvnBmnUvnkOhREPgIzRDGNuQ0XT+plVim O6MctON9jXkVi+OZHzO1QWsoIk1DkD4ysCKE+rpmT2Gf0ZtZvybaJDdy2VWAsWkApa Un388u3mEJ3tosql9AdazMmCw0m4h5zGnfc6lRcXM24aDW6HRmwRk91zGfnw6npLrX oqzto8tBGKVGnLy22ZFLkfqId62VHwf1ZrYwTm7Tx8ylYwdJ02yvZ50F4SKEYgCZxz AUPC+XXFb9nxg== From: Lukasz Majewski To: Liam Girdwood , Mark Brown Subject: [PATCH 1/3] ASoC: wm8940: Remove warning when no plat data Date: Mon, 6 Jun 2022 17:44:39 +0200 Message-Id: <20220606154441.20848-1-lukma@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, Takashi Iwai , linux-kernel@vger.kernel.org, Lukasz Majewski X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The lack of platform data in the contemporary Linux shall not be the reason to display warnings to the kernel logs. Signed-off-by: Lukasz Majewski --- sound/soc/codecs/wm8940.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index 440d048ef0c0..7cea54720436 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c @@ -709,9 +709,7 @@ static int wm8940_probe(struct snd_soc_component *component) if (ret < 0) return ret; - if (!pdata) - dev_warn(component->dev, "No platform data supplied\n"); - else { + if (pdata) { reg = snd_soc_component_read(component, WM8940_OUTPUTCTL); ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, reg | pdata->vroi); if (ret < 0) From patchwork Mon Jun 6 15:44:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 12870606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4650BCCA481 for ; Mon, 6 Jun 2022 15:46:39 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F2DD9193B; Mon, 6 Jun 2022 17:45:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F2DD9193B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654530398; bh=emM97RIbJK3ajVtkIo6Mfs7B4LWQZ3MZQTGY7H01aF4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LOwDN5Gge6oe1rpWMTmKfewUirqkoG4G8Ona8kGOrQVvPKI7ynsK8jRVKcBtjOmar ttMGVrbhmmTKMdpo3/vAZbMtm53xttRQM6kLAt2k9HPzTrWS7vcpSFVygyi8NA6zFp yIQEBaHKVcRMLY+kJ/Nw7ZRE7xjTpTsBho+ajZJo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2432FF8047C; Mon, 6 Jun 2022 17:45:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 29AC0F80116; Mon, 6 Jun 2022 17:45:15 +0200 (CEST) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id EA272F8012A for ; Mon, 6 Jun 2022 17:45:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EA272F8012A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="ztmcKReT" 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 F062D83C61; Mon, 6 Jun 2022 17:45:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1654530307; bh=7pWtef+oRH7wX2wP+LnlDhlscbgmm4pckw9tnmWgA/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ztmcKReTk1GHbhPwGROPTnYONvPzyAVj7shSwSG9nizeal+BC8hsEWnrxxQHCST7h btBJzK06PSfYqpta+LNbFKSEpuMpBFmg90OdTjh7kMw6tXa3yuqOxab/HO8tu+6Rom LlHUy9iK7AjlXBD4sRKJuy55AeIhkywDomdIo7zeKufYeQC1WnkNr/UEsT++fGUZoC 1srU9FNACafHtiH9afs6YEZf0rA/jYpRFc4Ai+bnP9b4MzaOcWBNbmIwSF6fbcNSSp lKQNCUOhnvasZHi+RQMFxK8YgwMZwMU4vTm0S6kglp0cYFxokmSyo8wezsUBdqYq9V IHJqIcuRHAVFg== From: Lukasz Majewski To: Liam Girdwood , Mark Brown Subject: [PATCH 2/3] ASoC: wm8940: Rewrite code to set proper clocks Date: Mon, 6 Jun 2022 17:44:40 +0200 Message-Id: <20220606154441.20848-2-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220606154441.20848-1-lukma@denx.de> References: <20220606154441.20848-1-lukma@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, Takashi Iwai , linux-kernel@vger.kernel.org, Lukasz Majewski X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Without this change, the wm8940 driver is not working when set_sysclk callback (wm8940_set_dai_sysclk) is called with freqency not listed in the switch clause. This change adjusts this driver to allow non-standard frequency set (just after the boot) being adjusted afterwards by the sound system core code. Moreover, support for internal wm8940's PLL is provided, so it can generate clocks when HOST system is not able to do it. Code in this commit is based on previous change done for wm8974 (SHA1: 51b2bb3f2568e6d9d81a001d38b8d70c2ba4af99). Signed-off-by: Lukasz Majewski --- sound/soc/codecs/wm8940.c | 103 ++++++++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index 7cea54720436..6fb1c3780439 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c @@ -37,7 +37,9 @@ #include "wm8940.h" struct wm8940_priv { - unsigned int sysclk; + unsigned int mclk; + unsigned int fs; + struct regmap *regmap; }; @@ -387,17 +389,24 @@ static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, return 0; } +static int wm8940_update_clocks(struct snd_soc_dai *dai); static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; + struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component); u16 iface = snd_soc_component_read(component, WM8940_IFACE) & 0xFD9F; u16 addcntrl = snd_soc_component_read(component, WM8940_ADDCNTRL) & 0xFFF1; u16 companding = snd_soc_component_read(component, WM8940_COMPANDINGCTL) & 0xFFDF; int ret; + wm8940->fs = params_rate(params); + ret = wm8940_update_clocks(dai); + if (ret) + return ret; + /* LoutR control */ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && params_channels(params) == 2) @@ -496,7 +505,6 @@ static int wm8940_set_bias_level(struct snd_soc_component *component, return ret; } } - /* ensure bufioen and biasen */ pwr_reg |= (1 << 2) | (1 << 3); /* set vmid to 300k for standby */ @@ -611,24 +619,6 @@ static int wm8940_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, return 0; } -static int wm8940_set_dai_sysclk(struct snd_soc_dai *codec_dai, - int clk_id, unsigned int freq, int dir) -{ - struct snd_soc_component *component = codec_dai->component; - struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component); - - switch (freq) { - case 11289600: - case 12000000: - case 12288000: - case 16934400: - case 18432000: - wm8940->sysclk = freq; - return 0; - } - return -EINVAL; -} - static int wm8940_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { @@ -653,6 +643,79 @@ static int wm8940_set_dai_clkdiv(struct snd_soc_dai *codec_dai, return ret; } +static unsigned int wm8940_get_mclkdiv(unsigned int f_in, unsigned int f_out, + int *mclkdiv) +{ + unsigned int ratio = 2 * f_in / f_out; + + if (ratio <= 2) { + *mclkdiv = WM8940_MCLKDIV_1; + ratio = 2; + } else if (ratio == 3) { + *mclkdiv = WM8940_MCLKDIV_1_5; + } else if (ratio == 4) { + *mclkdiv = WM8940_MCLKDIV_2; + } else if (ratio <= 6) { + *mclkdiv = WM8940_MCLKDIV_3; + ratio = 6; + } else if (ratio <= 8) { + *mclkdiv = WM8940_MCLKDIV_4; + ratio = 8; + } else if (ratio <= 12) { + *mclkdiv = WM8940_MCLKDIV_6; + ratio = 12; + } else if (ratio <= 16) { + *mclkdiv = WM8940_MCLKDIV_8; + ratio = 16; + } else { + *mclkdiv = WM8940_MCLKDIV_12; + ratio = 24; + } + + return f_out * ratio / 2; +} + +static int wm8940_update_clocks(struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct wm8940_priv *priv = snd_soc_component_get_drvdata(component); + unsigned int fs256; + unsigned int fpll = 0; + unsigned int f; + int mclkdiv; + + if (!priv->mclk || !priv->fs) + return 0; + + fs256 = 256 * priv->fs; + + f = wm8940_get_mclkdiv(priv->mclk, fs256, &mclkdiv); + if (f != priv->mclk) { + /* The PLL performs best around 90MHz */ + fpll = wm8940_get_mclkdiv(22500000, fs256, &mclkdiv); + } + + wm8940_set_dai_pll(dai, 0, 0, priv->mclk, fpll); + wm8940_set_dai_clkdiv(dai, WM8940_MCLKDIV, mclkdiv); + + return 0; +} + +static int wm8940_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, + unsigned int freq, int dir) +{ + struct snd_soc_component *component = dai->component; + struct wm8940_priv *priv = snd_soc_component_get_drvdata(component); + + if (dir != SND_SOC_CLOCK_IN) + return -EINVAL; + + priv->mclk = freq; + + return wm8940_update_clocks(dai); +} + + #define WM8940_RATES SNDRV_PCM_RATE_8000_48000 #define WM8940_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ From patchwork Mon Jun 6 15:44:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 12870607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 733E1C43334 for ; Mon, 6 Jun 2022 15:46:59 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9AAB71929; Mon, 6 Jun 2022 17:46:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9AAB71929 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654530417; bh=sKiycYafCwzwC+ZAsMjg8r2MgfWUm6i27frJzx9wJjM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EITjDcTDUnDnpplAqWyrdjNDZHqkCiesrcVTMk0Kq5BR1rF8/kWhYYX2eYnQGq/RG UGpJRhrh8OccqjMmT+8uOdBJWexj/MrG0B5nr+c46bx5fGOnZYcul3+eWOqy+ov31h lt3W8s/wOiYHfEvfVZmYhJKiJJPdPy39Timf/a9I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AC44EF80520; Mon, 6 Jun 2022 17:45:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 430C9F80526; Mon, 6 Jun 2022 17:45:19 +0200 (CEST) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 21AF7F80109 for ; Mon, 6 Jun 2022 17:45:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 21AF7F80109 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="jpndVbWR" 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 4789D83E63; Mon, 6 Jun 2022 17:45:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1654530307; bh=KHCCpJWpvoD0Y/WD41sZEKMPbIOi11fqmo/ZGOG53OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jpndVbWRhRsEaeapXjcuWY7rbEo8LJdxnGbFRFrBB8x3+IO0K2f/V8Y8kq3HtXO0K O8BCQSFbOcUrAChV0FKNoQKCHRhwYBVokwpT2Z0i2pgy305iIDb6szG2XkpO9EzR6B dI9MzJp3HQ0BDTVi1IZUdDbcm9qQOnVUAr5yJ++GcwBz9LU9/OMpJPxUgBoO5HpdQ/ fXnC6gj683X3Qd8VHonzVmqqgExOVUukvxv29H48fdhdyFgweYNjIVe5y6iHrofVQZ ser+7OOq2kJh8l6xEWe1P1Hc/m5GWY05yzA9rUdUAqyysCfbsAXV4Sdv5Zz444EYeo wrer/YmJNihig== From: Lukasz Majewski To: Liam Girdwood , Mark Brown Subject: [PATCH 3/3] ASoC: wm8940: Mute also the speaker output Date: Mon, 6 Jun 2022 17:44:41 +0200 Message-Id: <20220606154441.20848-3-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220606154441.20848-1-lukma@denx.de> References: <20220606154441.20848-1-lukma@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, Takashi Iwai , linux-kernel@vger.kernel.org, Lukasz Majewski X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- 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 6fb1c3780439..a8596f4089dd 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 */