From patchwork Wed Oct 4 11:28:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 114771 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2997185qgn; Wed, 4 Oct 2017 04:28:19 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAKRHM0YM4WErmPTW1icYObfDh2IiwkXA16W5pGeiQCAyW4UD4qmJJO03ReJGZEPq1CSP9P X-Received: by 10.28.95.10 with SMTP id t10mr5897231wmb.86.1507116498958; Wed, 04 Oct 2017 04:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507116498; cv=none; d=google.com; s=arc-20160816; b=hT1XaQlK7Pm/Zyh3Hk2vDCEOWZ6+6Ywvn+A3I6TG9nO4rQV9UE2ImsREgBr0ATAViJ 19RXfgWcIe0wk1DnJsJJmmRrOQY3DxUduNBIAPgX397B4K4h7+pikwnjnc/sHg1wVxWi nxZZq25KJDVZ2rMlLJ+fEIaBeyozo/+44vhAVlvpEIW79ea6mE3LxiqV/1aZhF6iJ3vM JMjDa4sgAOJHy4ZydUhskynEm6mjhmIu8D7C0BFTFTuu0kbWuc62/kF5zISx+uMD/Phm ohFwuluRtXImtIDgCvZF2Ux8J+8cxKyKOHE9qJnVAuGNMPrVGEfXh3xeg5bKk1jZavVK yZYA== 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 :dkim-signature:delivered-to:arc-authentication-results; bh=5gPzEUGlnSfQ2zwJyouF4EZIEwYr9EYZzxj4SH+j/Gk=; b=Z/KvvmF+CI9UfG78vXufaXDo6cpzJ63NeaYWI6xFyexqiW+gPM7MdFf4tHdyLVbAgx O3ThB2WzzM0+6ro9aJqM4bfpt60veZvr4uQiZfNT35MF8qaFlGk4pua/MvUWSqJNbeTU yR6vS2651+pdNDIMEKHyBeajW89/nt7W3Z382c+/s32SRRldQWvQf3IOSJvTwJLfhBdP nyba6qDIFbSZ4CDm4fRfaTqIX3pD6XJbJTMrYmpp8X9lmcvlRzBPe95NOHGKQJLR4hab GuMp4rwLIot967BhJfPibiImt93DFQ0WOF21qB1rPqKvBme4LPgNEcwgIT73plXmjw/1 N+VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=DSEH4Zre; 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 (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id w7si7238398wma.166.2017.10.04.04.28.18; Wed, 04 Oct 2017 04:28:18 -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; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=DSEH4Zre; 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 alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 996652673E1; Wed, 4 Oct 2017 13:28:17 +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 C95132673F4; Wed, 4 Oct 2017 13:28:16 +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.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_NEUTRAL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id E04782673E5 for ; Wed, 4 Oct 2017 13:28:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=bsJ7tb3Nl+CqkD0/Mk35x5auyGQFqBCyQOLVjB6isTQ=; b=DSEH4ZreIaAm eA0Zn8EhJPadtUCfJMBTTa2+qv7BM6lJyX20LFVlVdxKBo5XjiiaPK5dowDT7COD6RN6W461VyNe1 XN4RJ+3+PIz2pH2wACZC7NLspJgERe2qwMNF81OuWBdelp0mupHO7LqX1cRkCqnm8nHg9m9DpZtfi z8qxs=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1dzhqQ-0006Xm-Jk; Wed, 04 Oct 2017 11:28:06 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1dzhqQ-0004Gq-4Z; Wed, 04 Oct 2017 12:28:06 +0100 From: Mark Brown To: Kuninori Morimoto In-Reply-To: <87tvzimo5w.wl%kuninori.morimoto.gx@renesas.com> Message-Id: Date: Wed, 04 Oct 2017 12:28:06 +0100 Cc: linux-renesas-soc@vger.kernel.org, alsa-devel@alsa-project.org, Mark Brown , Hiroyuki Yokoyama , Simon Subject: [alsa-devel] Applied "ASoC: rsnd: add MIX Volume Ramp support" 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 MIX Volume Ramp support 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 3e3c9ee1e4b3d0ef1f68f2037752196e7260bad9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 1 Oct 2017 23:49:18 +0000 Subject: [PATCH] ASoC: rsnd: add MIX Volume Ramp support Both DVC/MIX have Volume Ramp Control. This patch supprts MIX Volume Ramp. One note is that main purpose of MIX Volume Ramp is to reduce noise, thus, MIX Ramp range is very few if you compare to DVC Volume Ramp (DVC = 5bit, MIX = 4bit). You can use MIX Volume Ranp like below amixer set "MIX Ramp Up Rate" "0.125 dB/1 step" amixer set "MIX Ramp Down Rate" "0.125 dB/1 step" amixer set "MIX Ramp" on aplay xxx.wav & amixer set "MIX",0 80% // DAI0 Volume Down amixer set "MIX",1 100% // DAI1 Volume Up Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 2 +- sound/soc/sh/rcar/mix.c | 158 +++++++++++++++++++++++++++++++++++++++++++++-- sound/soc/sh/rcar/rsnd.h | 1 + 3 files changed, 154 insertions(+), 7 deletions(-) -- 2.14.1 _______________________________________________ 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/core.c b/sound/soc/sh/rcar/core.c index 2d94b3d4519c..e9b0b0f5f0ee 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1253,7 +1253,7 @@ const char * const volume_ramp_rate[] = { "1 dB/1 step", /* 00111 */ "0.5 dB/1 step", /* 01000 */ "0.25 dB/1 step", /* 01001 */ - "0.125 dB/1 step", /* 01010 */ + "0.125 dB/1 step", /* 01010 = VOLUME_RAMP_MAX_MIX */ "0.125 dB/2 steps", /* 01011 */ "0.125 dB/4 steps", /* 01100 */ "0.125 dB/8 steps", /* 01101 */ diff --git a/sound/soc/sh/rcar/mix.c b/sound/soc/sh/rcar/mix.c index 6c4826c189a4..912cfec49038 100644 --- a/sound/soc/sh/rcar/mix.c +++ b/sound/soc/sh/rcar/mix.c @@ -7,6 +7,33 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +/* + * CTUn MIXn + * +------+ +------+ + * [SRC3 / SRC6] -> |CTU n0| -> [MIX n0| -> + * [SRC4 / SRC9] -> |CTU n1| -> [MIX n1| -> + * [SRC0 / SRC1] -> |CTU n2| -> [MIX n2| -> + * [SRC2 / SRC5] -> |CTU n3| -> [MIX n3| -> + * +------+ +------+ + * + * ex) + * DAI0 : playback = <&src0 &ctu02 &mix0 &dvc0 &ssi0>; + * DAI1 : playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>; + * + * MIX Volume + * amixer set "MIX",0 100% // DAI0 Volume + * amixer set "MIX",1 100% // DAI1 Volume + * + * Volume Ramp + * amixer set "MIX Ramp Up Rate" "0.125 dB/1 step" + * amixer set "MIX Ramp Down Rate" "4 dB/1 step" + * amixer set "MIX Ramp" on + * aplay xxx.wav & + * amixer set "MIX",0 80% // DAI0 Volume Down + * amixer set "MIX",1 100% // DAI1 Volume Up + */ + #include "rsnd.h" #define MIX_NAME_SIZE 16 @@ -14,8 +41,27 @@ struct rsnd_mix { struct rsnd_mod mod; + struct rsnd_kctrl_cfg_s volumeA; /* MDBAR */ + struct rsnd_kctrl_cfg_s volumeB; /* MDBBR */ + struct rsnd_kctrl_cfg_s volumeC; /* MDBCR */ + struct rsnd_kctrl_cfg_s volumeD; /* MDBDR */ + struct rsnd_kctrl_cfg_s ren; /* Ramp Enable */ + struct rsnd_kctrl_cfg_s rup; /* Ramp Rate Up */ + struct rsnd_kctrl_cfg_s rdw; /* Ramp Rate Down */ + u32 flags; }; +#define ONCE_KCTRL_INITIALIZED (1 << 0) +#define HAS_VOLA (1 << 1) +#define HAS_VOLB (1 << 2) +#define HAS_VOLC (1 << 3) +#define HAS_VOLD (1 << 4) + +#define VOL_MAX 0x3ff + +#define rsnd_mod_to_mix(_mod) \ + container_of((_mod), struct rsnd_mix, mod) + #define rsnd_mix_get(priv, id) ((struct rsnd_mix *)(priv->mix) + id) #define rsnd_mix_nr(priv) ((priv)->mix_nr) #define for_each_rsnd_mix(pos, priv, i) \ @@ -36,26 +82,43 @@ static void rsnd_mix_halt(struct rsnd_mod *mod) rsnd_mod_write(mod, MIX_SWRSR, 0); } +#define rsnd_mix_get_vol(mix, X) \ + rsnd_flags_has(mix, HAS_VOL##X) ? \ + (VOL_MAX - mix->volume##X.cfg.val[0]) : 0 static void rsnd_mix_volume_parameter(struct rsnd_dai_stream *io, struct rsnd_mod *mod) { - rsnd_mod_write(mod, MIX_MDBAR, 0); - rsnd_mod_write(mod, MIX_MDBBR, 0); - rsnd_mod_write(mod, MIX_MDBCR, 0); - rsnd_mod_write(mod, MIX_MDBDR, 0); + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); + struct rsnd_mix *mix = rsnd_mod_to_mix(mod); + u32 volA = rsnd_mix_get_vol(mix, A); + u32 volB = rsnd_mix_get_vol(mix, B); + u32 volC = rsnd_mix_get_vol(mix, C); + u32 volD = rsnd_mix_get_vol(mix, D); + + dev_dbg(dev, "MIX A/B/C/D = %02x/%02x/%02x/%02x\n", + volA, volB, volC, volD); + + rsnd_mod_write(mod, MIX_MDBAR, volA); + rsnd_mod_write(mod, MIX_MDBBR, volB); + rsnd_mod_write(mod, MIX_MDBCR, volC); + rsnd_mod_write(mod, MIX_MDBDR, volD); } static void rsnd_mix_volume_init(struct rsnd_dai_stream *io, struct rsnd_mod *mod) { + struct rsnd_mix *mix = rsnd_mod_to_mix(mod); + rsnd_mod_write(mod, MIX_MIXIR, 1); /* General Information */ rsnd_mod_write(mod, MIX_ADINR, rsnd_runtime_channel_after_ctu(io)); /* volume step */ - rsnd_mod_write(mod, MIX_MIXMR, 0); - rsnd_mod_write(mod, MIX_MVPDR, 0); + rsnd_mod_write(mod, MIX_MIXMR, mix->ren.cfg.val[0]); + rsnd_mod_write(mod, MIX_MVPDR, mix->rup.cfg.val[0] << 8 | + mix->rdw.cfg.val[0]); /* common volume parameter */ rsnd_mix_volume_parameter(io, mod); @@ -109,11 +172,94 @@ static int rsnd_mix_quit(struct rsnd_mod *mod, return 0; } +static int rsnd_mix_pcm_new(struct rsnd_mod *mod, + struct rsnd_dai_stream *io, + struct snd_soc_pcm_runtime *rtd) +{ + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); + struct rsnd_mix *mix = rsnd_mod_to_mix(mod); + struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io); + struct rsnd_kctrl_cfg_s *volume; + int ret; + + switch (rsnd_mod_id(src_mod)) { + case 3: + case 6: /* MDBAR */ + volume = &mix->volumeA; + rsnd_flags_set(mix, HAS_VOLA); + break; + case 4: + case 9: /* MDBBR */ + volume = &mix->volumeB; + rsnd_flags_set(mix, HAS_VOLB); + break; + case 0: + case 1: /* MDBCR */ + volume = &mix->volumeC; + rsnd_flags_set(mix, HAS_VOLC); + break; + case 2: + case 5: /* MDBDR */ + volume = &mix->volumeD; + rsnd_flags_set(mix, HAS_VOLD); + break; + default: + dev_err(dev, "unknown SRC is connected\n"); + return -EINVAL; + } + + /* Volume */ + ret = rsnd_kctrl_new_s(mod, io, rtd, + "MIX Playback Volume", + rsnd_kctrl_accept_anytime, + rsnd_mix_volume_update, + volume, VOL_MAX); + if (ret < 0) + return ret; + volume->cfg.val[0] = VOL_MAX; + + if (rsnd_flags_has(mix, ONCE_KCTRL_INITIALIZED)) + return ret; + + /* Ramp */ + ret = rsnd_kctrl_new_s(mod, io, rtd, + "MIX Ramp Switch", + rsnd_kctrl_accept_anytime, + rsnd_mix_volume_update, + &mix->ren, 1); + if (ret < 0) + return ret; + + ret = rsnd_kctrl_new_e(mod, io, rtd, + "MIX Ramp Up Rate", + rsnd_kctrl_accept_anytime, + rsnd_mix_volume_update, + &mix->rup, + volume_ramp_rate, + VOLUME_RAMP_MAX_MIX); + if (ret < 0) + return ret; + + ret = rsnd_kctrl_new_e(mod, io, rtd, + "MIX Ramp Down Rate", + rsnd_kctrl_accept_anytime, + rsnd_mix_volume_update, + &mix->rdw, + volume_ramp_rate, + VOLUME_RAMP_MAX_MIX); + + rsnd_flags_set(mix, ONCE_KCTRL_INITIALIZED); + + return ret; +} + static struct rsnd_mod_ops rsnd_mix_ops = { .name = MIX_NAME, .probe = rsnd_mix_probe_, .init = rsnd_mix_init, .quit = rsnd_mix_quit, + .pcm_new = rsnd_mix_pcm_new, }; struct rsnd_mod *rsnd_mix_mod_get(struct rsnd_priv *priv, int id) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 9d66a15000fa..0d9f9c3343da 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -662,6 +662,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, extern const char * const volume_ramp_rate[]; #define VOLUME_RAMP_MAX_DVC (0x17 + 1) +#define VOLUME_RAMP_MAX_MIX (0x0a + 1) /* * R-Car SSI