linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: add stop_dma_first flag to reverse the stop sequence
@ 2021-07-05 19:36 Vijendar Mukunda
  2021-07-06 12:28 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Vijendar Mukunda @ 2021-07-05 19:36 UTC (permalink / raw)
  To: broonie, peter.ujfalusi, alsa-devel
  Cc: amistry, nartemiev, Alexander.Deucher, Basavaraj.Hiregoudar,
	Sunil-kumar.Dommati, Vijendar Mukunda, Vijendar Mukunda,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Chuhong Yuan,
	Pierre-Louis Bossart, Kuninori Morimoto, open list

From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>

On stream stop, currently CPU DAI stop sequence invoked first
followed by DMA. For Few platforms, it is required to stop the
DMA first before stopping CPU DAI.

For Stoneyridge platform, it is required to invoke DMA driver stop
first rather than invoking DWC I2S controller stop.
Introduced new flag in sound card structure for reordering stop sequence.
Based on flag check, ASoC core will re-order the stop requence.

Signed-off-by: Vijendar Mukunda <vijendar.mukunda@amd.com>
---
v1 -> v2: renamed flag as "stop_dma_fist"
          fixed build error by removing extra + symbol 
          sound/soc/soc-pcm.c:1019:3: error: expected expression before 'struct'
          1019 | + struct snd_soc_card *card = rtd->card;  
 include/sound/soc.h                  |  1 +
 sound/soc/amd/acp-da7219-max98357a.c |  1 +
 sound/soc/soc-pcm.c                  | 23 +++++++++++++++++------
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 675849d07284..aa63282aac2c 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -982,6 +982,7 @@ struct snd_soc_card {
 	unsigned int disable_route_checks:1;
 	unsigned int probed:1;
 	unsigned int component_chaining:1;
+	unsigned int stop_dma_first:1;
 
 	void *drvdata;
 };
diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c
index 84e3906abd4f..a2bf49f81a80 100644
--- a/sound/soc/amd/acp-da7219-max98357a.c
+++ b/sound/soc/amd/acp-da7219-max98357a.c
@@ -742,6 +742,7 @@ static int cz_probe(struct platform_device *pdev)
 	if (!machine)
 		return -ENOMEM;
 	card->dev = &pdev->dev;
+	cz_card.stop_dma_first = true;
 	platform_set_drvdata(pdev, card);
 	snd_soc_card_set_drvdata(card, machine);
 	ret = devm_snd_soc_register_card(&pdev->dev, card);
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 46513bb97904..062fb6fcc03f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1015,6 +1015,8 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 
 static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
+	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+	struct snd_soc_card *card = rtd->card;
 	int ret = -EINVAL, _ret = 0;
 	int rollback = 0;
 
@@ -1055,14 +1057,23 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		ret = snd_soc_pcm_dai_trigger(substream, cmd, rollback);
-		if (ret < 0)
-			break;
+		if (card->stop_dma_first) {
+			ret = snd_soc_pcm_component_trigger(substream, cmd, rollback);
+			if (ret < 0)
+				break;
 
-		ret = snd_soc_pcm_component_trigger(substream, cmd, rollback);
-		if (ret < 0)
-			break;
+			ret = snd_soc_pcm_dai_trigger(substream, cmd, rollback);
+			if (ret < 0)
+				break;
+		} else {
+			ret = snd_soc_pcm_dai_trigger(substream, cmd, rollback);
+			if (ret < 0)
+				break;
 
+			ret = snd_soc_pcm_component_trigger(substream, cmd, rollback);
+			if (ret < 0)
+				break;
+		}
 		ret = snd_soc_link_trigger(substream, cmd, rollback);
 		break;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ASoC: add stop_dma_first flag to reverse the stop sequence
  2021-07-05 19:36 [PATCH v2] ASoC: add stop_dma_first flag to reverse the stop sequence Vijendar Mukunda
@ 2021-07-06 12:28 ` Mark Brown
  2021-07-07 10:25   ` Mukunda,Vijendar
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2021-07-06 12:28 UTC (permalink / raw)
  To: Vijendar Mukunda
  Cc: peter.ujfalusi, alsa-devel, amistry, nartemiev,
	Alexander.Deucher, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Chuhong Yuan,
	Pierre-Louis Bossart, Kuninori Morimoto, open list

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

On Tue, Jul 06, 2021 at 01:06:17AM +0530, Vijendar Mukunda wrote:

> @@ -982,6 +982,7 @@ struct snd_soc_card {
>  	unsigned int disable_route_checks:1;
>  	unsigned int probed:1;
>  	unsigned int component_chaining:1;
> +	unsigned int stop_dma_first:1;
>  
>  	void *drvdata;
>  };

This still doesn't seem like something which should be controlled at the
card level, I'd expect it to be configured at the dai_link level.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ASoC: add stop_dma_first flag to reverse the stop sequence
  2021-07-06 12:28 ` Mark Brown
@ 2021-07-07 10:25   ` Mukunda,Vijendar
  0 siblings, 0 replies; 3+ messages in thread
From: Mukunda,Vijendar @ 2021-07-07 10:25 UTC (permalink / raw)
  To: Mark Brown
  Cc: peter.ujfalusi, alsa-devel, amistry, nartemiev,
	Alexander.Deucher, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Chuhong Yuan,
	Pierre-Louis Bossart, Kuninori Morimoto, open list

On 7/6/21 5:58 PM, Mark Brown wrote:
> On Tue, Jul 06, 2021 at 01:06:17AM +0530, Vijendar Mukunda wrote:
> 
>> @@ -982,6 +982,7 @@ struct snd_soc_card {
>>  	unsigned int disable_route_checks:1;
>>  	unsigned int probed:1;
>>  	unsigned int component_chaining:1;
>> +	unsigned int stop_dma_first:1;
>>  
>>  	void *drvdata;
>>  };
> 
> This still doesn't seem like something which should be controlled at the
> card level, I'd expect it to be configured at the dai_link level.
> 
will make changes by adding flag in dai_link and will post the new version

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-07 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 19:36 [PATCH v2] ASoC: add stop_dma_first flag to reverse the stop sequence Vijendar Mukunda
2021-07-06 12:28 ` Mark Brown
2021-07-07 10:25   ` Mukunda,Vijendar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).