[PATCH v2 04/10] ASoC: tegra: Fix kcontrol put callback in DSPK

Sameer Pujar spujar at nvidia.com
Wed Nov 3 14:52:20 CET 2021


The kcontrol put callback is expected to return 1 when there is change
in HW or when the update is acknowledged by driver. This would ensure
that change notifications are sent to subscribed applications. Update
the DSPK driver accordingly.

Fixes: 327ef6470266 ("ASoC: tegra: Add Tegra186 based DSPK driver")
Suggested-by: Jaroslav Kysela <perex at perex.cz>
Suggested-by: Mark Brown <broonie at kernel.org>
Signed-off-by: Sameer Pujar <spujar at nvidia.com>
---
 sound/soc/tegra/tegra186_dspk.c | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/sound/soc/tegra/tegra186_dspk.c b/sound/soc/tegra/tegra186_dspk.c
index 8ee9a77..4cc06e9 100644
--- a/sound/soc/tegra/tegra186_dspk.c
+++ b/sound/soc/tegra/tegra186_dspk.c
@@ -55,20 +55,39 @@ static int tegra186_dspk_put_control(struct snd_kcontrol *kcontrol,
 	struct tegra186_dspk *dspk = snd_soc_component_get_drvdata(codec);
 	int val = ucontrol->value.integer.value[0];
 
-	if (strstr(kcontrol->id.name, "FIFO Threshold"))
+	if (strstr(kcontrol->id.name, "FIFO Threshold")) {
+		if (dspk->rx_fifo_th == val)
+			return 0;
+
 		dspk->rx_fifo_th = val;
-	else if (strstr(kcontrol->id.name, "OSR Value"))
+	} else if (strstr(kcontrol->id.name, "OSR Value")) {
+		if (dspk->osr_val == val)
+			return 0;
+
 		dspk->osr_val = val;
-	else if (strstr(kcontrol->id.name, "LR Polarity Select"))
+	} else if (strstr(kcontrol->id.name, "LR Polarity Select")) {
+		if (dspk->lrsel == val)
+			return 0;
+
 		dspk->lrsel = val;
-	else if (strstr(kcontrol->id.name, "Channel Select"))
+	} else if (strstr(kcontrol->id.name, "Channel Select")) {
+		if (dspk->ch_sel == val)
+			return 0;
+
 		dspk->ch_sel = val;
-	else if (strstr(kcontrol->id.name, "Mono To Stereo"))
+	} else if (strstr(kcontrol->id.name, "Mono To Stereo")) {
+		if (dspk->mono_to_stereo == val)
+			return 0;
+
 		dspk->mono_to_stereo = val;
-	else if (strstr(kcontrol->id.name, "Stereo To Mono"))
+	} else if (strstr(kcontrol->id.name, "Stereo To Mono")) {
+		if (dspk->stereo_to_mono == val)
+			return 0;
+
 		dspk->stereo_to_mono = val;
+	}
 
-	return 0;
+	return 1;
 }
 
 static int __maybe_unused tegra186_dspk_runtime_suspend(struct device *dev)
-- 
2.7.4



More information about the Alsa-devel mailing list