From patchwork Sat Apr 18 20:57:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 6237721 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 D9741BF4A6 for ; Sat, 18 Apr 2015 21:04:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E02E9203E3 for ; Sat, 18 Apr 2015 21:04:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 98531203DC for ; Sat, 18 Apr 2015 21:04:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 67C24265A98; Sat, 18 Apr 2015 23:04:11 +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 8CDBA2651ED; Sat, 18 Apr 2015 23:02:55 +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 12AD02651DB; Sat, 18 Apr 2015 23:02:53 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id 77673265133 for ; Sat, 18 Apr 2015 23:02:48 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 18 Apr 2015 14:02:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,600,1422950400"; d="scan'208";a="711505221" Received: from vkoul-udesk3.iind.intel.com ([10.223.84.65]) by fmsmga002.fm.intel.com with ESMTP; 18 Apr 2015 14:02:45 -0700 From: Vinod Koul To: alsa-devel@alsa-project.org Date: Sun, 19 Apr 2015 02:27:29 +0530 Message-Id: <1429390653-8194-4-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 3/7] ASoC: hda: add FW module init/bind 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 creates module init and bind IPC message based on module parameter and calls IPC interface to send the IPC to FW. Signed-off-by: Jeeja KP Signed-off-by: Vinod Koul --- sound/soc/hda/hda_soc_dsp.c | 133 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/sound/soc/hda/hda_soc_dsp.c b/sound/soc/hda/hda_soc_dsp.c index fea47645368e..5a9927b82852 100644 --- a/sound/soc/hda/hda_soc_dsp.c +++ b/sound/soc/hda/hda_soc_dsp.c @@ -455,3 +455,136 @@ static int ssth_free_queue(u8 *queue_mask, u8 queue_index) else return queue_index; } + +int ssth_init_module(struct ssth_lib *ctx, + struct ssth_module_config *mconfig, + struct hda_sst_algo_data *ac) +{ + u16 module_config_size = 0; + void *param_data = NULL; + int ret = 0; + struct ssth_init_instance_msg msg; + struct ssth_dxstate_info dx; + + dev_dbg(ctx->dev, "%s: module_id = %d instance=%d\n", __func__, + mconfig->id.module_id, mconfig->id.instance_id); + + ret = ssth_set_module_format(ctx, mconfig, + &module_config_size, ¶m_data); + if (ret < 0) { + dev_err(ctx->dev, "Failed to set module format ret=%d\n", ret); + goto exit; + } + + if (mconfig->core_id != SSTH_AFFINITY_CORE_0) { + dx.core_mask = mconfig->core_id; + dx.dx_mask = mconfig->core_id; + /*SET core to D0 */ + ret = ssth_ipc_set_dx(ctx->ipc, 0, 0, &dx); + if (ret < 0) + return ret; + + } + msg.module_id = mconfig->id.module_id; + msg.instance_id = mconfig->id.instance_id; + msg.ppl_instance_id = mconfig->pipe->ppl_id; + msg.param_data_size = module_config_size; + msg.core_id = mconfig->core_id; + + if (mconfig->pipe->state != SSTH_PIPE_STATE_CREATED) { + dev_err(ctx->dev, "Pipe not created for Module state= %d pipe_id= %d\n", + mconfig->pipe->state, mconfig->pipe->ppl_id); + return -EIO; + } + + ret = ssth_ipc_init_instance(ctx->ipc, &msg, param_data); + if (ret < 0) { + dev_err(ctx->dev, "Failed to init instance ret=%d\n", ret); + goto exit; + } + mconfig->m_state = SSTH_MODULE_STATE_INIT_DONE; + +exit: + if (param_data != NULL) + kfree(param_data); + + return ret; +} + +int ssth_bind_unbind_modules(struct ssth_lib *ctx, struct ssth_module_config + *src_module, struct ssth_module_config *dst_module, bool bind) +{ + int ret = 0; + struct ssth_bind_unbind_msg msg; + struct ssth_sink_module *sink_module, *__sink_module; + + dev_dbg(ctx->dev, "%s: src module_id = %d src_instance=%d dst_module=%d \ + dst_instacne=%d\n", __func__, src_module->id.module_id, + src_module->id.instance_id, dst_module->id.module_id, + dst_module->id.instance_id); + + dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n", + src_module->m_state, dst_module->m_state); + /*if module is not bind, then don't send unbind */ + if (!bind) { + if (src_module->m_state != SSTH_MODULE_STATE_BIND_DONE) + return ret; + /* if intra module unbind, check if both modules are BIND, + then send unbind + */ + if ((src_module->pipe->ppl_id != dst_module->pipe->ppl_id) && + dst_module->m_state != SSTH_MODULE_STATE_BIND_DONE) + return ret; + } else if (src_module->m_state != SSTH_MODULE_STATE_INIT_DONE && + dst_module->m_state != SSTH_MODULE_STATE_INIT_DONE) + return ret; + + msg.module_id = src_module->id.module_id; + msg.instance_id = src_module->id.instance_id; + msg.dst_module_id = dst_module->id.module_id; + msg.dst_instance_id = dst_module->id.instance_id; + if (bind) { + src_module->out_queue = ssth_alloc_queue(&src_module->out_queue_mask, + src_module->max_out_queue, src_module->out_queue); + dst_module->in_queue = ssth_alloc_queue(&dst_module->in_queue_mask, + dst_module->max_in_queue, dst_module->in_queue); + sink_module = devm_kzalloc(ctx->dev, sizeof(struct ssth_sink_module), GFP_KERNEL); + if (!sink_module) { + dev_err(ctx->dev, "Unable to allocate mem\n"); + return -ENOMEM; + } + sink_module->id.instance_id = dst_module->id.instance_id; + sink_module->id.module_id = dst_module->id.module_id; + sink_module->in_queue = dst_module->in_queue; + list_add_tail(&sink_module->node, &src_module->sink_list); + } else { + src_module->out_queue = ssth_free_queue(&src_module->out_queue_mask, + src_module->out_queue); + list_for_each_entry_safe(sink_module, __sink_module, &src_module->sink_list, node) { + if ((sink_module->id.module_id == dst_module->id.module_id) && + ((sink_module->id.instance_id == dst_module->id.instance_id))) { + list_del(&sink_module->node); + dst_module->in_queue = sink_module->in_queue; + devm_kfree(ctx->dev, sink_module); + break; + } + } + dst_module->in_queue = ssth_free_queue(&dst_module->in_queue_mask, + dst_module->in_queue); + } + dev_dbg(ctx->dev, "in queque = %d out_queue =%d\n", + src_module->out_queue, dst_module->in_queue); + msg.src_queue = src_module->out_queue; + msg.dst_queue = dst_module->in_queue; + msg.bind = bind; + + ret = ssth_ipc_bind_unbind(ctx->ipc, &msg); + + if (!ret) { + if (bind) + src_module->m_state = SSTH_MODULE_STATE_BIND_DONE; + else + src_module->m_state = SSTH_MODULE_STATE_UNINIT; + } + return ret; +}