Message ID | 20230524074156.147387-4-cristian.ciocaltea@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2669425vqo; Wed, 24 May 2023 00:55:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZXr5Cc1UabmvMvepVgYVgGp4Jn0R3V6tYqDWb+qPIzu0MFtKDg1bGZ5WnNNvvvSdEm5uv X-Received: by 2002:a05:6a20:1b26:b0:106:dfc8:6f4e with SMTP id ch38-20020a056a201b2600b00106dfc86f4emr14347890pzb.32.1684914935987; Wed, 24 May 2023 00:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684914935; cv=none; d=google.com; s=arc-20160816; b=OntBU+fMhOwbjRJfQOAn4yr7c/BMRjn7Gu+Cv+0M1PoF5FansXGt3pPJQyGm2RphXE P5IZNygeRdt0zerKRk1yT+3iOa8IjL4jC01heQXWzDVNoQWgqMTYH+ec32SM8YeRee9T X0ia0jdVWRNbC+acNsvqWLYOAI8BBGRgzWIMUFw5XRT+2Gh2YPZvDKMjLH3f9kiPnTVo SHeHrLot2TTt155Zb+vgsF3dkts9gqHTg1YqTqMof9Vdr4D+/2jA/WNvnYTasYLNxuox idV4S/QKPiN7/yFH02H70LYUhvPzzZ9vpU7vhypfp1X5BJvyt/h+A0+BC4Fh3to2da8w kqog== 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=MFVDh5xgMMARiI3cslvjVX0NVjFumB8W3NLLQ2yI33U=; b=h91PDLA6v+fplbvF2UEZM/DGfEqKa9TnyEzyLrTFTl+6alZ6lHw7dKmLg0UhnSHvv3 DbxYayEECNMTosGvxvL1Uv9OYYPGruxNs9x2wDUeRbHeGtZbsW4mkfxatY4uc2H2/fLJ mFdBeOMd/Hat/OrQGPUv8djJUnBlE/Le1b37JaeyJvWa5+uTipWrp5dfwEpKmeJ977os PiZNd7G8ye3XL95mUqRIOAKoYlCmK2aPF5rdptRJH5VENaRebyFvIY6J2BpCy/TOWnlR LOGkggsUscldvr35NtZjfkz0zwnrIjNH3jPolDe4mCuNd6OYMn1ZxC4kOgriw9Ymy7uB VH3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=J+8qeUL7; 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 x24-20020a63b218000000b00524db291facsi134833pge.504.2023.05.24.00.55.23; Wed, 24 May 2023 00:55:35 -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=J+8qeUL7; 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 S240051AbjEXHmR (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Wed, 24 May 2023 03:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240026AbjEXHmM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 24 May 2023 03:42:12 -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 ECDF98F; Wed, 24 May 2023 00:42:10 -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 8E2276606E75; Wed, 24 May 2023 08:42:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684914129; bh=iHcb9BFc/X1bbxtUKpaxg5GTnEgeVVJ1yraooXSIn1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+8qeUL7wLbyiWwOGcaIp1izZ9pvs2pzG+kKXf9VtlAgV1aIEOY3nxevi9XfcUKox OJYLHKoWg5DkHcg+7a+QJ2cYqYVkIu+fQSFLepbmnDNtTJ3Zd8d16JA/IdUFarzm47 X8RCPTHLDCeJ4b3zHJk4BIndaoGdwRhmmq3KMKL0a+0qdlaWxy8dfVlc7UH9yeoNeO vZORLe//LBSSgoVn94ITNS7MyHXzs6xmatvyGP48TYxFNkwVTbYxxDWVLk4HT8n0MO sgZo60pPr98ZANmyBLKDfNi+GXtIqw5rG3kmYjOFaN11/wzxgq+B7OtZsGRBwy7v7V dcYJc7OARA6jA== 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 3/3] arm64: dts: rockchip: Assign ES8316 MCLK rate on rk3588-rock-5b Date: Wed, 24 May 2023 10:41:56 +0300 Message-Id: <20230524074156.147387-4-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524074156.147387-1-cristian.ciocaltea@collabora.com> References: <20230524074156.147387-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 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?1766761363953408266?= X-GMAIL-MSGID: =?utf-8?q?1766761363953408266?= |
Series |
ES8316 audio codec fixes on Rock5B
|
|
Commit Message
Cristian Ciocaltea
May 24, 2023, 7:41 a.m. UTC
The I2S0_8CH_MCLKOUT clock rate on Rock 5B board defaults to 12 MHz and
it is used to provide the master clock (MCLK) for the ES8316 audio
codec.
On sound card initialization, this limits the allowed sample rates
according to the MCLK/LRCK ratios supported by the codec, which results
in the following non-standard rates: 15625, 30000, 31250, 46875.
Hence, the very first access of the sound card fails:
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument
However, all subsequent attempts will succeed, as the audio graph card
will request a correct clock frequency, based on the stream sample rate
and the multiplication factor.
Assign MCLK to 12.288 MHz, which allows the codec to advertise most of
the standard sample rates.
Fixes: 55529fe3f32d ("arm64: dts: rockchip: Add rk3588-rock-5b analog audio")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts | 2 ++
1 file changed, 2 insertions(+)
Comments
On Wed, May 24, 2023 at 10:41:56AM +0300, Cristian Ciocaltea wrote: > The I2S0_8CH_MCLKOUT clock rate on Rock 5B board defaults to 12 MHz and > it is used to provide the master clock (MCLK) for the ES8316 audio > codec. > > On sound card initialization, this limits the allowed sample rates > according to the MCLK/LRCK ratios supported by the codec, which results > in the following non-standard rates: 15625, 30000, 31250, 46875. > > Hence, the very first access of the sound card fails: > > Broken configuration for playback: no configurations available: Invalid argument > Setting of hwparams failed: Invalid argument > > However, all subsequent attempts will succeed, as the audio graph card > will request a correct clock frequency, based on the stream sample rate > and the multiplication factor. > > Assign MCLK to 12.288 MHz, which allows the codec to advertise most of > the standard sample rates. Surely this is irrelevant with your previous change, and if the clock is freely reprogrammable as it sounds even harmful given that it'll restrict rates that are not available with the selected MCLK?
On 5/24/23 13:39, Mark Brown wrote: > On Wed, May 24, 2023 at 10:41:56AM +0300, Cristian Ciocaltea wrote: >> The I2S0_8CH_MCLKOUT clock rate on Rock 5B board defaults to 12 MHz and >> it is used to provide the master clock (MCLK) for the ES8316 audio >> codec. >> >> On sound card initialization, this limits the allowed sample rates >> according to the MCLK/LRCK ratios supported by the codec, which results >> in the following non-standard rates: 15625, 30000, 31250, 46875. >> >> Hence, the very first access of the sound card fails: >> >> Broken configuration for playback: no configurations available: Invalid argument >> Setting of hwparams failed: Invalid argument >> >> However, all subsequent attempts will succeed, as the audio graph card >> will request a correct clock frequency, based on the stream sample rate >> and the multiplication factor. >> >> Assign MCLK to 12.288 MHz, which allows the codec to advertise most of >> the standard sample rates. > > Surely this is irrelevant with your previous change, and if the clock is > freely reprogrammable as it sounds even harmful given that it'll > restrict rates that are not available with the selected MCLK? As mentioned in the previous patch description, there's a bad timing with es8316_pcm_startup() being executed before the 2nd call to es8316_set_dai_sysclk(), with the effect that the new/updated rate constraints won't be used until the next playback attempt. Hence the approach here was to ensure the initial list of restricted rates is sane, by (pre)assigning a proper MCLK. Alternatively, we could have used an unsupported MCLK and, with the help of the previous patch, we would have ended up with no restrictions applied on es8316_pcm_startup().
diff --git a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts index 3e4aee8f70c1..30cdd366813f 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts +++ b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts @@ -133,6 +133,8 @@ es8316: audio-codec@11 { reg = <0x11>; clocks = <&cru I2S0_8CH_MCLKOUT>; clock-names = "mclk"; + assigned-clocks = <&cru I2S0_8CH_MCLKOUT>; + assigned-clock-rates = <12288000>; #sound-dai-cells = <0>; port {