From: Sriram Periyasamy <sriramx.periyasamy@intel.com>
To: ALSA ML <alsa-devel@alsa-project.org>, Mark Brown <broonie@kernel.org>
Cc: Takashi Iwai <tiwai@suse.de>,
Sriram Periyasamy <sriramx.periyasamy@intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Ramesh Babu <ramesh.babu@intel.com>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>,
Liam Girdwood <liam.r.girdwood@linux.intel.com>,
Patches Audio <patches.audio@intel.com>,
Vinod Koul <vinod.koul@intel.com>,
"Subhransu S . Prusty" <subhransu.s.prusty@intel.com>
Subject: [RESEND][PATCH v4 1/3] ALSA: core: let low-level driver or userspace disable rewinds
Date: Tue, 20 Mar 2018 21:31:06 +0530 [thread overview]
Message-ID: <1521561668-28613-2-git-send-email-sriramx.periyasamy@intel.com> (raw)
In-Reply-To: <1521561668-28613-1-git-send-email-sriramx.periyasamy@intel.com>
From: Pierre-Louis Bossart <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.
Note that the update of appl_ptr include both a read/write data
operation as well as snd_pcm_forward() whose behavior is not modified.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ramesh Babu <ramesh.babu@intel.com>
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@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 e054c583d3b3..f60397eb4aab 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -379,6 +379,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 ed0a120d4f08..ff57e4c89de4 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -377,6 +377,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 77ba50ddcf9e..4616420cdbf7 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -692,6 +692,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) ? 1 : 0;
bits = snd_pcm_format_physical_width(runtime->format);
runtime->sample_bits = bits;
@@ -2614,6 +2616,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 -ENODEV;
+
snd_pcm_stream_lock_irq(substream);
ret = do_pcm_hwsync(substream);
if (!ret)
@@ -2632,6 +2637,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 -ENODEV;
+
snd_pcm_stream_lock_irq(substream);
ret = do_pcm_hwsync(substream);
if (!ret)
--
2.7.4
next prev parent reply other threads:[~2018-03-20 16:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-20 16:01 [RESEND][PATCH v4 0/3] Add SPIB Support for Intel Skylake platforms Sriram Periyasamy
2018-03-20 16:01 ` Sriram Periyasamy [this message]
2018-03-20 16:17 ` [RESEND][PATCH v4 1/3] ALSA: core: let low-level driver or userspace disable rewinds Takashi Iwai
2018-03-25 10:46 ` Sriram Periyasamy
2018-03-25 14:58 ` Takashi Iwai
2018-03-28 14:30 ` Pierre-Louis Bossart
2018-03-28 15:20 ` Takashi Iwai
2018-03-28 17:58 ` Pierre-Louis Bossart
2018-03-28 18:35 ` Takashi Iwai
2018-03-28 19:50 ` Pierre-Louis Bossart
2018-03-28 21:09 ` Takashi Iwai
2018-03-28 21:51 ` Pierre-Louis Bossart
2018-03-29 15:42 ` Takashi Iwai
2018-03-29 19:16 ` Pierre-Louis Bossart
2018-03-29 20:10 ` Takashi Iwai
2018-03-29 21:40 ` Pierre-Louis Bossart
2018-03-20 16:01 ` [RESEND][PATCH v4 2/3] ALSA: hda: ext: add spib to stream context Sriram Periyasamy
2018-03-20 16:01 ` [RESEND][PATCH v4 3/3] ASoC: Intel: Skylake: Add support for spib mode Sriram Periyasamy
2018-03-21 1:34 ` [RESEND][PATCH v4 0/3] Add SPIB Support for Intel Skylake platforms Mark Brown
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=1521561668-28613-2-git-send-email-sriramx.periyasamy@intel.com \
--to=sriramx.periyasamy@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=o-takashi@sakamocchi.jp \
--cc=patches.audio@intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ramesh.babu@intel.com \
--cc=subhransu.s.prusty@intel.com \
--cc=tiwai@suse.de \
--cc=vinod.koul@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;
as well as URLs for NNTP newsgroup(s).