clear-pkgs-linux-iot-lts2018/0244-ALSA-core-let-low-leve...

80 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Tue, 17 May 2016 14:00:15 +0530
Subject: [PATCH] ALSA: core: let low-level driver or userspace disable rewinds
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>
---
include/sound/pcm.h | 1 +
include/uapi/sound/asound.h | 1 +
sound/core/pcm_native.c | 6 ++++++
3 files changed, 8 insertions(+)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index d6bd3caf6878..2eef65a9404e 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 db62dbe7eaa8..56ab147c8429 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -727,6 +727,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;
@@ -2673,11 +2675,15 @@ static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream,
static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream,
snd_pcm_uframes_t frames)
{
+ struct snd_pcm_runtime *runtime = substream->runtime;
snd_pcm_sframes_t ret;
if (frames == 0)
return 0;
+ if (runtime->no_rewinds)
+ return 0;
+
snd_pcm_stream_lock_irq(substream);
ret = do_pcm_hwsync(substream);
if (!ret)
--
https://clearlinux.org