From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>,
alsa-devel@alsa-project.org
Cc: tiwai@suse.de, "Bard Liao" <yung-chuan.liao@linux.intel.com>,
"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
"Rander Wang" <rander.wang@intel.com>,
broonie@kernel.org,
"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
Subject: Re: [PATCH 1/2] ASoC: soc-pcm: improve BE transition for PAUSE_RELEASE
Date: Thu, 7 Apr 2022 08:23:54 -0500 [thread overview]
Message-ID: <cbea05d4-ed7b-d0d7-53a6-80add0d8ffe2@linux.intel.com> (raw)
In-Reply-To: <bf8b2067-3d5d-c368-68b0-f5ab58d9c5b7@linux.intel.com>
>> diff --git a/include/sound/soc-dpcm.h b/include/sound/soc-dpcm.h
>> index 75b92d883976..5b689c663290 100644
>> --- a/include/sound/soc-dpcm.h
>> +++ b/include/sound/soc-dpcm.h
>> @@ -103,6 +103,8 @@ struct snd_soc_dpcm_runtime {
>> int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */
>> int be_start; /* refcount protected by BE stream pcm lock */
>> + int be_pause; /* refcount protected by BE stream pcm lock */
>> + bool fe_pause; /* used to track STOP after PAUSE */
>> };
>> #define for_each_dpcm_fe(be, stream, _dpcm) \
>> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
>> index 11c9853e9e80..e8700dd1839f 100644
>> --- a/sound/soc/soc-pcm.c
>> +++ b/sound/soc/soc-pcm.c
>> @@ -2090,6 +2090,7 @@ int dpcm_be_dai_trigger(struct
>> snd_soc_pcm_runtime *fe, int stream,
>> int cmd)
>> {
>> struct snd_soc_pcm_runtime *be;
>> + bool pause_stop_transition;
>> struct snd_soc_dpcm *dpcm;
>> unsigned long flags;
>> int ret = 0;
>> @@ -2148,10 +2149,12 @@ int dpcm_be_dai_trigger(struct
>> snd_soc_pcm_runtime *fe, int stream,
>> case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
>> if (!be->dpcm[stream].be_start &&
>> (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) &&
>> - (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
>> (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED))
>> goto next;
>> + fe->dpcm[stream].fe_pause = false;
>> + be->dpcm[stream].be_pause--;
>> +
>> be->dpcm[stream].be_start++;
>> if (be->dpcm[stream].be_start != 1)
>> goto next;
>> @@ -2175,14 +2178,33 @@ int dpcm_be_dai_trigger(struct
>> snd_soc_pcm_runtime *fe, int stream,
>> if (be->dpcm[stream].be_start != 0)
>> goto next;
>> - ret = soc_pcm_trigger(be_substream, cmd);
>> + pause_stop_transition = false;
>> + if (fe->dpcm[stream].fe_pause) {
>
> As you access fe here anyway, any chance something like
> if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PAUSED)
> can be used here instead of adding fe_pause to snd_soc_dpcm_runtime?
I didn't want to make any assumption on whether the state of the FE is
updated before or after the BE state, depending on the trigger order, so
only used the trigger command to drive the state machine changes.
>> + pause_stop_transition = true;
>> + fe->dpcm[stream].fe_pause = false;
>> + be->dpcm[stream].be_pause--;
>> + }
>> +
>> + if (be->dpcm[stream].be_pause != 0)
>> + ret = soc_pcm_trigger(be_substream,
>> SNDRV_PCM_TRIGGER_PAUSE_PUSH);
>> + else
>> + ret = soc_pcm_trigger(be_substream,
>> SNDRV_PCM_TRIGGER_STOP);
>> +
>> if (ret) {
>> if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START)
>> be->dpcm[stream].be_start++;
>> + if (pause_stop_transition) {
>> + fe->dpcm[stream].fe_pause = true;
>> + be->dpcm[stream].be_pause++;
>> + }
>> goto next;
>> }
>> - be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
>> + if (be->dpcm[stream].be_pause != 0)
>> + be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
>> + else
>> + be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
>> +
>> break;
>> case SNDRV_PCM_TRIGGER_SUSPEND:
>> if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
>> @@ -2204,6 +2226,9 @@ int dpcm_be_dai_trigger(struct
>> snd_soc_pcm_runtime *fe, int stream,
>> if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
>> goto next;
>> + fe->dpcm[stream].fe_pause = true;
>> + be->dpcm[stream].be_pause++;
>> +
>> be->dpcm[stream].be_start--;
>> if (be->dpcm[stream].be_start != 0)
>> goto next;
>
next prev parent reply other threads:[~2022-04-07 13:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-06 19:00 [PATCH 0/2] ASoC: soc-pcm: improve BE state transitions Pierre-Louis Bossart
2022-04-06 19:00 ` [PATCH 1/2] ASoC: soc-pcm: improve BE transition for PAUSE_RELEASE Pierre-Louis Bossart
2022-04-07 7:58 ` Amadeusz Sławiński
2022-04-07 13:23 ` Pierre-Louis Bossart [this message]
2022-04-06 19:00 ` [PATCH 2/2] ASoC: soc-pcm: improve BE transition for TRIGGER_START Pierre-Louis Bossart
2022-04-20 21:40 ` [PATCH 0/2] ASoC: soc-pcm: improve BE state transitions Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cbea05d4-ed7b-d0d7-53a6-80add0d8ffe2@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=broonie@kernel.org \
--cc=peter.ujfalusi@linux.intel.com \
--cc=rander.wang@intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=tiwai@suse.de \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox