aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/pcm.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-05-24 18:23:20 +0200
committerTakashi Iwai <tiwai@suse.de>2017-06-02 19:38:24 +0200
commit68541213720df9bb7904cc1fecab563d424849ae (patch)
treee8d3036ac6fe85d3e0b43bfa0dec7f16ee315127 /include/sound/pcm.h
parentALSA: pcm: Simplify snd_pcm_playback_silence() (diff)
downloadlinux-dev-68541213720df9bb7904cc1fecab563d424849ae.tar.xz
linux-dev-68541213720df9bb7904cc1fecab563d424849ae.zip
ALSA: pcm: Direct in-kernel read/write support
Now all materials are ready, let's allow the direct in-kernel read/write, i.e. a kernel-space buffer is passed for read or write, instead of the normal user-space buffer. This feature is used by OSS layer and UAC1 driver, for example. The __snd_pcm_lib_xfer() takes in_kernel argument that indicates the in-kernel buffer copy. When this flag is set, another transfer code is used. It's either via copy_kernel PCM ops or the normal memcpy(), depending on the driver setup. As external API, snd_pcm_kernel_read(), *_write() and other variants are provided. That's all. This support is really simple because of the code refactoring until now. Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound/pcm.h')
-rw-r--r--include/sound/pcm.h38
1 files changed, 33 insertions, 5 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index db649083c76d..c24f85f12b71 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -1074,34 +1074,62 @@ int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream,
void snd_pcm_period_elapsed(struct snd_pcm_substream *substream);
snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
void *buf, bool interleaved,
- snd_pcm_uframes_t frames);
+ snd_pcm_uframes_t frames, bool in_kernel);
static inline snd_pcm_sframes_t
snd_pcm_lib_write(struct snd_pcm_substream *substream,
const void __user *buf, snd_pcm_uframes_t frames)
{
- return __snd_pcm_lib_xfer(substream, (void *)buf, true, frames);
+ return __snd_pcm_lib_xfer(substream, (void *)buf, true, frames, false);
}
static inline snd_pcm_sframes_t
snd_pcm_lib_read(struct snd_pcm_substream *substream,
void __user *buf, snd_pcm_uframes_t frames)
{
- return __snd_pcm_lib_xfer(substream, (void *)buf, true, frames);
+ return __snd_pcm_lib_xfer(substream, (void *)buf, true, frames, false);
}
static inline snd_pcm_sframes_t
snd_pcm_lib_writev(struct snd_pcm_substream *substream,
void __user **bufs, snd_pcm_uframes_t frames)
{
- return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames);
+ return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames, false);
}
static inline snd_pcm_sframes_t
snd_pcm_lib_readv(struct snd_pcm_substream *substream,
void __user **bufs, snd_pcm_uframes_t frames)
{
- return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames);
+ return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames, false);
+}
+
+static inline snd_pcm_sframes_t
+snd_pcm_kernel_write(struct snd_pcm_substream *substream,
+ const void *buf, snd_pcm_uframes_t frames)
+{
+ return __snd_pcm_lib_xfer(substream, (void *)buf, true, frames, true);
+}
+
+static inline snd_pcm_sframes_t
+snd_pcm_kernel_read(struct snd_pcm_substream *substream,
+ void *buf, snd_pcm_uframes_t frames)
+{
+ return __snd_pcm_lib_xfer(substream, buf, true, frames, true);
+}
+
+static inline snd_pcm_sframes_t
+snd_pcm_kernel_writev(struct snd_pcm_substream *substream,
+ void **bufs, snd_pcm_uframes_t frames)
+{
+ return __snd_pcm_lib_xfer(substream, bufs, false, frames, true);
+}
+
+static inline snd_pcm_sframes_t
+snd_pcm_kernel_readv(struct snd_pcm_substream *substream,
+ void **bufs, snd_pcm_uframes_t frames)
+{
+ return __snd_pcm_lib_xfer(substream, bufs, false, frames, true);
}
int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime);