Skip to content

Commit ff04437

Browse files
Amadeusz Sławińskibroonie
authored andcommitted
ASoC: Intel: avs: Fix module lookup
When changing value of kcontrol, FW module to which data should be send needs to be found. Currently it is done in improper way, fix it. Change function name to indicate that it looks only for volume module. This allows to change volume during runtime, instead of only changing init value. Fixes: be2b81b ("ASoC: Intel: avs: Parse control tuples") Reviewed-by: Cezary Rojewski <[email protected]> Signed-off-by: Amadeusz Sławiński <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e123036 commit ff04437

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

sound/soc/intel/avs/control.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,25 @@ static struct avs_dev *avs_get_kcontrol_adev(struct snd_kcontrol *kcontrol)
2121
return to_avs_dev(w->dapm->component->dev);
2222
}
2323

24-
static struct avs_path_module *avs_get_kcontrol_module(struct avs_dev *adev, u32 id)
24+
static struct avs_path_module *avs_get_volume_module(struct avs_dev *adev, u32 id)
2525
{
2626
struct avs_path *path;
2727
struct avs_path_pipeline *ppl;
2828
struct avs_path_module *mod;
2929

30-
list_for_each_entry(path, &adev->path_list, node)
31-
list_for_each_entry(ppl, &path->ppl_list, node)
32-
list_for_each_entry(mod, &ppl->mod_list, node)
33-
if (mod->template->ctl_id && mod->template->ctl_id == id)
30+
spin_lock(&adev->path_list_lock);
31+
list_for_each_entry(path, &adev->path_list, node) {
32+
list_for_each_entry(ppl, &path->ppl_list, node) {
33+
list_for_each_entry(mod, &ppl->mod_list, node) {
34+
if (guid_equal(&mod->template->cfg_ext->type, &AVS_PEAKVOL_MOD_UUID)
35+
&& mod->template->ctl_id == id) {
36+
spin_unlock(&adev->path_list_lock);
3437
return mod;
38+
}
39+
}
40+
}
41+
}
42+
spin_unlock(&adev->path_list_lock);
3543

3644
return NULL;
3745
}
@@ -49,7 +57,7 @@ int avs_control_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
4957
/* prevent access to modules while path is being constructed */
5058
mutex_lock(&adev->path_mutex);
5159

52-
active_module = avs_get_kcontrol_module(adev, ctl_data->id);
60+
active_module = avs_get_volume_module(adev, ctl_data->id);
5361
if (active_module) {
5462
ret = avs_ipc_peakvol_get_volume(adev, active_module->module_id,
5563
active_module->instance_id, &dspvols,
@@ -89,7 +97,7 @@ int avs_control_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
8997
changed = 1;
9098
}
9199

92-
active_module = avs_get_kcontrol_module(adev, ctl_data->id);
100+
active_module = avs_get_volume_module(adev, ctl_data->id);
93101
if (active_module) {
94102
dspvol.channel_id = AVS_ALL_CHANNELS_MASK;
95103
dspvol.target_volume = *volume;

0 commit comments

Comments
 (0)