Skip to content

Commit

Permalink
ASoC: SOF: control: return true when kcontrol values change
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Pierre-Louis Bossart <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
dragosht authored and broonie committed Oct 18, 2019
1 parent 9b7a7f9 commit 95a32c9
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions sound/soc/sof/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
struct snd_sof_dev *sdev = scontrol->sdev;
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
unsigned int i, channels = scontrol->num_channels;
bool change = false;
u32 value;

/* update each channel */
for (i = 0; i < channels; i++) {
cdata->chanv[i].value =
mixer_to_ipc(ucontrol->value.integer.value[i],
value = mixer_to_ipc(ucontrol->value.integer.value[i],
scontrol->volume_table, sm->max + 1);
change = change || (value != cdata->chanv[i].value);
cdata->chanv[i].channel = i;
cdata->chanv[i].value = value;
}

/* notify DSP of mixer updates */
Expand All @@ -76,8 +79,7 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
SOF_CTRL_TYPE_VALUE_CHAN_GET,
SOF_CTRL_CMD_VOLUME,
true);

return 0;
return change;
}

int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
Expand Down Expand Up @@ -105,11 +107,15 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
struct snd_sof_dev *sdev = scontrol->sdev;
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
unsigned int i, channels = scontrol->num_channels;
bool change = false;
u32 value;

/* update each channel */
for (i = 0; i < channels; i++) {
cdata->chanv[i].value = ucontrol->value.integer.value[i];
value = ucontrol->value.integer.value[i];
change = change || (value != cdata->chanv[i].value);
cdata->chanv[i].channel = i;
cdata->chanv[i].value = value;
}

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

return 0;
return change;
}

int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
Expand Down Expand Up @@ -148,11 +154,15 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
struct snd_sof_dev *sdev = scontrol->sdev;
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
unsigned int i, channels = scontrol->num_channels;
bool change = false;
u32 value;

/* update each channel */
for (i = 0; i < channels; i++) {
cdata->chanv[i].value = ucontrol->value.enumerated.item[i];
value = ucontrol->value.enumerated.item[i];
change = change || (value != cdata->chanv[i].value);
cdata->chanv[i].channel = i;
cdata->chanv[i].value = value;
}

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

return 0;
return change;
}

int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,
Expand Down

0 comments on commit 95a32c9

Please sign in to comment.