Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3930832pxu; Mon, 12 Oct 2020 05:17:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTfNL3E3QF7Mm4LvgtWXEnn/CORffQ3x5EAgyZuK27VmhS632ogFuEXbfSaTBqW9I1CRo/ X-Received: by 2002:aa7:dc50:: with SMTP id g16mr13712451edu.95.1602505047380; Mon, 12 Oct 2020 05:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602505047; cv=none; d=google.com; s=arc-20160816; b=N38hcIEpP1Sa/7d6rnPh39EL8jW9GEFDespxXZBBVVxRZ/qX1UpcwRRFbCoeROzKru XyXFk0l6k+rhSMrw8QskCXS+ektSG3et4thPgCDzgNLolICCKOC9KlM2ZqAbIxXUaSUb rgk8uBVsx8GDDByWB7Cg9EWR6PygoFy1yOcovfcaWL1fmUmP+ohUUH1Qox5AROhayU+/ pl6NsLNdfQjUiinamg5GltUy+TicLSxJtNrVIVmaSzm+p4PaLgFgSJFT4Rurik2dWa/K U6zNKCIlFG+icoT6kd/oRo3241pu98nB0K1psSFYNO45aI6/O8uNKt1sUg0ug4/2USm8 Ha0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=IjmSkHG+RebQZ02RSsHtc/0Z3Iz8rbb2V+2upqrHWA0=; b=Z19WdlWYp9EgWM41H62sAPsWGPxIsHDlO2HzVpSV+cfDkQasF9m4kQKh1f75PYtUxZ lIgoueKcOK40td7RJl7fyvINeK0YdKSJspvbFlvPfruMTVkdDSXzyBV/brFM6SU2ilNI I9nHEJaWCASirrUv8S8JRCNsBW+AigYW3D9c6DlTPqi57vXCDDihlD20WX88EtNUFE69 gml8CPAT7529IgtvrcO9mZR8kCAA8HvNOxULO/N1fbE6IY1DLDqOoanlKRznHPrVm/Uo 9YnpT3cQ+VzfALcHOiWsaBmfp8ClFd5TnrjPBLVIMTvnp9Qy9Kv3tdK6eMvaV7TavYeu BoyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm1 header.b=ZsikuYpn; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Tq2O1ndJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gx3si11546190ejb.749.2020.10.12.05.17.03; Mon, 12 Oct 2020 05:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm1 header.b=ZsikuYpn; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Tq2O1ndJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388456AbgJLMPm (ORCPT + 99 others); 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: linux-kernel@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--