Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
Cc: Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>,
	lgirdwood@gmail.com, broonie@kernel.org, tiwai@suse.com,
	linux-sound@vger.kernel.org, kai.vehmanen@linux.intel.com,
	ranjani.sridharan@linux.intel.com,
	yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
	liam.r.girdwood@intel.com
Subject: Re: [PATCH] ALSA: pcm: Release paused streams before suspend if resume is not supported
Date: Wed, 02 Apr 2025 15:23:17 +0200	[thread overview]
Message-ID: <87o6xe7l4q.wl-tiwai@suse.de> (raw)
In-Reply-To: <8878feb6-362a-4541-91fb-318aea1c0870@linux.intel.com>

On Wed, 02 Apr 2025 14:52:48 +0200,
Péter Ujfalusi wrote:
> 
> 
> 
> On 02/04/2025 14:50, Takashi Iwai wrote:
> > On Wed, 02 Apr 2025 13:43:57 +0200,
> > Péter Ujfalusi wrote:
> >>
> >>
> >>
> >> On 02/04/2025 14:21, Takashi Iwai wrote:
> >>>>> On the second thought, yet another variant would be to introduce only
> >>>>> one new trigger, SNDRV_PCM_TRIGGER_PAUSE_RESET, for resetting the
> >>>>> PAUSED state as a step before stopping the stream.  This can be
> >>>>> applied to all cases for snd_pcm_drop() and snd_pcm_suspend(), too.
> >>>>> If the driver doesn't support this mode, the PCM core may fall back to
> >>>>> SNDRV_PCM_TRIGGER_PAUSE_RELEASE.
> >>>>
> >>>> This looks identical to my proposed
> >>>> SNDRV_PCM_TRIGGER_PAUSE_RELEASE_AND_STOP which is more
> >>>> explanatory. It's not clear what PAUSE_RESET should do (probably the
> >>>> stream should be kept inactive).
> >>>
> >>> There is a slight difference.  My proposal, *_TRIGGER_PAUSE_RESET,
> >>> doesn't have to stop the stream by itself, but it's only a preparation
> >>> for stopping.  That is, a proper TRIGGER_STOP always follows after
> >>> TRIGGER_PAUSE_RESET.
> >>
> >> But what state that we move after we reset the PAUSE? is it RUNNING
> >> (iow, equals to PAUSE_RELEASE) or something else?
> > 
> > It'll be temporarily set to RUNNING.
> > 
> >> In case of suspend while the state is paused we will:
> >> TRIGGER_PAUSE_RESET followed by STOP or SUSPEND?
> > 
> > For suspend, PAUSE_RESET, then SUSPEND.
> > For dropping, PAUSE_RESET, then STOP.
> 
> OK, but this is still the same as PAUSE_RELEASE+SUSPEND when it comes to
> suspended_state, no?
> I mean you need to move to RUNNING to be suspend, or stop to skip the
> suspend.

Yes, and this needs to be addressed.  e.g. save the suspended_state
beforehand.

> >> Most drivers are doing the same thing for STOP and SUSPEND trigger,
> >> however it is possible to do extra steps for SUSPEND to make sure that
> >> the whole system is in a lowest power state.
> > 
> > Yes, that's the reason I proposed PAUSE_RESET.  Then the driver can
> > handle the following stop or suspend operation differently.
> > 
> > That said, PAUSE_RESET is just another variant of PAUSE_RELEASE.
> > But this shouldn't actually enable the audio output again, but prepare
> > for the next SUSPEND or STOP trigger.
> 
> I'm not sure how this would be seen in ASoC level. Surely we need to
> have flag per components that it is handling PAUSE_RESET as codecs would
> like don't want to do it or they migh, hm.
> But ASoC maintains another set of state for the dpcm:
> SND_SOC_DPCM_STATE_* and it has this as well among other state-machine
> things:
> case SNDRV_PCM_TRIGGER_SUSPEND:
> 	if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
> 		goto next;
> 
> So, this is dpcm level, but one component can support PAUSE_RESET while
> the other does not and the transitions are not too clear to me.

It's a good question.  ASoC may have the own intermediate state
(SND_SOC_DPCM_STATE_PAUSED_RESET) or just use
SND_SOC_DPCM_STATE_START but leave all to BE trigger (by passing
SNDRV_PCM_TRIGGER_PAUSE_RESET).

> But the idea of resurrecting a paused stream with mute held is not bad.
>
> I'm still uncertain how this actually works now on systems where RESUME
> is supported and we suspend while a PCM is in paused...

Is it a general question about suspend+resume during pause, or the
behavior change after PAUSE_RESET?  PAUSE_RESET won't be applied to
the drivers that support RESUME.

BTW, I'm not pushing to sell PAUSE_RESET so much for now at all.
Currently rather in a brain storming phase.  Let's try to pick up the
more appropriate one.


thanks,

Takashi

  reply	other threads:[~2025-04-02 13:23 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 13:36 [PATCH] ALSA: pcm: Release paused streams before suspend if resume is not supported Peter Ujfalusi
2025-04-01 14:49 ` Takashi Iwai
2025-04-01 16:58   ` Jaroslav Kysela
2025-04-01 17:19     ` Takashi Iwai
2025-04-01 18:46       ` Jaroslav Kysela
2025-04-01 19:27         ` Takashi Iwai
2025-04-02  6:41           ` Péter Ujfalusi
2025-04-02  8:14             ` Jaroslav Kysela
2025-04-02  8:09           ` Jaroslav Kysela
2025-04-02  8:39             ` Takashi Iwai
2025-04-02  8:52               ` Jaroslav Kysela
2025-04-02  9:16                 ` Takashi Iwai
2025-04-02 10:45                   ` Jaroslav Kysela
2025-04-02 11:21                     ` Takashi Iwai
2025-04-02 11:43                       ` Péter Ujfalusi
2025-04-02 11:50                         ` Takashi Iwai
2025-04-02 12:52                           ` Péter Ujfalusi
2025-04-02 13:23                             ` Takashi Iwai [this message]
2025-04-03 10:13                               ` Péter Ujfalusi
2025-04-03 14:01                                 ` Takashi Iwai
2025-04-03 15:24                                   ` Jaroslav Kysela
2025-04-03 16:09                                     ` Takashi Iwai
2025-04-03 19:05                                       ` Jaroslav Kysela
2025-04-04 10:44                                         ` Takashi Iwai
2025-04-04 11:33                                           ` Jaroslav Kysela
2025-04-04 14:44                                             ` Takashi Iwai
2025-04-08  7:03                                         ` Péter Ujfalusi
2025-04-08  8:51                                           ` Jaroslav Kysela
2025-04-08  9:45                                             ` Péter Ujfalusi
2025-04-04  8:58                                     ` Péter Ujfalusi
2025-04-04  9:08                                       ` Jaroslav Kysela
2025-04-08  6:35                                   ` Péter Ujfalusi
2025-04-02 12:55                           ` Jaroslav Kysela
2025-04-02  9:28                 ` Péter Ujfalusi
2025-04-02 11:27                   ` Takashi Iwai
2025-04-02 11:53                     ` Takashi Iwai

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=87o6xe7l4q.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=liam.r.girdwood@intel.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.com \
    --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