Skip to content

Commit

Permalink
ASoC: SOF: Add support for hint from topology for pause support
Browse files Browse the repository at this point in the history
A new token is added to topology:
1202: SOF_TKN_STREAM_PLAYBACK_PAUSE_SUPPORTED

The snd_sof_pcm_stream.pause_supported is updated based on the new token
as hint for platform code that the PAUSE support should or should not be
advertised to user space.

If the token does not exist then the PAUSE is advised to be disabled.

Reasoning: End-users are using media servers to use audio (Pulseaudio,
Pipewire, CRAS, etc) and they never use pause operation. Media players
using ALSA directly have support for PCMs without pause support.

The pause/resume has never been tested in a same depth as other use cases
and we have corner cases that receives virtually no testing at all, like
suspending while the stream is paused.
We do not test the pause/resume in a more complex environment either and
it might have hidden issues.

Note: it is up to the platform code to use this flag to disable (or enable)
the pause support, this patch is just stores it as a hint.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
  • Loading branch information
ujfalusi committed Jun 7, 2024
1 parent ca0a005 commit 1921336
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/uapi/sound/sof/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@
/* Stream */
#define SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3 1200
#define SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3 1201
#define SOF_TKN_STREAM_PLAYBACK_PAUSE_SUPPORTED 1202
#define SOF_TKN_STREAM_CAPTURE_PAUSE_SUPPORTED 1203

/* Led control for mute switches */
#define SOF_TKN_MUTE_LED_USE 1300
Expand Down
8 changes: 8 additions & 0 deletions sound/soc/sof/sof-audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ struct snd_sof_pcm_stream {
struct work_struct period_elapsed_work;
struct snd_soc_dapm_widget_list *list; /* list of connected DAPM widgets */
bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
/*
* Hint for the core and platform code about PCM pause/resume support.
* Note: Users are using audio via media servers (Pulseaudio, Pipewire,
* CRAS, etc) and media servers do not use pause/resume.
* Media players using the ALSA directly have means to handle PCM devices
* without pause/resume support also.
*/
bool pause_supported;
unsigned int dsp_max_burst_size_in_ms; /* The maximum size of the host DMA burst in ms */
/*
* flag to indicate that the DSP pipelines should be kept
Expand Down
4 changes: 4 additions & 0 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ static const struct sof_topology_token stream_tokens[] = {
offsetof(struct snd_sof_pcm, stream[0].d0i3_compatible)},
{SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
offsetof(struct snd_sof_pcm, stream[1].d0i3_compatible)},
{SOF_TKN_STREAM_PLAYBACK_PAUSE_SUPPORTED, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
offsetof(struct snd_sof_pcm, stream[0].pause_supported)},
{SOF_TKN_STREAM_CAPTURE_PAUSE_SUPPORTED, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
offsetof(struct snd_sof_pcm, stream[1].pause_supported)},
};

/* Leds */
Expand Down

0 comments on commit 1921336

Please sign in to comment.