* [PATCH v1] ASoC: ops: Fix integer detection for when max possible values > 1
@ 2022-06-17 15:36 Stefan Binding
2022-06-17 15:50 ` Charles Keepax
2022-06-17 23:19 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Binding @ 2022-06-17 15:36 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: alsa-devel, linux-kernel, patches, Stefan Binding
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>
---
sound/soc/soc-ops.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index 0267e39de2a8..1970bda074d8 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;
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] ASoC: ops: Fix integer detection for when max possible values > 1
2022-06-17 15:36 [PATCH v1] ASoC: ops: Fix integer detection for when max possible values > 1 Stefan Binding
@ 2022-06-17 15:50 ` Charles Keepax
2022-06-17 23:19 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2022-06-17 15:50 UTC (permalink / raw)
To: Stefan Binding
Cc: Mark Brown, Liam Girdwood, alsa-devel, linux-kernel, patches
On Fri, Jun 17, 2022 at 04:36:06PM +0100, Stefan Binding wrote:
> 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>
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] ASoC: ops: Fix integer detection for when max possible values > 1
2022-06-17 15:36 [PATCH v1] ASoC: ops: Fix integer detection for when max possible values > 1 Stefan Binding
2022-06-17 15:50 ` Charles Keepax
@ 2022-06-17 23:19 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-06-17 23:19 UTC (permalink / raw)
To: sbinding, lgirdwood; +Cc: alsa-devel, patches, linux-kernel
On Fri, 17 Jun 2022 16:36:06 +0100, Stefan Binding wrote:
> 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.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: ops: Fix integer detection for when max possible values > 1
commit: 442302003bd2b151e12d52b0af9a7dac131bf931
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-17 23:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 15:36 [PATCH v1] ASoC: ops: Fix integer detection for when max possible values > 1 Stefan Binding
2022-06-17 15:50 ` Charles Keepax
2022-06-17 23:19 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®