Skip to content

Commit c7b34b5

Browse files
pujarsbroonie
authored andcommitted
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: e539891 ("ASoC: tegra: Add Tegra210 based MVC driver") Signed-off-by: Sameer Pujar <[email protected]> Suggested-by: Jaroslav Kysela <[email protected]> Suggested-by: Mark Brown <[email protected]> Reviewed-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a4e3795 commit c7b34b5

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

sound/soc/tegra/tegra210_mvc.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol,
136136
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
137137
struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt);
138138
unsigned int value;
139-
u8 mute_mask;
139+
u8 new_mask, old_mask;
140140
int err;
141141

142142
pm_runtime_get_sync(cmpnt->dev);
@@ -148,11 +148,19 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol,
148148
if (err < 0)
149149
goto end;
150150

151-
mute_mask = ucontrol->value.integer.value[0];
151+
regmap_read(mvc->regmap, TEGRA210_MVC_CTRL, &value);
152+
153+
old_mask = (value >> TEGRA210_MVC_MUTE_SHIFT) & TEGRA210_MUTE_MASK_EN;
154+
new_mask = ucontrol->value.integer.value[0];
155+
156+
if (new_mask == old_mask) {
157+
err = 0;
158+
goto end;
159+
}
152160

153161
err = regmap_update_bits(mvc->regmap, mc->reg,
154162
TEGRA210_MVC_MUTE_MASK,
155-
mute_mask << TEGRA210_MVC_MUTE_SHIFT);
163+
new_mask << TEGRA210_MVC_MUTE_SHIFT);
156164
if (err < 0)
157165
goto end;
158166

@@ -195,7 +203,7 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol,
195203
unsigned int reg = mc->reg;
196204
unsigned int value;
197205
u8 chan;
198-
int err;
206+
int err, old_volume;
199207

200208
pm_runtime_get_sync(cmpnt->dev);
201209

@@ -207,10 +215,16 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol,
207215
goto end;
208216

209217
chan = (reg - TEGRA210_MVC_TARGET_VOL) / REG_SIZE;
218+
old_volume = mvc->volume[chan];
210219

211220
tegra210_mvc_conv_vol(mvc, chan,
212221
ucontrol->value.integer.value[0]);
213222

223+
if (mvc->volume[chan] == old_volume) {
224+
err = 0;
225+
goto end;
226+
}
227+
214228
/* Configure init volume same as target volume */
215229
regmap_write(mvc->regmap,
216230
TEGRA210_MVC_REG_OFFSET(TEGRA210_MVC_INIT_VOL, chan),

0 commit comments

Comments
 (0)