ASoC: Intel: avs: Honor the invert flag for mixer controls

Values for the mute flag represented on the AudioDSP side are inverted.
Check mixer control description and initialize default values
accordingly.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20250217102115.3539427-10-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Cezary Rojewski 2025-02-17 11:21:14 +01:00 committed by Mark Brown
parent a4217a0368
commit 76e0131528
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -1943,18 +1943,20 @@ avs_control_load(struct snd_soc_component *comp, int index, struct snd_kcontrol_
struct avs_control_data *ctl_data;
struct soc_mixer_control *mc;
size_t block_size;
int ret;
int ret, i;
switch (le32_to_cpu(hdr->type)) {
case SND_SOC_TPLG_TYPE_MIXER:
tmc = container_of(hdr, typeof(*tmc), hdr);
tuples = tmc->priv.array;
block_size = le32_to_cpu(tmc->priv.size);
break;
default:
return -EINVAL;
}
mc = (struct soc_mixer_control *)ctmpl->private_value;
tmc = container_of(hdr, typeof(*tmc), hdr);
tuples = tmc->priv.array;
block_size = le32_to_cpu(tmc->priv.size);
ctl_data = devm_kzalloc(comp->card->dev, sizeof(*ctl_data), GFP_KERNEL);
if (!ctl_data)
return -ENOMEM;
@ -1965,8 +1967,13 @@ avs_control_load(struct snd_soc_component *comp, int index, struct snd_kcontrol_
if (ret)
return ret;
mc = (struct soc_mixer_control *)ctmpl->private_value;
mc->dobj.private = ctl_data;
if (tmc->invert) {
ctl_data->values[0] = mc->max;
for (i = 1; i < mc->num_channels; i++)
ctl_data->values[i] = mc->max;
}
return 0;
}