From patchwork Tue Nov 8 00:29:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13035559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4DF33C433FE for ; Tue, 8 Nov 2022 00:25:05 +0000 (UTC) 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 797DE823; Tue, 8 Nov 2022 01:24:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 797DE823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1667867103; bh=NuC8kKBrfvp08/rez3oFrzAks7/tQGO1pKDAS8gvr5Q=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Vs1LhH8N797rUMPGgrZwD9t82SRSslxhE4b8ZLZEeUSqGGUk6WgMCSvY15sugGfAp vFE5xXS7GnI6zjvVJQ51PU9FPBwZVQq0q8egLait1FadMIQpiSUuWHQ0kXIFBJW+Wv vHvlGyvXClKknCtqF0JdZnISBz2LcpdVZUT3fqD8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DD331F804C1; Tue, 8 Nov 2022 01:24:01 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3BEAF804D0; Tue, 8 Nov 2022 01:23:59 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 60D75F80116 for ; Tue, 8 Nov 2022 01:23:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 60D75F80116 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NqkpdC/+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667867034; x=1699403034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NuC8kKBrfvp08/rez3oFrzAks7/tQGO1pKDAS8gvr5Q=; b=NqkpdC/+7HI+vM4KhqCu1/92pQtLnU+d957F8Bz29hMYbVeQkKWrm1El iFOLshBxPbQKpbRNWQSrU6+8sjmURAb2rT9zQLYezRGNJYTuVYCDq2tWG d/sFk55kB2J3baJDL45LQsKTYhRhxcceG9I3BBPTEt85uQqwIck+0uL6i cDeUNwPIii9nji4hNbWDcP1kv572EixIr/A7wgZbqVOr24uaInC19kiI0 ZvjPWs1ExSVuIK6jC8xcRm3SGirqWkp+nm5n7WuG46x7Jp6a+TpxcUk4Z C/lZph0wycZpPYecE15RVgkLIeQiPMLRYcJtzbMkSchGy3mtUjmvkvxH+ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="293927269" X-IronPort-AV: E=Sophos;i="5.96,145,1665471600"; d="scan'208";a="293927269" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 16:23:46 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="614070231" X-IronPort-AV: E=Sophos;i="5.96,145,1665471600"; d="scan'208";a="614070231" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 16:23:44 -0800 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Subject: [PATCH 1/3] ASoC: SOF: ipc4-topology: rename sof_ipc4_widget_free_comp Date: Tue, 8 Nov 2022 08:29:08 +0800 Message-Id: <20221108002910.2819709-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221108002910.2819709-1-yung-chuan.liao@linux.intel.com> References: <20221108002910.2819709-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, peter.ujfalusi@linux.intel.com, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, ranjani.sridharan@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" sof_ipc4_widget_free_comp is dedicated to pipeline. Rename it to sof_ipc4_widget_free_comp_pipeline. Signed-off-by: Bard Liao Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi --- sound/soc/sof/ipc4-topology.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index ab85dde4303b..4f056adc7181 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -280,7 +280,7 @@ static void sof_ipc4_free_audio_fmt(struct sof_ipc4_available_audio_format *avai available_fmt->out_audio_fmt = NULL; } -static void sof_ipc4_widget_free_comp(struct snd_sof_widget *swidget) +static void sof_ipc4_widget_free_comp_pipeline(struct snd_sof_widget *swidget) { kfree(swidget->private); } @@ -1884,7 +1884,8 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc4_widget_ops[SND_SOC_DAPM_TY dai_token_list, ARRAY_SIZE(dai_token_list), NULL, sof_ipc4_prepare_copier_module, sof_ipc4_unprepare_copier_module}, - [snd_soc_dapm_scheduler] = {sof_ipc4_widget_setup_comp_pipeline, sof_ipc4_widget_free_comp, + [snd_soc_dapm_scheduler] = {sof_ipc4_widget_setup_comp_pipeline, + sof_ipc4_widget_free_comp_pipeline, pipeline_token_list, ARRAY_SIZE(pipeline_token_list), NULL, NULL, NULL}, [snd_soc_dapm_pga] = {sof_ipc4_widget_setup_comp_pga, sof_ipc4_widget_free_comp_pga, From patchwork Tue Nov 8 00:29:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13035560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 30DFFC4332F for ; Tue, 8 Nov 2022 00:25:33 +0000 (UTC) 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 39FFF1E4; Tue, 8 Nov 2022 01:24:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 39FFF1E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1667867131; bh=PypZ6wpXKMNNLuOqSFBC/06G/r/SaesQrJz1CmvAtdo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NKrmPZoj3osb5vLPgcxL92An1/m/4P2YAmAdlBH1ZyUmfYHf9ztwJTdf5ipA8SOOd C2Hlxj2M9oBzRjAg3rPDqV7mh/52TlW7fbE50UJAyryNH9b12jyEbLHGhzyN3UUvHi RzWdEiI9cT9GknBbhbUq/8AcxbcSO9zfOZZwXuxQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6723FF8052E; Tue, 8 Nov 2022 01:24:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 43D00F80549; Tue, 8 Nov 2022 01:24:19 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 7B99EF804DF for ; Tue, 8 Nov 2022 01:24:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7B99EF804DF Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="niVApYGC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667867053; x=1699403053; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PypZ6wpXKMNNLuOqSFBC/06G/r/SaesQrJz1CmvAtdo=; b=niVApYGCLGO/zZepe7fsaDyErrNKanKjuVCqLNBft6XRY5keZgyxyAkg +1KyKEF/VzEwLDAL3rfSbyvcTZmNpeH5mq66eNV7YuvC6QPF90wNgSoO0 e2ZhGklil34t0u/vTcssmbeMwPslXIeqSMmKEtPyhQcy5/FG9l/kZs911 lzr38mqeVxgP7EOXvIc+rmnVaxMD8aSda8aZcEosoo3xLYsxYdreHcNyW MMPiUxukgjwt3eMac1c1CK0wlN2YUAq2zI5WloXDi0wWE3cShPTEAd6kC ISSkacSlail6s7yeYmcYvGsc8ojX/x7LJyecfVP3FS1ngJkhiFUqt0yal Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="293927274" X-IronPort-AV: E=Sophos;i="5.96,145,1665471600"; d="scan'208";a="293927274" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 16:23:48 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="614070236" X-IronPort-AV: E=Sophos;i="5.96,145,1665471600"; d="scan'208";a="614070236" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 16:23:46 -0800 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Subject: [PATCH 2/3] ASoC: SOF: ipc4-loader: get max pipeline number Date: Tue, 8 Nov 2022 08:29:09 +0800 Message-Id: <20221108002910.2819709-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221108002910.2819709-1-yung-chuan.liao@linux.intel.com> References: <20221108002910.2819709-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, peter.ujfalusi@linux.intel.com, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, ranjani.sridharan@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" Get max pipeline number from firmware configuration. Signed-off-by: Bard Liao Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi --- sound/soc/sof/ipc4-loader.c | 11 +++++++++++ sound/soc/sof/ipc4-priv.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/sound/soc/sof/ipc4-loader.c b/sound/soc/sof/ipc4-loader.c index 702196774c50..1321acc402fd 100644 --- a/sound/soc/sof/ipc4-loader.c +++ b/sound/soc/sof/ipc4-loader.c @@ -383,6 +383,17 @@ int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev) if (!ipc4_data->max_libs_count) ipc4_data->max_libs_count = 1; break; + case SOF_IPC4_FW_CFG_MAX_PPL_COUNT: + ipc4_data->max_num_pipelines = *tuple->value; + trace_sof_ipc4_fw_config(sdev, "Max PPL count %d", + ipc4_data->max_num_pipelines); + if (ipc4_data->max_num_pipelines <= 0) { + dev_err(sdev->dev, "Invalid max_num_pipelines %d", + ipc4_data->max_num_pipelines); + ret = -EINVAL; + goto out; + } + break; default: break; } diff --git a/sound/soc/sof/ipc4-priv.h b/sound/soc/sof/ipc4-priv.h index d6f35004c4b7..fc9efdce67e0 100644 --- a/sound/soc/sof/ipc4-priv.h +++ b/sound/soc/sof/ipc4-priv.h @@ -65,6 +65,7 @@ struct sof_ipc4_fw_library { * @nhlt: NHLT table either from the BIOS or the topology manifest * @mtrace_type: mtrace type supported on the booted platform * @mtrace_log_bytes: log bytes as reported by the firmware via fw_config reply + * @max_num_pipelines: max number of pipelines * @max_libs_count: Maximum number of libraries support by the FW including the * base firmware * @@ -76,6 +77,7 @@ struct sof_ipc4_fw_data { void *nhlt; enum sof_ipc4_mtrace_type mtrace_type; u32 mtrace_log_bytes; + int max_num_pipelines; u32 max_libs_count; int (*load_library)(struct snd_sof_dev *sdev, From patchwork Tue Nov 8 00:29:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13035561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D9B23C4332F for ; Tue, 8 Nov 2022 00:25:38 +0000 (UTC) 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 D42C5868; Tue, 8 Nov 2022 01:24:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D42C5868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1667867136; bh=jbDzep2ixMXURV4WZfqw8ysOkd1UL1MMY7suiO1EPeI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KT42cc3yB1acRuUI/SU7fGWWSV57xCJNsDQRZGNMTaypCtckXg9L+ywphmA1QIs35 xsfSsNUOgTXeojQJtcF7NQCVX0doELDTuOYAZbrqwev1eAqBWOcIAA3By1qNj2PTLF dvPt/iliLJEBkBf9S40qSD6Y1O6u5Fs6Z89fi2Ng= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6C665F80563; Tue, 8 Nov 2022 01:24:23 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27EC5F80559; Tue, 8 Nov 2022 01:24:21 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 9888AF80116 for ; Tue, 8 Nov 2022 01:24:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9888AF80116 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HHzNu5tt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667867055; x=1699403055; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jbDzep2ixMXURV4WZfqw8ysOkd1UL1MMY7suiO1EPeI=; b=HHzNu5ttZqqgUrDcZJ79/ceCp4LBxIXuNYSFXD74PD1xvQMyIH88y0rC cd82LTfWbGhD5ZoIfAps7av0zL9nMJRdzQcMqnDk9A1Z1wEBOlFp4fvJF 2Gbz+Vm2mzdzzeKUpyea+AB2AuzauiXlFBvipiuFOCgcwESpvhcj5SucK ETs88SDzAoZLSxd1YGJ7MwZN7usDdKmMjnoLigQIWWDRpQJZrvQ7fOiv2 TH//Xo753El7jzfPnCZXNRinGu+EraBMZURFAA0Gc343ypYp1lvQLKpHn IjYYgdp0DSUgMnPp9mARzTrbbErEbRQ534hwEmv4vrlkzhs3GNJmiPg4O g==; X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="293927279" X-IronPort-AV: E=Sophos;i="5.96,145,1665471600"; d="scan'208";a="293927279" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 16:23:50 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="614070241" X-IronPort-AV: E=Sophos;i="5.96,145,1665471600"; d="scan'208";a="614070241" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 16:23:48 -0800 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Subject: [PATCH 3/3] ASoC: SOF: ipc4: get pipeline instance id from pipe_widget->instance_id Date: Tue, 8 Nov 2022 08:29:10 +0800 Message-Id: <20221108002910.2819709-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221108002910.2819709-1-yung-chuan.liao@linux.intel.com> References: <20221108002910.2819709-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, peter.ujfalusi@linux.intel.com, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, ranjani.sridharan@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" Currently we set pipeline instance id = swidget->pipeline_id, but pipeline_id is from topology and can be any number. In fact, the number of pipelines is limited. This patch use ida to allocate pipeline instance id and will be used for pipeline instance id in the IPC message. Signed-off-by: Bard Liao Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi --- sound/soc/sof/intel/hda-dai.c | 12 ++++++------ sound/soc/sof/ipc4-pcm.c | 4 ++-- sound/soc/sof/ipc4-topology.c | 25 +++++++++++++++++++++---- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 0cb7af719c66..1c3d4887aa30 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -478,7 +478,7 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream, struct snd_sof_widget *pipe_widget = swidget->pipe_widget; struct sof_ipc4_pipeline *pipeline = pipe_widget->private; - ret = sof_ipc4_set_pipeline_state(sdev, swidget->pipeline_id, + ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, SOF_IPC4_PIPE_PAUSED); if (ret < 0) return ret; @@ -487,7 +487,7 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream, snd_hdac_ext_stream_clear(hext_stream); - ret = sof_ipc4_set_pipeline_state(sdev, swidget->pipeline_id, + ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, SOF_IPC4_PIPE_RESET); if (ret < 0) return ret; @@ -506,7 +506,7 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream, struct snd_sof_widget *pipe_widget = swidget->pipe_widget; struct sof_ipc4_pipeline *pipeline = pipe_widget->private; - ret = sof_ipc4_set_pipeline_state(sdev, swidget->pipeline_id, + ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, SOF_IPC4_PIPE_PAUSED); if (ret < 0) return ret; @@ -721,20 +721,20 @@ static int ipc4_be_dai_common_trigger(struct snd_soc_dai *dai, int cmd, int stre switch (cmd) { case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: - ret = sof_ipc4_set_pipeline_state(sdev, swidget->pipeline_id, + ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, SOF_IPC4_PIPE_PAUSED); if (ret < 0) return ret; pipeline->state = SOF_IPC4_PIPE_PAUSED; - ret = sof_ipc4_set_pipeline_state(sdev, swidget->pipeline_id, + ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, SOF_IPC4_PIPE_RESET); if (ret < 0) return ret; pipeline->state = SOF_IPC4_PIPE_RESET; break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - ret = sof_ipc4_set_pipeline_state(sdev, swidget->pipeline_id, + ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, SOF_IPC4_PIPE_PAUSED); if (ret < 0) return ret; diff --git a/sound/soc/sof/ipc4-pcm.c b/sound/soc/sof/ipc4-pcm.c index 732872395980..96941bebc1f1 100644 --- a/sound/soc/sof/ipc4-pcm.c +++ b/sound/soc/sof/ipc4-pcm.c @@ -81,7 +81,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component, /* first set the pipeline to PAUSED state */ if (pipeline->state != SOF_IPC4_PIPE_PAUSED) { - ret = sof_ipc4_set_pipeline_state(sdev, swidget->pipeline_id, + ret = sof_ipc4_set_pipeline_state(sdev, pipeline_widget->instance_id, SOF_IPC4_PIPE_PAUSED); if (ret < 0) { dev_err(sdev->dev, "failed to pause pipeline %d\n", @@ -96,7 +96,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component, continue; /* then set the final state */ - ret = sof_ipc4_set_pipeline_state(sdev, swidget->pipeline_id, state); + ret = sof_ipc4_set_pipeline_state(sdev, pipeline_widget->instance_id, state); if (ret < 0) { dev_err(sdev->dev, "failed to set state %d for pipeline %d\n", state, swidget->pipeline_id); diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index 4f056adc7181..57d288bc695e 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -20,6 +20,7 @@ #define SOF_IPC4_TPLG_ABI_SIZE 6 static DEFINE_IDA(alh_group_ida); +static DEFINE_IDA(pipeline_ida); static const struct sof_topology_token ipc4_sched_tokens[] = { {SOF_TKN_SCHED_LP_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, @@ -317,8 +318,7 @@ static int sof_ipc4_widget_setup_msg(struct snd_sof_widget *swidget, struct sof_ msg->primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); msg->primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_MODULE_MSG); - msg->extension = SOF_IPC4_MOD_EXT_PPL_ID(swidget->pipeline_id); - msg->extension |= SOF_IPC4_MOD_EXT_CORE_ID(swidget->core); + msg->extension = SOF_IPC4_MOD_EXT_CORE_ID(swidget->core); type = (fw_module->man4_module_entry.type & SOF_IPC4_MODULE_DP) ? 1 : 0; msg->extension |= SOF_IPC4_MOD_EXT_DOMAIN(type); @@ -625,7 +625,6 @@ static int sof_ipc4_widget_setup_comp_pipeline(struct snd_sof_widget *swidget) swidget->private = pipeline; pipeline->msg.primary = SOF_IPC4_GLB_PIPE_PRIORITY(pipeline->priority); - pipeline->msg.primary |= SOF_IPC4_GLB_PIPE_INSTANCE_ID(swidget->pipeline_id); pipeline->msg.primary |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_GLB_CREATE_PIPELINE); pipeline->msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); pipeline->msg.primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_FW_GEN_MSG); @@ -1436,6 +1435,8 @@ static int sof_ipc4_control_setup(struct snd_sof_dev *sdev, struct snd_sof_contr static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) { + struct snd_sof_widget *pipe_widget = swidget->pipe_widget; + struct sof_ipc4_fw_data *ipc4_data = sdev->private; struct sof_ipc4_pipeline *pipeline; struct sof_ipc4_msg *msg; void *ipc_data = NULL; @@ -1451,6 +1452,16 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget msg = &pipeline->msg; msg->primary |= pipeline->mem_usage; + + swidget->instance_id = ida_alloc_max(&pipeline_ida, ipc4_data->max_num_pipelines, + GFP_KERNEL); + if (swidget->instance_id < 0) { + dev_err(sdev->dev, "failed to assign pipeline id for %s: %d\n", + swidget->widget->name, swidget->instance_id); + return swidget->instance_id; + } + msg->primary &= ~SOF_IPC4_GLB_PIPE_INSTANCE_MASK; + msg->primary |= SOF_IPC4_GLB_PIPE_INSTANCE_ID(swidget->instance_id); break; case snd_soc_dapm_aif_in: case snd_soc_dapm_aif_out: @@ -1524,6 +1535,9 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget msg->extension &= ~SOF_IPC4_MOD_EXT_PARAM_SIZE_MASK; msg->extension |= ipc_size >> 2; + + msg->extension &= ~SOF_IPC4_MOD_EXT_PPL_ID_MASK; + msg->extension |= SOF_IPC4_MOD_EXT_PPL_ID(pipe_widget->instance_id); } dev_dbg(sdev->dev, "Create widget %s instance %d - pipe %d - core %d\n", swidget->widget->name, swidget->instance_id, swidget->pipeline_id, swidget->core); @@ -1539,6 +1553,8 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget struct sof_ipc4_fw_module *fw_module = swidget->module_info; ida_free(&fw_module->m_ida, swidget->instance_id); + } else { + ida_free(&pipeline_ida, swidget->instance_id); } } @@ -1556,7 +1572,7 @@ static int sof_ipc4_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget struct sof_ipc4_msg msg = {{ 0 }}; u32 header; - header = SOF_IPC4_GLB_PIPE_INSTANCE_ID(swidget->pipeline_id); + header = SOF_IPC4_GLB_PIPE_INSTANCE_ID(swidget->instance_id); header |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_GLB_DELETE_PIPELINE); header |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); header |= SOF_IPC4_MSG_TARGET(SOF_IPC4_FW_GEN_MSG); @@ -1570,6 +1586,7 @@ static int sof_ipc4_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget pipeline->mem_usage = 0; pipeline->state = SOF_IPC4_PIPE_UNINITIALIZED; + ida_free(&pipeline_ida, swidget->instance_id); } else { ida_free(&fw_module->m_ida, swidget->instance_id); }