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" 100% // Mute as default amixer set "DVC Out Ramp Period" 80% amixer set "DVC Out Ramp Enable" on aplay xxx.wav & amixer set "DVC Out Ramp" 0% // to Volume 100% amixer set "DVC Out Ramp" 100% // to Mute
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/rcar/dvc.c | 34 ++++++++++++++++++++++++++++++++++ sound/soc/sh/rcar/gen.c | 3 +++ sound/soc/sh/rcar/rsnd.h | 6 ++++++ 3 files changed, 43 insertions(+)
diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 2654ab0..f353f7d 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -37,6 +37,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 rperiod; /* Ramp Period */ + struct rsnd_dvc_cfg_s rvol; /* Ramp Volume */ };
#define rsnd_mod_to_dvc(_mod) \ @@ -66,6 +69,15 @@ 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->rperiod.val << 8 | + dvc->rperiod.val); + rsnd_mod_write(mod, DVC_VRDBR, dvc->rvol.val); + } + /* Enable Mute */ if (mute) { dvucr |= 0x1; @@ -290,6 +302,28 @@ 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 Enable" : "DVC In Ramp Enable", + &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 Period" : "DVC In Ramp Period", + &dvc->rperiod, 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 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;