From patchwork Wed Feb 14 13:28:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 128333 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp609055ljc; Wed, 14 Feb 2018 05:29:03 -0800 (PST) X-Google-Smtp-Source: AH8x225O8zvaCeow+toyZX43ODpkv7RMXZhodegrn67Sm9KxxaSgHUOr4OFFhpcpYtNokb3w5GvG X-Received: by 10.28.238.18 with SMTP id m18mr2750674wmh.146.1518614943867; Wed, 14 Feb 2018 05:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518614943; cv=none; d=google.com; s=arc-20160816; b=YD/Za0+4L+/VJ2lVjGr24CwCx+TFD9j+NlNjqvLCNxG9xlpCYivbPYaEM6q47/cH1C YtQggOCYEXOK3/xntb0LiKrzsBPHpOmw4RtOwUNfKLfg9gjr9RR8WOUKjFo1vrO/e6+6 Qc7+P5Gztqeyp2MpyVUU6orhtc6Sh0W74SFInjsP+4dkvasEBF0DSxmOzmN/g2964kql 4ug9Gr53ZtgozzcxpeuFycMnOVDjrwf36kAWh697MkgcjOJb1xprAdxBK2SOnSHZWPBz KKDMVCG+cN4z3+EI7HuSzoPhF2/0ZnsrH4clwKoeoPosYcdklUgcA+x++aZamHzYpLDv yTZA== 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=pAyXfEkfmREBAjPJntbn1ce+845CgmlwtCLDaCMzAew=; b=DmiSZ6te8sFU+vinc/Y3YtzAyWe6SvdRYMe5McDOt8OZjHtLWsOdUzIEYwfXk9z2Gd jsAwevSwwmWQV36e5SpD73vEykzeJTCmzNvdapRG/te2GVvwBegdBa1Mks2KTp8yvb3f K8E/ywOFnyjZkNYv/UJ8F0JhyTXGc5mkExlDtEB8Lojn9GBf9gwikwQdIAPYqOiFAqF3 ydAQoQWNG/EzuEF4MjYiBECMV5QE2vWA/Wzuc7dNBHT3744fhSAMeBN2fSTkQKoCjsYw npkwOmzaLiFQQY3modeNfYOtihv4jVZOswXd9qtCRPdk/BU9BTPNe1wg/Bq3cZY71wAd L56A== 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=sJilCbO9; 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 h125si7278524wma.136.2018.02.14.05.29.03; Wed, 14 Feb 2018 05:29:03 -0800 (PST) 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=sJilCbO9; 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 D58D7267A7D; Wed, 14 Feb 2018 14:29:01 +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 A0683267A7D; Wed, 14 Feb 2018 14:29:00 +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 2FAC42677DA for ; Wed, 14 Feb 2018 14:28:56 +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=pNIQDV/zgn3+QQtI0xHo/UYfktpUPyzkdTzyzO9DbE4=; b=sJilCbO98CnK eefYZJI8d6IIyHrxMylnYcYNo/1uEvBjpxPzAQAiC5Ht0OjAb+cPvvqriYhsxGpii16Bpe3gkOu2a PV6lggw2UYKhG9J6Vnso34nrj/YnKLhqaYZXlg7ZAnAhFMe9nOcH6sYooMgf2pxH2/1gcWi4TnRgf 1zV9E=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1elx7F-0004oq-TO; Wed, 14 Feb 2018 13:28:54 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1elx7E-0006jR-RR; Wed, 14 Feb 2018 13:28:52 +0000 From: Mark Brown To: Peter Ujfalusi In-Reply-To: <20180214122056.5809-1-peter.ujfalusi@ti.com> Message-Id: Date: Wed, 14 Feb 2018 13:28:52 +0000 Cc: alsa-devel@alsa-project.org, Mark Brown , Liam Girdwood , Jyri Sarha , afd@ti.com Subject: [alsa-devel] Applied "ASoC: tlv320aic31xx: Fix master mode clock I2S bus clocks" 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: tlv320aic31xx: Fix master mode clock I2S bus clocks 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 d460b3f861e18b9c826abe178b2db57c6dc6b3e4 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 14 Feb 2018 14:20:56 +0200 Subject: [PATCH] ASoC: tlv320aic31xx: Fix master mode clock I2S bus clocks In the reset state of the codec we do not have complete playback or capture routes. The audio playback/capture will not work due to missing clock signals on the I2S bus if PLL, MDAC/NDAC/DAC MADC/NADC/ADC is powered down. To make sure that even if all output/input is disconnected the codec is generating clocks, we need to have valid DAPM route in every case to power up the must needed parts of the codec. I have verified that switching DAC (during playback) or ADC (during capture) will stop the I2S clocks, so the only solution is to connect the 'Off' routes as well to output/input. The routes will be only added if the codec is clock master. In case the role changes runtime, the applied routes are removed. Tested on am43x-epos-evm with aic3111 codec in master mode. Signed-off-by: Peter Ujfalusi Reviewed-by: Jyri Sarha Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic31xx.c | 73 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) -- 2.16.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index d3cd924dc300..7090342e8285 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -166,6 +166,7 @@ struct aic31xx_priv { unsigned int sysclk; u8 p_div; int rate_div_line; + bool master_dapm_route_applied; }; struct aic31xx_rate_divs { @@ -670,6 +671,29 @@ aic310x_audio_map[] = { {"SPK", NULL, "SPK ClassD"}, }; +/* + * Always connected DAPM routes for codec clock master modes. + * If the codec is the master on the I2S bus, we need to power on components + * to have valid DAC_CLK and also the DACs and ADC for playback/capture. + * Otherwise the codec will not generate clocks on the bus. + */ +static const struct snd_soc_dapm_route +common31xx_cm_audio_map[] = { + {"DAC Left Input", "Off", "DAC IN"}, + {"DAC Right Input", "Off", "DAC IN"}, + + {"HPL", NULL, "DAC Left"}, + {"HPR", NULL, "DAC Right"}, +}; + +static const struct snd_soc_dapm_route +aic31xx_cm_audio_map[] = { + {"MIC1LP P-Terminal", "Off", "MIC1LP"}, + {"MIC1RP P-Terminal", "Off", "MIC1RP"}, + {"MIC1LM P-Terminal", "Off", "MIC1LM"}, + {"MIC1LM M-Terminal", "Off", "MIC1LM"}, +}; + static int aic31xx_add_controls(struct snd_soc_component *component) { int ret = 0; @@ -912,6 +936,53 @@ static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) return 0; } +static int aic31xx_clock_master_routes(struct snd_soc_component *component, + unsigned int fmt) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); + int ret; + + fmt &= SND_SOC_DAIFMT_MASTER_MASK; + if (fmt == SND_SOC_DAIFMT_CBS_CFS && + aic31xx->master_dapm_route_applied) { + /* + * Remove the DAPM route(s) for codec clock master modes, + * if applied + */ + ret = snd_soc_dapm_del_routes(dapm, common31xx_cm_audio_map, + ARRAY_SIZE(common31xx_cm_audio_map)); + if (!ret && !(aic31xx->codec_type & DAC31XX_BIT)) + ret = snd_soc_dapm_del_routes(dapm, + aic31xx_cm_audio_map, + ARRAY_SIZE(aic31xx_cm_audio_map)); + + if (ret) + return ret; + + aic31xx->master_dapm_route_applied = false; + } else if (fmt != SND_SOC_DAIFMT_CBS_CFS && + !aic31xx->master_dapm_route_applied) { + /* + * Add the needed DAPM route(s) for codec clock master modes, + * if it is not done already + */ + ret = snd_soc_dapm_add_routes(dapm, common31xx_cm_audio_map, + ARRAY_SIZE(common31xx_cm_audio_map)); + if (!ret && !(aic31xx->codec_type & DAC31XX_BIT)) + ret = snd_soc_dapm_add_routes(dapm, + aic31xx_cm_audio_map, + ARRAY_SIZE(aic31xx_cm_audio_map)); + + if (ret) + return ret; + + aic31xx->master_dapm_route_applied = true; + } + + return 0; +} + static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { @@ -992,7 +1063,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, AIC31XX_BCLKINV_MASK, iface_reg2); - return 0; + return aic31xx_clock_master_routes(component, fmt); } static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,