Skip to content
Merged
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
8 changes: 8 additions & 0 deletions sound/core/pcm_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,14 @@ int snd_pcm_suspend_all(struct snd_pcm *pcm)
/* FIXME: the open/close code should lock this as well */
if (substream->runtime == NULL)
continue;

/*
* Skip BE dai link PCM's that are internal and may
* not have their substream ops set.
*/
if (!substream->ops)
continue;

err = snd_pcm_suspend(substream);
if (err < 0 && err != -EBUSY)
return err;
Expand Down
1 change: 1 addition & 0 deletions sound/soc/intel/boards/bxt_pcm512x.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ static int bxt_pcm512x_probe(struct platform_device *pdev)
static struct platform_driver bxt_pcm521x_driver = {
.driver = {
.name = "bxt-pcm512x",
.pm = &snd_soc_pm_ops,

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.

Probably worth checking if this is missing from the other Intel machine drivers.

},
.probe = bxt_pcm512x_probe,
};
Expand Down
33 changes: 17 additions & 16 deletions sound/soc/sof/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream,
/* save pcm hw_params */
memcpy(&spcm->params[substream->stream], params, sizeof(*params));

/* unset restore_stream */
spcm->restore_stream[substream->stream] = 0;

return ret;
}

Expand Down Expand Up @@ -252,22 +255,6 @@ static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
stream.comp_id = spcm->stream[substream->stream].comp_id;

switch (cmd) {
case SNDRV_PCM_TRIGGER_STOP:

/*
* Check if stream was marked for restore before suspend
*/
if (spcm->restore_stream[substream->stream]) {

/* unset restore_stream */
spcm->restore_stream[substream->stream] = 0;

/* do not send ipc as the stream hasn't been set up */
return 0;
}

stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_STOP;
break;
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_PAUSE;
break;
Expand Down Expand Up @@ -313,6 +300,20 @@ static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd)

break;
case SNDRV_PCM_TRIGGER_SUSPEND:
/* fallthrough */
case SNDRV_PCM_TRIGGER_STOP:

/* Check if stream was marked for restore before suspend */
if (spcm->restore_stream[substream->stream]) {

/* unset restore_stream */
spcm->restore_stream[substream->stream] = 0;

/* do not send ipc as the stream hasn't been set up */
return 0;
}

stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_STOP;
break;
default:
dev_err(sdev->dev, "error: unhandled trigger cmd %d\n", cmd);
Expand Down
33 changes: 6 additions & 27 deletions sound/soc/sof/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,35 +194,16 @@ static int sof_send_pm_ipc(struct snd_sof_dev *sdev, int cmd)
sizeof(pm_ctx), &reply, sizeof(reply));
}

static void sof_suspend_streams(struct snd_sof_dev *sdev)
static void sof_set_restore_stream(struct snd_sof_dev *sdev)
{
struct snd_sof_pcm *spcm;
struct snd_pcm_substream *substream;
int dir, playback_dir, capture_dir;

/* suspend all running streams */
list_for_each_entry(spcm, &sdev->pcm_list, list) {

mutex_lock(&spcm->mutex);

playback_dir = SNDRV_PCM_STREAM_PLAYBACK;
capture_dir = SNDRV_PCM_STREAM_CAPTURE;

/* suspend running streams in both directions */
for (dir = playback_dir; dir <= capture_dir; dir++) {
substream = spcm->stream[dir].substream;

if (substream && substream->runtime) {

snd_pcm_suspend(substream);

/*
* set restore_stream so that hw_params can be
* restored during resume
*/
spcm->restore_stream[dir] = 1;
}
}
spcm->restore_stream[0] = 1;
spcm->restore_stream[1] = 1;

mutex_unlock(&spcm->mutex);
}
Expand Down Expand Up @@ -311,11 +292,9 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
/* release trace */
snd_sof_release_trace(sdev);

/*
* Suspend running pcm streams.
* They will be restarted by ALSA resume trigger call.
*/
sof_suspend_streams(sdev);
/* set restore_stream for all streams during system suspend */
if (!runtime_suspend)
sof_set_restore_stream(sdev);

/* notify DSP of upcoming power down */
ret = sof_send_pm_ipc(sdev, SOF_IPC_PM_CTX_SAVE);
Expand Down