Commit 48d88297 authored by Libin Yang's avatar Libin Yang Committed by Takashi Iwai

ALSA: pcm: add SNDRV_PCM_TRIGGER_DRAIN trigger

Add SNDRV_PCM_TRIGGER_DRAIN trigger for pcm drain.

Some audio devices require notification of drain events
in order to properly drain and shutdown an audio stream.
Signed-off-by: default avatarLibin Yang <libin.yang@intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 0d02e129
...@@ -106,6 +106,7 @@ struct snd_pcm_ops { ...@@ -106,6 +106,7 @@ struct snd_pcm_ops {
#define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4 #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
#define SNDRV_PCM_TRIGGER_SUSPEND 5 #define SNDRV_PCM_TRIGGER_SUSPEND 5
#define SNDRV_PCM_TRIGGER_RESUME 6 #define SNDRV_PCM_TRIGGER_RESUME 6
#define SNDRV_PCM_TRIGGER_DRAIN 7
#define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1) #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
......
...@@ -268,6 +268,7 @@ typedef int __bitwise snd_pcm_subformat_t; ...@@ -268,6 +268,7 @@ typedef int __bitwise snd_pcm_subformat_t;
#define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */ #define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */
#define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP 0x00800000 /* period wakeup can be disabled */ #define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP 0x00800000 /* period wakeup can be disabled */
#define SNDRV_PCM_INFO_HAS_WALL_CLOCK 0x01000000 /* has audio wall clock for audio/system time sync */ #define SNDRV_PCM_INFO_HAS_WALL_CLOCK 0x01000000 /* has audio wall clock for audio/system time sync */
#define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */
#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */ #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */
typedef int __bitwise snd_pcm_state_t; typedef int __bitwise snd_pcm_state_t;
......
...@@ -420,7 +420,8 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream, ...@@ -420,7 +420,8 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
hw = &substream->runtime->hw; hw = &substream->runtime->hw;
if (!params->info) { if (!params->info) {
params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES; params->info = hw->info & ~(SNDRV_PCM_INFO_FIFO_IN_FRAMES |
SNDRV_PCM_INFO_DRAIN_TRIGGER);
if (!hw_support_mmap(substream)) if (!hw_support_mmap(substream))
params->info &= ~(SNDRV_PCM_INFO_MMAP | params->info &= ~(SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID); SNDRV_PCM_INFO_MMAP_VALID);
...@@ -1566,6 +1567,13 @@ static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) ...@@ -1566,6 +1567,13 @@ static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state)
snd_pcm_post_stop(substream, new_state); snd_pcm_post_stop(substream, new_state);
} }
} }
if (runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
runtime->trigger_master == substream &&
(runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER))
return substream->ops->trigger(substream,
SNDRV_PCM_TRIGGER_DRAIN);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment