[PATCH v2 07/10] ASoC: tegra: Fix kcontrol put callback in SFC

From: Sameer Pujar
Date: Wed Nov 03 2021 - 09:53:54 EST


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. Filter
out duplicate updates in SFC driver.

Fixes: b2f74ec53a6c ("ASoC: tegra: Add Tegra210 based SFC driver")
Signed-off-by: Sameer Pujar <spujar@xxxxxxxxxx>
Suggested-by: Jaroslav Kysela <perex@xxxxxxxx>
Suggested-by: Mark Brown <broonie@xxxxxxxxxx>
---
sound/soc/tegra/tegra210_sfc.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/sound/soc/tegra/tegra210_sfc.c b/sound/soc/tegra/tegra210_sfc.c
index dc477ee..ac24980 100644
--- a/sound/soc/tegra/tegra210_sfc.c
+++ b/sound/soc/tegra/tegra210_sfc.c
@@ -3273,16 +3273,27 @@ static int tegra210_sfc_put_control(struct snd_kcontrol *kcontrol,
struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt);
int value = ucontrol->value.integer.value[0];

- if (strstr(kcontrol->id.name, "Input Stereo To Mono"))
+ if (strstr(kcontrol->id.name, "Input Stereo To Mono")) {
+ if (sfc->stereo_to_mono[SFC_RX_PATH] == value)
+ return 0;
+
sfc->stereo_to_mono[SFC_RX_PATH] = value;
- else if (strstr(kcontrol->id.name, "Input Mono To Stereo"))
+ } else if (strstr(kcontrol->id.name, "Input Mono To Stereo")) {
+ if (sfc->mono_to_stereo[SFC_RX_PATH] == value)
+ return 0;
+
sfc->mono_to_stereo[SFC_RX_PATH] = value;
- else if (strstr(kcontrol->id.name, "Output Stereo To Mono"))
+ } else if (strstr(kcontrol->id.name, "Output Stereo To Mono")) {
+ if (sfc->stereo_to_mono[SFC_TX_PATH] == value)
+ return 0;
+
sfc->stereo_to_mono[SFC_TX_PATH] = value;
- else if (strstr(kcontrol->id.name, "Output Mono To Stereo"))
+ } else if (strstr(kcontrol->id.name, "Output Mono To Stereo")) {
+ if (sfc->mono_to_stereo[SFC_TX_PATH] == value)
+ return 0;
+
sfc->mono_to_stereo[SFC_TX_PATH] = value;
- else
- return 0;
+ }

return 1;
}
--
2.7.4