mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnav Kapoor <kapoorarnav43@gmail.com>
To: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
	Bard Liao <yung-chuan.liao@linux.intel.com>,
	Daniel Baluta <daniel.baluta@nxp.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Kai Vehmanen <kai.vehmanen@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	sound-open-firmware@alsa-project.org,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	Arnav Kapoor <kapoorarnav43@gmail.com>
Subject: [PATCH 3/4] ASoC: SOF: report volume changes in mixer steps
Date: Tue, 17 Nov 2026 16:29:49 +0530	[thread overview]
Message-ID: <20261117105953.188645-4-kapoorarnav43@gmail.com> (raw)
In-Reply-To: <20261117105953.188645-1-kapoorarnav43@gmail.com>

The IPC3 and IPC4 volume_put() ops decide whether the control changed by
comparing the new linear gain from the volume table with the stored one.
The stored gain does not always come from the table: topology loading
initialises it to 0 dB (VOL_ZERO_DB or SOF_IPC4_VOL_ZERO_DB), and
volume_get() reports that as the first table entry at or above it, which
is usually not exactly 0 dB. Writing back the value that was just read
then changes the stored gain, so put() returns true and user space gets
a change notification although the control value is the same.

On a Tiger Lake laptop with sof-hda-generic-2ch.tplg (IPC3), the ALSA
mixer-test selftest reports this as event_spurious failures for every
PGA playback volume and for "Dmic0 Capture Volume".

Compare in mixer steps instead, using the same ipc_to_mixer() conversion
as volume_get(), so put() returns true only when the value user space
sees changes.

Fixes: 95a32c98055f ("ASoC: SOF: control: return true when kcontrol values change")
Fixes: 955e84fc0b6d ("ASoC: SOF: ipc4-topology: Add control IO ops")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
 sound/soc/sof/ipc3-control.c | 4 +++-
 sound/soc/sof/ipc4-control.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sof/ipc3-control.c b/sound/soc/sof/ipc3-control.c
index b1d00a2a860a..b8f4d963e07d 100644
--- a/sound/soc/sof/ipc3-control.c
+++ b/sound/soc/sof/ipc3-control.c
@@ -180,10 +180,12 @@ static bool sof_ipc3_volume_put(struct snd_sof_control *scontrol,
 
 	/* update each channel */
 	for (i = 0; i < channels; i++) {
+		u32 old = ipc_to_mixer(cdata->chanv[i].value,
+				       scontrol->volume_table, scontrol->max + 1);
 		u32 value = mixer_to_ipc(ucontrol->value.integer.value[i],
 					 scontrol->volume_table, scontrol->max + 1);
 
-		change = change || (value != cdata->chanv[i].value);
+		change = change || (ucontrol->value.integer.value[i] != old);
 		cdata->chanv[i].channel = i;
 		cdata->chanv[i].value = value;
 	}
diff --git a/sound/soc/sof/ipc4-control.c b/sound/soc/sof/ipc4-control.c
index e29c8d89284a..8bf300373d22 100644
--- a/sound/soc/sof/ipc4-control.c
+++ b/sound/soc/sof/ipc4-control.c
@@ -153,10 +153,12 @@ static bool sof_ipc4_volume_put(struct snd_sof_control *scontrol,
 
 	/* update each channel */
 	for (i = 0; i < channels; i++) {
+		u32 old = ipc_to_mixer(cdata->chanv[i].value,
+				       scontrol->volume_table, scontrol->max + 1);
 		u32 value = mixer_to_ipc(ucontrol->value.integer.value[i],
 					 scontrol->volume_table, scontrol->max + 1);
 
-		change = change || (value != cdata->chanv[i].value);
+		change = change || (ucontrol->value.integer.value[i] != old);
 		cdata->chanv[i].channel = i;
 		cdata->chanv[i].value = value;
 	}
-- 
2.53.0



  parent reply	other threads:[~2026-11-17 11:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 10:59 [PATCH 0/4] ASoC: SOF: control: fix volume, switch and enum value handling Arnav Kapoor
2026-11-17 10:59 ` [PATCH 1/4] ASoC: SOF: control: reject out-of-range volume values Arnav Kapoor
2026-11-17 10:59 ` [PATCH 2/4] ASoC: SOF: control: reject invalid switch values Arnav Kapoor
2026-11-17 10:59 ` Arnav Kapoor [this message]
2026-11-17 10:59 ` [PATCH 4/4] ASoC: SOF: control: reject out-of-range enum values Arnav Kapoor
2026-11-17 12:24 ` [PATCH 0/4] ASoC: SOF: control: fix volume, switch and enum value handling 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=20261117105953.188645-4-kapoorarnav43@gmail.com \
    --to=kapoorarnav43@gmail.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=kai.vehmanen@linux.intel.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=ranjani.sridharan@linux.intel.com \
    --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®