Commit a6668746 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown
parent 838d04f3
...@@ -127,17 +127,14 @@ int snd_sof_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info ...@@ -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, int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct soc_mixer_control *sm = struct soc_mixer_control *sm = (struct soc_mixer_control *)kcontrol->private_value;
(struct soc_mixer_control *)kcontrol->private_value;
struct snd_sof_control *scontrol = sm->dobj.private; struct snd_sof_control *scontrol = sm->dobj.private;
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data; struct snd_soc_component *scomp = scontrol->scomp;
unsigned int i, channels = scontrol->num_channels; struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg;
snd_sof_refresh_control(scontrol);
/* read back each channel */ if (tplg_ops->control->switch_get)
for (i = 0; i < channels; i++) return tplg_ops->control->switch_get(scontrol, ucontrol);
ucontrol->value.integer.value[i] = cdata->chanv[i].value;
return 0; return 0;
} }
...@@ -145,31 +142,19 @@ int snd_sof_switch_get(struct snd_kcontrol *kcontrol, ...@@ -145,31 +142,19 @@ int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
int snd_sof_switch_put(struct snd_kcontrol *kcontrol, int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct soc_mixer_control *sm = struct soc_mixer_control *sm = (struct soc_mixer_control *)kcontrol->private_value;
(struct soc_mixer_control *)kcontrol->private_value;
struct snd_sof_control *scontrol = sm->dobj.private; struct snd_sof_control *scontrol = sm->dobj.private;
struct snd_soc_component *scomp = scontrol->scomp; struct snd_soc_component *scomp = scontrol->scomp;
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data; struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
unsigned int i, channels = scontrol->num_channels; const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg;
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;
}
if (scontrol->led_ctl.use_led) if (scontrol->led_ctl.use_led)
update_mute_led(scontrol, kcontrol, ucontrol); update_mute_led(scontrol, kcontrol, ucontrol);
/* notify DSP of mixer updates */ if (tplg_ops->control->switch_put)
if (pm_runtime_active(scomp->dev)) return tplg_ops->control->switch_put(scontrol, ucontrol);
snd_sof_ipc_set_get_comp_data(scontrol, true);
return change; return false;
} }
int snd_sof_enum_get(struct snd_kcontrol *kcontrol, int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
......
...@@ -109,6 +109,54 @@ static bool sof_ipc3_volume_put(struct snd_sof_control *scontrol, ...@@ -109,6 +109,54 @@ static bool sof_ipc3_volume_put(struct snd_sof_control *scontrol,
return change; return change;
} }
static int sof_ipc3_switch_get(struct snd_sof_control *scontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
unsigned int channels = scontrol->num_channels;
unsigned int i;
snd_sof_refresh_control(scontrol);
/* read back each channel */
for (i = 0; i < channels; i++)
ucontrol->value.integer.value[i] = cdata->chanv[i].value;
return 0;
}
static bool sof_ipc3_switch_put(struct snd_sof_control *scontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
struct snd_soc_component *scomp = scontrol->scomp;
unsigned int channels = scontrol->num_channels;
unsigned int i;
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;
}
/* notify DSP of mixer updates */
if (pm_runtime_active(scomp->dev)) {
int ret = snd_sof_ipc_set_get_comp_data(scontrol, true);
if (ret < 0) {
dev_err(scomp->dev, "Failed to set mixer updates for %s\n",
scontrol->name);
return false;
}
}
return change;
}
static void snd_sof_update_control(struct snd_sof_control *scontrol, static void snd_sof_update_control(struct snd_sof_control *scontrol,
struct sof_ipc_ctrl_data *cdata) struct sof_ipc_ctrl_data *cdata)
{ {
...@@ -252,5 +300,7 @@ static void sof_ipc3_control_update(struct snd_sof_dev *sdev, void *ipc_control_ ...@@ -252,5 +300,7 @@ static void sof_ipc3_control_update(struct snd_sof_dev *sdev, void *ipc_control_
const struct sof_ipc_tplg_control_ops tplg_ipc3_control_ops = { const struct sof_ipc_tplg_control_ops tplg_ipc3_control_ops = {
.volume_put = sof_ipc3_volume_put, .volume_put = sof_ipc3_volume_put,
.volume_get = sof_ipc3_volume_get, .volume_get = sof_ipc3_volume_get,
.switch_put = sof_ipc3_switch_put,
.switch_get = sof_ipc3_switch_get,
.update = sof_ipc3_control_update, .update = sof_ipc3_control_update,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment