@@ -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;
+}