All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5 v2] ASoC: rsnd: Add Volume Ramp support
@ 2014-10-31  1:18 Kuninori Morimoto
  2014-10-31  1:19 ` [PATCH 1/5 v2] ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update() Kuninori Morimoto
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Kuninori Morimoto @ 2014-10-31  1:18 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


Hi Mark

These are v2 of Renesas R-Car sound Volume Ramp support.
It uses "Volume Ramp Up/Down Rate" on last patch instead of "Period".
Because it is good match naming, and it was difficult to calculate
real period time on this HW.

Kuninori Morimoto (5):
      ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update()
      ASoC: rsnd: move DVC_DVUER settings under rsnd_dvc_volume_update()
      ASoC: rsnd: enable multiple DVC valume settings
      ASoC: rsnd: enable single DVC valume settings
      ASoC: rsnd: Add Volume Ramp support

 sound/soc/sh/rcar/dvc.c  |  126 +++++++++++++++++++++++++++++++++++++++-------
 sound/soc/sh/rcar/gen.c  |    3 ++
 sound/soc/sh/rcar/rsnd.h |    6 +++
 3 files changed, 116 insertions(+), 19 deletions(-)

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 1/5 v2] ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update()
  2014-10-31  1:18 [PATCH 0/5 v2] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
@ 2014-10-31  1:19 ` Kuninori Morimoto
  2014-10-31  1:20 ` [PATCH 2/5 v2] ASoC: rsnd: move DVC_DVUER settings " Kuninori Morimoto
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Kuninori Morimoto @ 2014-10-31  1:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

rsnd_dvc_volume_update() is main function to control
DVC feature like Digital Volume / Mute / Ramp etc.
DVC_DVUCR should be controlled under this function.

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

 - no change

 sound/soc/sh/rcar/dvc.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index deaf0fa..3952237 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -40,6 +40,7 @@ struct rsnd_dvc {
 static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 {
 	struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+	u32 dvucr = 0;
 	u32 mute = 0;
 	int i;
 
@@ -47,10 +48,18 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 		mute |= (!!dvc->mute.val[i]) << i;
 	}
 
+	/* Enable Digital Volume */
+	dvucr = 0x100;
 	rsnd_mod_write(mod, DVC_VOL0R, dvc->volume.val[0]);
 	rsnd_mod_write(mod, DVC_VOL1R, dvc->volume.val[1]);
 
-	rsnd_mod_write(mod, DVC_ZCMCR, mute);
+	/*  Enable Mute */
+	if (mute) {
+		dvucr |= 0x1;
+		rsnd_mod_write(mod, DVC_ZCMCR, mute);
+	}
+
+	rsnd_mod_write(mod, DVC_DVUCR, dvucr);
 }
 
 static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
@@ -103,9 +112,6 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
 
 	rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod));
 
-	/*  enable Volume / Mute */
-	rsnd_mod_write(dvc_mod, DVC_DVUCR, 0x101);
-
 	/* ch0/ch1 Volume */
 	rsnd_dvc_volume_update(dvc_mod);
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/5 v2] ASoC: rsnd: move DVC_DVUER settings under rsnd_dvc_volume_update()
  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 ` Kuninori Morimoto
  2014-10-31  1:20 ` [PATCH 3/5 v2] ASoC: rsnd: enable multiple DVC valume settings Kuninori Morimoto
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Kuninori Morimoto @ 2014-10-31  1:20 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

We need to Enable/Disable DVC_DVUER register if we set
DVCp_ZCMCR, DVCp_VRCTR, DVCp_VRPDR, DVCp_VRDBR,
DVCp_VOL0R, DVCp_VOL1R, DVCp_VOL2R, DVCp_VOL3R,
DVCp_VOL4R, DVCp_VOL5R, DVCp_VOL6R, DVCp_VOL7R
and, these are controlled under rsnd_dvc_volume_update().
This patch moves DVC_DVUER settings to it.

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

 - fixup inverted Enable/Disable

 sound/soc/sh/rcar/dvc.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index 3952237..ce1512e 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -48,6 +48,9 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 		mute |= (!!dvc->mute.val[i]) << i;
 	}
 
+	/* Disable DVC Register access */
+	rsnd_mod_write(mod, DVC_DVUER, 0);
+
 	/* Enable Digital Volume */
 	dvucr = 0x100;
 	rsnd_mod_write(mod, DVC_VOL0R, dvc->volume.val[0]);
@@ -60,6 +63,9 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 	}
 
 	rsnd_mod_write(mod, DVC_DVUCR, dvucr);
+
+	/* Enable DVC Register access */
+	rsnd_mod_write(mod, DVC_DVUER, 1);
 }
 
 static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
@@ -117,8 +123,6 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
 
 	rsnd_mod_write(dvc_mod, DVC_DVUIR, 0);
 
-	rsnd_mod_write(dvc_mod, DVC_DVUER, 1);
-
 	rsnd_adg_set_cmd_timsel_gen2(rdai, dvc_mod, io);
 
 	return 0;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 3/5 v2] ASoC: rsnd: enable multiple DVC valume settings
  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 ` Kuninori Morimoto
  2014-10-31  1:22 ` [PATCH 5/5 v2] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
  2014-11-05  4:26 ` [PATCH 0/6 v3] " Kuninori Morimoto
  4 siblings, 0 replies; 22+ messages in thread
From: Kuninori Morimoto @ 2014-10-31  1:20 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

DVC controls some digital volume features.
Some of them requests values for "each channels",
but, some of them requests values for "feature".
Current dvc.c is supporting Mute/Volume,
and these have "each channels" settings.
This patch adds rsnd_dvc_cfg_m and care about
multiple settings for each channels.

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

 - no change

 sound/soc/sh/rcar/dvc.c |   42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index ce1512e..7fd7230 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -17,6 +17,12 @@
 
 struct rsnd_dvc_cfg {
 	unsigned int max;
+	unsigned int size;
+	u32 *val;
+};
+
+struct rsnd_dvc_cfg_m {
+	struct rsnd_dvc_cfg cfg;
 	u32 val[RSND_DVC_CHANNELS];
 };
 
@@ -24,8 +30,8 @@ struct rsnd_dvc {
 	struct rsnd_dvc_platform_info *info; /* rcar_snd.h */
 	struct rsnd_mod mod;
 	struct clk *clk;
-	struct rsnd_dvc_cfg volume;
-	struct rsnd_dvc_cfg mute;
+	struct rsnd_dvc_cfg_m volume;
+	struct rsnd_dvc_cfg_m mute;
 };
 
 #define rsnd_mod_to_dvc(_mod)	\
@@ -44,9 +50,8 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 	u32 mute = 0;
 	int i;
 
-	for (i = 0; i < RSND_DVC_CHANNELS; i++) {
-		mute |= (!!dvc->mute.val[i]) << i;
-	}
+	for (i = 0; i < dvc->mute.cfg.size; i++)
+		mute |= (!!dvc->mute.cfg.val[i]) << i;
 
 	/* Disable DVC Register access */
 	rsnd_mod_write(mod, DVC_DVUER, 0);
@@ -177,7 +182,7 @@ static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl,
 	struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value;
 	int i;
 
-	for (i = 0; i < RSND_DVC_CHANNELS; i++)
+	for (i = 0; i < cfg->size; i++)
 		ucontrol->value.integer.value[i] = cfg->val[i];
 
 	return 0;
@@ -190,7 +195,7 @@ static int rsnd_dvc_volume_put(struct snd_kcontrol *kctrl,
 	struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value;
 	int i, change = 0;
 
-	for (i = 0; i < RSND_DVC_CHANNELS; i++) {
+	for (i = 0; i < cfg->size; i++) {
 		change |= (ucontrol->value.integer.value[i] != cfg->val[i]);
 		cfg->val[i] = ucontrol->value.integer.value[i];
 	}
@@ -230,6 +235,19 @@ static int __rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 	return 0;
 }
 
+static int _rsnd_dvc_pcm_new_m(struct rsnd_mod *mod,
+			       struct rsnd_dai *rdai,
+			       struct snd_soc_pcm_runtime *rtd,
+			       const unsigned char *name,
+			       struct rsnd_dvc_cfg_m *private,
+			       u32 max)
+{
+	private->cfg.max	= max;
+	private->cfg.size	= RSND_DVC_CHANNELS;
+	private->cfg.val	= private->val;
+	return __rsnd_dvc_pcm_new(mod, rdai, rtd, name, &private->cfg);
+}
+
 static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 			    struct rsnd_dai *rdai,
 			    struct snd_soc_pcm_runtime *rtd)
@@ -239,20 +257,18 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 	int ret;
 
 	/* Volume */
-	dvc->volume.max = 0x00800000 - 1;
-	ret = __rsnd_dvc_pcm_new(mod, rdai, rtd,
+	ret = _rsnd_dvc_pcm_new_m(mod, rdai, rtd,
 			rsnd_dai_is_play(rdai, io) ?
 			"DVC Out Playback Volume" : "DVC In Capture Volume",
-			&dvc->volume);
+			&dvc->volume, 0x00800000 - 1);
 	if (ret < 0)
 		return ret;
 
 	/* Mute */
-	dvc->mute.max = 1;
-	ret = __rsnd_dvc_pcm_new(mod, rdai, rtd,
+	ret = _rsnd_dvc_pcm_new_m(mod, rdai, rtd,
 			rsnd_dai_is_play(rdai, io) ?
 			"DVC Out Mute Switch" : "DVC In Mute Switch",
-			&dvc->mute);
+			&dvc->mute, 1);
 	if (ret < 0)
 		return ret;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 5/5 v2] ASoC: rsnd: Add Volume Ramp support
  2014-10-31  1:18 [PATCH 0/5 v2] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
                   ` (2 preceding siblings ...)
  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
  2014-11-05  4:26 ` [PATCH 0/6 v3] " Kuninori Morimoto
  4 siblings, 0 replies; 22+ messages in thread
From: Kuninori Morimoto @ 2014-10-31  1:22 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/6 v3] ASoC: rsnd: Add Volume Ramp support
  2014-10-31  1:18 [PATCH 0/5 v2] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2014-10-31  1:22 ` [PATCH 5/5 v2] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
@ 2014-11-05  4:26 ` Kuninori Morimoto
  2014-11-05  4:26   ` [PATCH 1/6 v3] ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update() Kuninori Morimoto
                     ` (5 more replies)
  4 siblings, 6 replies; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-05  4:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


Hi Mark

These are v3 of Renesas R-Car sound Volume Ramp support.
It uses "xxx db / yy step" as enumerated item.
(It came from datasheet works)

Kuninori Morimoto (6):
      ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update()
      ASoC: rsnd: move DVC_DVUER settings under rsnd_dvc_volume_update()
      ASoC: rsnd: enable multiple DVC valume settings
      ASoC: rsnd: enable single DVC valume settings
      ASoC: rsnd: enable enumerated DVC valume settings
      ASoC: rsnd: Add Volume Ramp support

 sound/soc/sh/rcar/dvc.c  |  211 +++++++++++++++++++++++++++++++++++++++-------
 sound/soc/sh/rcar/gen.c  |    3 +
 sound/soc/sh/rcar/rsnd.h |    6 ++
 3 files changed, 190 insertions(+), 30 deletions(-)


Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 1/6 v3] ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update()
  2014-11-05  4:26 ` [PATCH 0/6 v3] " Kuninori Morimoto
@ 2014-11-05  4:26   ` 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
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-05  4:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

rsnd_dvc_volume_update() is main function to control
DVC feature like Digital Volume / Mute / Ramp etc.
DVC_DVUCR should be controlled under this function.

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

 - no change

 sound/soc/sh/rcar/dvc.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index deaf0fa..3952237 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -40,6 +40,7 @@ struct rsnd_dvc {
 static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 {
 	struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+	u32 dvucr = 0;
 	u32 mute = 0;
 	int i;
 
@@ -47,10 +48,18 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 		mute |= (!!dvc->mute.val[i]) << i;
 	}
 
+	/* Enable Digital Volume */
+	dvucr = 0x100;
 	rsnd_mod_write(mod, DVC_VOL0R, dvc->volume.val[0]);
 	rsnd_mod_write(mod, DVC_VOL1R, dvc->volume.val[1]);
 
-	rsnd_mod_write(mod, DVC_ZCMCR, mute);
+	/*  Enable Mute */
+	if (mute) {
+		dvucr |= 0x1;
+		rsnd_mod_write(mod, DVC_ZCMCR, mute);
+	}
+
+	rsnd_mod_write(mod, DVC_DVUCR, dvucr);
 }
 
 static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
@@ -103,9 +112,6 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
 
 	rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod));
 
-	/*  enable Volume / Mute */
-	rsnd_mod_write(dvc_mod, DVC_DVUCR, 0x101);
-
 	/* ch0/ch1 Volume */
 	rsnd_dvc_volume_update(dvc_mod);
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/6 v3] ASoC: rsnd: move DVC_DVUER settings under rsnd_dvc_volume_update()
  2014-11-05  4:26 ` [PATCH 0/6 v3] " 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-05  4:27   ` 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
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-05  4:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

We need to Enable/Disable DVC_DVUER register if we set
DVCp_ZCMCR, DVCp_VRCTR, DVCp_VRPDR, DVCp_VRDBR,
DVCp_VOL0R, DVCp_VOL1R, DVCp_VOL2R, DVCp_VOL3R,
DVCp_VOL4R, DVCp_VOL5R, DVCp_VOL6R, DVCp_VOL7R
and, these are controlled under rsnd_dvc_volume_update().
This patch moves DVC_DVUER settings to it.

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

 - no change

 sound/soc/sh/rcar/dvc.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index 3952237..ce1512e 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -48,6 +48,9 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 		mute |= (!!dvc->mute.val[i]) << i;
 	}
 
+	/* Disable DVC Register access */
+	rsnd_mod_write(mod, DVC_DVUER, 0);
+
 	/* Enable Digital Volume */
 	dvucr = 0x100;
 	rsnd_mod_write(mod, DVC_VOL0R, dvc->volume.val[0]);
@@ -60,6 +63,9 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 	}
 
 	rsnd_mod_write(mod, DVC_DVUCR, dvucr);
+
+	/* Enable DVC Register access */
+	rsnd_mod_write(mod, DVC_DVUER, 1);
 }
 
 static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
@@ -117,8 +123,6 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
 
 	rsnd_mod_write(dvc_mod, DVC_DVUIR, 0);
 
-	rsnd_mod_write(dvc_mod, DVC_DVUER, 1);
-
 	rsnd_adg_set_cmd_timsel_gen2(rdai, dvc_mod, io);
 
 	return 0;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 3/6 v3] ASoC: rsnd: enable multiple DVC valume settings
  2014-11-05  4:26 ` [PATCH 0/6 v3] " 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-05  4:27   ` [PATCH 2/6 v3] ASoC: rsnd: move DVC_DVUER settings " Kuninori Morimoto
@ 2014-11-05  4:27   ` Kuninori Morimoto
  2014-11-06 17:05     ` Mark Brown
  2014-11-05  4:28   ` [PATCH 4/6 v3] ASoC: rsnd: enable single " Kuninori Morimoto
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-05  4:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

DVC controls some digital volume features.
Some of them requests values for "each channels",
but, some of them requests values for "feature".
Current dvc.c is supporting Mute/Volume,
and these have "each channels" settings.
This patch adds rsnd_dvc_cfg_m and care about
multiple settings for each channels.

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

 - no change

 sound/soc/sh/rcar/dvc.c |   44 ++++++++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index ce1512e..c729e26 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -17,6 +17,12 @@
 
 struct rsnd_dvc_cfg {
 	unsigned int max;
+	unsigned int size;
+	u32 *val;
+};
+
+struct rsnd_dvc_cfg_m {
+	struct rsnd_dvc_cfg cfg;
 	u32 val[RSND_DVC_CHANNELS];
 };
 
@@ -24,8 +30,8 @@ struct rsnd_dvc {
 	struct rsnd_dvc_platform_info *info; /* rcar_snd.h */
 	struct rsnd_mod mod;
 	struct clk *clk;
-	struct rsnd_dvc_cfg volume;
-	struct rsnd_dvc_cfg mute;
+	struct rsnd_dvc_cfg_m volume;
+	struct rsnd_dvc_cfg_m mute;
 };
 
 #define rsnd_mod_to_dvc(_mod)	\
@@ -44,9 +50,8 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 	u32 mute = 0;
 	int i;
 
-	for (i = 0; i < RSND_DVC_CHANNELS; i++) {
-		mute |= (!!dvc->mute.val[i]) << i;
-	}
+	for (i = 0; i < dvc->mute.cfg.size; i++)
+		mute |= (!!dvc->mute.cfg.val[i]) << i;
 
 	/* Disable DVC Register access */
 	rsnd_mod_write(mod, DVC_DVUER, 0);
@@ -159,7 +164,7 @@ static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl,
 {
 	struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value;
 
-	uinfo->count = RSND_DVC_CHANNELS;
+	uinfo->count = cfg->size;
 	uinfo->value.integer.min = 0;
 	uinfo->value.integer.max = cfg->max;
 
@@ -177,7 +182,7 @@ static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl,
 	struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value;
 	int i;
 
-	for (i = 0; i < RSND_DVC_CHANNELS; i++)
+	for (i = 0; i < cfg->size; i++)
 		ucontrol->value.integer.value[i] = cfg->val[i];
 
 	return 0;
@@ -190,7 +195,7 @@ static int rsnd_dvc_volume_put(struct snd_kcontrol *kctrl,
 	struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value;
 	int i, change = 0;
 
-	for (i = 0; i < RSND_DVC_CHANNELS; i++) {
+	for (i = 0; i < cfg->size; i++) {
 		change |= (ucontrol->value.integer.value[i] != cfg->val[i]);
 		cfg->val[i] = ucontrol->value.integer.value[i];
 	}
@@ -230,6 +235,19 @@ static int __rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 	return 0;
 }
 
+static int _rsnd_dvc_pcm_new_m(struct rsnd_mod *mod,
+			       struct rsnd_dai *rdai,
+			       struct snd_soc_pcm_runtime *rtd,
+			       const unsigned char *name,
+			       struct rsnd_dvc_cfg_m *private,
+			       u32 max)
+{
+	private->cfg.max	= max;
+	private->cfg.size	= RSND_DVC_CHANNELS;
+	private->cfg.val	= private->val;
+	return __rsnd_dvc_pcm_new(mod, rdai, rtd, name, &private->cfg);
+}
+
 static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 			    struct rsnd_dai *rdai,
 			    struct snd_soc_pcm_runtime *rtd)
@@ -239,20 +257,18 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 	int ret;
 
 	/* Volume */
-	dvc->volume.max = 0x00800000 - 1;
-	ret = __rsnd_dvc_pcm_new(mod, rdai, rtd,
+	ret = _rsnd_dvc_pcm_new_m(mod, rdai, rtd,
 			rsnd_dai_is_play(rdai, io) ?
 			"DVC Out Playback Volume" : "DVC In Capture Volume",
-			&dvc->volume);
+			&dvc->volume, 0x00800000 - 1);
 	if (ret < 0)
 		return ret;
 
 	/* Mute */
-	dvc->mute.max = 1;
-	ret = __rsnd_dvc_pcm_new(mod, rdai, rtd,
+	ret = _rsnd_dvc_pcm_new_m(mod, rdai, rtd,
 			rsnd_dai_is_play(rdai, io) ?
 			"DVC Out Mute Switch" : "DVC In Mute Switch",
-			&dvc->mute);
+			&dvc->mute, 1);
 	if (ret < 0)
 		return ret;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 4/6 v3] ASoC: rsnd: enable single DVC valume settings
  2014-11-05  4:26 ` [PATCH 0/6 v3] " Kuninori Morimoto
                     ` (2 preceding siblings ...)
  2014-11-05  4:27   ` [PATCH 3/6 v3] ASoC: rsnd: enable multiple DVC valume settings Kuninori Morimoto
@ 2014-11-05  4:28   ` 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-05  4:29   ` [PATCH 6/6 v3] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
  5 siblings, 1 reply; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-05  4:28 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

DVC controls some digital volume features.
Some of them requests values for "each channels",
but, some of them requests values for "feature".
And, Volume Ramp has "feature" settings.
This patch adds rsnd_dvc_cfg_s and care about
single settings.
Compiler will report like below at this point,
but, it will be removed if Volume Ramp was supported.
  warning: '_rsnd_dvc_pcm_new_s' defined but not used

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

 - no change

 sound/soc/sh/rcar/dvc.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index c729e26..e7cfc71 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -26,6 +26,11 @@ struct rsnd_dvc_cfg_m {
 	u32 val[RSND_DVC_CHANNELS];
 };
 
+struct rsnd_dvc_cfg_s {
+	struct rsnd_dvc_cfg cfg;
+	u32 val;
+};
+
 struct rsnd_dvc {
 	struct rsnd_dvc_platform_info *info; /* rcar_snd.h */
 	struct rsnd_mod mod;
@@ -248,6 +253,19 @@ static int _rsnd_dvc_pcm_new_m(struct rsnd_mod *mod,
 	return __rsnd_dvc_pcm_new(mod, rdai, rtd, name, &private->cfg);
 }
 
+static int _rsnd_dvc_pcm_new_s(struct rsnd_mod *mod,
+			       struct rsnd_dai *rdai,
+			       struct snd_soc_pcm_runtime *rtd,
+			       const unsigned char *name,
+			       struct rsnd_dvc_cfg_s *private,
+			       u32 max)
+{
+	private->cfg.max	= max;
+	private->cfg.size	= 1;
+	private->cfg.val	= &private->val;
+	return __rsnd_dvc_pcm_new(mod, rdai, rtd, name, &private->cfg);
+}
+
 static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 			    struct rsnd_dai *rdai,
 			    struct snd_soc_pcm_runtime *rtd)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 5/6 v3] ASoC: rsnd: enable enumerated DVC valume settings
  2014-11-05  4:26 ` [PATCH 0/6 v3] " Kuninori Morimoto
                     ` (3 preceding siblings ...)
  2014-11-05  4:28   ` [PATCH 4/6 v3] ASoC: rsnd: enable single " Kuninori Morimoto
@ 2014-11-05  4:28   ` 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
  5 siblings, 1 reply; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-05  4:28 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

DVC controls some digital volume features.
Volume Ramp is listed as "XX dB / YY steps",
and this enumerated settings are easy for users.
This patch adds rsnd_dvc_cfg_e and care about
enumerated settings.
Compiler will report like below at this point,
but, it will be removed if Volume Ramp was supported.
  warning: '_rsnd_dvc_pcm_new_e' defined but not used

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

 - new patch

 sound/soc/sh/rcar/dvc.c |   55 +++++++++++++++++++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 11 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index e7cfc71..8504f6b 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -19,6 +19,7 @@ struct rsnd_dvc_cfg {
 	unsigned int max;
 	unsigned int size;
 	u32 *val;
+	const char * const *texts;
 };
 
 struct rsnd_dvc_cfg_m {
@@ -169,14 +170,23 @@ static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl,
 {
 	struct rsnd_dvc_cfg *cfg = (struct rsnd_dvc_cfg *)kctrl->private_value;
 
-	uinfo->count = cfg->size;
-	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = cfg->max;
-
-	if (cfg->max == 1)
-		uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-	else
-		uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+	if (cfg->texts) {
+		uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+		uinfo->count = cfg->size;
+		uinfo->value.enumerated.items = cfg->max;
+		if (uinfo->value.enumerated.item >= cfg->max)
+			uinfo->value.enumerated.item = cfg->max - 1;
+		strlcpy(uinfo->value.enumerated.name,
+			cfg->texts[uinfo->value.enumerated.item],
+			sizeof(uinfo->value.enumerated.name));
+	} else {
+		uinfo->count = cfg->size;
+		uinfo->value.integer.min = 0;
+		uinfo->value.integer.max = cfg->max;
+		uinfo->type = (cfg->max == 1) ?
+			SNDRV_CTL_ELEM_TYPE_BOOLEAN :
+			SNDRV_CTL_ELEM_TYPE_INTEGER;
+	}
 
 	return 0;
 }
@@ -188,7 +198,10 @@ static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl,
 	int i;
 
 	for (i = 0; i < cfg->size; i++)
-		ucontrol->value.integer.value[i] = cfg->val[i];
+		if (cfg->texts)
+			ucontrol->value.enumerated.item[i] = cfg->val[i];
+		else
+			ucontrol->value.integer.value[i] = cfg->val[i];
 
 	return 0;
 }
@@ -201,8 +214,13 @@ static int rsnd_dvc_volume_put(struct snd_kcontrol *kctrl,
 	int i, change = 0;
 
 	for (i = 0; i < cfg->size; i++) {
-		change |= (ucontrol->value.integer.value[i] != cfg->val[i]);
-		cfg->val[i] = ucontrol->value.integer.value[i];
+		if (cfg->texts) {
+			change |= (ucontrol->value.enumerated.item[i] != cfg->val[i]);
+			cfg->val[i] = ucontrol->value.enumerated.item[i];
+		} else {
+			change |= (ucontrol->value.integer.value[i] != cfg->val[i]);
+			cfg->val[i] = ucontrol->value.integer.value[i];
+		}
 	}
 
 	if (change)
@@ -266,6 +284,21 @@ static int _rsnd_dvc_pcm_new_s(struct rsnd_mod *mod,
 	return __rsnd_dvc_pcm_new(mod, rdai, rtd, name, &private->cfg);
 }
 
+static int _rsnd_dvc_pcm_new_e(struct rsnd_mod *mod,
+			       struct rsnd_dai *rdai,
+			       struct snd_soc_pcm_runtime *rtd,
+			       const unsigned char *name,
+			       struct rsnd_dvc_cfg_s *private,
+			       const char * const *texts,
+			       u32 max)
+{
+	private->cfg.max	= max;
+	private->cfg.size	= 1;
+	private->cfg.val	= &private->val;
+	private->cfg.texts	= texts;
+	return __rsnd_dvc_pcm_new(mod, rdai, rtd, name, &private->cfg);
+}
+
 static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 			    struct rsnd_dai *rdai,
 			    struct snd_soc_pcm_runtime *rtd)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 6/6 v3] ASoC: rsnd: Add Volume Ramp support
  2014-11-05  4:26 ` [PATCH 0/6 v3] " Kuninori Morimoto
                     ` (4 preceding siblings ...)
  2014-11-05  4:28   ` [PATCH 5/6 v3] ASoC: rsnd: enable enumerated " Kuninori Morimoto
@ 2014-11-05  4:29   ` Kuninori Morimoto
  2014-11-06 16:58     ` Mark Brown
  5 siblings, 1 reply; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-05  4:29 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

This patch adds Volume Ramp to Renesas sound driver.

Below sample indicates
Mute -> Volume 100% -> Mute.
Here,
 - Mute        (= Normal Volume x 0%)
 - Volume 100% (= Normal Volume x 100%)

amixer set "DVC Out" 100%      // = Normal Volume
amixer set "DVC Out Ramp Up Rate"   "0.125 dB/64 steps"
amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
amixer set "DVC Out Ramp" 0%   // Mute = Normal Volume x 0%
amixer set "DVC Out Ramp" on   // Volume Ramp ON
aplay xxx.wav &
amixer set "DVC Out Ramp" 100% // Mute to Normal Volume x 100%
amixer set "DVC Out Ramp" 0%   // Normal Volume x 100% to Mute

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

 - use enumerated list
 - it is using datasheet words (= xxx dB / yy step)

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

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index 8504f6b..0b38f888 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -38,6 +38,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)	\
@@ -49,6 +53,33 @@ struct rsnd_dvc {
 	     ((pos) = (struct rsnd_dvc *)(priv)->dvc + i);	\
 	     i++)
 
+static const char const *dvc_ramp_rate[] = {
+	"128 dB/1 step",	 /* 00000 */
+	"64 dB/1 step",		 /* 00001 */
+	"32 dB/1 step",		 /* 00010 */
+	"16 dB/1 step",		 /* 00011 */
+	"8 dB/1 step",		 /* 00100 */
+	"4 dB/1 step",		 /* 00101 */
+	"2 dB/1 step",		 /* 00110 */
+	"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/2 steps",	 /* 01011 */
+	"0.125 dB/4 steps",	 /* 01100 */
+	"0.125 dB/8 steps",	 /* 01101 */
+	"0.125 dB/16 steps",	 /* 01110 */
+	"0.125 dB/32 steps",	 /* 01111 */
+	"0.125 dB/64 steps",	 /* 10000 */
+	"0.125 dB/128 steps",	 /* 10001 */
+	"0.125 dB/256 steps",	 /* 10010 */
+	"0.125 dB/512 steps",	 /* 10011 */
+	"0.125 dB/1024 steps",	 /* 10100 */
+	"0.125 dB/2048 steps",	 /* 10101 */
+	"0.125 dB/4096 steps",	 /* 10110 */
+	"0.125 dB/8192 steps",	 /* 10111 */
+};
+
 static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 {
 	struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
@@ -67,6 +98,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;
@@ -323,6 +365,38 @@ 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_e(mod, rdai, rtd,
+			rsnd_dai_is_play(rdai, io) ?
+			"DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate",
+			&dvc->rup,
+			dvc_ramp_rate, ARRAY_SIZE(dvc_ramp_rate));
+	if (ret < 0)
+		return ret;
+
+	ret = _rsnd_dvc_pcm_new_e(mod, rdai, rtd,
+			rsnd_dai_is_play(rdai, io) ?
+			"DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate",
+			&dvc->rdown,
+			dvc_ramp_rate, ARRAY_SIZE(dvc_ramp_rate));
+
+	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 d119adf..ed44ca8 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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 6/6 v3] ASoC: rsnd: Add Volume Ramp support
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Mark Brown @ 2014-11-06 16:58 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 867 bytes --]

On Tue, Nov 04, 2014 at 08:29:53PM -0800, Kuninori Morimoto wrote:

> amixer set "DVC Out" 100%      // = Normal Volume
> amixer set "DVC Out Ramp Up Rate"   "0.125 dB/64 steps"
> amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
> amixer set "DVC Out Ramp" 0%   // Mute = Normal Volume x 0%
> amixer set "DVC Out Ramp" on   // Volume Ramp ON
> aplay xxx.wav &
> amixer set "DVC Out Ramp" 100% // Mute to Normal Volume x 100%
> amixer set "DVC Out Ramp" 0%   // Normal Volume x 100% to Mute

Correct me if I'm wrong but I think what's confusing me here is that
what I'd expect to happen is that setting the ramp rate would cause any
volume change done by the user to ramp to the target volume (or mute)
but it looks like what's actually happening is that the ramp control is
providing an additional layer of volume control on top of the normal
volume control.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/6 v3] ASoC: rsnd: control DVC_DVUCR under rsnd_dvc_volume_update()
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2014-11-06 17:04 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 319 bytes --]

On Tue, Nov 04, 2014 at 08:26:53PM -0800, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> rsnd_dvc_volume_update() is main function to control
> DVC feature like Digital Volume / Mute / Ramp etc.
> DVC_DVUCR should be controlled under this function.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6 v3] ASoC: rsnd: move DVC_DVUER settings under rsnd_dvc_volume_update()
  2014-11-05  4:27   ` [PATCH 2/6 v3] ASoC: rsnd: move DVC_DVUER settings " Kuninori Morimoto
@ 2014-11-06 17:05     ` Mark Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2014-11-06 17:05 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 471 bytes --]

On Tue, Nov 04, 2014 at 08:27:18PM -0800, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> We need to Enable/Disable DVC_DVUER register if we set
> DVCp_ZCMCR, DVCp_VRCTR, DVCp_VRPDR, DVCp_VRDBR,
> DVCp_VOL0R, DVCp_VOL1R, DVCp_VOL2R, DVCp_VOL3R,
> DVCp_VOL4R, DVCp_VOL5R, DVCp_VOL6R, DVCp_VOL7R
> and, these are controlled under rsnd_dvc_volume_update().
> This patch moves DVC_DVUER settings to it.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/6 v3] ASoC: rsnd: enable multiple DVC valume settings
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2014-11-06 17:05 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 305 bytes --]

On Tue, Nov 04, 2014 at 08:27:46PM -0800, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> DVC controls some digital volume features.
> Some of them requests values for "each channels",
> but, some of them requests values for "feature".

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/6 v3] ASoC: rsnd: enable single DVC valume settings
  2014-11-05  4:28   ` [PATCH 4/6 v3] ASoC: rsnd: enable single " Kuninori Morimoto
@ 2014-11-06 17:05     ` Mark Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2014-11-06 17:05 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 305 bytes --]

On Tue, Nov 04, 2014 at 08:28:10PM -0800, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> DVC controls some digital volume features.
> Some of them requests values for "each channels",
> but, some of them requests values for "feature".

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/6 v3] ASoC: rsnd: enable enumerated DVC valume settings
  2014-11-05  4:28   ` [PATCH 5/6 v3] ASoC: rsnd: enable enumerated " Kuninori Morimoto
@ 2014-11-06 17:05     ` Mark Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2014-11-06 17:05 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 300 bytes --]

On Tue, Nov 04, 2014 at 08:28:50PM -0800, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> DVC controls some digital volume features.
> Volume Ramp is listed as "XX dB / YY steps",
> and this enumerated settings are easy for users.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 6/6 v3] ASoC: rsnd: Add Volume Ramp support
  2014-11-06 16:58     ` Mark Brown
@ 2014-11-07  0:11       ` Kuninori Morimoto
  2014-11-07 10:45         ` Mark Brown
  0 siblings, 1 reply; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-07  0:11 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


Hi Mark

Thank you for your review

> > amixer set "DVC Out" 100%      // = Normal Volume
> > amixer set "DVC Out Ramp Up Rate"   "0.125 dB/64 steps"
> > amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
> > amixer set "DVC Out Ramp" 0%   // Mute = Normal Volume x 0%
> > amixer set "DVC Out Ramp" on   // Volume Ramp ON
> > aplay xxx.wav &
> > amixer set "DVC Out Ramp" 100% // Mute to Normal Volume x 100%
> > amixer set "DVC Out Ramp" 0%   // Normal Volume x 100% to Mute
> 
> Correct me if I'm wrong but I think what's confusing me here is that
> what I'd expect to happen is that setting the ramp rate would cause any
> volume change done by the user to ramp to the target volume (or mute)
> but it looks like what's actually happening is that the ramp control is
> providing an additional layer of volume control on top of the normal
> volume control.

Sorry for my poor explanation.
Yes, you are correct.
Volume Ramp chenges [ramp layer] (0% - 100%)
[ramp layer] is always 100% if you don't use Volume Ramp.

         [Normal Volume] x [ramp layer] = output

Please let me better/understandable naming.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 6/6 v3] ASoC: rsnd: Add Volume Ramp support
  2014-11-07  0:11       ` Kuninori Morimoto
@ 2014-11-07 10:45         ` Mark Brown
  2014-11-10  3:52           ` [PATCH v4] " Kuninori Morimoto
  0 siblings, 1 reply; 22+ messages in thread
From: Mark Brown @ 2014-11-07 10:45 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 1117 bytes --]

On Thu, Nov 06, 2014 at 04:11:12PM -0800, Kuninori Morimoto wrote:

> > Correct me if I'm wrong but I think what's confusing me here is that
> > what I'd expect to happen is that setting the ramp rate would cause any
> > volume change done by the user to ramp to the target volume (or mute)
> > but it looks like what's actually happening is that the ramp control is
> > providing an additional layer of volume control on top of the normal
> > volume control.

> Sorry for my poor explanation.
> Yes, you are correct.
> Volume Ramp chenges [ramp layer] (0% - 100%)
> [ramp layer] is always 100% if you don't use Volume Ramp.

>          [Normal Volume] x [ramp layer] = output

> Please let me better/understandable naming.

OK, right.  In that case what I'd expect is that the only control the
user gets is of the ramp rate and then if that's configured any time the
volume is changed the driver will ensure that the change is implemented
with a ramp - that'd correspond to the normal implementation of this in
other devices (usually the hardware just does this so we don't have to
do anything special in software).

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v4] ASoC: rsnd: Add Volume Ramp support
  2014-11-07 10:45         ` Mark Brown
@ 2014-11-10  3:52           ` Kuninori Morimoto
  2014-11-10 15:14             ` Mark Brown
  0 siblings, 1 reply; 22+ messages in thread
From: Kuninori Morimoto @ 2014-11-10  3:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto

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

This patch adds Volume Ramp to Renesas sound driver.

amixer set "DVC Out" 100%
amixer set "DVC Out Ramp Up Rate"   "0.125 dB/64 steps"
amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
amixer set "DVC Out Ramp" on
aplay xxx.wav &
amixer set "DVC Out"  80%  // Volume Down
amixer set "DVC Out" 100%  // Volume Up

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

- use "DVC Out" instead of "DVC Out Ramp"

 sound/soc/sh/rcar/dvc.c  |   87 ++++++++++++++++++++++++++++++++++++++++++++--
 sound/soc/sh/rcar/gen.c  |    3 ++
 sound/soc/sh/rcar/rsnd.h |    6 ++++
 3 files changed, 93 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index 8504f6b..d6d8e64 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -38,6 +38,9 @@ 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 */
 };
 
 #define rsnd_mod_to_dvc(_mod)	\
@@ -49,9 +52,37 @@ struct rsnd_dvc {
 	     ((pos) = (struct rsnd_dvc *)(priv)->dvc + i);	\
 	     i++)
 
+static const char const *dvc_ramp_rate[] = {
+	"128 dB/1 step",	 /* 00000 */
+	"64 dB/1 step",		 /* 00001 */
+	"32 dB/1 step",		 /* 00010 */
+	"16 dB/1 step",		 /* 00011 */
+	"8 dB/1 step",		 /* 00100 */
+	"4 dB/1 step",		 /* 00101 */
+	"2 dB/1 step",		 /* 00110 */
+	"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/2 steps",	 /* 01011 */
+	"0.125 dB/4 steps",	 /* 01100 */
+	"0.125 dB/8 steps",	 /* 01101 */
+	"0.125 dB/16 steps",	 /* 01110 */
+	"0.125 dB/32 steps",	 /* 01111 */
+	"0.125 dB/64 steps",	 /* 10000 */
+	"0.125 dB/128 steps",	 /* 10001 */
+	"0.125 dB/256 steps",	 /* 10010 */
+	"0.125 dB/512 steps",	 /* 10011 */
+	"0.125 dB/1024 steps",	 /* 10100 */
+	"0.125 dB/2048 steps",	 /* 10101 */
+	"0.125 dB/4096 steps",	 /* 10110 */
+	"0.125 dB/8192 steps",	 /* 10111 */
+};
+
 static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 {
 	struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+	u32 val[RSND_DVC_CHANNELS];
 	u32 dvucr = 0;
 	u32 mute = 0;
 	int i;
@@ -62,10 +93,35 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 	/* Disable DVC Register access */
 	rsnd_mod_write(mod, DVC_DVUER, 0);
 
+	/* Enable Ramp */
+	if (dvc->ren.val) {
+		dvucr |= 0x10;
+
+		/* Digital Volume Max */
+		for (i = 0; i < RSND_DVC_CHANNELS; i++)
+			val[i] = dvc->volume.cfg.max;
+
+		rsnd_mod_write(mod, DVC_VRCTR, 0xff);
+		rsnd_mod_write(mod, DVC_VRPDR, dvc->rup.val << 8 |
+					       dvc->rdown.val);
+		/*
+		 * FIXME !!
+		 * use scale-downed Digital Volume
+		 * as Volume Ramp
+		 * 7F FFFF -> 3FF
+		 */
+		rsnd_mod_write(mod, DVC_VRDBR,
+			       0x3ff - (dvc->volume.val[0] >> 13));
+
+	} else {
+		for (i = 0; i < RSND_DVC_CHANNELS; i++)
+			val[i] = dvc->volume.val[i];
+	}
+
 	/* Enable Digital Volume */
-	dvucr = 0x100;
-	rsnd_mod_write(mod, DVC_VOL0R, dvc->volume.val[0]);
-	rsnd_mod_write(mod, DVC_VOL1R, dvc->volume.val[1]);
+	dvucr |= 0x100;
+	rsnd_mod_write(mod, DVC_VOL0R, val[0]);
+	rsnd_mod_write(mod, DVC_VOL1R, val[1]);
 
 	/*  Enable Mute */
 	if (mute) {
@@ -323,6 +379,31 @@ 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_e(mod, rdai, rtd,
+			rsnd_dai_is_play(rdai, io) ?
+			"DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate",
+			&dvc->rup,
+			dvc_ramp_rate, ARRAY_SIZE(dvc_ramp_rate));
+	if (ret < 0)
+		return ret;
+
+	ret = _rsnd_dvc_pcm_new_e(mod, rdai, rtd,
+			rsnd_dai_is_play(rdai, io) ?
+			"DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate",
+			&dvc->rdown,
+			dvc_ramp_rate, ARRAY_SIZE(dvc_ramp_rate));
+
+	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 d119adf..ed44ca8 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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v4] ASoC: rsnd: Add Volume Ramp support
  2014-11-10  3:52           ` [PATCH v4] " Kuninori Morimoto
@ 2014-11-10 15:14             ` Mark Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2014-11-10 15:14 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 210 bytes --]

On Sun, Nov 09, 2014 at 07:52:06PM -0800, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> This patch adds Volume Ramp to Renesas sound driver.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2014-11-10 15:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 5/5 v2] ASoC: rsnd: Add Volume Ramp support Kuninori Morimoto
2014-11-05  4:26 ` [PATCH 0/6 v3] " 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

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.