summaryrefslogtreecommitdiff
path: root/sound/soc/soc-ops.c
diff options
context:
space:
mode:
authorStefan Binding <sbinding@opensource.cirrus.com>2022-06-17 16:36:06 +0100
committerMark Brown <broonie@kernel.org>2022-06-17 18:25:23 +0100
commit442302003bd2b151e12d52b0af9a7dac131bf931 (patch)
treecb23bf23d48aad72ed4e16ebf72da4aad68d8608 /sound/soc/soc-ops.c
parentba46bd04a4218defa2b35d84983e915e166f1572 (diff)
ASoC: ops: Fix integer detection for when max possible values > 1
The standard snd_soc_info_volsw() allows a two value control to be defined as an integer control only if the control name ends in "Volume". It achieves this by creating a substring if it contains " Volume", and ensuring this exists at the end of the name. The volume substring is then used to decide whether the type is a SNDRV_CTL_ELEM_TYPE_INTEGER or SNDRV_CTL_ELEM_TYPE_BOOLEAN. However this volume substring is only computed for a two value control. This means for controls where there are more than two possible values, the substring is never created, so in this case the substring remains NULL, and the condition yields SNDRV_CTL_ELEM_TYPE_BOOLEAN, even though there are more than 2 possible values. If there are more than 2 possible values for the control, then it should always be an integer control. Fixes: aa2a4b897132 ("ASoC: ops: Fix boolean/integer detection for simple controls") Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220617153606.2619457-1-sbinding@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-ops.c')
-rw-r--r--sound/soc/soc-ops.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index c22d87581f6f..bd88de056358 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -183,17 +183,16 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
if (mc->platform_max && mc->platform_max < max)
max = mc->platform_max;
- /* Even two value controls ending in Volume should always be integer */
if (max == 1) {
+ /* Even two value controls ending in Volume should always be integer */
vol_string = strstr(kcontrol->id.name, " Volume");
- if (vol_string && strcmp(vol_string, " Volume"))
- vol_string = NULL;
- }
-
- if (!vol_string)
- uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
- else
+ if (vol_string && !strcmp(vol_string, " Volume"))
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ else
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+ } else {
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ }
uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
uinfo->value.integer.min = 0;