Skip to content

Commit 5f3aad7

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: restore kcontrols for widget during set up
Restore kcontrols for each widget after it has been set up successfully. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Seppo Ingalsuo <seppo.ingalsuo@intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20210927120517.20505-8-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 0a2dea1 commit 5f3aad7

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

sound/soc/sof/sof-audio.c

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ static int sof_dai_config_setup(struct snd_sof_dev *sdev, struct snd_sof_dai *da
6464
return ret;
6565
}
6666

67+
static int sof_widget_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
68+
{
69+
struct snd_sof_control *scontrol;
70+
int ret;
71+
72+
/* set up all controls for the widget */
73+
list_for_each_entry(scontrol, &sdev->kcontrol_list, list)
74+
if (scontrol->comp_id == swidget->comp_id) {
75+
ret = sof_kcontrol_setup(sdev, scontrol);
76+
if (ret < 0) {
77+
dev_err(sdev->dev, "error: fail to set up kcontrols for widget %s\n",
78+
swidget->widget->name);
79+
return ret;
80+
}
81+
}
82+
83+
return 0;
84+
}
85+
6786
static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
6887
{
6988
struct sof_ipc_pipe_new *pipeline;
@@ -113,10 +132,20 @@ static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swi
113132
&r, sizeof(r));
114133
break;
115134
}
116-
if (ret < 0)
135+
if (ret < 0) {
117136
dev_err(sdev->dev, "error: failed to load widget %s\n", swidget->widget->name);
118-
else
119-
dev_dbg(sdev->dev, "widget %s setup complete\n", swidget->widget->name);
137+
return ret;
138+
}
139+
140+
/* restore kcontrols for widget */
141+
ret = sof_widget_kcontrol_setup(sdev, swidget);
142+
if (ret < 0) {
143+
dev_err(sdev->dev, "error: failed to restore kcontrols for widget %s\n",
144+
swidget->widget->name);
145+
return ret;
146+
}
147+
148+
dev_dbg(sdev->dev, "widget %s setup complete\n", swidget->widget->name);
120149

121150
return ret;
122151
}
@@ -203,22 +232,6 @@ int sof_set_hw_params_upon_resume(struct device *dev)
203232
return snd_sof_dsp_hw_params_upon_resume(sdev);
204233
}
205234

206-
static int sof_restore_kcontrols(struct device *dev)
207-
{
208-
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
209-
struct snd_sof_control *scontrol;
210-
int ret = 0;
211-
212-
/* restore kcontrol values */
213-
list_for_each_entry(scontrol, &sdev->kcontrol_list, list) {
214-
ret = sof_kcontrol_setup(sdev, scontrol);
215-
if (ret < 0)
216-
return ret;
217-
}
218-
219-
return 0;
220-
}
221-
222235
const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
223236
int pipeline_id)
224237
{
@@ -309,13 +322,7 @@ int sof_restore_pipelines(struct device *dev)
309322
}
310323
}
311324

312-
/* restore pipeline kcontrols */
313-
ret = sof_restore_kcontrols(dev);
314-
if (ret < 0)
315-
dev_err(dev,
316-
"error: restoring kcontrols after resume\n");
317-
318-
return ret;
325+
return 0;
319326
}
320327

321328
/* This function doesn't free widgets. It only resets the set up status for all routes */

0 commit comments

Comments
 (0)