From patchwork Sat Apr 18 20:57:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 6237731 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C3428BF4A6 for ; Sat, 18 Apr 2015 21:05:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E09C3203DF for ; Sat, 18 Apr 2015 21:05:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7B91C203C1 for ; Sat, 18 Apr 2015 21:05:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 540E02651AA; Sat, 18 Apr 2015 23:05:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 45B312651C0; Sat, 18 Apr 2015 23:03:42 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id BD13D2651C0; Sat, 18 Apr 2015 23:03:40 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id DC53726517F for ; Sat, 18 Apr 2015 23:02:50 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 18 Apr 2015 14:02:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,600,1422950400"; d="scan'208";a="711505235" Received: from vkoul-udesk3.iind.intel.com ([10.223.84.65]) by fmsmga002.fm.intel.com with ESMTP; 18 Apr 2015 14:02:48 -0700 From: Vinod Koul To: alsa-devel@alsa-project.org Date: Sun, 19 Apr 2015 02:27:30 +0530 Message-Id: <1429390653-8194-5-git-send-email-vinod.koul@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1429390653-8194-1-git-send-email-vinod.koul@intel.com> References: <1429390653-8194-1-git-send-email-vinod.koul@intel.com> Cc: tiwai@suse.de, patches.audio@intel.com, liam.r.girdwood@linux.intel.com, Vinod Koul , broonie@kernel.org, Jeeja KP Subject: [alsa-devel] [RFC 4/7] ASoC: hda: add FW pipe create/delete/set_pipe_state IPC X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeeja KP 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 Signed-off-by: Vinod Koul --- 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; +}