Skip to content

Commit

Permalink
ASoC: rsnd: enable Mute control on DVC
Browse files Browse the repository at this point in the history
DVC can control Mute.
This patch supports it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Kuninori Morimoto authored and Mark Brown committed Aug 1, 2014
1 parent 486b09c commit cd2b657
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions sound/soc/sh/rcar/dvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct rsnd_dvc {
struct rsnd_mod mod;
struct clk *clk;
u8 volume[RSND_DVC_VOLUME_NUM];
u8 mute[RSND_DVC_VOLUME_NUM];
};

#define rsnd_mod_to_dvc(_mod) \
Expand All @@ -37,13 +38,18 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
u32 max = (0x00800000 - 1);
u32 vol[RSND_DVC_VOLUME_NUM];
u32 mute = 0;
int i;

for (i = 0; i < RSND_DVC_VOLUME_NUM; i++)
for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) {
vol[i] = max / RSND_DVC_VOLUME_MAX * dvc->volume[i];
mute |= (!!dvc->mute[i]) << i;
}

rsnd_mod_write(mod, DVC_VOL0R, vol[0]);
rsnd_mod_write(mod, DVC_VOL1R, vol[1]);

rsnd_mod_write(mod, DVC_ZCMCR, mute);
}

static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
Expand Down Expand Up @@ -96,8 +102,8 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,

rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod));

/* enable Volume */
rsnd_mod_write(dvc_mod, DVC_DVUCR, 0x100);
/* enable Volume / Mute */
rsnd_mod_write(dvc_mod, DVC_DVUCR, 0x101);

/* ch0/ch1 Volume */
rsnd_dvc_volume_update(dvc_mod);
Expand Down Expand Up @@ -140,10 +146,20 @@ static int rsnd_dvc_stop(struct rsnd_mod *mod,
static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
struct rsnd_mod *mod = snd_kcontrol_chip(kctrl);
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
u8 *val = (u8 *)kctrl->private_value;

uinfo->count = RSND_DVC_VOLUME_NUM;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = RSND_DVC_VOLUME_MAX;

if (val == dvc->volume) {
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->value.integer.max = RSND_DVC_VOLUME_MAX;
} else {
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->value.integer.max = 1;
}

return 0;
}
Expand Down Expand Up @@ -223,6 +239,14 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
if (ret < 0)
return ret;

/* Mute */
ret = __rsnd_dvc_pcm_new(mod, rdai, rtd,
rsnd_dai_is_play(rdai, io) ?
"DVC Out Mute Switch" : "DVC In Mute Switch",
dvc->mute);
if (ret < 0)
return ret;

return 0;
}

Expand Down

0 comments on commit cd2b657

Please sign in to comment.