summaryrefslogtreecommitdiff
path: root/backport/backport-include/sound/pcm.h
diff options
context:
space:
mode:
authorDominik Sliwa <dominik.sliwa@toradex.com>2019-02-21 10:23:08 +0100
committerDominik Sliwa <dominik.sliwa@toradex.com>2019-02-21 10:23:44 +0100
commit0bdb080c70495ea4efbed7661b4fe6100bd5adde (patch)
tree9b0e0278c74c56b724540c9c12621f2fed70a6ff /backport/backport-include/sound/pcm.h
parente5561ba59729bf97f11bc11bb61fd4ef5c08c3b9 (diff)
Revert "backports: Remove unused parts"
This reverts commit ab3fd3b9a801a9faa2619e2e65207e736f859a6d.
Diffstat (limited to 'backport/backport-include/sound/pcm.h')
-rw-r--r--backport/backport-include/sound/pcm.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/backport/backport-include/sound/pcm.h b/backport/backport-include/sound/pcm.h
new file mode 100644
index 00000000..d5794ef9
--- /dev/null
+++ b/backport/backport-include/sound/pcm.h
@@ -0,0 +1,29 @@
+#ifndef __BACKPORT_SOUND_PCM_H
+#define __BACKPORT_SOUND_PCM_H
+#include_next <sound/pcm.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_IS_LESS(3,19,0)
+/**
+ * snd_pcm_stop_xrun - stop the running streams as XRUN
+ * @substream: the PCM substream instance
+ *
+ * This stops the given running substream (and all linked substreams) as XRUN.
+ * Unlike snd_pcm_stop(), this function takes the substream lock by itself.
+ *
+ * Return: Zero if successful, or a negative error code.
+ */
+static inline int snd_pcm_stop_xrun(struct snd_pcm_substream *substream)
+{
+ unsigned long flags;
+ int ret = 0;
+
+ snd_pcm_stream_lock_irqsave(substream, flags);
+ if (snd_pcm_running(substream))
+ ret = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+ snd_pcm_stream_unlock_irqrestore(substream, flags);
+ return ret;
+}
+#endif /* LINUX_VERSION_IS_LESS(3,19,0) */
+
+#endif /* __BACKPORT_SOUND_PCM_H */