From: Kuninori Morimoto Date: Wed, 5 Nov 2014 04:28:50 +0000 (-0800) Subject: ASoC: rsnd: enable enumerated DVC valume settings X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=018342976ce971944dd4d9309f75e86382079a2b;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git ASoC: rsnd: enable enumerated DVC valume settings 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 Signed-off-by: Mark Brown --- diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index e7cfc71a9006..8504f6b1c086 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)