From patchwork Wed Sep 20 09:43:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 142357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4050975vqi; Wed, 20 Sep 2023 04:11:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtxdXEI1sCjW6ITBLDvaJbdigkBtOXfmAT5HvjSv0+uOYrq7Wjfa+eyEPqRRcDoqm/NLaL X-Received: by 2002:a05:6a00:80c2:b0:68f:a92a:8509 with SMTP id ei2-20020a056a0080c200b0068fa92a8509mr6774026pfb.7.1695208312002; Wed, 20 Sep 2023 04:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695208311; cv=none; d=google.com; s=arc-20160816; b=PufY/fhKGCBeCzELBKoK9sD6jFktHns5OapaBYN5jCaEs7c4OHyycxT45pDCsgAgFv 8RPixRBmdPzQuPryfO9BjWuDq1nd0aEci9Gw5s7REK2occqEoHCyXs/7+sbBKcY2ybov QjEcBJ8gm0zPgTVe9WruYUiKShsHAsC9oZpBR5JO7gO4nbcNRu/UCNl/oHGkgd57pweI NweWrZKa5wGtXg1E5cSgvExarlLxno7f9YA6UgbRyJYeBaRv4ssUnGyttu0VMM8LimP3 m68TBucv3ftoEQWhEuhZqWuRuQFVyGESKl8ebL7mvSYFuw2A1cvJHPeTb+lqxqX7veE9 8ITQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from; bh=8RHwmLPYI1amW4OwHgo6td0pR8ibwBmJ6MtmvkqBZzQ=; fh=ej+ES4Dwh1V08gn2d72DvDWSU19D6ZzjsW9Imw8Zke8=; b=BRw5/SINe2cPyWkrxBCW0Vtf/MWW2Ag51Ymcqx5qpEC8R1xfc6UqXH9JNiDaPvjyAj fpc+bHvjjAdPkW46OAjwqvIt6iR7QSFshlAZ69o2cgv0b5+PvgdGx64TO85Jk0G4B52q 3zB7IiU5ChLW2vC57+Gw6VDpHjSgL4FUItu38nipl+tN2QwXkPJ8XTfItyj5kUkrBNbb /ND2zC7iOqDWt30cXg9UtXzRgTmlGK4I4bjI2+SRE0cTDuTAFRo4/RSnv87u7NDCLY8D PjMtAs0Z9kG4pnh8uUrf0+wgUNRxSk5PfkgivXPAlIuYezDtI4Ad8WdKSy5WrhpLSYV+ 6+eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l24-20020a637018000000b0056af922fdc9si11349985pgc.852.2023.09.20.04.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 04:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4036481DD7E8; Wed, 20 Sep 2023 03:20:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233866AbjITKUK (ORCPT + 26 others); Wed, 20 Sep 2023 06:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233950AbjITKUG (ORCPT ); Wed, 20 Sep 2023 06:20:06 -0400 Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A673AC for ; Wed, 20 Sep 2023 03:20:00 -0700 (PDT) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A38AD200B1D; Wed, 20 Sep 2023 12:19:58 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 6AF6E200B27; Wed, 20 Sep 2023 12:19:58 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id E88891802200; Wed, 20 Sep 2023 18:19:56 +0800 (+08) From: Shengjiu Wang To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: fsl-asoc-card: use integer type for fll_id and pll_id Date: Wed, 20 Sep 2023 17:43:12 +0800 Message-Id: <1695202992-24864-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 20 Sep 2023 03:20:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777554751275030212 X-GMAIL-MSGID: 1777554751275030212 As the pll_id and pll_id can be zero (WM8960_SYSCLK_AUTO) with the commit 2bbc2df46e67 ("ASoC: wm8960: Make automatic the default clocking mode") Then the machine driver will skip to call set_sysclk() and set_pll() for codec, when the sysclk rate is different with what wm8960 read at probe, the output sound frequency is wrong. So change the fll_id and pll_id initial value, still keep machine driver's behavior same as before. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl-asoc-card.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 76b5bfc288fd..bab7d34cf585 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -52,8 +52,8 @@ struct codec_priv { unsigned long mclk_freq; unsigned long free_freq; u32 mclk_id; - u32 fll_id; - u32 pll_id; + int fll_id; + int pll_id; }; /** @@ -206,7 +206,7 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream, } /* Specific configuration for PLL */ - if (codec_priv->pll_id && codec_priv->fll_id) { + if (codec_priv->pll_id >= 0 && codec_priv->fll_id >= 0) { if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE) pll_out = priv->sample_rate * 384; else @@ -248,7 +248,7 @@ static int fsl_asoc_card_hw_free(struct snd_pcm_substream *substream) priv->streams &= ~BIT(substream->stream); - if (!priv->streams && codec_priv->pll_id && codec_priv->fll_id) { + if (!priv->streams && codec_priv->pll_id >= 0 && codec_priv->fll_id >= 0) { /* Force freq to be free_freq to avoid error message in codec */ ret = snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), codec_priv->mclk_id, @@ -621,6 +621,10 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) priv->card.dapm_routes = audio_map; priv->card.num_dapm_routes = ARRAY_SIZE(audio_map); priv->card.driver_name = DRIVER_NAME; + + priv->codec_priv.fll_id = -1; + priv->codec_priv.pll_id = -1; + /* Diversify the card configurations */ if (of_device_is_compatible(np, "fsl,imx-audio-cs42888")) { codec_dai_name = "cs42888";