Skip to content

Commit 8cf72c4

Browse files
pujarsbroonie
authored andcommitted
ASoC: tegra: Fix kcontrol put callback in Mixer
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 Mixer driver. Fixes: 05bb3d5 ("ASoC: tegra: Add Tegra210 based Mixer 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 3c97881 commit 8cf72c4

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

sound/soc/tegra/tegra210_mixer.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,24 +192,24 @@ static int tegra210_mixer_get_gain(struct snd_kcontrol *kcontrol,
192192
return 0;
193193
}
194194

195-
static int tegra210_mixer_put_gain(struct snd_kcontrol *kcontrol,
196-
struct snd_ctl_elem_value *ucontrol)
195+
static int tegra210_mixer_apply_gain(struct snd_kcontrol *kcontrol,
196+
struct snd_ctl_elem_value *ucontrol,
197+
bool instant_gain)
197198
{
198199
struct soc_mixer_control *mc =
199200
(struct soc_mixer_control *)kcontrol->private_value;
200201
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
201202
struct tegra210_mixer *mixer = snd_soc_component_get_drvdata(cmpnt);
202203
unsigned int reg = mc->reg, id;
203-
bool instant_gain = false;
204204
int err;
205205

206-
if (strstr(kcontrol->id.name, "Instant Gain Volume"))
207-
instant_gain = true;
208-
209206
/* Save gain value for specific MIXER input */
210207
id = (reg - TEGRA210_MIXER_GAIN_CFG_RAM_ADDR_0) /
211208
TEGRA210_MIXER_GAIN_CFG_RAM_ADDR_STRIDE;
212209

210+
if (mixer->gain_value[id] == ucontrol->value.integer.value[0])
211+
return 0;
212+
213213
mixer->gain_value[id] = ucontrol->value.integer.value[0];
214214

215215
err = tegra210_mixer_configure_gain(cmpnt, id, instant_gain);
@@ -221,6 +221,18 @@ static int tegra210_mixer_put_gain(struct snd_kcontrol *kcontrol,
221221
return 1;
222222
}
223223

224+
static int tegra210_mixer_put_gain(struct snd_kcontrol *kcontrol,
225+
struct snd_ctl_elem_value *ucontrol)
226+
{
227+
return tegra210_mixer_apply_gain(kcontrol, ucontrol, false);
228+
}
229+
230+
static int tegra210_mixer_put_instant_gain(struct snd_kcontrol *kcontrol,
231+
struct snd_ctl_elem_value *ucontrol)
232+
{
233+
return tegra210_mixer_apply_gain(kcontrol, ucontrol, true);
234+
}
235+
224236
static int tegra210_mixer_set_audio_cif(struct tegra210_mixer *mixer,
225237
struct snd_pcm_hw_params *params,
226238
unsigned int reg,
@@ -388,7 +400,7 @@ ADDER_CTRL_DECL(adder5, TEGRA210_MIXER_TX5_ADDER_CONFIG);
388400
SOC_SINGLE_EXT("RX" #id " Instant Gain Volume", \
389401
MIXER_GAIN_CFG_RAM_ADDR((id) - 1), 0, \
390402
0x20000, 0, tegra210_mixer_get_gain, \
391-
tegra210_mixer_put_gain),
403+
tegra210_mixer_put_instant_gain),
392404

393405
/* Volume controls for all MIXER inputs */
394406
static const struct snd_kcontrol_new tegra210_mixer_gain_ctls[] = {

0 commit comments

Comments
 (0)