* [PATCH] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger
@ 2014-12-31 3:03 libin.yang
2014-12-31 8:53 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: libin.yang @ 2014-12-31 3:03 UTC (permalink / raw)
To: tiwai, alsa-devel; +Cc: libin.yang, liam.r.girdwood
From: Libin Yang <libin.yang@intel.com>
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: Libin Yang <libin.yang@intel.com>
---
include/sound/pcm.h | 1 +
include/uapi/sound/asound.h | 1 +
sound/core/pcm_native.c | 10 +++++++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 3652c94..bf32cea 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -106,6 +106,7 @@ struct snd_pcm_ops {
#define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
#define SNDRV_PCM_TRIGGER_SUSPEND 5
#define SNDRV_PCM_TRIGGER_RESUME 6
+#define SNDRV_PCM_TRIGGER_DRAIN 7
#define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 1f23cd6..0e88e7a 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -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_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_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 */
typedef int __bitwise snd_pcm_state_t;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 095d957..bd57f6e 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -420,7 +420,8 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
hw = &substream->runtime->hw;
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))
params->info &= ~(SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID);
@@ -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);
}
}
+
+ if (runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
+ substream->runtime->trigger_master == substream &&
+ (substream->runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER))
+ return substream->ops->trigger(substream,
+ SNDRV_PCM_TRIGGER_DRAIN);
+
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger
2014-12-31 3:03 [PATCH] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger libin.yang
@ 2014-12-31 8:53 ` Takashi Iwai
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2014-12-31 8:53 UTC (permalink / raw)
To: libin.yang; +Cc: liam.r.girdwood, alsa-devel
At Wed, 31 Dec 2014 11:03:40 +0800,
libin.yang@intel.com wrote:
>
> From: Libin Yang <libin.yang@intel.com>
>
> 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: Libin Yang <libin.yang@intel.com>
> ---
> include/sound/pcm.h | 1 +
> include/uapi/sound/asound.h | 1 +
> sound/core/pcm_native.c | 10 +++++++++-
> 3 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/include/sound/pcm.h b/include/sound/pcm.h
> index 3652c94..bf32cea 100644
> --- a/include/sound/pcm.h
> +++ b/include/sound/pcm.h
> @@ -106,6 +106,7 @@ struct snd_pcm_ops {
> #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
> #define SNDRV_PCM_TRIGGER_SUSPEND 5
> #define SNDRV_PCM_TRIGGER_RESUME 6
> +#define SNDRV_PCM_TRIGGER_DRAIN 7
>
> #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
>
> diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> index 1f23cd6..0e88e7a 100644
> --- a/include/uapi/sound/asound.h
> +++ b/include/uapi/sound/asound.h
> @@ -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_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_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 */
>
> typedef int __bitwise snd_pcm_state_t;
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index 095d957..bd57f6e 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -420,7 +420,8 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
>
> hw = &substream->runtime->hw;
> 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;
Usually written like ~(A | B).
Takashi
> if (!hw_support_mmap(substream))
> params->info &= ~(SNDRV_PCM_INFO_MMAP |
> SNDRV_PCM_INFO_MMAP_VALID);
> @@ -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);
> }
> }
> +
> + if (runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
> + substream->runtime->trigger_master == substream &&
> + (substream->runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER))
> + return substream->ops->trigger(substream,
> + SNDRV_PCM_TRIGGER_DRAIN);
> +
> return 0;
> }
>
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger
@ 2014-12-31 14:09 libin.yang
2014-12-31 16:17 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: libin.yang @ 2014-12-31 14:09 UTC (permalink / raw)
To: tiwai, alsa-devel; +Cc: libin.yang, liam.r.girdwood
From: Libin Yang <libin.yang@intel.com>
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: Libin Yang <libin.yang@intel.com>
---
include/sound/pcm.h | 1 +
include/uapi/sound/asound.h | 1 +
sound/core/pcm_native.c | 10 +++++++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 3652c94..bf32cea 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -106,6 +106,7 @@ struct snd_pcm_ops {
#define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
#define SNDRV_PCM_TRIGGER_SUSPEND 5
#define SNDRV_PCM_TRIGGER_RESUME 6
+#define SNDRV_PCM_TRIGGER_DRAIN 7
#define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 1f23cd6..0e88e7a 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -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_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_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 */
typedef int __bitwise snd_pcm_state_t;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 095d957..a5fe336 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -420,7 +420,8 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
hw = &substream->runtime->hw;
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))
params->info &= ~(SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID);
@@ -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);
}
}
+
+ if (runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
+ substream->runtime->trigger_master == substream &&
+ (substream->runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER))
+ return substream->ops->trigger(substream,
+ SNDRV_PCM_TRIGGER_DRAIN);
+
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger
2014-12-31 14:09 libin.yang
@ 2014-12-31 16:17 ` Takashi Iwai
2015-01-01 0:30 ` Yang, Libin
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2014-12-31 16:17 UTC (permalink / raw)
To: libin.yang; +Cc: liam.r.girdwood, alsa-devel
At Wed, 31 Dec 2014 22:09:54 +0800,
libin.yang@intel.com wrote:
>
> From: Libin Yang <libin.yang@intel.com>
>
> 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: Libin Yang <libin.yang@intel.com>
Thanks, applied now with micro optimizations (replacing
substream->runtime with runtime) and space alignment.
Takashi
> ---
> include/sound/pcm.h | 1 +
> include/uapi/sound/asound.h | 1 +
> sound/core/pcm_native.c | 10 +++++++++-
> 3 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/include/sound/pcm.h b/include/sound/pcm.h
> index 3652c94..bf32cea 100644
> --- a/include/sound/pcm.h
> +++ b/include/sound/pcm.h
> @@ -106,6 +106,7 @@ struct snd_pcm_ops {
> #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
> #define SNDRV_PCM_TRIGGER_SUSPEND 5
> #define SNDRV_PCM_TRIGGER_RESUME 6
> +#define SNDRV_PCM_TRIGGER_DRAIN 7
>
> #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
>
> diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> index 1f23cd6..0e88e7a 100644
> --- a/include/uapi/sound/asound.h
> +++ b/include/uapi/sound/asound.h
> @@ -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_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_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 */
>
> typedef int __bitwise snd_pcm_state_t;
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index 095d957..a5fe336 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -420,7 +420,8 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
>
> hw = &substream->runtime->hw;
> 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))
> params->info &= ~(SNDRV_PCM_INFO_MMAP |
> SNDRV_PCM_INFO_MMAP_VALID);
> @@ -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);
> }
> }
> +
> + if (runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
> + substream->runtime->trigger_master == substream &&
> + (substream->runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER))
> + return substream->ops->trigger(substream,
> + SNDRV_PCM_TRIGGER_DRAIN);
> +
> return 0;
> }
>
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger
2014-12-31 16:17 ` Takashi Iwai
@ 2015-01-01 0:30 ` Yang, Libin
0 siblings, 0 replies; 5+ messages in thread
From: Yang, Libin @ 2015-01-01 0:30 UTC (permalink / raw)
To: Takashi Iwai; +Cc: liam.r.girdwood@linux.intel.com, alsa-devel@alsa-project.org
Hi Takashi,
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de]
> Sent: Thursday, January 01, 2015 12:18 AM
> To: Yang, Libin
> Cc: alsa-devel@alsa-project.org; liam.r.girdwood@linux.intel.com; Jie, Yang
> Subject: Re: [PATCH] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger
>
> At Wed, 31 Dec 2014 22:09:54 +0800,
> libin.yang@intel.com wrote:
> >
> > From: Libin Yang <libin.yang@intel.com>
> >
> > 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: Libin Yang <libin.yang@intel.com>
>
> Thanks, applied now with micro optimizations (replacing
> substream->runtime with runtime) and space alignment.
Thanks for help.
>
>
> Takashi
>
> > ---
> > include/sound/pcm.h | 1 +
> > include/uapi/sound/asound.h | 1 +
> > sound/core/pcm_native.c | 10 +++++++++-
> > 3 files changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/sound/pcm.h b/include/sound/pcm.h index
> > 3652c94..bf32cea 100644
> > --- a/include/sound/pcm.h
> > +++ b/include/sound/pcm.h
> > @@ -106,6 +106,7 @@ struct snd_pcm_ops {
> > #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
> > #define SNDRV_PCM_TRIGGER_SUSPEND 5
> > #define SNDRV_PCM_TRIGGER_RESUME 6
> > +#define SNDRV_PCM_TRIGGER_DRAIN 7
> >
> > #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
> >
> > diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> > index 1f23cd6..0e88e7a 100644
> > --- a/include/uapi/sound/asound.h
> > +++ b/include/uapi/sound/asound.h
> > @@ -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_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_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 */
> >
> > typedef int __bitwise snd_pcm_state_t; diff --git
> > a/sound/core/pcm_native.c b/sound/core/pcm_native.c index
> > 095d957..a5fe336 100644
> > --- a/sound/core/pcm_native.c
> > +++ b/sound/core/pcm_native.c
> > @@ -420,7 +420,8 @@ int snd_pcm_hw_refine(struct
> snd_pcm_substream
> > *substream,
> >
> > hw = &substream->runtime->hw;
> > 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))
> > params->info &= ~(SNDRV_PCM_INFO_MMAP |
> > SNDRV_PCM_INFO_MMAP_VALID);
> > @@ -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);
> > }
> > }
> > +
> > + if (runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
> > + substream->runtime->trigger_master == substream &&
> > + (substream->runtime->hw.info &
> SNDRV_PCM_INFO_DRAIN_TRIGGER))
> > + return substream->ops->trigger(substream,
> > + SNDRV_PCM_TRIGGER_DRAIN);
> > +
> > return 0;
> > }
> >
> > --
> > 1.9.1
> >
Regards,
Libin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-01-01 0:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-31 3:03 [PATCH] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger libin.yang
2014-12-31 8:53 ` Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2014-12-31 14:09 libin.yang
2014-12-31 16:17 ` Takashi Iwai
2015-01-01 0:30 ` Yang, Libin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox