Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp18880ybp; Thu, 3 Oct 2019 09:34:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPxqVjXP/gZpAkLNO4RyWa53GKYAKtymkbV6JBDYvILxvI5Z/5eNuys+aYktxsk45t7eON X-Received: by 2002:a05:6402:290:: with SMTP id l16mr10548290edv.178.1570120488812; Thu, 03 Oct 2019 09:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570120488; cv=none; d=google.com; s=arc-20160816; b=u6FlQdyaXBGCmPd3PPMdTG1gH2ltR0kleS4EQ254gaueIHK6UWdVGgqnpGbm8oPBng olhoomU8cS6gqI7jldVEJhMRK+2jA6aPgDT6zkia5sXt7sKiupOvGgE9bfHYi1Qs7CG2 TRQik5JWxJI3WHCexiCJYjJ1Uli43/eJOszqx5i4rNKEBdWpyOknWDEYLE+dsuxPN4eB rkLDIkIsx5gh8jWVhof7LIxVcvGhAYIXhIOJRhe0Vjcp4HFDCoMTOHU7iRxh/PEAY0Jh 8guZH+tuMSZbNb6HrQdP42dai4Ht8Zj0SJRXxzyPINePRMadV8f4GF79TdWYSY9w0k6t V7iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sgGpuhdsd+rQhmIz2A66psxSLisOjHgxfT0FXUt+cxU=; b=c5nTH6elQOgVG4V0I0D9v3wmk970NSzeywVlIiscNu5zb4KnX548SzmFITAwgYS6Zw KBVTKiejb86SLESfHZFFUTwXTMAgfdGSFlXDgs7BorGYXzNARtC+Z+uSTEIPFW5gIhaV IF3pOWOorVx6hr0xCKQ5e7JWmrEKTucEbvdc1L+wTYLFbYR/VJ68YIJFHbNcM8ue9SVA je88cT3CDGAikO+HhF4fgilaDBcov1AfldTmkSGJJ/LGFya4Z7Wm41YfGQzgtHSE/E1C a6AxLFB7WETOvq6TeBqPBaBDAuoEK18LF0Odds8a3TscXdsAcywZpctH3w9HybkSS3lZ nL0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="qdF/L0P4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r24si1514333ejs.166.2019.10.03.09.34.24; Thu, 03 Oct 2019 09:34:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="qdF/L0P4"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391897AbfJCQcS (ORCPT + 99 others); Thu, 3 Oct 2019 12:32:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:39712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391889AbfJCQcQ (ORCPT ); Thu, 3 Oct 2019 12:32:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 253D421848; Thu, 3 Oct 2019 16:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120335; bh=PFmsVWFZwfpmAheslFDDoN3WmtOQ4A68VbTVliDI6Oc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qdF/L0P47ywsBJkj8y0CSQL7w3Qj/6PrVHpk0g6fKrOp0cUlhq9frvrKXQDsAk112 9nfSFYrD/K+S7LWycK5W95hvC9FVvQ2YKZPcAo0o6jeKN9C4VVDoKnncerVn3tLfju ZKQIhboX0jV37wFncH23faD0OOeaSjSdbEWNnNrc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Katsuhiro Suzuki , Mark Brown , Sasha Levin Subject: [PATCH 5.2 184/313] SoC: simple-card-utils: set 0Hz to sysclk when shutdown Date: Thu, 3 Oct 2019 17:52:42 +0200 Message-Id: <20191003154551.123149795@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Katsuhiro Suzuki [ Upstream commit 2458adb8f92ad4d07ef7ab27c5bafa1d3f4678d6 ] This patch set 0Hz to sysclk when shutdown the card. Some codecs set rate constraints that derives from sysclk. This mechanism works correctly if machine drivers give fixed frequency. But simple-audio and audio-graph card set variable clock rate if 'mclk-fs' property exists. In this case, rate constraints will go bad scenario. For example a codec accepts three limited rates (mclk / 256, mclk / 384, mclk / 512). Bad scenario as follows (mclk-fs = 256): - Initialize sysclk by correct value (Ex. 12.288MHz) - Codec set constraints of PCM rate by sysclk 48kHz (1/256), 32kHz (1/384), 24kHz (1/512) - Play 48kHz sound, it's acceptable - Sysclk is not changed - Play 32kHz sound, it's acceptable - Set sysclk to 8.192MHz (= fs * mclk-fs = 32k * 256) - Codec set constraints of PCM rate by sysclk 32kHz (1/256), 21.33kHz (1/384), 16kHz (1/512) - Play 48kHz again, but it's NOT acceptable because constraints do not allow 48kHz So codecs treat 0Hz sysclk as signal of applying no constraints to avoid this problem. Signed-off-by: Katsuhiro Suzuki Link: https://lore.kernel.org/r/20190907174501.19833-1-katsuhiro@katsuster.net Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/generic/simple-card-utils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index f4c6375d11c7a..ef1adf87cbc8b 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -224,10 +224,17 @@ EXPORT_SYMBOL_GPL(asoc_simple_startup); void asoc_simple_shutdown(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); + if (dai_props->mclk_fs) { + snd_soc_dai_set_sysclk(codec_dai, 0, 0, SND_SOC_CLOCK_IN); + snd_soc_dai_set_sysclk(cpu_dai, 0, 0, SND_SOC_CLOCK_OUT); + } + asoc_simple_clk_disable(dai_props->cpu_dai); asoc_simple_clk_disable(dai_props->codec_dai); -- 2.20.1