Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3720845ybe; Sun, 8 Sep 2019 20:35:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdYqDIhJbLHY3FCDn8MkPGWAUyx8Sq7+3pxvKmghiK255OnJNQgggpmNF3apFyWbkx0Sdk X-Received: by 2002:a50:9e6c:: with SMTP id z99mr21559313ede.200.1568000159534; Sun, 08 Sep 2019 20:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568000159; cv=none; d=google.com; s=arc-20160816; b=HMvdN3/gZHMO/6QzpQXeQe8Ye7n+qNs2DmPbP0W+012XREzbrBXrHwAClyHsGH5J6J aYWAUX9pbe8K1iGI9SZ9suvOS58s/tb9LfzfYTJ89W/2CEdui9BIs3o7vQ0FyflC+u/T R6imQ/d3/8663eDzkL52SbkfrgjQf+gj1f7XsIuHMhE4YF4FbGVNc8esvsIU7Je4wWfl PB6Xzm56QaLfbHKv6dGCByug7bFBnj+Zt0Ui7FPkaN/scuk/zd1Vt7vIJ6Nl1xOgh8wj vzzZEGBCSpIPIgdO6rWdLBuhepZ3iOa8LwZeGR8/OSU247zWVRAEhtS5I6IAKwUsXxRK MnAQ== 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 :message-id:date:subject:cc:to:from; bh=Sk2OtBnkE7/ADwhCTRbEvz+P857YSPQOLBs3lFY9kHk=; b=l6E2arcF7n+ESMfia/9tzd8U0eVlmzfgalbtZTKZe0ntuGl5wvKAAyAFEVKUfiqNdG hA2ArYKBr4ev29gI0FMMzVpLZYNJ1dNoCwSEqvHJ8Piz06r6AxUs5GVR4M7HOq8DTDed 8FFKAtFJKu6TRUX4GOmTOj4NNtJV/9mELr1cv2cUbvCKnYCWnk2aX9wL1gMRoJJv/qR4 nM/1sG5YRTSY29glsUMARuUSyp1aUBilBbgpqpjexTAr9K9/jlqLYkC8SXj/itWWWVtz yueJTyMMBLCzY4nTHhA6OiGwI+gxBy0DBc5Cmt5G0zZtWNn5A5euo33GdIacCDym1R7y 40Wg== ARC-Authentication-Results: i=1; mx.google.com; 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 e20si7008443ejl.225.2019.09.08.20.35.30; Sun, 08 Sep 2019 20:35:59 -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; 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 S2405231AbfIGRpQ (ORCPT + 99 others); Sat, 7 Sep 2019 13:45:16 -0400 Received: from www1102.sakura.ne.jp ([219.94.129.142]:47962 "EHLO www1102.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730303AbfIGRpQ (ORCPT ); Sat, 7 Sep 2019 13:45:16 -0400 Received: from fsav401.sakura.ne.jp (fsav401.sakura.ne.jp [133.242.250.100]) by www1102.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id x87Hj6mw009250; Sun, 8 Sep 2019 02:45:06 +0900 (JST) (envelope-from katsuhiro@katsuster.net) Received: from www1102.sakura.ne.jp (219.94.129.142) by fsav401.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav401.sakura.ne.jp); Sun, 08 Sep 2019 02:45:06 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav401.sakura.ne.jp) Received: from localhost.localdomain (118.153.231.153.ap.dti.ne.jp [153.231.153.118]) (authenticated bits=0) by www1102.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id x87Hj3KZ009238 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 8 Sep 2019 02:45:06 +0900 (JST) (envelope-from katsuhiro@katsuster.net) From: Katsuhiro Suzuki To: Mark Brown , Kuninori Morimoto Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Katsuhiro Suzuki Subject: [PATCH] SoC: simple-card-utils: set 0Hz to sysclk when shutdown Date: Sun, 8 Sep 2019 02:45:01 +0900 Message-Id: <20190907174501.19833-1-katsuhiro@katsuster.net> X-Mailer: git-send-email 2.23.0.rc1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 556b1a789629..9b794775df53 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -213,10 +213,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.23.0.rc1