From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: broonie@kernel.org
Cc: alsa-devel@alsa-project.org, vinod.koul@intel.com,
patches@opensource.wolfsonmicro.com, lgirdwood@gmail.com,
tiwai@suse.com
Subject: [PATCH 11/13] ASoC: wm_adsp: Attach buffers and streams together
Date: Tue, 8 Dec 2015 16:08:35 +0000 [thread overview]
Message-ID: <1449590917-21170-11-git-send-email-ckeepax@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1449590917-21170-1-git-send-email-ckeepax@opensource.wolfsonmicro.com>
The stream is created whilst the compressed stream is opened and a
buffer is created when the DSP powers up. It is necessary at a point
once both the DSP has powered up and the the stream has been opened to
connect a stream to a buffer on the DSP. This is done in the trigger
callback as this is after the DSP has been powered and obviously the
stream must be open. Note that whilst the connect is currently trivial
it is expected that this will get more complex when support for multiple
buffers/streams per DSP is added.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
sound/soc/codecs/wm5110.c | 1 +
sound/soc/codecs/wm_adsp.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++
sound/soc/codecs/wm_adsp.h | 1 +
3 files changed, 64 insertions(+)
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 8c0fd91..c364096 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -2272,6 +2272,7 @@ static struct snd_compr_ops wm5110_compr_ops = {
.free = wm_adsp_compr_free,
.set_params = wm_adsp_compr_set_params,
.get_caps = wm_adsp_compr_get_caps,
+ .trigger = wm_adsp_compr_trigger,
};
static struct snd_soc_platform_driver wm5110_compr_platform = {
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index cf68557..de015da 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -283,6 +283,7 @@ struct wm_adsp_compr_buf {
struct wm_adsp_compr {
struct wm_adsp *dsp;
+ struct wm_adsp_compr_buf *buf;
struct snd_compr_stream *stream;
struct snd_compressed_buffer size;
@@ -2338,6 +2339,13 @@ int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream)
goto out;
}
+ if (dsp->compr) {
+ /* It is expect this limitation will be removed in future */
+ adsp_err(dsp, "Only a single stream supported per DSP\n");
+ ret = -EBUSY;
+ goto out;
+ }
+
compr = kzalloc(sizeof(*compr), GFP_KERNEL);
if (!compr) {
ret = -ENOMEM;
@@ -2655,4 +2663,58 @@ static int wm_adsp_buffer_free(struct wm_adsp *dsp)
return 0;
}
+static inline int wm_adsp_compr_attached(struct wm_adsp_compr *compr)
+{
+ return compr->buf != NULL;
+}
+
+static int wm_adsp_compr_attach(struct wm_adsp_compr *compr)
+{
+ /*
+ * Note this will be more complex once each DSP can support multiple
+ * streams
+ */
+ if (!compr->dsp->buffer)
+ return -EINVAL;
+
+ compr->buf = compr->dsp->buffer;
+
+ return 0;
+}
+
+int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)
+{
+ struct wm_adsp_compr *compr = stream->runtime->private_data;
+ struct wm_adsp *dsp = compr->dsp;
+ int ret = 0;
+
+ adsp_dbg(dsp, "Trigger: %d\n", cmd);
+
+ mutex_lock(&dsp->pwr_lock);
+
+ switch (cmd) {
+ case SNDRV_PCM_TRIGGER_START:
+ if (wm_adsp_compr_attached(compr))
+ break;
+
+ ret = wm_adsp_compr_attach(compr);
+ if (ret < 0) {
+ adsp_err(dsp, "Failed to link buffer and stream: %d\n",
+ ret);
+ break;
+ }
+ break;
+ case SNDRV_PCM_TRIGGER_STOP:
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ mutex_unlock(&dsp->pwr_lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(wm_adsp_compr_trigger);
+
MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h
index 0b2205a..43af093 100644
--- a/sound/soc/codecs/wm_adsp.h
+++ b/sound/soc/codecs/wm_adsp.h
@@ -111,5 +111,6 @@ extern int wm_adsp_compr_set_params(struct snd_compr_stream *stream,
struct snd_compr_params *params);
extern int wm_adsp_compr_get_caps(struct snd_compr_stream *stream,
struct snd_compr_caps *caps);
+extern int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd);
#endif
--
2.1.4
next prev parent reply other threads:[~2015-12-08 16:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-08 16:08 [PATCH 01/13] ASoC: wm_adsp: Fixup some minor formatting and checkpatch errors Charles Keepax
2015-12-08 16:08 ` [PATCH 02/13] ASoC: wm_adsp: Replace debugfs lock with more general DSP power lock Charles Keepax
2015-12-12 23:07 ` Applied "ASoC: wm_adsp: Replace debugfs lock with more general DSP power lock" to the asoc tree Mark Brown
2015-12-08 16:08 ` [PATCH 03/13] ASoC: wm_adsp: Add locking to DSP firmware controls Charles Keepax
2015-12-12 23:07 ` Applied "ASoC: wm_adsp: Add locking to DSP firmware controls" to the asoc tree Mark Brown
2015-12-08 16:08 ` [PATCH 04/13] ASoC: wm_adsp: Add power lock for firmware change control Charles Keepax
2015-12-12 23:07 ` Applied "ASoC: wm_adsp: Add power lock for firmware change control" to the asoc tree Mark Brown
2015-12-08 16:08 ` [PATCH 05/13] ASoC: wm_adsp: Select SND_SOC_COMPRESS Charles Keepax
2015-12-10 8:09 ` Vinod Koul
2015-12-10 13:49 ` Charles Keepax
2015-12-08 16:08 ` [PATCH 06/13] ASoC: wm5110: Provide basic hookup for voice control Charles Keepax
2015-12-08 16:08 ` [PATCH 07/13] ASoC: wm_adsp: Factor out finding the location of an algorithm region Charles Keepax
2015-12-23 0:23 ` Applied "ASoC: wm_adsp: Factor out finding the location of an algorithm region" to the asoc tree Mark Brown
2015-12-08 16:08 ` [PATCH v2 RESEND 08/13] ALSA: compress: Add SND_AUDIOCODEC_BESPOKE Charles Keepax
2015-12-08 16:08 ` [PATCH 09/13] ASoC: wm_adsp: Add support for opening a compressed stream Charles Keepax
2015-12-23 0:23 ` Applied "ASoC: wm_adsp: Add support for opening a compressed stream" to the asoc tree Mark Brown
2015-12-08 16:08 ` [PATCH 10/13] ASoC: wm_adsp: Add code to locate and initialise compressed buffer Charles Keepax
2015-12-08 16:08 ` Charles Keepax [this message]
2015-12-23 0:23 ` Applied "ASoC: wm_adsp: Attach buffers and streams together" to the asoc tree Mark Brown
2015-12-08 16:08 ` [PATCH 12/13] ASoC: wm_adsp: Add a handler for the compressed IRQ Charles Keepax
2015-12-08 16:08 ` [PATCH 13/13] ASoC: wm_adsp: Pull data through compressed read Charles Keepax
2015-12-08 16:33 ` [PATCH 01/13] ASoC: wm_adsp: Fixup some minor formatting and checkpatch errors Charles Keepax
2015-12-12 23:07 ` Applied "ASoC: wm_adsp: Fixup some minor formatting and checkpatch errors" to the asoc tree Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449590917-21170-11-git-send-email-ckeepax@opensource.wolfsonmicro.com \
--to=ckeepax@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=patches@opensource.wolfsonmicro.com \
--cc=tiwai@suse.com \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).