Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions sound/soc/sof/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ static int sof_restore_pipelines(struct snd_sof_dev *sdev)
struct snd_sof_dai *dai;
struct sof_ipc_comp_dai *comp_dai;
struct sof_ipc_cmd_hdr *hdr;
int max_index = 0;
int link_index = 0;
int ret = 0;

/* restore pipeline components */
list_for_each_entry_reverse(swidget, &sdev->widget_list, list) {
struct sof_ipc_comp_reply r;
struct sof_ipc_dai_config *config;

/* skip if there is no private data */
if (!swidget->private)
Expand All @@ -82,6 +85,11 @@ static int sof_restore_pipelines(struct snd_sof_dev *sdev)
comp_dai->comp.hdr.cmd,
comp_dai, sizeof(*comp_dai),
&r, sizeof(r));

config = dai->dai_config;
if (config->dai_index > max_index)
max_index = config->dai_index;

break;
case snd_soc_dapm_scheduler:

Expand Down Expand Up @@ -138,23 +146,32 @@ static int sof_restore_pipelines(struct snd_sof_dev *sdev)
}
}

/* restore dai links */
list_for_each_entry_reverse(dai, &sdev->dai_list, list) {
struct sof_ipc_reply reply;
struct sof_ipc_dai_config *config = dai->dai_config;
/* restore dai links from index 0 to max index */
while (link_index <= max_index) {
list_for_each_entry_reverse(dai, &sdev->dai_list, list) {
struct sof_ipc_reply reply;
struct sof_ipc_dai_config *config = dai->dai_config;

ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd, config,
config->hdr.size,
&reply, sizeof(reply));
if (config->dai_index == link_index) {
ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd,
config,
config->hdr.size,
&reply, sizeof(reply));

if (ret < 0) {
dev_err(sdev->dev,
"error: failed to set dai config for %s\n",
dai->name);
if (ret < 0) {
dev_err(sdev->dev,
"error: failed to set dai config for %s\n",
dai->name);

return ret;
return ret;
}

break;
}
}

link_index++;
}

/* complete pipeline */
Expand Down
55 changes: 37 additions & 18 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -1920,15 +1920,17 @@ static void sof_dai_set_format(struct snd_soc_tplg_hw_config *hw_config,
/* set config for all DAI's with name matching the link name */
static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size,
struct snd_soc_dai_link *link,
struct sof_ipc_dai_config *config)
struct sof_ipc_dai_config *config,
int direction)
{
struct snd_sof_dai *dai;

list_for_each_entry(dai, &sdev->dai_list, list) {
if (!dai->name)
continue;

if (strcmp(link->name, dai->name) == 0) {
if (strcmp(link->name, dai->name) == 0 &&
dai->comp_dai.direction == direction) {
dai->dai_config = kmemdup(config, size, GFP_KERNEL);
if (!dai->dai_config)
return -ENOMEM;
Expand Down Expand Up @@ -1993,11 +1995,23 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index,
return ret;
}

/* set config for all DAI's with name matching the link name */
ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0)
dev_err(sdev->dev, "error: failed to save DAI config for SSP%d\n",
config->dai_index);
/* set config to dai component of playback */
if (link->dpcm_playback) {
ret = sof_set_dai_config(sdev, size, link, config,
SNDRV_PCM_STREAM_PLAYBACK);
if (ret < 0)
dev_err(sdev->dev, "error: failed to save DAI config in dai component of playback for SSP%d\n",
config->dai_index);
}

/* set config to dai component of capture */
if (link->dpcm_capture) {
ret = sof_set_dai_config(sdev, size, link, config,
SNDRV_PCM_STREAM_CAPTURE);
if (ret < 0)
dev_err(sdev->dev, "error: failed to save DAI config in dai component of capture for SSP%d\n",
config->dai_index);
}

return ret;
}
Expand Down Expand Up @@ -2113,8 +2127,9 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index,
goto err;
}

/* set config for all DAI's with name matching the link name */
ret = sof_set_dai_config(sdev, size, link, ipc_config);
/* set config to dai component of capture */
ret = sof_set_dai_config(sdev, size, link, ipc_config,
SNDRV_PCM_STREAM_CAPTURE);
if (ret < 0)
dev_err(sdev->dev, "error: failed to save DAI config for DMIC%d\n",
config->dai_index);
Expand Down Expand Up @@ -2237,6 +2252,14 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index,

return ret;
}

/* set config to dai component of playback */
ret = sof_set_dai_config(sdev, size, link, config,
SNDRV_PCM_STREAM_PLAYBACK);
if (ret < 0) {
dev_err(sdev->dev, "error: failed to save DAI config for playback HDA%d\n",
config->dai_index);
}
}

if (link->dpcm_capture) {
Expand All @@ -2248,18 +2271,14 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index,

return ret;
}
}

/* set config for all DAI's with name matching the link name */
ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0) {
if (link->dpcm_playback)
dev_err(sdev->dev, "error: failed to save DAI config for playback HDA%d\n",
config->dai_index);

if (link->dpcm_capture)
/* set config to dai component of capture */
ret = sof_set_dai_config(sdev, size, link, config,
SNDRV_PCM_STREAM_CAPTURE);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, you could do all this in the sof_set_dai_config, and you store the config in all components supported (playback, capture, playback and capture).

if (ret < 0) {
dev_err(sdev->dev, "error: failed to save DAI config for capture HDA%d\n",
config->dai_index);
}
}

return ret;
Expand Down