Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3116123ybl; Mon, 19 Aug 2019 12:28:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqydMrt5EocoOD2nNFZloPcM2Dsu7Ybs5SlyWEhe35k0cHyL+dGakEFjElAQeS4PutEggvYL X-Received: by 2002:a17:90a:fc90:: with SMTP id ci16mr22320893pjb.48.1566242930037; Mon, 19 Aug 2019 12:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566242930; cv=none; d=google.com; s=arc-20160816; b=ZD5ImRI86U4QWOERUoIqrhTMVqwDwS2B20bLAv/IAQlBBkxNnNZ3M1b65yNO65Lm9z khUeD1+m6uYCU3ElgjFUgUF9Fcyd2p07rEQxCH6jJAhevXfkY+Ug9kML9XPWKzhPjUny QFfocXoxe0qdx7qnYWiVYcUw7Q/+jJvMDwnoUPgOTs7xOlpG5pBdquNZATyZO5CQVg4w cpHm4MStC6r2p5dEHcyYgZfOWOI6lgeyeEYaBP1GnaOT9Su3kfFApFbAyu10oRzcZnLJ 28FwKjbLYTS/kR8kTHY55p/MJFGqqYwFs3ZXDeT0VNeRyrAP27vdX96nwuq+2g1uNiqW cSJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cjGaqEiHsahOem+J2CwALzQgYGzneKGcauE6XUwSaTE=; b=g4OXRdRYzPhqY8gj95ceceNhsZETnpycY2JHvmYDWKys511+qQa9nc6c88OVMDu5Ik 2Vc5eiz2/LT7hp6RW9cKYED70zmjpiA1Rs+xAUGD2kW4NJIr4u6VVjgEPm/wHOoHIQ+B /pChyUp0p8zNW7bOgBlvWdk9R9Ght0334rrddhxepolJYOGosAq3pqy8h2/QgVbjirsW U9u3+6NRyoXZ2prv20L5Z4QLg0TTA9zexMgcIDu3wqvy3bn2BdPA514GPLIQZX+SfHuJ MHAl6RXR6HK3T7sZgb0RWiMsj82dBuykGyFTBQZRsvwqIgT+VAGiRFqk/v3O0dO8104x ou3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jX5YpjCR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si9428170pji.65.2019.08.19.12.28.34; Mon, 19 Aug 2019 12:28:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jX5YpjCR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728865AbfHST1M (ORCPT + 99 others); Mon, 19 Aug 2019 15:27:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:42456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728737AbfHST01 (ORCPT ); Mon, 19 Aug 2019 15:26:27 -0400 Received: from localhost (lfbn-1-10718-76.w90-89.abo.wanadoo.fr [90.89.68.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 14FF4206C1; Mon, 19 Aug 2019 19:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566242786; bh=lxoSThi24SXgg6Bi+ISpQJ6IhICcstHztsngc91tupU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jX5YpjCR6Cy5taU2uu95MCXzwXruGWw5Fg3YRi8pLtYNw8bHv3htNZ+8dlD3NSYZ/ 8mVF3pTOnIEeSdHhUy6ijh4GvuTjyCyzEWz8AcBevmuSWJ8LbjFW9HBO5FAjJs+9/b YTCaAM6cXrVVF1XIcSDWMwsKaXhav19FUncboFss= From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard , lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, codekipper@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 18/21] ASoC: sun4i-i2s: Pass the channels number as an argument Date: Mon, 19 Aug 2019 21:25:25 +0200 Message-Id: <48887cf7abfaab6597db233b24d7a088a913e48a.1566242458.git-series.maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxime Ripard The channels number have been hardcoded to 2 so far, while the controller supports more than that. Remove the instance where it has been hardcoded to compute the BCLK divider, and pass it through as an argument to ease further support of more channels. Signed-off-by: Maxime Ripard --- sound/soc/sunxi/sun4i-i2s.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 5dcbab0b4bcb..905e9bd16024 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -238,10 +238,11 @@ static unsigned long sun8i_i2s_get_bclk_parent_rate(const struct sun4i_i2s *i2s) static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s, unsigned long parent_rate, unsigned int sampling_rate, + unsigned int channels, unsigned int word_size) { const struct sun4i_i2s_clk_div *dividers = i2s->variant->bclk_dividers; - int div = parent_rate / sampling_rate / word_size / 2; + int div = parent_rate / sampling_rate / word_size / channels; int i; for (i = 0; i < i2s->variant->num_bclk_dividers; i++) { @@ -286,6 +287,7 @@ static bool sun4i_i2s_oversample_is_valid(unsigned int oversample) static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, unsigned int rate, + unsigned int channels, unsigned int word_size) { struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); @@ -333,7 +335,7 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, bclk_parent_rate = i2s->variant->get_bclk_parent_rate(i2s); bclk_div = sun4i_i2s_get_bclk_div(i2s, bclk_parent_rate, - rate, word_size); + rate, channels, word_size); if (bclk_div < 0) { dev_err(dai->dev, "Unsupported BCLK divider: %d\n", bclk_div); return -EINVAL; @@ -488,7 +490,7 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, regmap_field_write(i2s->field_fmt_sr, sr); return sun4i_i2s_set_clk_rate(dai, params_rate(params), - params_width(params)); + 2, params_width(params)); } static int sun4i_i2s_set_soc_fmt(const struct sun4i_i2s *i2s, -- git-series 0.9.1