From patchwork Thu Jun 15 17:20:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 105681 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp909455qgd; Thu, 15 Jun 2017 10:21:27 -0700 (PDT) X-Received: by 10.28.92.130 with SMTP id q124mr1254608wmb.21.1497547286972; Thu, 15 Jun 2017 10:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497547286; cv=none; d=google.com; s=arc-20160816; b=iSi11MvnXD7sE3eUBOyADluBes2Z1E8fA7QUoKQ8HdkLILnV+L1ur/X04fMiDOELW2 imCuR0DeRWjnxSvGnQsBC5u49+vom8NLPDHKvehNMDxjUNQ9KfUg7nMLnjzqHvIp2twi tXBon3bL6Zke5uMB/5IJHzMUWHKz3PPVD9dQ0rIc//N+HH8+nCy03azXJJ7Zis61A5dy nbM+oJ+iPLPwcOTtf06ChlNr9/vx6U1X02RHIOEhRzvjfkuh+2Qbu9UADUv15TkHjw7T T4CqBNfr/F+U4dT2oCeqdU4UyjUJR13eNxxECV10Ds4hO5vYulPDrEn2nMWxAeEdVjRl ojKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :delivered-to:arc-authentication-results; bh=E8RkGcKLsaGb1053U+XO3KqD8Dcf4TrQJOnp9hVR1dA=; b=AVBUwVuZBJrCeRUEIWT0PQQJPNqcJEsG/YPWEZVzE7g3Pim0Gr6uttygCs1mOXZElb KRKoPvGvn9iOUe5WELTkx87lgOnBS0hRdgkgcAj+f7jkK++nkR3iwmrP4AR9OekhImfO M+mMq6/kT8vsTzeFR+0ofOK9XDuBzoRnbFUw1U2BQE4lh1xOMEkhaAJ8DgusefyPMPzC xdsup5FLGRGwTp1pdn2nsafp/0PlwPqlVUdLws737MqmNOrzuFgYh25honLeKrBTMlhY 1XAv8AT8kWkKLW60bIu0SgLFhccjFSaRkOMO6365gfqkUgrxnRXpG16l5Bi7yOEgmcwd WC4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz ([77.48.224.243]) by mx.google.com with ESMTP id 75si623860wmk.106.2017.06.15.10.21.26; Thu, 15 Jun 2017 10:21:26 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa.alsa-project.org (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D03D82673E2; Thu, 15 Jun 2017 19:20:58 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 909AF2673DC; Thu, 15 Jun 2017 19:20:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mezzanine.sirena.org.uk (mezzanine.sirena.org.uk [106.187.55.193]) by alsa0.perex.cz (Postfix) with ESMTP id CB46A266AFC for ; Thu, 15 Jun 2017 19:20:23 +0200 (CEST) Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1dLYRN-0001zB-RF; Thu, 15 Jun 2017 17:20:20 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1dLYRL-0001bP-Cq; Thu, 15 Jun 2017 18:20:15 +0100 From: Mark Brown To: Kuninori Morimoto In-Reply-To: <87injym64o.wl%kuninori.morimoto.gx@renesas.com> Message-Id: Date: Thu, 15 Jun 2017 18:20:15 +0100 X-SA-Exim-Connect-IP: 2001:470:1f1d:6b5::3 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: No (on mezzanine.sirena.org.uk); Unknown failure Cc: linux-renesas-soc@vger.kernel.org, alsa-devel@alsa-project.org, Mark Brown , Hiroyuki Yokoyama , Simon Subject: [alsa-devel] Applied "ASoC: rsnd: add rsnd_ssi_clk_query()" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: rsnd: add rsnd_ssi_clk_query() has been applied to the asoc tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From ef4cf5d6a143e04e149ad81fc491fe10855544fe Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jun 2017 00:50:02 +0000 Subject: [PATCH] ASoC: rsnd: add rsnd_ssi_clk_query() Current Renesas sound driver is assuming that all Sampling rate and channles are possible to use, but these are depends on inputed clock and SSI connection situation. For example, if it is using 1 SSI, enabled TDM mode and has 12288000 input clock, 2ch output can support until 192000Hz, but 6ch output can support until 64000Hz, 8ch can support 48000Hz. To control these situation correctly, it needs to support hw_constraints / refine feature. To support such feature, this patch adds new rsnd_ssi_clk_query(). Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama Signed-off-by: Mark Brown --- sound/soc/sh/rcar/rsnd.h | 2 + sound/soc/sh/rcar/ssi.c | 95 ++++++++++++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 39 deletions(-) -- 2.11.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 7b76f3998fd7..3aa07a07bbcb 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -679,6 +679,8 @@ int __rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod); void rsnd_parse_connect_ssi(struct rsnd_dai *rdai, struct device_node *playback, struct device_node *capture); +int rsnd_ssi_clk_query(struct rsnd_priv *priv, + int param1, int param2, int *idx); /* * R-Car SSIU diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 6450095eb547..c8956c3484dd 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -208,6 +208,46 @@ u32 rsnd_ssi_multi_slaves_runtime(struct rsnd_dai_stream *io) return 0; } +int rsnd_ssi_clk_query(struct rsnd_priv *priv, + int param1, int param2, int *idx) +{ + int ssi_clk_mul_table[] = { + 1, 2, 4, 8, 16, 6, 12, + }; + int j, ret; + int main_rate; + + for (j = 0; j < ARRAY_SIZE(ssi_clk_mul_table); j++) { + + /* + * It will set SSIWSR.CONT here, but SSICR.CKDV = 000 + * with it is not allowed. (SSIWSR.WS_MODE with + * SSICR.CKDV = 000 is not allowed either). + * Skip it. See SSICR.CKDV + */ + if (j == 0) + continue; + + /* + * this driver is assuming that + * system word is 32bit x chan + * see rsnd_ssi_init() + */ + main_rate = 32 * param1 * param2 * ssi_clk_mul_table[j]; + + ret = rsnd_adg_clk_query(priv, main_rate); + if (ret < 0) + continue; + + if (idx) + *idx = j; + + return main_rate; + } + + return -EINVAL; +} + static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, struct rsnd_dai_stream *io) { @@ -217,10 +257,7 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); struct rsnd_mod *ssi_parent_mod = rsnd_io_to_mod_ssip(io); int chan = rsnd_runtime_channel_for_ssi(io); - int j, ret; - int ssi_clk_mul_table[] = { - 1, 2, 4, 8, 16, 6, 12, - }; + int idx, ret; unsigned int main_rate; unsigned int rate = rsnd_io_is_play(io) ? rsnd_src_get_out_rate(priv, io) : @@ -244,45 +281,25 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, return 0; } - /* - * Find best clock, and try to start ADG - */ - for (j = 0; j < ARRAY_SIZE(ssi_clk_mul_table); j++) { - - /* - * It will set SSIWSR.CONT here, but SSICR.CKDV = 000 - * with it is not allowed. (SSIWSR.WS_MODE with - * SSICR.CKDV = 000 is not allowed either). - * Skip it. See SSICR.CKDV - */ - if (j == 0) - continue; - - /* - * this driver is assuming that - * system word is 32bit x chan - * see rsnd_ssi_init() - */ - main_rate = rate * 32 * chan * ssi_clk_mul_table[j]; - - ret = rsnd_adg_ssi_clk_try_start(mod, main_rate); - if (0 == ret) { - ssi->cr_clk = FORCE | SWL_32 | - SCKD | SWSD | CKDV(j); - ssi->wsr = CONT; + main_rate = rsnd_ssi_clk_query(priv, rate, chan, &idx); + if (main_rate < 0) { + dev_err(dev, "unsupported clock rate\n"); + return -EIO; + } - ssi->rate = rate; + ret = rsnd_adg_ssi_clk_try_start(mod, main_rate); + if (ret < 0) + return ret; - dev_dbg(dev, "%s[%d] outputs %u Hz\n", - rsnd_mod_name(mod), - rsnd_mod_id(mod), rate); + ssi->cr_clk = FORCE | SWL_32 | SCKD | SWSD | CKDV(idx); + ssi->wsr = CONT; + ssi->rate = rate; - return 0; - } - } + dev_dbg(dev, "%s[%d] outputs %u Hz\n", + rsnd_mod_name(mod), + rsnd_mod_id(mod), rate); - dev_err(dev, "unsupported clock rate\n"); - return -EIO; + return 0; } static void rsnd_ssi_master_clk_stop(struct rsnd_mod *mod,