Skip to content

Commit

Permalink
ASoC: SOF: pipelines: Harmonize all functions to use struct snd_sof_dev
Browse files Browse the repository at this point in the history
First thing the pipelines function which have "struct device *dev" as
parameter do is:
struct snd_sof_dev *sdev = dev_get_drvdata(dev);

and in all cases the passed dev is actually coming from sdev->dev.

Skip this steps and pass directly the sdev to all pipelines related
functions as few of them already does this.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
  • Loading branch information
ujfalusi authored and kv2019i committed Jun 28, 2021
1 parent 5b851f4 commit 6b53609
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
4 changes: 2 additions & 2 deletions sound/soc/sof/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static int sof_resume(struct device *dev, bool runtime_resume)
}

/* restore pipelines */
ret = sof_set_up_pipelines(sdev->dev, false);
ret = sof_set_up_pipelines(sdev, false);
if (ret < 0) {
dev_err(sdev->dev,
"error: failed to restore pipeline after resume %d\n",
Expand Down Expand Up @@ -208,7 +208,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
if (target_state == SOF_DSP_PM_D0)
goto suspend;

sof_tear_down_pipelines(dev, false);
sof_tear_down_pipelines(sdev, false);

/* release trace */
snd_sof_release_trace(sdev);
Expand Down
14 changes: 6 additions & 8 deletions sound/soc/sof/sof-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
break;
case snd_soc_dapm_scheduler:
pipeline = swidget->private;
ret = sof_load_pipeline_ipc(sdev->dev, pipeline, &r);
ret = sof_load_pipeline_ipc(sdev, pipeline, &r);
break;
default:
hdr = swidget->private;
Expand Down Expand Up @@ -414,7 +414,7 @@ int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, in
if (pipe_widget->complete)
continue;

pipe_widget->complete = snd_sof_complete_pipeline(sdev->dev, pipe_widget);
pipe_widget->complete = snd_sof_complete_pipeline(sdev, pipe_widget);
if (pipe_widget->complete < 0) {
ret = pipe_widget->complete;
goto widget_free;
Expand Down Expand Up @@ -579,9 +579,8 @@ const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
return NULL;
}

int sof_set_up_pipelines(struct device *dev, bool verify)
int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)
{
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
struct snd_sof_widget *swidget;
struct snd_sof_route *sroute;
int ret;
Expand Down Expand Up @@ -638,7 +637,7 @@ int sof_set_up_pipelines(struct device *dev, bool verify)
connect, sizeof(*connect),
&reply, sizeof(reply));
if (ret < 0) {
dev_err(dev,
dev_err(sdev->dev,
"error: failed to load route sink %s control %s source %s\n",
sroute->route->sink,
sroute->route->control ? sroute->route->control
Expand All @@ -660,7 +659,7 @@ int sof_set_up_pipelines(struct device *dev, bool verify)
continue;

swidget->complete =
snd_sof_complete_pipeline(dev, swidget);
snd_sof_complete_pipeline(sdev, swidget);
break;
default:
break;
Expand All @@ -674,9 +673,8 @@ int sof_set_up_pipelines(struct device *dev, bool verify)
* This function doesn't free widgets during suspend. It only resets the set up status for all
* routes and use_count for all widgets.
*/
int sof_tear_down_pipelines(struct device *dev, bool verify)
int sof_tear_down_pipelines(struct snd_sof_dev *sdev, bool verify)
{
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
struct snd_sof_widget *swidget;
struct snd_sof_route *sroute;
int ret;
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/sof/sof-audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ void snd_sof_control_notify(struct snd_sof_dev *sdev,
* be freed by snd_soc_unregister_component,
*/
int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file);
int snd_sof_complete_pipeline(struct device *dev,
int snd_sof_complete_pipeline(struct snd_sof_dev *sdev,
struct snd_sof_widget *swidget);

int sof_load_pipeline_ipc(struct device *dev,
int sof_load_pipeline_ipc(struct snd_sof_dev *sdev,
struct sof_ipc_pipe_new *pipeline,
struct sof_ipc_comp_reply *r);
int sof_pipeline_core_enable(struct snd_sof_dev *sdev,
Expand Down Expand Up @@ -246,8 +246,8 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);

/* PM */
int sof_set_up_pipelines(struct device *dev, bool verify);
int sof_tear_down_pipelines(struct device *dev, bool verify);
int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify);
int sof_tear_down_pipelines(struct snd_sof_dev *sdev, bool verify);
int sof_set_hw_params_upon_resume(struct device *dev);
bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev);
bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev);
Expand Down
16 changes: 7 additions & 9 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,11 +1690,10 @@ static int sof_widget_load_pcm(struct snd_soc_component *scomp, int index,
/*
* Pipeline Topology
*/
int sof_load_pipeline_ipc(struct device *dev,
int sof_load_pipeline_ipc(struct snd_sof_dev *sdev,
struct sof_ipc_pipe_new *pipeline,
struct sof_ipc_comp_reply *r)
{
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
int ret = sof_core_enable(sdev, pipeline->core);

if (ret < 0)
Expand All @@ -1703,7 +1702,7 @@ int sof_load_pipeline_ipc(struct device *dev,
ret = sof_ipc_tx_message(sdev->ipc, pipeline->hdr.cmd, pipeline,
sizeof(*pipeline), r, sizeof(*r));
if (ret < 0)
dev_err(dev, "error: load pipeline ipc failure\n");
dev_err(sdev->dev, "error: load pipeline ipc failure\n");

return ret;
}
Expand Down Expand Up @@ -3388,15 +3387,14 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
return ret;
}

int snd_sof_complete_pipeline(struct device *dev,
int snd_sof_complete_pipeline(struct snd_sof_dev *sdev,
struct snd_sof_widget *swidget)
{
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
struct sof_ipc_pipe_ready ready;
struct sof_ipc_reply reply;
int ret;

dev_dbg(dev, "tplg: complete pipeline %s id %d\n",
dev_dbg(sdev->dev, "tplg: complete pipeline %s id %d\n",
swidget->widget->name, swidget->comp_id);

memset(&ready, 0, sizeof(ready));
Expand Down Expand Up @@ -3475,21 +3473,21 @@ static int sof_complete(struct snd_soc_component *scomp)

/* verify topology components loading including dynamic pipelines */
if (sof_core_debug & SOF_DBG_VERIFY_TPLG) {
ret = sof_set_up_pipelines(scomp->dev, true);
ret = sof_set_up_pipelines(sdev, true);
if (ret < 0) {
dev_err(sdev->dev, "error: topology verification failed %d\n", ret);
return ret;
}

ret = sof_tear_down_pipelines(scomp->dev, true);
ret = sof_tear_down_pipelines(sdev, true);
if (ret < 0) {
dev_err(sdev->dev, "error: topology tear down pipelines failed %d\n", ret);
return ret;
}
}

/* set up static pipelines */
return sof_set_up_pipelines(scomp->dev, false);
return sof_set_up_pipelines(sdev, false);
}

/* manifest - optional to inform component of manifest */
Expand Down

0 comments on commit 6b53609

Please sign in to comment.