From: HyeongJun An <sammiee5311@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
Vijendar Mukunda <Vijendar.Mukunda@amd.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Arnav Kapoor <kapoorarnav43@gmail.com>,
sound-open-firmware@alsa-project.org,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
HyeongJun An <sammiee5311@gmail.com>
Subject: [PATCH v2 1/2] ASoC: SOF: control: Report the volume range as ASoC does
Date: Wed, 18 Nov 2026 18:38:39 +0900 [thread overview]
Message-ID: <20261118093840.3514408-2-sammiee5311@gmail.com> (raw)
In-Reply-To: <20261118093840.3514408-1-sammiee5311@gmail.com>
SOF controls with more than two channels use snd_sof_volume_info()
instead of snd_soc_info_volsw(). The snd_sof_volume_info() reports
platform_max - min as the maximum, while snd_soc_info_volsw() reports
max - min, limited by platform_max. With min 10, max 100 and
platform_max 80, a control reports 70 with more than two channels and
80 with up to two.
To fix this, compute the maximum the way snd_soc_info_volsw() does. The
helper is reused by the next patch to check the values written to the
controls. It also no longer stores max in platform_max as a side
effect.
No SOF topology sets min or platform_max today, so the reported ranges
do not change.
Suggested-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
sound/soc/sof/control.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index 74d997a4f620..136e2ce15201 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -15,6 +15,17 @@
#include "sof-priv.h"
#include "sof-audio.h"
+/* the maximum value as snd_soc_info_volsw() reports it */
+static int sof_mixer_max(const struct soc_mixer_control *sm)
+{
+ int max = sm->max - sm->min;
+
+ if (sm->platform_max && sm->platform_max < max)
+ max = sm->platform_max;
+
+ return max;
+}
+
int snd_sof_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -50,20 +61,16 @@ int snd_sof_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
struct soc_mixer_control *sm = (struct soc_mixer_control *)kcontrol->private_value;
struct snd_sof_control *scontrol = sm->dobj.private;
unsigned int channels = scontrol->num_channels;
- int platform_max;
-
- if (!sm->platform_max)
- sm->platform_max = sm->max;
- platform_max = sm->platform_max;
+ int max = sof_mixer_max(sm);
- if (platform_max == 1 && !strstr(kcontrol->id.name, " Volume"))
+ if (max == 1 && !strstr(kcontrol->id.name, " Volume"))
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
else
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = channels;
uinfo->value.integer.min = 0;
- uinfo->value.integer.max = platform_max - sm->min;
+ uinfo->value.integer.max = max;
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-11-18 9:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 9:38 [PATCH v2 0/2] ASoC: SOF: control: Check the volume and switch values HyeongJun An
2026-11-18 9:38 ` HyeongJun An [this message]
2026-11-18 9:38 ` [PATCH v2 2/2] ASoC: SOF: control: Reject out of range " HyeongJun An
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118093840.3514408-2-sammiee5311@gmail.com \
--to=sammiee5311@gmail.com \
--cc=Vijendar.Mukunda@amd.com \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=kapoorarnav43@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=sound-open-firmware@alsa-project.org \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®