Skip to content

Commit

Permalink
ASoC: ops: add correct range check for limiting volume
Browse files Browse the repository at this point in the history
Volume can have ranges that start with negative values, ex: -84dB to
+40dB. Apply correct range check in snd_soc_limit_volume before setting
the platform_max. Without this patch, for example setting a 0dB limit on
a volume range of -84dB to +40dB would fail.

Signed-off-by: Srinivas Kandagatla <[email protected]>
Tested-by: Johan Hovold <[email protected]>
Reviewed-by: Johan Hovold <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
Srinivas-Kandagatla authored and broonie committed Dec 4, 2023
1 parent e238b68 commit fb9ad24
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/soc-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ int snd_soc_limit_volume(struct snd_soc_card *card,
kctl = snd_soc_card_get_kcontrol(card, name);
if (kctl) {
struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
if (max <= mc->max) {
if (max <= mc->max - mc->min) {
mc->platform_max = max;
ret = 0;
}
Expand Down

0 comments on commit fb9ad24

Please sign in to comment.