Skip to content
Open
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
31 changes: 7 additions & 24 deletions drivers/soundwire/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,19 +906,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
}

switch (cmd) {
case SNDRV_PCM_TRIGGER_SUSPEND:

/*
* The .prepare callback is used to deal with xruns and resume operations.
* In the case of xruns, the DMAs and SHIM registers cannot be touched,
* but for resume operations the DMAs and SHIM registers need to be initialized.
* the .trigger callback is used to track the suspend case only.
*/

dai_runtime->suspended = true;

break;

case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
dai_runtime->paused = true;
break;
Expand Down Expand Up @@ -955,24 +942,20 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
struct snd_soc_dai *dai;

/*
* In the corner case where a SUSPEND happens during a PAUSE, the ALSA core
* does not throw the TRIGGER_SUSPEND. This leaves the DAIs in an unbalanced state.
* Since the component suspend is called last, we can trap this corner case
* and force the DAIs to release their resources.
* Mark all open streams as suspended.
* Open streams at this point can be in SUSPENDED, PAUSED or STOPPED
* state and during prepare the DMAs and SHIM registers need to be
* initialized for them.
* The STOPPED state is a special corner case which can happen if audio
* experiences xrun at suspend time.
*/
for_each_component_dais(component, dai) {
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
struct sdw_cdns_dai_runtime *dai_runtime;

dai_runtime = cdns->dai_runtime_array[dai->id];

if (!dai_runtime)
continue;

if (dai_runtime->suspended)
continue;

if (dai_runtime->paused)
if (dai_runtime)
dai_runtime->suspended = true;
}

Expand Down
39 changes: 26 additions & 13 deletions drivers/soundwire/intel_ace2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,19 +895,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
}

switch (cmd) {
case SNDRV_PCM_TRIGGER_SUSPEND:

/*
* The .prepare callback is used to deal with xruns and resume operations.
* In the case of xruns, the DMAs and SHIM registers cannot be touched,
* but for resume operations the DMAs and SHIM registers need to be initialized.
* the .trigger callback is used to track the suspend case only.
*/

dai_runtime->suspended = true;

break;

case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
dai_runtime->paused = true;
break;
Expand All @@ -931,8 +918,34 @@ static const struct snd_soc_dai_ops intel_pcm_dai_ops = {
.get_stream = intel_get_sdw_stream,
};

static int intel_component_dais_suspend(struct snd_soc_component *component)
{
struct snd_soc_dai *dai;

/*
* Mark all open streams as suspended.
* Open streams at this point can be in SUSPENDED, PAUSED or STOPPED
* state and during prepare the DMAs and SHIM registers need to be
* initialized for them.
* The STOPPED state is a special corner case which can happen if audio
* experiences xrun at suspend time.
*/
for_each_component_dais(component, dai) {
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
struct sdw_cdns_dai_runtime *dai_runtime;

dai_runtime = cdns->dai_runtime_array[dai->id];

if (dai_runtime)
dai_runtime->suspended = true;
}

return 0;
}

static const struct snd_soc_component_driver dai_component = {
.name = "soundwire",
.suspend = intel_component_dais_suspend,
};

/*
Expand Down
Loading