Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2073675pxk; Sat, 3 Oct 2020 07:21:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfaIXgon6cMod75YF94l1LecWye9IqZyLA7gbGAKmZNuqRwK11eTAoJszfIwn8N/sYtBB9 X-Received: by 2002:a17:906:390d:: with SMTP id f13mr6616726eje.86.1601734895994; Sat, 03 Oct 2020 07:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601734895; cv=none; d=google.com; s=arc-20160816; b=0SzngjV4+Y4bAbytAL5KFWCf4j/1MgHoee3rLDGEu+PADplk/g+qmvYES1lQ8SknRX CUgHrVtlZUMOU41MffZ+5ra8Y6xhTIx7Q58eIWSJwMncG58spAoqDwmiPM59YNJJivkr FF9rrkLSXbuAtW/PG0OQQLasntLtT3OOgqeRkBErrx+FBSYePYbmkq8R5dKrnnKuiaXF fiAf0cvOjqfv4shXdN4KpecBd1rl71CZ+Rckwe7Kxaw8qoDDoWRrNyYzLMOacSbUFrgA lHnAQiBkTitqvj9N8r6fNfVq9Lk5wNUrl3cJEuX9Of1T/gnNPcZaaDVOVTReoaLkdIPt eNsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IgkalPEbKtznNoSzLsc7BvU41TbdIgjUI3URRRrjqdg=; b=K1Ho6W62oeBj0+dqnkzjtlmtsEWAaCa6Sonv7LzA8u9z1i4sWjFNpRWs55LvR7vhtK YXQyAUThPyK3ed91qtCJZryG3/sSWQfdso9KlLGKmmdvufQ6a0b/swO3X37689m3cYiL 5C4uzV/ch4MOXyU2Y6CtmS+ylO5fn19W3awV+iXOBAWbTlLN5Bhm8kuwy6EbNDfhRxF8 ioNERvl5P6Wpanz7b3G7Z/mIRBT53zlOUegEle36rNKn/ZT/vB2rkPnW1gY8jsb1YHTv JDWpqGe52e3jIOgpxqnjb0cw6OcZjTqx4lh+0eC1hK6GXW72ENf1dzIGDR4AFlM5qiA1 ZRXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CH33hOXu; 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 pg3si3490749ejb.94.2020.10.03.07.21.13; Sat, 03 Oct 2020 07:21:35 -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=CH33hOXu; 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 S1725866AbgJCOUD (ORCPT + 99 others); Sat, 3 Oct 2020 10:20:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgJCOUA (ORCPT ); Sat, 3 Oct 2020 10:20:00 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33397C0613D0; Sat, 3 Oct 2020 07:20:00 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id s13so4339122wmh.4; Sat, 03 Oct 2020 07:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IgkalPEbKtznNoSzLsc7BvU41TbdIgjUI3URRRrjqdg=; b=CH33hOXu7gPOg/g8mUXl4obuEa1GtnpyQ+EtzU/2DZuhBCh9Laa5EuBtZYV+wFSBt8 1RRGj5pLB0X9QiMhxBnpkNRF85OnW8SvT3thneiU0qCi+bjua69BJjoR2YtpzMieaMgn F58RFLIJ4KzRLN8aqKSzTA/BxiRVqTlJOA0zbzdbSdIK8C6MFCr2/lzZ2haZg6fvPsqf H0HB9X4DOZj4g92wEwOVHrvFVQ7VH3QBZo7KWrD/HQVlWg3XP40DNCw4u8cvO9MDsOh/ Y4qUlUXS4VBA5PbJkhM5MOHiujtja3wFcyp56rkFNKsLjANlvbw8XI9xNCd25fpSXNvr SvXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IgkalPEbKtznNoSzLsc7BvU41TbdIgjUI3URRRrjqdg=; b=BDXqink3AcNtUBLkOha8kZRe0VqwjrRfo+LHG3GMsGVO6mmXajoKAHXIJzkoYOsIhu vs113s7PtzNaE0rWtaPfZdBQPtt904Oo3warEl7cXilaq7bs4JaKTXjNKI4rrXQwviTN 9324b1Wlh1aXHsX2YlbzmM1Q2EkN8la7TmnV4holjT1VsVXxwDq2rChfYw869jSOMQl9 sBgsAatfoqu5GQ38/63avI/jIV5rlMSwtCGy9+EV2HA2pR7+6ws6Hek/67rjRgInSq3B 9wMmlsCM0A+obuVNBXx5r3HuEeGdgxD4w7Nok3iIPNRhPevnjcBDHqYtNHtCrMLgyz3c vASw== X-Gm-Message-State: AOAM530RZCXeMoy4CvcNxeCHak9Y7cQAtHocFN3xPfJBE/Rb6gNqjHnE 02+ITQU6ECkhEzBKkZ8OgNiwz23+Ih4cgA== X-Received: by 2002:a1c:65c1:: with SMTP id z184mr7671690wmb.61.1601734798595; Sat, 03 Oct 2020 07:19:58 -0700 (PDT) Received: from clement-Latitude-7490.numericable.fr (213-245-241-245.rev.numericable.fr. [213.245.241.245]) by smtp.gmail.com with ESMTPSA id d18sm5417473wrm.10.2020.10.03.07.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Oct 2020 07:19:57 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= To: Maxime Ripard , Chen-Yu Tsai , Rob Herring , Mark Brown , Liam Girdwood Cc: Jaroslav Kysela , Takashi Iwai , Marcus Cooper , Jernej Skrabec , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= , Samuel Holland Subject: [PATCH v6 02/14] ASoC: sun4i-i2s: Change set_chan_cfg() params Date: Sat, 3 Oct 2020 16:19:38 +0200 Message-Id: <20201003141950.455829-3-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201003141950.455829-1-peron.clem@gmail.com> References: <20201003141950.455829-1-peron.clem@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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ément Péron --- 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 slots, + 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 slots, + unsigned int slot_width) { - unsigned int channels = 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 *params) + unsigned int channels, unsigned int slots, + unsigned int slot_width) { - unsigned int channels = params_channels(params); - unsigned int slots = channels; unsigned int lrck_period; - if (i2s->slots) - slots = 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 = params_physical_width(params) * slots; + lrck_period = slot_width * slots; break; case SND_SOC_DAIFMT_I2S: - lrck_period = params_physical_width(params); + lrck_period = 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 *params) + unsigned int channels, unsigned int slots, + unsigned int slot_width) { - unsigned int channels = params_channels(params); - unsigned int slots = channels; unsigned int lrck_period; - if (i2s->slots) - slots = i2s->slots; - /* Map the channels for playback and capture */ regmap_write(i2s->regmap, SUN50I_H6_I2S_TX_CHAN_MAP0_REG, 0xFEDCBA98); regmap_write(i2s->regmap, SUN50I_H6_I2S_TX_CHAN_MAP1_REG, 0x76543210); @@ -525,11 +517,11 @@ static int sun50i_h6_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 = params_physical_width(params) * slots; + lrck_period = slot_width * slots; break; case SND_SOC_DAIFMT_I2S: - lrck_period = params_physical_width(params); + lrck_period = slot_width; break; default: @@ -565,7 +557,7 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, if (i2s->slot_width) slot_width = i2s->slot_width; - ret = i2s->variant->set_chan_cfg(i2s, params); + ret = i2s->variant->set_chan_cfg(i2s, channels, slots, slot_width); if (ret < 0) { dev_err(dai->dev, "Invalid channel configuration\n"); return ret; -- 2.25.1