From b45b11503a44b48e1bee649ecaf1867a4d800fa7 Mon Sep 17 00:00:00 2001 From: Sudheer Papothi Date: Fri, 29 Jan 2016 02:27:17 +0530 Subject: [PATCH] ALSA: pcm - add support for hostless audio Allow some PCM devices to be hostless, i.e. there is no PCM data transferred to or from the host CPU. This can be used to minimise power on systems since the CPU can idle/sleep during the PCM device operation (e.g. a phone call where the DAI is between a MODEM and DSP) TODO: cleanup, look at adding a read/write blocker. Singed-off-by: Liam Girdwood Signed-off-by: Banajit Goswami Signed-off-by: Sudheer Papothi --- include/sound/pcm.h | 1 + sound/core/pcm_lib.c | 3 +++ sound/core/pcm_native.c | 1 + 3 files changed, 5 insertions(+) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index e1dafdcb3c82..b293f60108ac 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -490,6 +490,7 @@ struct snd_pcm_substream { #endif /* CONFIG_SND_VERBOSE_PROCFS */ /* misc flags */ unsigned int hw_opened: 1; + unsigned int hw_no_buffer: 1; /* substream may not have a buffer */ }; #define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 6b5a811e01a5..eeb9c6eee1b5 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -2115,6 +2115,9 @@ static int pcm_sanity_check(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; + /* TODO: consider and -EINVAL here */ + if (substream->hw_no_buffer) + snd_printd("%s: warning this PCM is host less\n", __func__); runtime = substream->runtime; if (snd_BUG_ON(!substream->ops->copy && !runtime->dma_area)) return -EINVAL; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 3a963538a133..8c5e520e6970 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1024,6 +1024,7 @@ static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) if (runtime->status->state != SNDRV_PCM_STATE_PREPARED) return -EBADFD; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && + !substream->hw_no_buffer && !snd_pcm_playback_data(substream)) return -EPIPE; runtime->trigger_tstamp_latched = false;