Skip to content

Commit 95a32c9

Browse files
Dragos Tarcatubroonie
authored andcommitted
ASoC: SOF: control: return true when kcontrol values change
All the kcontrol put() functions are currently returning 0 when successful. This does not go well with alsamixer as it does not seem to get notified on SND_CTL_EVENT_MASK_VALUE callbacks when values change for (some of) the sof kcontrols. This patch fixes that by returning true for volume, switch and enum type kcontrols when values do change in put(). Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20191018123806.18063-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 9b7a7f9 commit 95a32c9

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

‎sound/soc/sof/control.c‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,16 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
6060
struct snd_sof_dev *sdev = scontrol->sdev;
6161
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
6262
unsigned int i, channels = scontrol->num_channels;
63+
bool change = false;
64+
u32 value;
6365

6466
/* update each channel */
6567
for (i = 0; i < channels; i++) {
66-
cdata->chanv[i].value =
67-
mixer_to_ipc(ucontrol->value.integer.value[i],
68+
value = mixer_to_ipc(ucontrol->value.integer.value[i],
6869
scontrol->volume_table, sm->max + 1);
70+
change = change || (value != cdata->chanv[i].value);
6971
cdata->chanv[i].channel = i;
72+
cdata->chanv[i].value = value;
7073
}
7174

7275
/* notify DSP of mixer updates */
@@ -76,8 +79,7 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
7679
SOF_CTRL_TYPE_VALUE_CHAN_GET,
7780
SOF_CTRL_CMD_VOLUME,
7881
true);
79-
80-
return 0;
82+
return change;
8183
}
8284

8385
int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
@@ -105,11 +107,15 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
105107
struct snd_sof_dev *sdev = scontrol->sdev;
106108
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
107109
unsigned int i, channels = scontrol->num_channels;
110+
bool change = false;
111+
u32 value;
108112

109113
/* update each channel */
110114
for (i = 0; i < channels; i++) {
111-
cdata->chanv[i].value = ucontrol->value.integer.value[i];
115+
value = ucontrol->value.integer.value[i];
116+
change = change || (value != cdata->chanv[i].value);
112117
cdata->chanv[i].channel = i;
118+
cdata->chanv[i].value = value;
113119
}
114120

115121
/* notify DSP of mixer updates */
@@ -120,7 +126,7 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
120126
SOF_CTRL_CMD_SWITCH,
121127
true);
122128

123-
return 0;
129+
return change;
124130
}
125131

126132
int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
@@ -148,11 +154,15 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
148154
struct snd_sof_dev *sdev = scontrol->sdev;
149155
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
150156
unsigned int i, channels = scontrol->num_channels;
157+
bool change = false;
158+
u32 value;
151159

152160
/* update each channel */
153161
for (i = 0; i < channels; i++) {
154-
cdata->chanv[i].value = ucontrol->value.enumerated.item[i];
162+
value = ucontrol->value.enumerated.item[i];
163+
change = change || (value != cdata->chanv[i].value);
155164
cdata->chanv[i].channel = i;
165+
cdata->chanv[i].value = value;
156166
}
157167

158168
/* notify DSP of enum updates */
@@ -163,7 +173,7 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
163173
SOF_CTRL_CMD_ENUM,
164174
true);
165175

166-
return 0;
176+
return change;
167177
}
168178

169179
int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,

0 commit comments

Comments
 (0)