summaryrefslogtreecommitdiff
path: root/sound/soc/sof/control.c
diff options
context:
space:
mode:
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>2022-03-17 10:50:32 -0700
committerMark Brown <broonie@kernel.org>2022-03-18 16:04:41 +0000
commita6668746436824c46b54b3f7fd72523f05f089eb (patch)
treeb75d055c18fcbf2a49730b4e7347bbf4edcf088e /sound/soc/sof/control.c
parent838d04f3e232c3fb8c421959e8ff09e3a918011e (diff)
ASoC: SOF: Add switch get/put IPC3 ops
Add the switch_get/put control IPC ops for IPC3. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20220317175044.1752400-8-ranjani.sridharan@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/control.c')
-rw-r--r--sound/soc/sof/control.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index 9eb54b7024b3..f9f8bd37b480 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -127,17 +127,14 @@ int snd_sof_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
- struct soc_mixer_control *sm =
- (struct soc_mixer_control *)kcontrol->private_value;
+ struct soc_mixer_control *sm = (struct soc_mixer_control *)kcontrol->private_value;
struct snd_sof_control *scontrol = sm->dobj.private;
- struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
- unsigned int i, channels = scontrol->num_channels;
-
- snd_sof_refresh_control(scontrol);
+ struct snd_soc_component *scomp = scontrol->scomp;
+ struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
+ const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg;
- /* read back each channel */
- for (i = 0; i < channels; i++)
- ucontrol->value.integer.value[i] = cdata->chanv[i].value;
+ if (tplg_ops->control->switch_get)
+ return tplg_ops->control->switch_get(scontrol, ucontrol);
return 0;
}
@@ -145,31 +142,19 @@ int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
- struct soc_mixer_control *sm =
- (struct soc_mixer_control *)kcontrol->private_value;
+ struct soc_mixer_control *sm = (struct soc_mixer_control *)kcontrol->private_value;
struct snd_sof_control *scontrol = sm->dobj.private;
struct snd_soc_component *scomp = scontrol->scomp;
- struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
- unsigned int i, channels = scontrol->num_channels;
- bool change = false;
- u32 value;
-
- /* update each channel */
- for (i = 0; i < channels; i++) {
- value = ucontrol->value.integer.value[i];
- change = change || (value != cdata->chanv[i].value);
- cdata->chanv[i].channel = i;
- cdata->chanv[i].value = value;
- }
+ struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
+ const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg;
if (scontrol->led_ctl.use_led)
update_mute_led(scontrol, kcontrol, ucontrol);
- /* notify DSP of mixer updates */
- if (pm_runtime_active(scomp->dev))
- snd_sof_ipc_set_get_comp_data(scontrol, true);
+ if (tplg_ops->control->switch_put)
+ return tplg_ops->control->switch_put(scontrol, ucontrol);
- return change;
+ return false;
}
int snd_sof_enum_get(struct snd_kcontrol *kcontrol,