summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2014-08-01 03:10:47 -0700
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>2015-02-04 11:15:45 +0100
commit23ac5c26e273ab023c18efbd681dfaeacc965334 (patch)
tree0c64de25b2da0d45a2a101a21ef4cdcfbab28e22
parentaaf873b795a243edd24d3cbe11dbe534ad4aed6d (diff)
downloadkernel-common-23ac5c26e273ab023c18efbd681dfaeacc965334.tar.gz
kernel-common-23ac5c26e273ab023c18efbd681dfaeacc965334.tar.bz2
kernel-common-23ac5c26e273ab023c18efbd681dfaeacc965334.zip
ASoC: rsnd: tidyup DVC control method
DVC can use Volume and Mute control, and these control methods doesn't have much difference. This patch cleanup current method, and it will be used for Mute control. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit 486b09c750e58777976ad74a37de7b4252630332) Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
-rw-r--r--sound/soc/sh/rcar/dvc.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index 9096fb03d001..12a0a2068d34 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -20,7 +20,7 @@ struct rsnd_dvc {
struct rsnd_dvc_platform_info *info; /* rcar_snd.h */
struct rsnd_mod mod;
struct clk *clk;
- long volume[RSND_DVC_VOLUME_NUM];
+ u8 volume[RSND_DVC_VOLUME_NUM];
};
#define rsnd_mod_to_dvc(_mod) \
@@ -151,12 +151,11 @@ static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl,
static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl,
struct snd_ctl_elem_value *ucontrol)
{
- struct rsnd_mod *mod = snd_kcontrol_chip(kctrl);
- struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+ u8 *val = (u8 *)kctrl->private_value;
int i;
for (i = 0; i < RSND_DVC_VOLUME_NUM; i++)
- ucontrol->value.integer.value[i] = dvc->volume[i];
+ ucontrol->value.integer.value[i] = val[i];
return 0;
}
@@ -165,47 +164,38 @@ static int rsnd_dvc_volume_put(struct snd_kcontrol *kctrl,
struct snd_ctl_elem_value *ucontrol)
{
struct rsnd_mod *mod = snd_kcontrol_chip(kctrl);
- struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+ u8 *val = (u8 *)kctrl->private_value;
int i, change = 0;
for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) {
- if (ucontrol->value.integer.value[i] < 0 ||
- ucontrol->value.integer.value[i] > RSND_DVC_VOLUME_MAX)
- return -EINVAL;
-
- change |= (ucontrol->value.integer.value[i] != dvc->volume[i]);
+ change |= (ucontrol->value.integer.value[i] != val[i]);
+ val[i] = ucontrol->value.integer.value[i];
}
- if (change) {
- for (i = 0; i < RSND_DVC_VOLUME_NUM; i++)
- dvc->volume[i] = ucontrol->value.integer.value[i];
-
+ if (change)
rsnd_dvc_volume_update(mod);
- }
return change;
}
-static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
- struct rsnd_dai *rdai,
- struct snd_soc_pcm_runtime *rtd)
+static int __rsnd_dvc_pcm_new(struct rsnd_mod *mod,
+ struct rsnd_dai *rdai,
+ struct snd_soc_pcm_runtime *rtd,
+ const unsigned char *name,
+ u8 *private)
{
- struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
struct snd_card *card = rtd->card->snd_card;
struct snd_kcontrol *kctrl;
- static struct snd_kcontrol_new knew = {
+ struct snd_kcontrol_new knew = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = name,
.info = rsnd_dvc_volume_info,
.get = rsnd_dvc_volume_get,
.put = rsnd_dvc_volume_put,
+ .private_value = (unsigned long)private,
};
int ret;
- if (rsnd_dai_is_play(rdai, io))
- knew.name = "Playback Volume";
- else
- knew.name = "Capture Volume";
-
kctrl = snd_ctl_new1(&knew, mod);
if (!kctrl)
return -ENOMEM;
@@ -217,6 +207,25 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
return 0;
}
+static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
+ struct rsnd_dai *rdai,
+ struct snd_soc_pcm_runtime *rtd)
+{
+ struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+ struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+ int ret;
+
+ /* Volume */
+ ret = __rsnd_dvc_pcm_new(mod, rdai, rtd,
+ rsnd_dai_is_play(rdai, io) ?
+ "DVC Out Playback Volume" : "DVC In Capture Volume",
+ dvc->volume);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
static struct rsnd_mod_ops rsnd_dvc_ops = {
.name = DVC_NAME,
.probe = rsnd_dvc_probe_gen2,