From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66E0CC433E7 for ; Mon, 12 Oct 2020 12:15:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B5522145D for ; Mon, 12 Oct 2020 12:15:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388382AbgJLMPm (ORCPT ); Mon, 12 Oct 2020 08:15:42 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:58971 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388209AbgJLMPl (ORCPT ); Mon, 12 Oct 2020 08:15:41 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id D95E05802D4; Mon, 12 Oct 2020 08:15:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 12 Oct 2020 08:15:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=IjmSkHG+RebQZ02RSsHtc/0Z3Iz 8rbb2V+2upqrHWA0=; b=ZsikuYpnUfe/BcAE9hGG/bNtDltimbdoyEBcKt7oNpW up2AkMvGRClxsHuqleg0SN/UeBbvrFb4lLiIRdyNSggri8DO+PirdJZutbq/dKQ8 gWaCmgMd59xknXxSEVH44DBve9zlpUA/+56L3GeryUXf7n+NypcLGoaMguscrMi/ fcl2WA2nFNk+CzUcua0A742dU24gJyM0O5AfuIHo0jBbHNPUxcFvMwU8JQPA277K 8qr9RCfbHQW1kalJ2+kEXzYjSyF+lVJyH6LcH42O+0r4XukcGU0Kf4te049aN3+v meWbLUFdNx7PEUCs88/dy2duzkPH9VB1uwKzXPWC91Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=IjmSkH G+RebQZ02RSsHtc/0Z3Iz8rbb2V+2upqrHWA0=; b=Tq2O1ndJd8ICA9oWGdBruv zdIsy+vShHuiQkUBE1AZXBKPoFXwQJabmdHOkfX0JfGry8sdjePTISV43HsoKm0b 5WYAIaCg2TYOLQD5Of63L7xTBsuDYC2ObbOALwBuyJMR2Mi2XgtKvEhEpkS8YiDa 54wPyV5qtN9UNXZbrQ4abHGszxMeA5J5Vmy32uzEz9xxWo9ebwyQ1EMfzpQ0/4dV FyHxX2TA7SVlOlaAPGs/UlNodXJHeU7++8p0ScvC+B8tN0km6xdgo74y8BHfbqny 3y6q5KFrrz9UtB3fFvgoFuLoRDSJd1ync6SGYok12whDerxd+KgNCoX9Rzo4jnqg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrheejgdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtudenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpeduvdduhfekkeehgffftefflefgffdtheffudffgeevteffheeuiedvvdejvdfg veenucfkphepledtrdekledrieekrdejieenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id D8154328005A; Mon, 12 Oct 2020 08:15:37 -0400 (EDT) Date: Mon, 12 Oct 2020 14:15:36 +0200 From: Maxime Ripard To: =?utf-8?B?Q2zDqW1lbnQgUMOpcm9u?= Cc: Chen-Yu Tsai , Rob Herring , Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Marcus Cooper , Jernej Skrabec , Linux-ALSA , devicetree , linux-arm-kernel , linux-kernel , linux-sunxi , Samuel Holland Subject: Re: [PATCH v6 02/14] ASoC: sun4i-i2s: Change set_chan_cfg() params Message-ID: <20201012121536.z5d7kecdxaabw35n@gilmour.lan> References: <20201003141950.455829-1-peron.clem@gmail.com> <20201003141950.455829-3-peron.clem@gmail.com> <20201005121307.v6jpyeyfi4kxc2cl@gilmour.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="phliouq6fvfyh5hw" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org --phliouq6fvfyh5hw Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Mon, Oct 05, 2020 at 03:23:12PM +0200, Cl=E9ment P=E9ron wrote: > On Mon, 5 Oct 2020 at 14:13, Maxime Ripard wrote: > > > > On Sat, Oct 03, 2020 at 04:19:38PM +0200, Cl=E9ment P=E9ron wrote: > > > As slots and slot_width can be set manually using set_tdm(). > > > These values are then kept in sun4i_i2s struct. > > > So we need to check if these values are setted or not > > > in the struct. > > > > > > Avoid to check for this logic in set_chan_cfg(). This will > > > duplicate the same check instead pass the required values > > > as params to set_chan_cfg(). > > > > > > This will also avoid a bug when we will enable 20/24bits support, > > > i2s->slot_width is not actually used in the lrck_period computation. > > > > > > Suggested-by: Samuel Holland > > > Signed-off-by: Cl=E9ment P=E9ron > > > --- > > > sound/soc/sunxi/sun4i-i2s.c | 36 ++++++++++++++---------------------- > > > 1 file changed, 14 insertions(+), 22 deletions(-) > > > > > > diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c > > > index c5ccd423e6d3..1f577dbc20a6 100644 > > > --- a/sound/soc/sunxi/sun4i-i2s.c > > > +++ b/sound/soc/sunxi/sun4i-i2s.c > > > @@ -177,8 +177,9 @@ struct sun4i_i2s_quirks { > > > unsigned long (*get_bclk_parent_rate)(const struct sun4i_i2s *); > > > s8 (*get_sr)(const struct sun4i_i2s *, int); > > > s8 (*get_wss)(const struct sun4i_i2s *, int); > > > - int (*set_chan_cfg)(const struct sun4i_i2s *, > > > - const struct snd_pcm_hw_params *); > > > + int (*set_chan_cfg)(const struct sun4i_i2s *i2s, > > > + unsigned int channels, unsigned int sl= ots, > > > + unsigned int slot_width); > > > int (*set_fmt)(const struct sun4i_i2s *, unsigned int); > > > }; > > > > > > @@ -414,10 +415,9 @@ static s8 sun8i_i2s_get_sr_wss(const struct sun4= i_i2s *i2s, int width) > > > } > > > > > > static int sun4i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, > > > - const struct snd_pcm_hw_params *param= s) > > > + unsigned int channels, unsigned int s= lots, > > > + unsigned int slot_width) > > > { > > > - unsigned int channels =3D params_channels(params); > > > - > > > /* Map the channels for playback and capture */ > > > regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG, 0x76543210= ); > > > regmap_write(i2s->regmap, SUN4I_I2S_RX_CHAN_MAP_REG, 0x00003210= ); > > > @@ -434,15 +434,11 @@ static int sun4i_i2s_set_chan_cfg(const struct = sun4i_i2s *i2s, > > > } > > > > > > static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, > > > - const struct snd_pcm_hw_params *param= s) > > > + unsigned int channels, unsigned int s= lots, > > > + unsigned int slot_width) > > > { > > > - unsigned int channels =3D params_channels(params); > > > - unsigned int slots =3D channels; > > > unsigned int lrck_period; > > > > > > - if (i2s->slots) > > > - slots =3D i2s->slots; > > > - > > > /* Map the channels for playback and capture */ > > > regmap_write(i2s->regmap, SUN8I_I2S_TX_CHAN_MAP_REG, 0x76543210= ); > > > regmap_write(i2s->regmap, SUN8I_I2S_RX_CHAN_MAP_REG, 0x76543210= ); > > > @@ -467,11 +463,11 @@ static int sun8i_i2s_set_chan_cfg(const struct = sun4i_i2s *i2s, > > > case SND_SOC_DAIFMT_DSP_B: > > > case SND_SOC_DAIFMT_LEFT_J: > > > case SND_SOC_DAIFMT_RIGHT_J: > > > - lrck_period =3D params_physical_width(params) * slots; > > > + lrck_period =3D slot_width * slots; > > > break; > > > > > > case SND_SOC_DAIFMT_I2S: > > > - lrck_period =3D params_physical_width(params); > > > + lrck_period =3D slot_width; > > > break; > > > > > > default: > > > @@ -490,15 +486,11 @@ static int sun8i_i2s_set_chan_cfg(const struct = sun4i_i2s *i2s, > > > } > > > > > > static int sun50i_h6_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, > > > - const struct snd_pcm_hw_params *p= arams) > > > + unsigned int channels, unsigned i= nt slots, > > > + unsigned int slot_width) > > > { > > > - unsigned int channels =3D params_channels(params); > > > - unsigned int slots =3D channels; > > > unsigned int lrck_period; > > > > > > - if (i2s->slots) > > > - slots =3D i2s->slots; > > > - > > > /* Map the channels for playback and capture */ > > > regmap_write(i2s->regmap, SUN50I_H6_I2S_TX_CHAN_MAP0_REG, 0xFED= CBA98); > > > regmap_write(i2s->regmap, SUN50I_H6_I2S_TX_CHAN_MAP1_REG, 0x765= 43210); > > > @@ -525,11 +517,11 @@ static int sun50i_h6_i2s_set_chan_cfg(const str= uct sun4i_i2s *i2s, > > > case SND_SOC_DAIFMT_DSP_B: > > > case SND_SOC_DAIFMT_LEFT_J: > > > case SND_SOC_DAIFMT_RIGHT_J: > > > - lrck_period =3D params_physical_width(params) * slots; > > > + lrck_period =3D slot_width * slots; > > > break; > > > > > > case SND_SOC_DAIFMT_I2S: > > > - lrck_period =3D params_physical_width(params); > > > + lrck_period =3D slot_width; > > > break; > > > > > > default: > > > @@ -565,7 +557,7 @@ static int sun4i_i2s_hw_params(struct snd_pcm_sub= stream *substream, > > > if (i2s->slot_width) > > > slot_width =3D i2s->slot_width; > > > > > > - ret =3D i2s->variant->set_chan_cfg(i2s, params); > > > + ret =3D i2s->variant->set_chan_cfg(i2s, channels, slots, slot_w= idth); > > > > Isn't slots and slot_width set to 0 here ? >=20 > No, there is still a check before calling the set_cfg function. >=20 > unsigned int slot_width =3D params_physical_width(params); > unsigned int channels =3D params_channels(params); > unsigned int slots =3D channels; >=20 > if (i2s->slots) > slots =3D i2s->slots; >=20 > if (i2s->slot_width) > slot_width =3D i2s->slot_width; >=20 > ret =3D i2s->variant->set_chan_cfg(i2s, channels, slots, slot_width); >=20 > So slot_width will be equal to params_physical_width(params); > like before Still, it's not obvious what slots and slot_width are going to be set to in a non-TDM setup where that doesn't really make much sense. I assume you want to reduce the boilerplate, then we can make an helper to get the frame size and the number of channels / slots if needed Maxime --phliouq6fvfyh5hw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCX4RI6AAKCRDj7w1vZxhR xWZ/AQCPwhn7X1Jytz5VV8NHRQXexz4dJIIusxesiha4X1AN/gEAr9v/2MjG2Wpg A9g0xJSWTrZ3btCSWB5slUokdWcv9Q4= =cLEy -----END PGP SIGNATURE----- --phliouq6fvfyh5hw--