Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3028639pxk; Mon, 21 Sep 2020 03:31:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKN5i2Nmr3E1Y7m5lfiLqg05PzROu6SLCyqDIrU9xyO97UUKzEaeo+iINclXN9VMvJO2Lo X-Received: by 2002:a50:d4ce:: with SMTP id e14mr53263372edj.126.1600684260210; Mon, 21 Sep 2020 03:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600684260; cv=none; d=google.com; s=arc-20160816; b=J2CFYpdNdzZ0oqxSTiOTl7GVh2r1yiDo+jWcZhCRkYtM+IdKrKRp9n19M+FMAbzQ4W DO/2WUyzEDqGWvizrZK3yCZuyra5vljRRZmgtcD0oe2G537I9Z4fj1UviyjLt0ad/pir O9cxz6zSd4bCPZZhyYJQK8qBjhPhv7TpCq4qJmcSSdTphl/diPPzKTodItcciCdew9SK 9ZlSL3Q31qWdi+hZvqr29u+OwP/+0AVhEgDC5o6uw0QPOLtFtQoRSyVzwHXxjezjZT1b Q3ZIwdK/YobIHCiClssqRSZ/UP9K1Y2yqfYvF6bPObVudoZ9CcWttlRlQa8zox5sVZAi xaCQ== 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=J9ky65YbsZC3CedpwwIal2HmJikYG0o0zSGAmShyp9M=; b=cN48NG87DCV+i3uentHPk/GiGPel4On1h+K5ulrRztIdd/j9qkLHoTEYLiQdxuCLFu 7sslLSS8FKotT7UVBq1AZKzjxGCMPKdK7qawMzPXik6sa7iFsSm9XgBf18uH5zQUVS2+ gc2i81Zpx0F92ZfuFrnu9OwgsS0U1XyfWCp5/z21J4/hEyA4WhjKyQ45TjafC97Oc8dZ v1nlSDr26ylkdzvw3V5OHDMANABkZFLkQlzQnD3so2skj+QtR9V6KFaZ5ocvVtW9gNIb FyY/xS36w92mQD8NxR0W2PaDjl+vwyc9Ps01V8s/KA/Vso2bfiKPhmBR2KkSoPclu1Ju cRwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="fmW/8c7E"; 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 u10si8144327ejx.142.2020.09.21.03.30.37; Mon, 21 Sep 2020 03:31:00 -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="fmW/8c7E"; 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 S1726603AbgIUK1m (ORCPT + 99 others); Mon, 21 Sep 2020 06:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbgIUK1j (ORCPT ); Mon, 21 Sep 2020 06:27:39 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15EE4C0613CF; Mon, 21 Sep 2020 03:27:39 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id x23so11563779wmi.3; Mon, 21 Sep 2020 03:27:39 -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=J9ky65YbsZC3CedpwwIal2HmJikYG0o0zSGAmShyp9M=; b=fmW/8c7EA0BKO4rC8y+/NIKl9FUO4rC+CEaKG+BWT+d5ZAFB6OKb7htadnZXJd33aY uZer4yI/mkG+9whINtJqlZxB5HPzGC6+a4jZdvs7aBMHbpl0aLtDvwaeS0voreBbd3Rv UixGYTnvEEiWKfMsnDmekB15LLLiErK82ZK6T+5D55KekZq5XK+VlDDhAQU/CxauNtXL 27Iof80Bl/lT77qT2SZh+Un3TeTs8ekHSSPrkcsAf83frtDuBPvsJVE7rsjBxIZ0i1Jn NOvl9o8DHIgQ43gFhJ+RgcF1srDM3uT2aLoy+XoFRVmVL1LpB3fS5j98JzYl9xkZU+HZ r+uA== 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=J9ky65YbsZC3CedpwwIal2HmJikYG0o0zSGAmShyp9M=; b=uCVWSwZt7ZwfJis+fgl5K1GlOaM5oLmIwa+2VBF19+91eWxB15Ubj3Cd+ABiVUYlIE T7Rjw8/u2lXqklZNaI2TF8SICEr6JtBh/CSzGOccJKztIesLgsO8vM+HDSnl0Mlb8nmt 5BzyZ0C9YC7YvWB8hqlmRWpinHdF50Ajcvr4Fx13ZduWyXm3rF8SmZErvY3HeVxytREZ aCC5NSuNoPsb3B2dmXPmKE5oQg3DM5BqpXL4yqxo+/LvDpixCgUA8wG+trhcWcnMwecO UAMLwlRUWkE1Gozku2ux6nTi+KR9Bqf6C9aqBcn/nVC80QlSqhRRcQ3xqdHIR/zal1OS cniw== X-Gm-Message-State: AOAM531D9T5i6/to0EgM23P2+pardTXbAEmR4QmeUB6UxVsoZ/sF5rZ7 xJO5ZvjhAteIGNLRLgN88ew= X-Received: by 2002:a1c:e484:: with SMTP id b126mr28632272wmh.44.1600684057701; Mon, 21 Sep 2020 03:27:37 -0700 (PDT) Received: from localhost.localdomain (lputeaux-656-1-11-33.w82-127.abo.wanadoo.fr. [82.127.142.33]) by smtp.gmail.com with ESMTPSA id h2sm20713774wrp.69.2020.09.21.03.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 03:27:36 -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 v4 02/22] ASoC: sun4i-i2s: Change set_chan_cfg() params Date: Mon, 21 Sep 2020 12:27:11 +0200 Message-Id: <20200921102731.747736-3-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200921102731.747736-1-peron.clem@gmail.com> References: <20200921102731.747736-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 overwritter in case set_tdm() is called. Avoid to have this logic in set_chan_cfg(). Instead pass the required values as params to set_chan_cfg(). This also fix a bug when i2s->slot_width is set for TDM but not properly used in set_chan_cfg(). 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 2baf6c276280..0633b9fba3d7 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_MAP1_REG, 0x76543210); regmap_write(i2s->regmap, SUN50I_H6_I2S_RX_CHAN_MAP1_REG, 0x76543210); @@ -523,11 +515,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: @@ -563,7 +555,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