All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [RFC PATCH 1/4] ALSA: core: let low-level driver or userspace disable rewinds
Date: Wed,  8 Jul 2015 05:10:33 -0500	[thread overview]
Message-ID: <1436350236-17509-2-git-send-email-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <1436350236-17509-1-git-send-email-pierre-louis.bossart@linux.intel.com>

Add new hw_params flag to explicitly tell driver that rewinds
will never be used. This can be used by low-level driver to
optimize DMA operations and reduce power consumption.
Use this flag only when data written in ring buffer will
never be invalidated, e.g. any update of appl_ptr is final.

Caveat: there is currently no way to query capabilities without
opening a pcm stream, so applications might need to serially
open all exposed devices, check what they support by looking at
hw_params->info and close them (this is what PulseAudio does so
might not be an issue)

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 include/sound/pcm.h         | 1 +
 include/uapi/sound/asound.h | 1 +
 sound/core/pcm_native.c     | 8 ++++++++
 3 files changed, 10 insertions(+)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 691e7ee..25310b7 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -370,6 +370,7 @@ struct snd_pcm_runtime {
 	unsigned int rate_num;
 	unsigned int rate_den;
 	unsigned int no_period_wakeup: 1;
+	unsigned int no_rewinds:1;
 
 	/* -- SW params -- */
 	int tstamp_mode;		/* mmap timestamp is updated */
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index a45be6b..b62b162 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -356,6 +356,7 @@ typedef int snd_pcm_hw_param_t;
 #define SNDRV_PCM_HW_PARAMS_NORESAMPLE	(1<<0)	/* avoid rate resampling */
 #define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER	(1<<1)	/* export buffer */
 #define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP	(1<<2)	/* disable period wakeups */
+#define SNDRV_PCM_HW_PARAMS_NO_REWINDS	        (1<<3)	/* disable rewinds */
 
 struct snd_interval {
 	unsigned int min, max;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index d126c03..a70e52d 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -543,6 +543,8 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
 	runtime->no_period_wakeup =
 			(params->info & SNDRV_PCM_INFO_NO_PERIOD_WAKEUP) &&
 			(params->flags & SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP);
+	runtime->no_rewinds =
+			params->flags & SNDRV_PCM_HW_PARAMS_NO_REWINDS;
 
 	bits = snd_pcm_format_physical_width(runtime->format);
 	runtime->sample_bits = bits;
@@ -2428,6 +2430,9 @@ static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *subst
 	if (frames == 0)
 		return 0;
 
+	if (runtime->no_rewinds)
+		return 0;
+
 	snd_pcm_stream_lock_irq(substream);
 	switch (runtime->status->state) {
 	case SNDRV_PCM_STATE_PREPARED:
@@ -2476,6 +2481,9 @@ static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substr
 	if (frames == 0)
 		return 0;
 
+	if (runtime->no_rewinds)
+		return 0;
+
 	snd_pcm_stream_lock_irq(substream);
 	switch (runtime->status->state) {
 	case SNDRV_PCM_STATE_PREPARED:
-- 
1.9.1

  reply	other threads:[~2015-07-08 10:10 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 10:10 [RFC PATCH 0/4] better support for bursty DMA usages Pierre-Louis Bossart
2015-07-08 10:10 ` Pierre-Louis Bossart [this message]
2015-07-08 14:21   ` [RFC PATCH 1/4] ALSA: core: let low-level driver or userspace disable rewinds Takashi Iwai
2015-07-08 16:58     ` Pierre-Louis Bossart
2015-07-11 17:06   ` Alexander E. Patrakov
2015-07-14  3:32     ` Raymond Yau
2015-07-14 17:39       ` Alexander E. Patrakov
2015-07-15  1:23         ` Raymond Yau
2015-07-15  4:51           ` Alexander E. Patrakov
2015-07-28 14:19     ` Pierre-Louis Bossart
2015-07-28 15:43       ` Alexander E. Patrakov
2015-07-29 17:46         ` Pierre-Louis Bossart
2015-07-30  6:11           ` Alexander E. Patrakov
2015-07-30 13:46             ` Pierre-Louis Bossart
2015-07-08 10:10 ` [RFC PATCH 2/4] ALSA: core: add .notify callback for pcm ops Pierre-Louis Bossart
2015-07-08 14:27   ` Takashi Iwai
2015-07-08 17:10     ` Pierre-Louis Bossart
2015-07-09 14:44       ` Takashi Iwai
2015-07-09  7:25     ` Raymond Yau
2015-07-09  7:35       ` Pierre-Louis Bossart
2015-07-08 10:10 ` [RFC PATCH 3/4] ALSA: core: add report of max dma burst Pierre-Louis Bossart
2015-07-08 14:37   ` Takashi Iwai
2015-07-08 17:46     ` Pierre-Louis Bossart
2015-07-10  2:35       ` Raymond Yau
2015-07-10 17:13         ` Lars-Peter Clausen
2015-07-11 17:46     ` Alexander E. Patrakov
2015-07-11 18:28       ` Jaroslav Kysela
2015-07-16  2:11         ` Raymond Yau
2015-07-08 10:10 ` [RFC PATCH 4/4] ALSA: hda: add default value for max_dma_burst Pierre-Louis Bossart
2015-07-08 14:31 ` [RFC PATCH 0/4] better support for bursty DMA usages Takashi Iwai
2015-07-08 17:50   ` Pierre-Louis Bossart
2015-07-15 10:14 ` Raymond Yau
2015-07-15 10:38   ` Alexander E. Patrakov
2015-07-22 14:44     ` Raymond Yau

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=1436350236-17509-2-git-send-email-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.