Commit c7b34b51 authored by Sameer Pujar's avatar Sameer Pujar Committed by Mark Brown

ASoC: tegra: Fix kcontrol put callback in MVC

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 MVC driver.

Fixes: e539891f ("ASoC: tegra: Add Tegra210 based MVC driver")
Signed-off-by: default avatarSameer Pujar <spujar@nvidia.com>
Suggested-by: default avatarJaroslav Kysela <perex@perex.cz>
Suggested-by: default avatarMark Brown <broonie@kernel.org>
Reviewed-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/1637219231-406-13-git-send-email-spujar@nvidia.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a4e37950
...@@ -136,7 +136,7 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol, ...@@ -136,7 +136,7 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol,
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt);
unsigned int value; unsigned int value;
u8 mute_mask; u8 new_mask, old_mask;
int err; int err;
pm_runtime_get_sync(cmpnt->dev); pm_runtime_get_sync(cmpnt->dev);
...@@ -148,11 +148,19 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol, ...@@ -148,11 +148,19 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol,
if (err < 0) if (err < 0)
goto end; goto end;
mute_mask = ucontrol->value.integer.value[0]; regmap_read(mvc->regmap, TEGRA210_MVC_CTRL, &value);
old_mask = (value >> TEGRA210_MVC_MUTE_SHIFT) & TEGRA210_MUTE_MASK_EN;
new_mask = ucontrol->value.integer.value[0];
if (new_mask == old_mask) {
err = 0;
goto end;
}
err = regmap_update_bits(mvc->regmap, mc->reg, err = regmap_update_bits(mvc->regmap, mc->reg,
TEGRA210_MVC_MUTE_MASK, TEGRA210_MVC_MUTE_MASK,
mute_mask << TEGRA210_MVC_MUTE_SHIFT); new_mask << TEGRA210_MVC_MUTE_SHIFT);
if (err < 0) if (err < 0)
goto end; goto end;
...@@ -195,7 +203,7 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol, ...@@ -195,7 +203,7 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol,
unsigned int reg = mc->reg; unsigned int reg = mc->reg;
unsigned int value; unsigned int value;
u8 chan; u8 chan;
int err; int err, old_volume;
pm_runtime_get_sync(cmpnt->dev); pm_runtime_get_sync(cmpnt->dev);
...@@ -207,10 +215,16 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol, ...@@ -207,10 +215,16 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol,
goto end; goto end;
chan = (reg - TEGRA210_MVC_TARGET_VOL) / REG_SIZE; chan = (reg - TEGRA210_MVC_TARGET_VOL) / REG_SIZE;
old_volume = mvc->volume[chan];
tegra210_mvc_conv_vol(mvc, chan, tegra210_mvc_conv_vol(mvc, chan,
ucontrol->value.integer.value[0]); ucontrol->value.integer.value[0]);
if (mvc->volume[chan] == old_volume) {
err = 0;
goto end;
}
/* Configure init volume same as target volume */ /* Configure init volume same as target volume */
regmap_write(mvc->regmap, regmap_write(mvc->regmap,
TEGRA210_MVC_REG_OFFSET(TEGRA210_MVC_INIT_VOL, chan), TEGRA210_MVC_REG_OFFSET(TEGRA210_MVC_INIT_VOL, chan),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment