From 2475eaa833dc9a4961a3fcc8b6d6364188b0c4cb Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Date: Wed, 12 May 2010 11:46:11 -0500
Subject: [PATCH] add support for disabling of period interrupts


Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
---
 configure.in           |    2 +-
 include/pcm.h          |    3 ++-
 include/sound/asound.h |    1 +
 src/Versions.in        |    5 +++++
 src/pcm/pcm.c          |   33 +++++++++++++++++++++++++++++++++
 src/pcm/pcm_local.h    |    1 +
 6 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/configure.in b/configure.in
index abc4687..e930621 100644
--- a/configure.in
+++ b/configure.in
@@ -12,7 +12,7 @@ dnl add API = c+1:0:a+1
 dnl remove API = c+1:0:0
 dnl *************************************************
 AC_CANONICAL_HOST
-AM_INIT_AUTOMAKE(alsa-lib, 1.0.23)
+AM_INIT_AUTOMAKE(alsa-lib, 1.0.24rc1)
 eval LIBTOOL_VERSION_INFO="2:0:0"
 dnl *************************************************
 AM_CONDITIONAL(INSTALL_M4, test -n "${ACLOCAL}")
diff --git a/include/pcm.h b/include/pcm.h
index f3618c3..5157877 100644
--- a/include/pcm.h
+++ b/include/pcm.h
@@ -626,7 +626,8 @@ int snd_pcm_hw_params_set_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *par
 int snd_pcm_hw_params_get_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
 int snd_pcm_hw_params_set_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
 int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
-
+int snd_pcm_hw_params_set_disable_interrupts(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
+int snd_pcm_hw_params_get_disable_interrupts(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
 int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
 int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
 int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
diff --git a/include/sound/asound.h b/include/sound/asound.h
index fa88938..0686da4 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -346,6 +346,7 @@ enum sndrv_pcm_hw_param {
 
 #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_DISABLE_PERIOD_INTERRUPTS	(1<<2)	/* disable period interrupts */
 
 struct sndrv_interval {
 	unsigned int min, max;
diff --git a/src/Versions.in b/src/Versions.in
index 8d2dd11..f907912 100644
--- a/src/Versions.in
+++ b/src/Versions.in
@@ -129,3 +129,8 @@ ALSA_0.9.7 {
     @SYMBOL_PREFIX@alsa_lisp_*;
 } ALSA_0.9.5;
 
+ALSA_1.0.24rc1 {
+  global:
+    @SYMBOL_PREFIX@snd_pcm_hw_params_set_disable_period_interrupts;
+    @SYMBOL_PREFIX@snd_pcm_hw_params_get_disable_period_interrupts;
+} ALSA_0.9.7;
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index f910189..55a67cd 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -4204,6 +4204,39 @@ int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *par
 }
 
 /**
+ * \brief Restrict a configuration space to disable period interrupts 
+ * \param pcm PCM handle
+ * \param params Configuration space
+ * \param val 1 = disable interrupts, 0 = enable (default) interrupts
+ * \return 0 otherwise a negative error code
+ */
+int snd_pcm_hw_params_set_disable_period_interrupts(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val)
+{
+	assert(pcm && params);
+
+        if (val)
+                params->flags |= SND_PCM_HW_PARAMS_DISABLE_PERIOD_INTERRUPTS;
+	else
+                params->flags &= ~SND_PCM_HW_PARAMS_DISABLE_PERIOD_INTERRUPTS;
+	return snd_pcm_hw_refine(pcm, params);
+}
+
+/**
+ * \brief Extract interrupt disable info from a configuration space
+ * \param pcm PCM handle
+ * \param params Configuration space
+ * \param val 1 = disable, 0 = enable interrupts
+ * \return 0
+ */
+int snd_pcm_hw_params_get_interrupt_disable(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
+{
+	assert(pcm && params && val);
+	*val = params->flags & SND_PCM_HW_PARAMS_DISABLE_PERIOD_INTERRUPTS ? 1 : 0;
+	return 0;
+}
+
+
+/**
  * \brief Extract period time from a configuration space
  * \param params Configuration space
  * \param val Returned approximate period duration in us
diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h
index 9aa81e1..6e9929f 100644
--- a/src/pcm/pcm_local.h
+++ b/src/pcm/pcm_local.h
@@ -94,6 +94,7 @@ typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
 
 #define SND_PCM_HW_PARAMS_NORESAMPLE SNDRV_PCM_HW_PARAMS_NORESAMPLE
 #define SND_PCM_HW_PARAMS_EXPORT_BUFFER SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER
+#define SND_PCM_HW_PARAMS_DISABLE_PERIOD_INTERRUPTS SNDRV_PCM_HW_PARAMS_DISABLE_PERIOD_INTERRUPTS
 
 #define SND_PCM_INFO_MONOTONIC	0x80000000
 
-- 
1.6.6.1

