From: Vinod Koul <vinod.koul@intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, patches.audio@intel.com,
liam.r.girdwood@linux.intel.com,
Vinod Koul <vinod.koul@intel.com>,
broonie@kernel.org, Jeeja KP <jeeja.kp@intel.com>
Subject: [RFC 4/7] ASoC: hda: add FW pipe create/delete/set_pipe_state IPC
Date: Sun, 19 Apr 2015 02:27:30 +0530 [thread overview]
Message-ID: <1429390653-8194-5-git-send-email-vinod.koul@intel.com> (raw)
In-Reply-To: <1429390653-8194-1-git-send-email-vinod.koul@intel.com>
From: Jeeja KP <jeeja.kp@intel.com>
This helper function is called when FW pipeline has to created/deleted/ to
set the pipe to run/pause and uses IPC lib to send the msg to dsp.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
sound/soc/hda/hda_soc_dsp.c | 112 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 112 insertions(+)
diff --git a/sound/soc/hda/hda_soc_dsp.c b/sound/soc/hda/hda_soc_dsp.c
index 5a9927b82852..5f36ebdc0fba 100644
--- a/sound/soc/hda/hda_soc_dsp.c
+++ b/sound/soc/hda/hda_soc_dsp.c
@@ -588,3 +588,115 @@ int ssth_bind_unbind_modules(struct ssth_lib *ctx, struct ssth_module_config
}
return ret;
}
+
+static int ssth_set_pipe_state(struct ssth_lib *ctx, struct ssth_pipe *pipe,
+ enum ssth_pipe_state state)
+{
+ int ret = 0;
+
+ dev_dbg(ctx->dev, "%s: pipe_satate = %d\n", __func__, state);
+ ret = ssth_ipc_set_pipeline_state(ctx->ipc, pipe->ppl_id, state);
+ return ret;
+}
+
+/*
+ * Creates pipeline, by sending IPC messages to FW
+ */
+int ssth_create_pipeline(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+{
+ int ret = 0;
+
+ dev_dbg(ctx->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id);
+
+ ret = ssth_ipc_create_pipeline(ctx->ipc, pipe->memory_pages,
+ pipe->pipe_priority, pipe->ppl_id);
+ if (ret < 0) {
+ dev_err(ctx->dev, "Failed to create pipeline\n");
+ return ret;
+ }
+ pipe->state = SSTH_PIPE_STATE_CREATED;
+ return ret;
+}
+
+/*
+ * Sets pipe state to RUNNING
+ */
+int ssth_run_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+{
+ int ret = 0;
+
+ dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
+
+ /* If pipe was not created in FW, do not try to pause or delete */
+ if (pipe->state < SSTH_PIPE_STATE_CREATED)
+ return ret;
+
+ /* Pipe has to be paused before it is started */
+ ret = ssth_set_pipe_state(ctx, pipe, PPL_PAUSED);
+ if (ret < 0) {
+ dev_err(ctx->dev, "Failed to pause pipe\n");
+ return ret;
+ }
+ pipe->state = SSTH_PIPE_STATE_PAUSED;
+ ret = ssth_set_pipe_state(ctx, pipe, PPL_RUNNING);
+ if (ret < 0) {
+ dev_err(ctx->dev, "Failed to start pipe\n");
+ return ret;
+ }
+
+ pipe->state = SSTH_PIPE_STATE_STARTED;
+
+ return ret;
+}
+
+/*
+ * Sets pipe state to PAUSED in FW, stops DMA engines and releases resources
+ */
+int hda_sst_delete_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+{
+ int ret = 0;
+
+ dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
+
+ /* If pipe is not started, do not try to stop the pipe in FW. */
+ if (pipe->state < SSTH_PIPE_STATE_STARTED)
+ goto delete_pipe;
+
+ ret = ssth_set_pipe_state(ctx, pipe, PPL_PAUSED);
+ if (ret < 0) {
+ dev_err(ctx->dev, "Failed to stop pipeline\n");
+ return ret;
+ }
+ pipe->state = SSTH_PIPE_STATE_PAUSED;
+
+delete_pipe:
+ /* If pipe was not created in FW, do not try to delete it */
+ if (pipe->state < SSTH_PIPE_STATE_CREATED)
+ return ret;
+
+ ret = ssth_ipc_delete_pipeline(ctx->ipc, pipe->ppl_id);
+ if (ret < 0) {
+ dev_err(ctx->dev, "Failed to delete pipeline\n");
+ return ret;
+ }
+ return ret;
+}
+
+int hda_sst_stop_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+{
+ int ret = 0;
+
+ dev_dbg(ctx->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id);
+
+ /* If pipe was not created in FW, do not try to pause or delete */
+ if (pipe->state < SSTH_PIPE_STATE_PAUSED)
+ return ret;
+ ret = ssth_set_pipe_state(ctx, pipe, PPL_PAUSED);
+ if (ret < 0) {
+ dev_dbg(ctx->dev, "Failed to stop pipe\n");
+ return ret;
+ }
+ pipe->state = SSTH_PIPE_STATE_CREATED;
+
+ return ret;
+}
--
1.7.9.5
next prev parent reply other threads:[~2015-04-18 21:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-18 20:57 [RFC 0/7] ASoC: hda - ASoC DSP widget event handlers Vinod Koul
2015-04-18 20:57 ` [RFC 1/7] ASoC: hda: Add skl dsp init and registering with SST IPC lib Vinod Koul
2015-04-24 17:36 ` Mark Brown
2015-04-26 13:53 ` Vinod Koul
2015-04-18 20:57 ` [RFC 2/7] ASoC: hda: add helper to configure module params Vinod Koul
2015-04-24 17:38 ` Mark Brown
2015-04-26 14:06 ` Vinod Koul
2015-04-18 20:57 ` [RFC 3/7] ASoC: hda: add FW module init/bind IPC Vinod Koul
2015-04-18 20:57 ` Vinod Koul [this message]
2015-04-18 20:57 ` [RFC 5/7] ASOC: hda: add DSP platfrom controls widget event handlers Vinod Koul
2015-04-24 17:51 ` Mark Brown
2015-04-26 14:14 ` Vinod Koul
2015-04-18 20:57 ` [RFC 6/7] ASoC: hda: Add support for SSP register settings Vinod Koul
2015-04-24 17:55 ` Mark Brown
2015-04-26 14:18 ` Vinod Koul
2015-04-27 14:15 ` Mark Brown
2015-04-29 23:45 ` Pierre-Louis Bossart
2015-04-29 23:50 ` Pierre-Louis Bossart
2015-04-30 4:39 ` Vinod Koul
2015-04-30 14:36 ` Mark Brown
2015-04-30 15:55 ` Pierre-Louis Bossart
2015-04-18 20:57 ` [RFC 7/7] ASoC: hda: Apply dai params_fixup for DSP widgets Vinod Koul
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=1429390653-8194-5-git-send-email-vinod.koul@intel.com \
--to=vinod.koul@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jeeja.kp@intel.com \
--cc=liam.r.girdwood@linux.intel.com \
--cc=patches.audio@intel.com \
--cc=tiwai@suse.de \
/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