From patchwork Thu Mar 22 02:13:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 132247 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp274861ljb; Wed, 21 Mar 2018 19:13:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELs6T1+NsR9C84UMFsa5cvgNONLPktgsdASEE4mWaIpV6YKaK6m6uN9WX7ykYg3ltRhYtp7W X-Received: by 10.223.149.129 with SMTP id p1mr17289754wrp.11.1521684830505; Wed, 21 Mar 2018 19:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521684830; cv=none; d=google.com; s=arc-20160816; b=Hp+AYjc5WjCsL0zVQuhJz5NnYXqM/j9mzEWaCW4FRa23/AElfG+jAOFrkYvCQIfFue RRuBCaTyTAl4KXoSJRTF6K0RvOM7O4B67+mnSJQHQLuivt51OPOZkq+r+fJdhh2aMBNn /buspmSUvU+PyfMVziHcHYhTrkvd7UtD804l5QyLzutwzscdiPsbUpcTD5JA9ssQT3op SmtjEF8vuVnRI7ecaw4dCf6dVxr3jrpp+kzOv+0HjD4PUaMAIaDk/+HhGJQ4NKY4Gnbo 4zU8yfKNpM79yBPQlPqSg1ypQ/vRTj9jGgNdD6TqeV8v0flJ9nTNGhzNtr7LpH7INvbE WpWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=4cgPVy8eQaBjkDR0PYNAwxPBDlK5Ya4s6W2aMZiHPo0=; b=LFqYHq1oQX+vXrPIW4mMYVfE/IYF4scCnyVHV5ZxiiE828GadQNapn7jZcqZ86nP9T GMoYjYuL9cp1ENmfy+R7wFQ6BmRTp7DBb1oRZ+ECE3tgmBkvebNYSbPfANgAEvq6RuUd kWstyYj0zqwMnFCibPmtcsF7/7aZpY7vehkh63CmEjH02iARWyp0eaW/Z7c55a3Dsxi8 kN+uEhMNQvlOEYVfX+uOs8Tnttjpw4OfaSR+oZo8rk4alggrwqNLouN11m3iW2YfD6df W3ZeOw3v2bKPBfSVc13MXbG+d5gNJ/1lzIf6XKG/eh1ldVwtu7qMuf6jYr9FPACTzU+Z Anxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=pbv46vn5; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id 71si4193033wrm.65.2018.03.21.19.13.50; Wed, 21 Mar 2018 19:13:50 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=pbv46vn5; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 410D6267396; Thu, 22 Mar 2018 03:13:49 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C334726739D; Thu, 22 Mar 2018 03:13:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id 56275267282 for ; Thu, 22 Mar 2018 03:13:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=uXMw4nskPgBJIOqFbgg3vSkHqjKbUuHuVFl1aZcZ84c=; b=pbv46vn5brve xAMEJSx1A15e8v9cG+WUsaNgJ7z41GbuIrhtF8xQ3RwkkBTnI0pBmcQVIEHorhP8WVCKal7G97oba DleJv81iRTRoCpzIlZO/y7a7fmL5g4v3RP5Wa14J7WE6GnhB9j2HnvWOCCuPkdL4pknxw/81Gstsn qIxZo=; Received: from [218.255.99.6] (helo=finisterre.ee.mobilebroadband) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eypjb-0002lR-K8; Thu, 22 Mar 2018 02:13:43 +0000 Received: by finisterre.ee.mobilebroadband (Postfix, from userid 1000) id 973D244007A; Thu, 22 Mar 2018 02:13:39 +0000 (GMT) From: Mark Brown To: John Hsu In-Reply-To: <1521605792-17360-1-git-send-email-KCHSU0@nuvoton.com> Message-Id: <20180322021339.973D244007A@finisterre.ee.mobilebroadband> Date: Thu, 22 Mar 2018 02:13:39 +0000 (GMT) Cc: alsa-devel@alsa-project.org, WTLI@nuvoton.com, lgirdwood@gmail.com, YHCHuang@nuvoton.com, broonie@kernel.org, CTLIN0@nuvoton.com Subject: [alsa-devel] Applied "ASoC: nau8824: recover system clock when device changes" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: nau8824: recover system clock when device changes has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From b53117c0b881d78d5d66a7e1be11d62a077c1e25 Mon Sep 17 00:00:00 2001 From: John Hsu Date: Wed, 21 Mar 2018 12:16:32 +0800 Subject: [PATCH] ASoC: nau8824: recover system clock when device changes User reports an issue in Ubuntu about the device switch upon playback. We find the FLL will disalbe when switching headphone to speaker. The pulseaudio will stop the headphone and close its power. Then, it just opens the speaker and turn on its power. Therefore, the supply of system clock does the OFF event and disables FLL. But the FLL doesn't enable again when the speaker powers on. The patch adds the recovery of system clock to enable FLL again for this case. And it covers the case that system clock from MCLK. Signed-off-by: John Hsu Signed-off-by: Mark Brown --- sound/soc/codecs/nau8824.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) -- 2.16.2 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c index 4d9148a6a080..637e9527805f 100644 --- a/sound/soc/codecs/nau8824.c +++ b/sound/soc/codecs/nau8824.c @@ -489,8 +489,12 @@ static int system_clock_control(struct snd_soc_dapm_widget *w, { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); + struct regmap *regmap = nau8824->regmap; + unsigned int value; + bool clk_fll, error; if (SND_SOC_DAPM_EVENT_OFF(event)) { + dev_dbg(nau8824->dev, "system clock control : POWER OFF\n"); /* Set clock source to disable or internal clock before the * playback or capture end. Codec needs clock for Jack * detection and button press if jack inserted; otherwise, @@ -502,7 +506,40 @@ static int system_clock_control(struct snd_soc_dapm_widget *w, } else { nau8824_config_sysclk(nau8824, NAU8824_CLK_DIS, 0); } + } else { + dev_dbg(nau8824->dev, "system clock control : POWER ON\n"); + /* Check the clock source setting is proper or not + * no matter the source is from FLL or MCLK. + */ + regmap_read(regmap, NAU8824_REG_FLL1, &value); + clk_fll = value & NAU8824_FLL_RATIO_MASK; + /* It's error to use internal clock when playback */ + regmap_read(regmap, NAU8824_REG_FLL6, &value); + error = value & NAU8824_DCO_EN; + if (!error) { + /* Check error depending on source is FLL or MCLK. */ + regmap_read(regmap, NAU8824_REG_CLK_DIVIDER, &value); + if (clk_fll) + error = !(value & NAU8824_CLK_SRC_VCO); + else + error = value & NAU8824_CLK_SRC_VCO; + } + /* Recover the clock source setting if error. */ + if (error) { + if (clk_fll) { + regmap_update_bits(regmap, + NAU8824_REG_FLL6, NAU8824_DCO_EN, 0); + regmap_update_bits(regmap, + NAU8824_REG_CLK_DIVIDER, + NAU8824_CLK_SRC_MASK, + NAU8824_CLK_SRC_VCO); + } else { + nau8824_config_sysclk(nau8824, + NAU8824_CLK_MCLK, 0); + } + } } + return 0; } @@ -591,7 +628,8 @@ static const struct snd_kcontrol_new nau8824_dacr_mux = static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("System Clock", SND_SOC_NOPM, 0, 0, - system_clock_control, SND_SOC_DAPM_POST_PMD), + system_clock_control, SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_INPUT("HSMIC1"), SND_SOC_DAPM_INPUT("HSMIC2"),