From nobody Wed Apr 8 14:47:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E0A5ECAAA1 for ; Fri, 9 Sep 2022 13:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231131AbiIINzY (ORCPT ); Fri, 9 Sep 2022 09:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230358AbiIINyx (ORCPT ); Fri, 9 Sep 2022 09:54:53 -0400 Received: from hutie.ust.cz (hutie.ust.cz [185.8.165.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B12F2F003; Fri, 9 Sep 2022 06:54:46 -0700 (PDT) From: =?UTF-8?q?Martin=20Povi=C5=A1er?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1662731682; bh=F2niW+KZ7cR+aKTNLQ9ayIzd0xynY1DOFy+scVH0nu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f19OV5FyCizyB27g4LsgdtN2U8izv06YSBjl/ZQxM2ox6/qL12dv0sVE/opDmQzKJ ECGWqYgfwQInmlO/dngqMBr13P2VTx9CBUGWfGtaaRZsyemqPrWMbcPPP6g1r/g0JS S6SmZRJogie0GpaIa15JBn4kvcsBj8cmOlJ4MMHQ= To: James Schulman , David Rhodes , Lucas Tanure , Richard Fitzgerald , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai , =?UTF-8?q?Martin=20Povi=C5=A1er?= Cc: Charles Keepax , ChiYuan Huang , Pierre-Louis Bossart , Lukas Bulwahn , Matt Flax , - , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev Subject: [PATCH 10/10] ASoC: cs42l42: Implement 'set_bclk_ratio' Date: Fri, 9 Sep 2022 15:53:34 +0200 Message-Id: <20220909135334.98220-11-povik+lin@cutebit.org> In-Reply-To: <20220909135334.98220-1-povik+lin@cutebit.org> References: <20220909135334.98220-1-povik+lin@cutebit.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver wants to know the bit rate on the serial bus and takes that to be the value set by 'set_sysclk'. The 'set_bclk_ratio' op is a better fit for figuring out the clocking parameters of the serial bus, so implement that and give it precedence over the prior methods. Signed-off-by: Martin Povi=C5=A1er --- sound/soc/codecs/cs42l42.c | 17 ++++++++++++++++- sound/soc/codecs/cs42l42.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index 3f067cf9131a..36761ba0f2c4 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -898,7 +898,10 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substr= eam *substream, =20 cs42l42->srate =3D params_rate(params); =20 - if (cs42l42->sclk) { + if (cs42l42->bclk_ratio) { + /* machine driver has set the BCLK/samp-rate ratio */ + bclk =3D cs42l42->bclk_ratio * params_rate(params); + } else if (cs42l42->sclk) { /* machine driver has set the SCLK */ bclk =3D cs42l42->sclk; } else { @@ -984,6 +987,17 @@ static int cs42l42_set_sysclk(struct snd_soc_dai *dai, return -EINVAL; } =20 +static int cs42l42_set_bclk_ratio(struct snd_soc_dai *dai, + unsigned int bclk_ratio) +{ + struct snd_soc_component *component =3D dai->component; + struct cs42l42_private *cs42l42 =3D snd_soc_component_get_drvdata(compone= nt); + + cs42l42->bclk_ratio =3D bclk_ratio; + + return 0; +} + static int cs42l42_mute_stream(struct snd_soc_dai *dai, int mute, int stre= am) { struct snd_soc_component *component =3D dai->component; @@ -1087,6 +1101,7 @@ static const struct snd_soc_dai_ops cs42l42_ops =3D { .hw_params =3D cs42l42_pcm_hw_params, .set_fmt =3D cs42l42_set_dai_fmt, .set_sysclk =3D cs42l42_set_sysclk, + .set_bclk_ratio =3D cs42l42_set_bclk_ratio, .mute_stream =3D cs42l42_mute_stream, }; =20 diff --git a/sound/soc/codecs/cs42l42.h b/sound/soc/codecs/cs42l42.h index bc51bb09da5c..a72136664112 100644 --- a/sound/soc/codecs/cs42l42.h +++ b/sound/soc/codecs/cs42l42.h @@ -35,6 +35,7 @@ struct cs42l42_private { int irq; int pll_config; u32 sclk; + u32 bclk_ratio; u32 srate; u8 plug_state; u8 hs_type; --=20 2.33.0