All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	Simon <horms@verge.net.au>, Liam Girdwood <lgirdwood@gmail.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: [PATCH 5/5 v2] ASoC: rsnd: Add Volume Ramp support
Date: Thu, 30 Oct 2014 18:22:42 -0700 (PDT)	[thread overview]
Message-ID: <877fzh2ftq.wl%kuninori.morimoto.gx@gmail.com> (raw)
In-Reply-To: <87egtp2g05.wl%kuninori.morimoto.gx@gmail.com>

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch adds Volume Ramp to
Renesas sound driver.

This sample indicates Mute -> Volume 100% -> Mute

amixer set "DVC Out Ramp Up Rate" 0x10
amixer set "DVC Out Ramp Down Rate" 0x13
amixer set "DVC Out Ramp" 0%   // Mute as default
amixer set "DVC Out Ramp" on   // Volume Ramp ON
aplay xxx.wav &
amixer set "DVC Out Ramp" 100% // Ramp up to 100%
amixer set "DVC Out Ramp" 0%   // Ramp down to Mute

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

 - "Period" -> "Rate"
 - add Up/Down rate
 - Ramp Volume was inverted for user experience
 - "Ramp Enable" -> "Ramp Switch"

 sound/soc/sh/rcar/dvc.c  |   44 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/sh/rcar/gen.c  |    3 +++
 sound/soc/sh/rcar/rsnd.h |    6 ++++++
 3 files changed, 53 insertions(+)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index 55c8d7c..9ccf77b 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -37,6 +37,10 @@ struct rsnd_dvc {
 	struct clk *clk;
 	struct rsnd_dvc_cfg_m volume;
 	struct rsnd_dvc_cfg_m mute;
+	struct rsnd_dvc_cfg_s ren;	/* Ramp Enable */
+	struct rsnd_dvc_cfg_s rup;	/* Ramp Rate Up */
+	struct rsnd_dvc_cfg_s rdown;	/* Ramp Rate Down */
+	struct rsnd_dvc_cfg_s rvol;	/* Ramp Volume */
 };
 
 #define rsnd_mod_to_dvc(_mod)	\
@@ -66,6 +70,17 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 	rsnd_mod_write(mod, DVC_VOL0R, dvc->volume.val[0]);
 	rsnd_mod_write(mod, DVC_VOL1R, dvc->volume.val[1]);
 
+	/* Enable Ramp */
+	if (dvc->ren.val) {
+		dvucr |= 0x10;
+		rsnd_mod_write(mod, DVC_VRCTR, 0xff);
+		rsnd_mod_write(mod, DVC_VRPDR, dvc->rup.val << 8 |
+					       dvc->rdown.val);
+		/* use inverted value for user experience */
+		rsnd_mod_write(mod, DVC_VRDBR, dvc->rvol.cfg.max -
+					       dvc->rvol.val);
+	}
+
 	/*  Enable Mute */
 	if (mute) {
 		dvucr |= 0x1;
@@ -290,6 +305,35 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 	if (ret < 0)
 		return ret;
 
+	/* Ramp */
+	ret = _rsnd_dvc_pcm_new_s(mod, rdai, rtd,
+			rsnd_dai_is_play(rdai, io) ?
+			"DVC Out Ramp Switch" : "DVC In Ramp Switch",
+			&dvc->ren, 1);
+	if (ret < 0)
+		return ret;
+
+	ret = _rsnd_dvc_pcm_new_s(mod, rdai, rtd,
+			rsnd_dai_is_play(rdai, io) ?
+			"DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate",
+			&dvc->rup, 0x17); /* 10111 */
+	if (ret < 0)
+		return ret;
+
+	ret = _rsnd_dvc_pcm_new_s(mod, rdai, rtd,
+			rsnd_dai_is_play(rdai, io) ?
+			"DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate",
+			&dvc->rdown, 0x17); /* 10111 */
+	if (ret < 0)
+		return ret;
+
+	ret = _rsnd_dvc_pcm_new_s(mod, rdai, rtd,
+			rsnd_dai_is_play(rdai, io) ?
+			"DVC Out Ramp Volume" : "DVC In Ramp Volume",
+			&dvc->rvol, 0x3ff);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
index 61dee68..4cb3202 100644
--- a/sound/soc/sh/rcar/gen.c
+++ b/sound/soc/sh/rcar/gen.c
@@ -324,6 +324,9 @@ static int rsnd_gen2_probe(struct platform_device *pdev,
 		RSND_GEN_M_REG(DVC_ADINR,	0xe08,	0x100),
 		RSND_GEN_M_REG(DVC_DVUCR,	0xe10,	0x100),
 		RSND_GEN_M_REG(DVC_ZCMCR,	0xe14,	0x100),
+		RSND_GEN_M_REG(DVC_VRCTR,	0xe18,	0x100),
+		RSND_GEN_M_REG(DVC_VRPDR,	0xe1c,	0x100),
+		RSND_GEN_M_REG(DVC_VRDBR,	0xe20,	0x100),
 		RSND_GEN_M_REG(DVC_VOL0R,	0xe28,	0x100),
 		RSND_GEN_M_REG(DVC_VOL1R,	0xe2c,	0x100),
 		RSND_GEN_M_REG(DVC_DVUER,	0xe48,	0x100),
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 56b93a0..08c686d 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -91,6 +91,9 @@ enum rsnd_reg {
 	RSND_REG_SHARE20,
 	RSND_REG_SHARE21,
 	RSND_REG_SHARE22,
+	RSND_REG_SHARE23,
+	RSND_REG_SHARE24,
+	RSND_REG_SHARE25,
 
 	RSND_REG_MAX,
 };
@@ -129,6 +132,9 @@ enum rsnd_reg {
 #define RSND_REG_CMD_CTRL		RSND_REG_SHARE20
 #define RSND_REG_CMDOUT_TIMSEL		RSND_REG_SHARE21
 #define RSND_REG_BUSIF_DALIGN		RSND_REG_SHARE22
+#define RSND_REG_DVC_VRCTR		RSND_REG_SHARE23
+#define RSND_REG_DVC_VRPDR		RSND_REG_SHARE24
+#define RSND_REG_DVC_VRDBR		RSND_REG_SHARE25
 
 struct rsnd_of_data;
 struct rsnd_priv;
-- 
1.7.9.5

  parent reply	other threads:[~2014-10-31  1:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-31  1:18 [PATCH 0/5 v2] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
2014-10-31  1:19 ` [PATCH 1/5 v2] ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update() Kuninori Morimoto
2014-10-31  1:20 ` [PATCH 2/5 v2] ASoC: rsnd: move DVC_DVUER settings " Kuninori Morimoto
2014-10-31  1:20 ` [PATCH 3/5 v2] ASoC: rsnd: enable multiple DVC valume settings Kuninori Morimoto
2014-10-31  1:22 ` Kuninori Morimoto [this message]
2014-11-05  4:26 ` [PATCH 0/6 v3] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
2014-11-05  4:26   ` [PATCH 1/6 v3] ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update() Kuninori Morimoto
2014-11-06 17:04     ` Mark Brown
2014-11-05  4:27   ` [PATCH 2/6 v3] ASoC: rsnd: move DVC_DVUER settings " Kuninori Morimoto
2014-11-06 17:05     ` Mark Brown
2014-11-05  4:27   ` [PATCH 3/6 v3] ASoC: rsnd: enable multiple DVC valume settings Kuninori Morimoto
2014-11-06 17:05     ` Mark Brown
2014-11-05  4:28   ` [PATCH 4/6 v3] ASoC: rsnd: enable single " Kuninori Morimoto
2014-11-06 17:05     ` Mark Brown
2014-11-05  4:28   ` [PATCH 5/6 v3] ASoC: rsnd: enable enumerated " Kuninori Morimoto
2014-11-06 17:05     ` Mark Brown
2014-11-05  4:29   ` [PATCH 6/6 v3] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
2014-11-06 16:58     ` Mark Brown
2014-11-07  0:11       ` Kuninori Morimoto
2014-11-07 10:45         ` Mark Brown
2014-11-10  3:52           ` [PATCH v4] " Kuninori Morimoto
2014-11-10 15:14             ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877fzh2ftq.wl%kuninori.morimoto.gx@gmail.com \
    --to=kuninori.morimoto.gx@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=horms@verge.net.au \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.