Message ID | 20230530181140.483936-3-cristian.ciocaltea@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2377596vqr; Tue, 30 May 2023 11:25:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+L7vGMd0rsik7S1fzqr36iBIFzOYZn4RTx/X8VmkxHmk2CXN9bmWQauQuLLWjaezGuLFV X-Received: by 2002:a05:6a20:be85:b0:f1:c63a:f7fa with SMTP id gf5-20020a056a20be8500b000f1c63af7famr2755419pzb.15.1685471111437; Tue, 30 May 2023 11:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685471111; cv=none; d=google.com; s=arc-20160816; b=AkdKeiS5ejl2qE6E/y75LuzjhlZ0rIFLMe0PZnQgmgleSq2UoVLb/IBZT3YgVcIhX4 QyCffNnM5Mp8Weauv8ZIyAT6+bzywF6vnIC6oIWJ7FJCrWwH1PlTQjWU1mZMVTutdk1i Zm87Pceh3WZv0LszjAhobSfEINm/2QcVPFTR+0HACbgg9HhAquCd11CSmbi6Qw2p+53I /umWocUnmLn8yRzXWjT27xj/kZux96pLM+InBE8y9VelKJNlz9ie7b4kMkumN+2WRyw8 PWRA8XuZTkPJS8y+Zrmfw0XfrcmklFT93tWyvrTidDz28YINGsrky3oQiwAJtghBeHfa rbZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2NteQC++iQ6nSymWcneeQuYyuwT/19puVFl6jCBLwww=; b=fg8C8JSJLPatZqGGzqIDTFKto/Qf29f5u4SvftUoCsDSGmwEkHXDgC8RrWYdCz1UDl Mo1hRJd4tG9OIG79Le+hhcTfNZKDcnD1oOf6Wr2IMRJDerMDBLk8Y4X9iweuSeUwnP7x FPwxOXYlsU8nxsK9J3rgRAOCADcroppVN8Bfue7yELL8Q48zDyEV34wUsEPhdImeygCe Sz38Owd/Yc115CYNsF9P33akkWCjWt+9aQWvWBgEWb5m9SizkBrWZkHmS6W8kNCHYTXc dmkOJ7/srpA5iwMkZjvcb07o4pRWQpz6+lkrWmwMbVIFNMWow/pRpVT2z96OwVvgyKy9 r/qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=jSeuSeX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p22-20020a637416000000b0053eef42c759si6422998pgc.851.2023.05.30.11.24.57; Tue, 30 May 2023 11:25:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=jSeuSeX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233311AbjE3SL6 (ORCPT <rfc822;andrewvogler123@gmail.com> + 99 others); Tue, 30 May 2023 14:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232673AbjE3SLw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 30 May 2023 14:11:52 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78439A3; Tue, 30 May 2023 11:11:51 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 312836605840; Tue, 30 May 2023 19:11:50 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685470310; bh=sMhuZ+7skk9Nz8F8CqkKKe/JQIPAguLL7MXGBbO2Dt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jSeuSeX3vb9uNFXqB5SBwWMN/i7ouAXBywLxiMCsC7i+7SUEN9TsHC+eJ331EeZ6p FQc2qNLPcePsPRIsRr7JxQ2KhT7Zo7xILISvaPxW2pkuA8kkEsUfHgrRk6DfmX6W8K xlwJwrNcAujY06uE1+n2TrzSyFs95Cz6kXxkGlfxLFW1BrFxGV1yLonTBQIHR5lAfh Nk1+djddCn+ffS8paqMobLyhoGEohaOYxQ/IQC7ZK++2BlVtcKopJDS3eHDItAaUwU 8NCXUzcM81o5Z18Z938O0rIAZJWIHrYLmEn6Qy7ZkgrnHwHJYhp6UKBMY//7wR3Tvt Dm5BhJH4Sa8Zg== From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> To: Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Heiko Stuebner <heiko@sntech.de>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Zhu Ning <zhuning0077@gmail.com>, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>, Charles Keepax <ckeepax@opensource.cirrus.com>, =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= <u.kleine-koenig@pengutronix.de>, David Yang <yangxiaohua@everest-semi.com>, Daniel Drake <drake@endlessm.com> Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, kernel@collabora.com Subject: [PATCH v2 2/3] ASoC: es8316: Do not set rate constraints for unsupported MCLKs Date: Tue, 30 May 2023 21:11:39 +0300 Message-Id: <20230530181140.483936-3-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230530181140.483936-1-cristian.ciocaltea@collabora.com> References: <20230530181140.483936-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767344556119486226?= X-GMAIL-MSGID: =?utf-8?q?1767344556119486226?= |
Series |
ES8316 audio codec fixes on Rock5B
|
|
Commit Message
Cristian Ciocaltea
May 30, 2023, 6:11 p.m. UTC
When using the codec through the generic audio graph card, there are at
least two calls of es8316_set_dai_sysclk(), with the effect of limiting
the allowed sample rates according to the MCLK/LRCK ratios supported by
the codec:
1. During audio card setup, to set the initial MCLK - see
asoc_simple_init_dai().
2. Before opening a stream, to update MCLK, according to the stream
sample rate and the multiplication factor - see
asoc_simple_hw_params().
In some cases the initial MCLK might be set to a frequency that doesn't
match any of the supported ratios, e.g. 12287999 instead of 12288000,
which is only 1 Hz below the supported clock, as that is what the
hardware reports. This creates an empty list of rate constraints, which
is further passed to snd_pcm_hw_constraint_list() via
es8316_pcm_startup(), and causes the following error on the very first
access of the sound card:
$ speaker-test -D hw:Analog,0 -F S16_LE -c 2 -t wav
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument
Note that all subsequent retries succeed thanks to the updated MCLK set
at point 2 above, which uses a computed frequency value instead of a
reading from the hardware registers. Normally this would have mitigated
the issue, but es8316_pcm_startup() executes before the 2nd call to
es8316_set_dai_sysclk(), hence it cannot make use of the updated
constraints.
Since es8316_pcm_hw_params() performs anyway a final validation of MCLK
against the stream sample rate and the supported MCLK/LRCK ratios, fix
the issue by ensuring that sysclk_constraints list is only set when at
least one supported sample rate is autodetected by the codec.
Fixes: b8b88b70875a ("ASoC: add es8316 codec driver")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
sound/soc/codecs/es8316.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index 8f0625b45b7c..069f1ce1cd50 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -369,13 +369,11 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai, int count = 0; es8316->sysclk = freq; + es8316->sysclk_constraints.list = NULL; + es8316->sysclk_constraints.count = 0; - if (freq == 0) { - es8316->sysclk_constraints.list = NULL; - es8316->sysclk_constraints.count = 0; - + if (freq == 0) return 0; - } ret = clk_set_rate(es8316->mclk, freq); if (ret) @@ -391,8 +389,10 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai, es8316->allowed_rates[count++] = freq / ratio; } - es8316->sysclk_constraints.list = es8316->allowed_rates; - es8316->sysclk_constraints.count = count; + if (count) { + es8316->sysclk_constraints.list = es8316->allowed_rates; + es8316->sysclk_constraints.count = count; + } return 0; }