]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: Intel: avs: Move to the new control operations
authorCezary Rojewski <cezary.rojewski@intel.com>
Mon, 17 Feb 2025 10:21:12 +0000 (11:21 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 24 Feb 2025 16:01:56 +0000 (16:01 +0000)
Allow for multi-channel volume controls to be utilized by an application
by moving over to the new implementation. Drop all unused code in the
process.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20250217102115.3539427-8-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/avs/control.c
sound/soc/intel/avs/control.h
sound/soc/intel/avs/path.c
sound/soc/intel/avs/topology.c

index a1c7431cfe134183d4af5682adf1461655e56205..64283aa3528104ef09d28fd53f0332a9a4affaaf 100644 (file)
@@ -48,75 +48,7 @@ static struct avs_path_module *avs_get_volume_module(struct avs_dev *adev, u32 i
        return NULL;
 }
 
-int avs_control_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
-{
-       struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
-       struct avs_control_data *ctl_data = (struct avs_control_data *)mc->dobj.private;
-       struct avs_dev *adev = avs_get_kcontrol_adev(kcontrol);
-       struct avs_volume_cfg *dspvols = NULL;
-       struct avs_path_module *active_module;
-       size_t num_dspvols;
-       int ret = 0;
-
-       /* prevent access to modules while path is being constructed */
-       mutex_lock(&adev->path_mutex);
-
-       active_module = avs_get_volume_module(adev, ctl_data->id);
-       if (active_module) {
-               ret = avs_ipc_peakvol_get_volume(adev, active_module->module_id,
-                                                active_module->instance_id, &dspvols,
-                                                &num_dspvols);
-               if (!ret)
-                       ucontrol->value.integer.value[0] = dspvols[0].target_volume;
-
-               ret = AVS_IPC_RET(ret);
-               kfree(dspvols);
-       } else {
-               ucontrol->value.integer.value[0] = ctl_data->volume;
-       }
-
-       mutex_unlock(&adev->path_mutex);
-       return ret;
-}
-
-int avs_control_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
-{
-       struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
-       struct avs_control_data *ctl_data = (struct avs_control_data *)mc->dobj.private;
-       struct avs_dev *adev = avs_get_kcontrol_adev(kcontrol);
-       long *volume = &ctl_data->volume;
-       struct avs_path_module *active_module;
-       struct avs_volume_cfg dspvol = {0};
-       long ctlvol = ucontrol->value.integer.value[0];
-       int ret = 0, changed = 0;
-
-       if (ctlvol < 0 || ctlvol > mc->max)
-               return -EINVAL;
-
-       /* prevent access to modules while path is being constructed */
-       mutex_lock(&adev->path_mutex);
-
-       if (*volume != ctlvol) {
-               *volume = ctlvol;
-               changed = 1;
-       }
-
-       active_module = avs_get_volume_module(adev, ctl_data->id);
-       if (active_module) {
-               dspvol.channel_id = AVS_ALL_CHANNELS_MASK;
-               dspvol.target_volume = *volume;
-
-               ret = avs_ipc_peakvol_set_volume(adev, active_module->module_id,
-                                                active_module->instance_id, &dspvol);
-               ret = AVS_IPC_RET(ret);
-       }
-
-       mutex_unlock(&adev->path_mutex);
-
-       return ret ? ret : changed;
-}
-
-int avs_control_volume_get2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
+int avs_control_volume_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
 {
        struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
        struct avs_control_data *ctl_data = mc->dobj.private;
@@ -150,7 +82,7 @@ int avs_control_volume_get2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value
        return 0;
 }
 
-int avs_control_volume_put2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
+int avs_control_volume_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
 {
        struct avs_path_module *active_module;
        struct avs_control_data *ctl_data;
index e16fa79962de8a17f4f59a240d13066fb6e76ef0..66f3fe064e1d670926886607f5f1bbe4bba540a2 100644 (file)
 
 struct avs_control_data {
        u32 id;
-
-       long volume;
        long values[SND_SOC_TPLG_MAX_CHAN];
 };
 
-int avs_control_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
-int avs_control_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
-int avs_control_volume_get2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl);
-int avs_control_volume_put2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl);
+int avs_control_volume_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl);
+int avs_control_volume_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl);
 int avs_control_volume_info(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo);
 
 #endif
index a72ebde7d011593fa4b92840b1f541ad3a4a67e8..56a2916eec5e6508f9ce11e4c3967e9fcb6acdeb 100644 (file)
@@ -370,7 +370,7 @@ static int avs_peakvol_create(struct avs_dev *adev, struct avs_path_module *mod)
 
        ctl_data = avs_get_module_control(mod);
        if (ctl_data)
-               volume = ctl_data->volume;
+               volume = ctl_data->values[0];
 
        /* As 2+ channels controls are unsupported, have a single block for all channels. */
        cfg_size = struct_size(cfg, vols, 1);
index 45952fbe9694bf930e7aff030bdf342eaa2196a4..ee70e3d0e889004f64a1e14b3850b70c02c185dc 100644 (file)
@@ -1912,6 +1912,7 @@ static const struct snd_soc_tplg_kcontrol_ops avs_control_ops[] = {
                .id = AVS_CONTROL_OPS_VOLUME,
                .get = avs_control_volume_get,
                .put = avs_control_volume_put,
+               .info = avs_control_volume_info,
        },
 };