From patchwork Mon Apr 27 17:29:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 11513025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E35581 for ; Mon, 27 Apr 2020 17:43:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF29E208FE for ; Mon, 27 Apr 2020 17:43:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="FjAgCZLi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF29E208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3E5D21682; Mon, 27 Apr 2020 19:42:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3E5D21682 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1588009398; bh=BELKh+Sy2qDZDfbxgdHYPvJs7h9p+t4pDeBQBx2r7k0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FjAgCZLiu8M5ewbh1RhJ/LoUnUcoWUv5N/oaJcZSjBu+EgIeHFQrkNZsmuxGUJozM rGehCeyJq8X429vW1za6sDEjVkbnigYeRdsTo1JbPv9yaUZrsWQwfeNErQfZBUHIqB lIwugzLOaG4HHfKv1v9c7XggWnANGfhb+rwnHbDA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5A117F802DB; Mon, 27 Apr 2020 19:29:52 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id BECB1F8027D; Mon, 27 Apr 2020 19:29:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A101BF8027D for ; Mon, 27 Apr 2020 19:29:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A101BF8027D IronPort-SDR: mnEv2ljwajyROW4M43tpOi14pzRtd+kx/HwV8vTG6jz3cwT1cOP/4YVwFYnS63TYsC0wk5QIYd IMhDG/wESDzQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 10:29:40 -0700 IronPort-SDR: 8SAuGUhLQG3OqaJ8h0zWy7T0pbLvCCzLRFhXWrS1fiQdhz6ZSN3cFL/gIUF4ESHKV2gSt7wgSa deH5rmFJi5LQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,324,1583222400"; d="scan'208";a="458935996" Received: from dbombien-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.254.51.189]) by fmsmga006.fm.intel.com with ESMTP; 27 Apr 2020 10:29:39 -0700 From: Ranjani Sridharan To: alsa-devel@alsa-project.org Subject: [PATCH 1/4] ASoC: SOF: topology: send ipc for all found DAIs in sof_set_dai_config Date: Mon, 27 Apr 2020 10:29:36 -0700 Message-Id: <20200427172939.25848-2-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200427172939.25848-1-ranjani.sridharan@linux.intel.com> References: <20200427172939.25848-1-ranjani.sridharan@linux.intel.com> Cc: tiwai@suse.de, broonie@kernel.org, Bard Liao , pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Bard Liao We may find more than one DAIs in sof_set_dai_config() and we should send message to DSP for each DAI we found. Signed-off-by: Bard Liao Reviewed-by: Guennadi Liakhovetski Reviewed-by: Kai Vehmanen Signed-off-by: Ranjani Sridharan --- sound/soc/sof/topology.c | 81 +++++++++------------------------------- 1 file changed, 18 insertions(+), 63 deletions(-) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index e88ffc25025f..0b15b4055f32 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -2673,7 +2673,11 @@ static void sof_dai_set_format(struct snd_soc_tplg_hw_config *hw_config, } } -/* set config for all DAI's with name matching the link name */ +/* + * Send IPC and set the same config for all DAIs with name matching the link + * name. Note that the function can only be used for the case that all DAIs + * have a common DAI config for now. + */ static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, struct snd_soc_dai_link *link, struct sof_ipc_dai_config *config) @@ -2686,6 +2690,19 @@ static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, continue; if (strcmp(link->name, dai->name) == 0) { + struct sof_ipc_reply reply; + int ret; + + /* send message to DSP */ + ret = sof_ipc_tx_message(sdev->ipc, + config->hdr.cmd, config, size, + &reply, sizeof(reply)); + + if (ret < 0) { + dev_err(sdev->dev, "error: failed to set DAI config for %s index %d\n", + dai->name, config->dai_index); + return ret; + } dai->dai_config = kmemdup(config, size, GFP_KERNEL); if (!dai->dai_config) return -ENOMEM; @@ -2718,7 +2735,6 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &cfg->priv; - struct sof_ipc_reply reply; u32 size = sizeof(*config); int ret; @@ -2767,17 +2783,6 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, return -EINVAL; } - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, - config->hdr.cmd, config, size, &reply, - sizeof(reply)); - - if (ret < 0) { - dev_err(scomp->dev, "error: failed to set DAI config for SSP%d\n", - config->dai_index); - return ret; - } - /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) @@ -2795,7 +2800,6 @@ static int sof_link_sai_load(struct snd_soc_component *scomp, int index, { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &cfg->priv; - struct sof_ipc_reply reply; u32 size = sizeof(*config); int ret; @@ -2835,17 +2839,6 @@ static int sof_link_sai_load(struct snd_soc_component *scomp, int index, return -EINVAL; } - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, - config->hdr.cmd, config, size, &reply, - sizeof(reply)); - - if (ret < 0) { - dev_err(scomp->dev, "error: failed to set DAI config for SAI%d\n", - config->dai_index); - return ret; - } - /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) @@ -2863,7 +2856,6 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &cfg->priv; - struct sof_ipc_reply reply; u32 size = sizeof(*config); int ret; @@ -2904,16 +2896,6 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, return -EINVAL; } - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, - config->hdr.cmd, config, size, &reply, - sizeof(reply)); - if (ret < 0) { - dev_err(scomp->dev, "error: failed to set DAI config for ESAI%d\n", - config->dai_index); - return ret; - } - /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) @@ -2931,7 +2913,6 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &cfg->priv; - struct sof_ipc_reply reply; struct sof_ipc_fw_ready *ready = &sdev->fw_ready; struct sof_ipc_fw_version *v = &ready->version; size_t size = sizeof(*config); @@ -3007,17 +2988,6 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, if (SOF_ABI_VER(v->major, v->minor, v->micro) < SOF_ABI_VER(3, 0, 1)) config->dmic.fifo_bits_b = config->dmic.fifo_bits; - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, size, - &reply, sizeof(reply)); - - if (ret < 0) { - dev_err(scomp->dev, - "error: failed to set DAI config for DMIC%d\n", - config->dai_index); - goto err; - } - /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) @@ -3142,7 +3112,6 @@ static int sof_link_alh_load(struct snd_soc_component *scomp, int index, { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &cfg->priv; - struct sof_ipc_reply reply; u32 size = sizeof(*config); int ret; @@ -3158,20 +3127,6 @@ static int sof_link_alh_load(struct snd_soc_component *scomp, int index, /* init IPC */ config->hdr.size = size; - dev_dbg(scomp->dev, "ALH config rate %d channels %d\n", - config->alh.rate, config->alh.channels); - - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, - config->hdr.cmd, config, size, &reply, - sizeof(reply)); - - if (ret < 0) { - dev_err(scomp->dev, "error: failed to set DAI config for ALH %d\n", - config->dai_index); - return ret; - } - /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) From patchwork Mon Apr 27 17:29:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 11513033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 287A481 for ; Mon, 27 Apr 2020 17:44:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AEFD12168B for ; Mon, 27 Apr 2020 17:44:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="fK2aYuzl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AEFD12168B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0A228168C; Mon, 27 Apr 2020 19:43:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0A228168C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1588009459; bh=yMzo42yeEro+v+ptQHQmoa4KojG+ZOu6yWFRDTR+T4A=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fK2aYuzlJ68PO6IzQrozWhxHm8lCUZzHX4BW3gWk+gyjGsmJ9XXfUutPWI6i8cijZ PtcZujY+ITF9xSTqDfEHEEXHTt7zKoVaceACv20ZptSX5JBJ6Apgx+Avf7mZDFaj9z he+ZnW/LnRX5EliAm+eWNuBoHF7azCVaIyrO4ckk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DE4B1F802E3; Mon, 27 Apr 2020 19:29:57 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4CCD3F802E1; Mon, 27 Apr 2020 19:29:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9C8F3F80247 for ; Mon, 27 Apr 2020 19:29:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9C8F3F80247 IronPort-SDR: f5U7EqekrC4IhHByrPjpL9Kdh0vFW8ItpJLZ/hMAQ44csRPUf9lGEk7gZUlmubNnlh1qxCJ3yZ OD3eCV73X0vg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 10:29:40 -0700 IronPort-SDR: PItZYp/D2hoFzCJ8gDaNx2c8NIcxm/qVcboiM9GXyogi9bVFyPFM1COVSsmHfK3Fuwkx9OxgfW WrHCVeUXhkxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,324,1583222400"; d="scan'208";a="458935997" Received: from dbombien-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.254.51.189]) by fmsmga006.fm.intel.com with ESMTP; 27 Apr 2020 10:29:39 -0700 From: Ranjani Sridharan To: alsa-devel@alsa-project.org Subject: [PATCH 2/4] ASoC: topology: set component dai_index to ipc dai config dai_index Date: Mon, 27 Apr 2020 10:29:37 -0700 Message-Id: <20200427172939.25848-3-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200427172939.25848-1-ranjani.sridharan@linux.intel.com> References: <20200427172939.25848-1-ranjani.sridharan@linux.intel.com> Cc: tiwai@suse.de, broonie@kernel.org, Bard Liao , pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Bard Liao The ipc dai config dai_index is from topology. However, the same dai config will be applied to all DAIs in the same dai link. We have to ensure that the ipc dai config's dai_index match to the component's dai_index. Signed-off-by: Bard Liao Reviewed-by: Guennadi Liakhovetski Reviewed-by: Kai Vehmanen Signed-off-by: Ranjani Sridharan --- sound/soc/sof/topology.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 0b15b4055f32..0ed3ab35e9f9 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -2693,6 +2693,14 @@ static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, struct sof_ipc_reply reply; int ret; + /* + * the same dai config will be applied to all DAIs in + * the same dai link. We have to ensure that the ipc + * dai config's dai_index match to the component's + * dai_index. + */ + config->dai_index = dai->comp_dai.dai_index; + /* send message to DSP */ ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, size, From patchwork Mon Apr 27 17:29:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 11513031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA01F81 for ; Mon, 27 Apr 2020 17:44:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B25A214AF for ; Mon, 27 Apr 2020 17:44:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="bX+WKWh8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B25A214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A570716B9; Mon, 27 Apr 2020 19:43:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A570716B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1588009448; bh=hgGmhJiEoIWBXMblP/9poO0dYhLc+JfAzy7pYggeeGA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bX+WKWh8jhU9jfR/JpwNhHa9wh2VKoALT+t8vRSitkuIzSTv2qCgchf75ZeO8IMEm 7udA9D0ObOKdmFV9RW9tuKcKAWuYCXmE1RwtnR7UYcMCQVoZidM8jU05Xnfov4J16m 3YkOig1rsagOitfel90IEr1Xv8C3vA0sX48vJOlM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C495AF802E9; Mon, 27 Apr 2020 19:30:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id CFDC4F802E0; Mon, 27 Apr 2020 19:29:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 29B19F802C4 for ; Mon, 27 Apr 2020 19:29:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 29B19F802C4 IronPort-SDR: PBgPJ9DRaFJRFr8c3aCHLhzlhKIYvpH8T8BhiOuLg3QHToad+f6f+bN47JTp5CNR/rNgX98Wuv tNRBxZqcT4tg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 10:29:40 -0700 IronPort-SDR: rB0jl63b/h7iivFU4eIpzKUUSasIcC+elf33B9RFz0RJcVRUHtpIJ/h6G/cpJm1RgjEEjF7Hm7 zXHaN3zZ6eFA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,324,1583222400"; d="scan'208";a="458935998" Received: from dbombien-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.254.51.189]) by fmsmga006.fm.intel.com with ESMTP; 27 Apr 2020 10:29:39 -0700 From: Ranjani Sridharan To: alsa-devel@alsa-project.org Subject: [PATCH 3/4] ASoC: SOF: topology: replace sof_link_hda_process by sof_set_dai_config Date: Mon, 27 Apr 2020 10:29:38 -0700 Message-Id: <20200427172939.25848-4-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200427172939.25848-1-ranjani.sridharan@linux.intel.com> References: <20200427172939.25848-1-ranjani.sridharan@linux.intel.com> Cc: tiwai@suse.de, broonie@kernel.org, Bard Liao , pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Bard Liao Now we send ipc in sof_set_dai_config(), too. Therefore, we can use sof_set_dai_config() in sof_link_hda_load() just like other link load functions do. Signed-off-by: Bard Liao Reviewed-by: Guennadi Liakhovetski Reviewed-by: Kai Vehmanen Signed-off-by: Ranjani Sridharan --- sound/soc/sof/topology.c | 64 ++-------------------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 0ed3ab35e9f9..6fd75fe9f699 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -3008,66 +3008,6 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, return ret; } -/* - * for hda link, playback and capture are supported by different dai - * in FW. Here get the dai_index, set dma channel of each dai - * and send config to FW. In FW, each dai sets config by dai_index - */ -static int sof_link_hda_process(struct snd_sof_dev *sdev, - struct snd_soc_dai_link *link, - struct sof_ipc_dai_config *config) -{ - struct sof_ipc_reply reply; - u32 size = sizeof(*config); - struct snd_sof_dai *sof_dai; - int found = 0; - int ret; - - list_for_each_entry(sof_dai, &sdev->dai_list, list) { - if (!sof_dai->name) - continue; - - if (strcmp(link->name, sof_dai->name) == 0) { - config->dai_index = sof_dai->comp_dai.dai_index; - found = 1; - - config->hda.link_dma_ch = DMA_CHAN_INVALID; - - /* save config in dai component */ - sof_dai->dai_config = kmemdup(config, size, GFP_KERNEL); - if (!sof_dai->dai_config) - return -ENOMEM; - - sof_dai->cpu_dai_name = link->cpus->dai_name; - - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, - config->hdr.cmd, config, size, - &reply, sizeof(reply)); - - if (ret < 0) { - dev_err(sdev->dev, "error: failed to set DAI config for direction:%d of HDA dai %d\n", - sof_dai->comp_dai.direction, - config->dai_index); - - return ret; - } - } - } - - /* - * machine driver may define a dai link with playback and capture - * dai enabled, but the dai link in topology would support both, one - * or none of them. Here print a warning message to notify user - */ - if (!found) { - dev_warn(sdev->dev, "warning: failed to find dai for dai link %s", - link->name); - } - - return 0; -} - static int sof_link_hda_load(struct snd_soc_component *scomp, int index, struct snd_soc_dai_link *link, struct snd_soc_tplg_link_config *cfg, @@ -3104,7 +3044,9 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index, return -EINVAL; } - ret = sof_link_hda_process(sdev, link, config); + config->hda.link_dma_ch = DMA_CHAN_INVALID; + + ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) dev_err(scomp->dev, "error: failed to process hda dai link %s", link->name); From patchwork Mon Apr 27 17:29:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 11513027 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6676B81 for ; Mon, 27 Apr 2020 17:43:48 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED298208FE for ; Mon, 27 Apr 2020 17:43:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="U31bt3ba" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED298208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4D0961680; Mon, 27 Apr 2020 19:42:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4D0961680 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1588009426; bh=KkbaosToRHBWEpGwKtm4KXDZRpl+0WDnkcPNCaseRVM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=U31bt3baGXg3m/ZUnuuUVc0mYmOU2tkXDlJUoQ/Kln08mYAZSVdeqFhEnUHNNciYZ tjsEexJp1SeZgtNFauICFCbicUyJeUH4rVM4VM5hHBOGrDqtST2FTeStyCh4dT2s5J esRcy+41tAycVtXdImRLRnITysHvkEtNUAk65HQE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5E5C5F802F7; Mon, 27 Apr 2020 19:30:08 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 85D20F802EA; Mon, 27 Apr 2020 19:30:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0FC01F802DC for ; Mon, 27 Apr 2020 19:29:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0FC01F802DC IronPort-SDR: 4IECd9F2UniqMIlyHQkcZCIQqclMK/qLNcPqM8O1WgJu1LBZdFgANCotarL/1Hi6QPC6Yd2pXf MThd56Fs0uZg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 10:29:40 -0700 IronPort-SDR: AGkkGpDJobXofbSL9P+f2mXgvr0jsQ8DgljSef+Js+tam8FPIJM3g/e1vF+LdzJIFNTcLU93lW VmU38KlKil/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,324,1583222400"; d="scan'208";a="458935999" Received: from dbombien-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.254.51.189]) by fmsmga006.fm.intel.com with ESMTP; 27 Apr 2020 10:29:40 -0700 From: Ranjani Sridharan To: alsa-devel@alsa-project.org Subject: [PATCH 4/4] ASoC: SOF: Intel: change trigger sequence to fix pop noise when stopping playback on sdw platforms Date: Mon, 27 Apr 2020 10:29:39 -0700 Message-Id: <20200427172939.25848-5-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200427172939.25848-1-ranjani.sridharan@linux.intel.com> References: <20200427172939.25848-1-ranjani.sridharan@linux.intel.com> Cc: tiwai@suse.de, broonie@kernel.org, pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com, randerwang X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: randerwang Now the trigger sequence is set to SND_SOC_DPCM_TRIGGER_POST for SOF. This means FE will be stopped before BE, so BE will consume invalid data and this generates huge pop noise. This sequence is introduced for HDA DAI which requires SND_SOC_DPCM_TRIGGER_POST for some reasons. Now set default trigger sequence to SND_SOC_DPCM_TRIGGER_PRE for playback with all DAI and fix sequence only for HDA DAI. Fully tested on Comet Lake for a few cycles. Signed-off-by: randerwang Reviewed-by: Clarex Zhou Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Signed-off-by: Ranjani Sridharan --- sound/soc/sof/pcm.c | 12 +++++++++++- sound/soc/sof/topology.c | 14 +++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 0885826adb6c..e9679fcba428 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -639,6 +639,7 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); struct snd_sof_dai *dai = snd_sof_find_dai(component, (char *)rtd->dai_link->name); + struct snd_soc_dpcm *dpcm; /* no topology exists for this BE, try a common configuration */ if (!dai) { @@ -702,7 +703,16 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, } break; case SOF_DAI_INTEL_HDA: - /* do nothing for HDA dai_link */ + /* + * HDaudio does not follow the default trigger + * sequence due to firmware implementation + */ + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) { + struct snd_soc_pcm_runtime *fe = dpcm->fe; + + fe->dai_link->trigger[SNDRV_PCM_STREAM_PLAYBACK] = + SND_SOC_DPCM_TRIGGER_POST; + } break; case SOF_DAI_INTEL_ALH: /* do nothing for ALH dai_link */ diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 6fd75fe9f699..8ab0fc558054 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -3111,9 +3111,17 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, if (!link->no_pcm) { link->nonatomic = true; - /* set trigger order */ - link->trigger[0] = SND_SOC_DPCM_TRIGGER_POST; - link->trigger[1] = SND_SOC_DPCM_TRIGGER_POST; + /* + * set default trigger order for all links. Exceptions to + * the rule will be handled in sof_pcm_dai_link_fixup() + * For playback, the sequence is the following: start FE, + * start BE, stop BE, stop FE; for Capture the sequence is + * inverted start BE, start FE, stop FE, stop BE + */ + link->trigger[SNDRV_PCM_STREAM_PLAYBACK] = + SND_SOC_DPCM_TRIGGER_PRE; + link->trigger[SNDRV_PCM_STREAM_CAPTURE] = + SND_SOC_DPCM_TRIGGER_POST; /* nothing more to do for FE dai links */ return 0;