Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3297867pxk; Mon, 5 Oct 2020 06:25:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjAWAM3I6jT0WQuLe8YeANDlH5FrZEHFUs29KI0WaKfvamoLgU5BPXa1Bk6a3P1R5ayrax X-Received: by 2002:aa7:c497:: with SMTP id m23mr17393729edq.57.1601904305918; Mon, 05 Oct 2020 06:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601904305; cv=none; d=google.com; s=arc-20160816; b=vrsBCsEpBOxpqqHWzQrdh+yzL1R5rjTt5JdDBzIrkDLAW/q9tJ9E/I4X0I9vU25uQF 0uCUhDD362aHAXtBH136GVYVNYV8mlOXFVT47REc10sSHOnSANVm3wj2kNVU50lnU5ci qms98pZa7RfQl8aCQxKqtTqOTKV/qoWBTkmt6k/QSgyIGuTi9A4mrGvGwN8f6HhZECe9 B5YhqJFnGME8djxFn9RdXKWbc/ByGIecjloTjB0eL+twCv7xBwWFZ5fJD8aCK5LLDWSR m4RcF5DToDMqAG/1lanhpAsoq1xPa6Yy9711yJok3s/ARWSKlJ3KnBRChKmJpvhQ7Yd4 VcdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=weoxlCL4s68iLYumYf/JNpJEA/fRjS1GFyVHxrT3h78=; b=0POMp00DR6plTkfo6f1THYdt3wQXSZk9IhvXJobIlYWft59KsJlzjJtMaQq+8jBVE5 R/ykIoqSERMJQP7op6xR8PaVFLCSmaTP4nlzvuj/vA2y//Ulp2cVQXxtzKPyYVixOKr3 9O8QIXhxkDWJYguxcrnkXLuHxXhU5xI41ntYup2z/gVXBE2g0mkXTAvVsdJO9pTl5Aa2 E8qkhPj8dP3H07+y0rc/5n+G7Tp6RmX3g1Ay9RorudyQtKWNBlvxQa0fw29JjJqMS4ja Km/BijT7l6g2blBD7CaKf+7/gZAEGSkXZGi3jGYYcAKijo9xtsqWwhtsZeV7GIKCv9rb a2gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gbr3xWDv; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g90si8760902edd.205.2020.10.05.06.24.39; Mon, 05 Oct 2020 06:25:05 -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=@gmail.com header.s=20161025 header.b=Gbr3xWDv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725983AbgJENXZ (ORCPT + 99 others); Mon, 5 Oct 2020 09:23:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgJENXY (ORCPT ); Mon, 5 Oct 2020 09:23:24 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0601C0613CE; Mon, 5 Oct 2020 06:23:24 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id g7so9045732iov.13; Mon, 05 Oct 2020 06:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=weoxlCL4s68iLYumYf/JNpJEA/fRjS1GFyVHxrT3h78=; b=Gbr3xWDvbVqxUML79XLnV/AUmP/ErPLZoHbMZ7f0nGxyEBzHSpYYq4zpcU/awEGQ+w /mo76U6ltG3G9MhSVSuhSghO6J4kuPoXF+gNIrsI8ugoQCx0wyHPEk0ZBVaRlToS5mUW QZLxg51j9mlubjHWEJFlTvAmhCsae4AKO4/CeWSpv5l20h09PRlcnQDWQLTR3hMzJONF 9VOlF5pWJx+mwbrYkncigo3MGAbXWkHPR7kL/uc3H8l6pQjfrtmNSfmKP7+sYtWpT3bX QiGD96Qpw34aPE2eV0ad+h5U5cnv35lOUUWiz0cR+0Kt9NbqWrQXCuGjHJmpsmMfMZmO 9CZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=weoxlCL4s68iLYumYf/JNpJEA/fRjS1GFyVHxrT3h78=; b=gfWRYlCfopUbFldoTTxrXPv8b32csN/KU4KaSQkeAP4EuDGDDKxnes+AT1fx+AR576 yDf0DANewOiRhlPT0MX60jBqot3X7d8CytJ47rG4NuYvXz9ARIOsfze1XG/6zT355k02 KVZANXOWtxVaybFLcRFy6w9cH+lhG4o7aos14irTOD9SHbIkHJ8fo/zz1MP48ABt1lti hxikvMeu/Akh8uEZP1np3N9C37VeHCHDzhEbOOVXwBiV7EuhOEHPGFiZuoiJMNSVkU6y fPosqT/9hjwoJKdE/UoqMkT6zxKcbWuEW/iFgoCmHkO9RL98BQ1OLcRSCMAJEqzJ0OqU eDpQ== X-Gm-Message-State: AOAM530Lfhog1rwmr7NXcJpwXn8HLoKRiC8SAfG2VZYfsFy4YxenGmQO KSAYmxmhyllhceyqqiO9EhZ3ZWTkXkl1LWd+elw= X-Received: by 2002:a5d:8ace:: with SMTP id e14mr10756345iot.124.1601904203837; Mon, 05 Oct 2020 06:23:23 -0700 (PDT) MIME-Version: 1.0 References: <20201003141950.455829-1-peron.clem@gmail.com> <20201003141950.455829-3-peron.clem@gmail.com> <20201005121307.v6jpyeyfi4kxc2cl@gilmour.lan> In-Reply-To: <20201005121307.v6jpyeyfi4kxc2cl@gilmour.lan> From: =?UTF-8?B?Q2zDqW1lbnQgUMOpcm9u?= Date: Mon, 5 Oct 2020 15:23:12 +0200 Message-ID: Subject: Re: [PATCH v6 02/14] ASoC: sun4i-i2s: Change set_chan_cfg() params To: Maxime Ripard 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime, On Mon, 5 Oct 2020 at 14:13, Maxime Ripard wrote: > > On Sat, Oct 03, 2020 at 04:19:38PM +0200, Cl=C3=A9ment P=C3=A9ron 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=C3=A9ment P=C3=A9ron > > --- > > 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 slot= s, > > + 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 sun4i_= i2s *i2s, int width) > > } > > > > static int sun4i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, > > - const struct snd_pcm_hw_params *params) > > + unsigned int channels, unsigned int slo= ts, > > + 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 su= n4i_i2s *i2s, > > } > > > > static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, > > - const struct snd_pcm_hw_params *params) > > + unsigned int channels, unsigned int slo= ts, > > + 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 su= n4i_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 su= n4i_i2s *i2s, > > } > > > > static int sun50i_h6_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, > > - const struct snd_pcm_hw_params *par= ams) > > + unsigned int channels, unsigned int= 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, 0xFEDCB= A98); > > regmap_write(i2s->regmap, SUN50I_H6_I2S_TX_CHAN_MAP1_REG, 0x76543= 210); > > @@ -525,11 +517,11 @@ static int sun50i_h6_i2s_set_chan_cfg(const struc= t 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_subst= ream *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_wid= th); > > Isn't slots and slot_width set to 0 here ? No, there is still a check before calling the set_cfg function. unsigned int slot_width =3D params_physical_width(params); unsigned int channels =3D params_channels(params); unsigned int slots =3D channels; if (i2s->slots) slots =3D i2s->slots; if (i2s->slot_width) slot_width =3D i2s->slot_width; ret =3D i2s->variant->set_chan_cfg(i2s, channels, slots, slot_width); So slot_width will be equal to params_physical_width(params); like before Clement > > And therefore, wouldn't we set lrck_period to 0 if we're using any > format but I2S? > > More importantly, I'm not really convinced this needs to be done, and it > introduces some side effects that are not explained. > > Maxime