From patchwork Fri Jun 2 20:56:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 689303 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 B1737C7EE29 for ; Fri, 2 Jun 2023 20:57:38 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A565882A; Fri, 2 Jun 2023 22:56:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A565882A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739455; bh=eFeidUUmhnXKYS0uKMSaUrsDc7iSwQ0ELiLt27l+OeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=G5S5tQcko4jb4x37bicdh5NTAwr/sMbXw74vspbHvMy53CvT6b2du50bmk03NUSTi mBCMTNP386L5TWZvR0/bX9uirzmK4MoGxt47PJI8rpBsQYZaQC4htqeurZCHbuK9YJ SW9HSXS2GUiiCf7tJF2WHzCe4SvDdJI9ax6lOxHI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id DB8EDF80199; Fri, 2 Jun 2023 22:56:43 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 26161F80199; Fri, 2 Jun 2023 22:56:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0204BF8016B; Fri, 2 Jun 2023 22:56:39 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 D4C40F800BD for ; Fri, 2 Jun 2023 22:56:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D4C40F800BD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UXtdOjFr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739398; x=1717275398; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eFeidUUmhnXKYS0uKMSaUrsDc7iSwQ0ELiLt27l+OeU=; b=UXtdOjFrZ379kqGcgb/pB99TdIaCnKlk8uV6YHP0ls0zCH/Ski649uTM HyxGKLRncYWOPJy1U9I5bnBH1Mk2PalbHY7WZz0nHMZGrM5z67dSwcx9F LfLh3/UQQcEb4scAtux4ju7iXnkEkwev210TqqDe7sIFQVpcqGjGS/ugg qTHiQRL8lsiSSkiywBA3KtENTJwyIof5Qiw9L1p82j+EZ4pgUdIvbT8ip e/aACNFhQnP9fyHFyaAS7WlWSDBdsz3IPBG9JcMSXUKbFykOvWOJe8ZPE BUNnJDk+FBI2e+wX/VAN9NtM3BGcQpsICbuiBzIubjZkVUJq4hwfp+ZnR Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272078" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272078" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092681" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092681" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:33 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , Bard Liao , =?utf-8?q?P=C3=A9ter_Ujfalusi?= , Ranjani Sridharan Subject: [PATCH 1/9] ASoC: SOF: Intel: hda-dai: add error checks to prevent static analysis warnings Date: Fri, 2 Jun 2023 15:56:12 -0500 Message-Id: <20230602205620.310879-2-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: NAE6ZWS7RSTL77GTEEF2UZFCF72GGH7X X-Message-ID-Hash: NAE6ZWS7RSTL77GTEEF2UZFCF72GGH7X X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: make KCFLAGS='-fanalyzer' sound/soc/sof/intel/ reports several NULL pointer dereference paths. Example log: ops = hda_dai_get_ops(substream, cpu_dai); | | ^~~~~ | | | | | (14) return of NULL to ‘non_hda_dai_hw_params’ from ‘hda_dai_get_ops’ | 353 | sdev = widget_to_sdev(w); | 354 | hext_stream = ops->get_hext_stream(sdev, cpu_dai, substream); | | ~~~~~~~~~~~~~~~~~~~~ | | | | | (15) dereference of NULL ‘ops’ The function hda_dai_get_ops() can return NULL, but the return value is not checked across the board. It's not a problem today, since we do check in the first use of the function, but static analysis tools are not aware of the different ALSA stages. Rather than argue forever, let's just add the error checks consistently and make sure this tool can be added to the CI checks. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Péter Ujfalusi Reviewed-by: Ranjani Sridharan --- sound/soc/sof/intel/hda-dai.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 09d8ee98581d..3d89c1923b03 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -120,6 +120,11 @@ static int hda_link_dma_cleanup(struct snd_pcm_substream *substream, struct snd_sof_dev *sdev; int stream_tag; + if (!ops) { + dev_err(cpu_dai->dev, "DAI widget ops not set\n"); + return -EINVAL; + } + sdev = dai_to_sdev(substream, cpu_dai); hlink = snd_hdac_ext_bus_get_hlink_by_name(bus, codec_dai->component->name); @@ -158,6 +163,11 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream, unsigned int link_bps; int stream_tag; + if (!ops) { + dev_err(cpu_dai->dev, "DAI widget ops not set\n"); + return -EINVAL; + } + sdev = dai_to_sdev(substream, cpu_dai); bus = sof_to_bus(sdev); @@ -216,7 +226,7 @@ static int __maybe_unused hda_dai_hw_free(struct snd_pcm_substream *substream, struct snd_sof_dev *sdev = dai_to_sdev(substream, cpu_dai); if (!ops) { - dev_err(sdev->dev, "DAI widget ops not set\n"); + dev_err(cpu_dai->dev, "DAI widget ops not set\n"); return -EINVAL; } @@ -274,6 +284,11 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i struct snd_sof_dev *sdev; int ret; + if (!ops) { + dev_err(dai->dev, "DAI widget ops not set\n"); + return -EINVAL; + } + dev_dbg(dai->dev, "cmd=%d dai %s direction %d\n", cmd, dai->name, substream->stream); From patchwork Fri Jun 2 20:56:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 689302 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 BD405C77B7A for ; Fri, 2 Jun 2023 20:58:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3B47A82B; Fri, 2 Jun 2023 22:57:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3B47A82B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739509; bh=PWkXT1N+z3pK2wTxxef5ZGLINLgrekCHiI5HTifTQBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lx4FkWwEuCFBCvsWFSvnKmiu4T8ogUK3kpYIs//OYr/MJqxupoSil3aGq3r5wMhFH QubPuoLYYYphxmJjQTN8BPEQNvOb/ggFVdhLCALNhf4ezAq+soWgyJSOGDCmCLjmCp nGoiBGUtEH/OwKJqQxeChn8prY60oKSSNT6M7Mbg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 243D0F80568; Fri, 2 Jun 2023 22:56:48 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id C9EA0F80563; Fri, 2 Jun 2023 22:56:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73636F80199; Fri, 2 Jun 2023 22:56:40 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 43B6FF800BD for ; Fri, 2 Jun 2023 22:56:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 43B6FF800BD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VhxTN4Us DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739399; x=1717275399; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PWkXT1N+z3pK2wTxxef5ZGLINLgrekCHiI5HTifTQBw=; b=VhxTN4Usay224ukEiV+zTvMCpZamlqRQ7w7PEQ0h7nCZriJePi+NmfPL 7wL2nMrPSw82UXxhMnYxV2kP2sLSMmM64eysXMlmWwq13HQP4CTV/yAc5 6jFojkhRi2P+BKtg4t5g7wCDwiIUEjZ57sDHJaOoO55ckgP9d+4s926zU beb/lEWQC6Sc3I5szXSh9vGuBoR/vMi2RdcMG2n2T8X8WY2NEYW4PJOAw 2p76daQ3ycIbqg/rMNfjbv7cBG/YPfSmA+Z+6wakJ+R+Fs/b35xeMgn2f 8DvJ3LAL71AcI2DoC9xaavHjJdd/My5igmlVb35Ltm842j5hz1xJ95lIc Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272082" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272082" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092688" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092688" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:34 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , Ranjani Sridharan , =?utf-8?q?P=C3=A9ter?= =?utf-8?q?_Ujfalusi?= , Bard Liao Subject: [PATCH 2/9] ASoC: SOF: Intel: hda-dai: add codec_dai_set_stream callback Date: Fri, 2 Jun 2023 15:56:13 -0500 Message-Id: <20230602205620.310879-3-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: MZTGOBV6JZWG3MES5ILWTUJUBGOSMKLF X-Message-ID-Hash: MZTGOBV6JZWG3MES5ILWTUJUBGOSMKLF X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The existing code for HDAudio DAIs cannot be extended to other types of DAIs, specific programming sequences need to be abstracted away. Start here with hiding the stream_tag needed by the HDAudio codec_dai. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Bard Liao --- sound/soc/sof/intel/hda-dai-ops.c | 17 ++++++++++++++++- sound/soc/sof/intel/hda-dai.c | 3 ++- sound/soc/sof/intel/hda.h | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index 1e58256c8003..2d2953cee1d8 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -175,6 +175,17 @@ static void hda_reset_hext_stream(struct snd_sof_dev *sdev, struct hdac_ext_stre snd_hdac_ext_stream_reset(hext_stream); } +static void hda_codec_dai_set_stream(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream, + struct hdac_stream *hstream) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + + /* set the hdac_stream in the codec dai */ + snd_soc_dai_set_stream(codec_dai, hstream, substream->stream); +} + static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, struct snd_pcm_substream *substream, int cmd) { @@ -307,7 +318,8 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_dma_ops = { .reset_hext_stream = hda_reset_hext_stream, .pre_trigger = hda_ipc4_pre_trigger, .trigger = hda_trigger, - .post_trigger = hda_ipc4_post_trigger + .post_trigger = hda_ipc4_post_trigger, + .codec_dai_set_stream = hda_codec_dai_set_stream, }; static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = { @@ -317,6 +329,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = { .setup_hext_stream = hda_setup_hext_stream, .reset_hext_stream = hda_reset_hext_stream, .trigger = hda_trigger, + .codec_dai_set_stream = hda_codec_dai_set_stream, }; static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, @@ -350,6 +363,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc3_dma_ops = { .reset_hext_stream = hda_reset_hext_stream, .trigger = hda_trigger, .post_trigger = hda_ipc3_post_trigger, + .codec_dai_set_stream = hda_codec_dai_set_stream, }; static struct hdac_ext_stream * @@ -376,6 +390,7 @@ static void hda_dspless_setup_hext_stream(struct snd_sof_dev *sdev, static const struct hda_dai_widget_dma_ops hda_dspless_dma_ops = { .get_hext_stream = hda_dspless_get_hext_stream, .setup_hext_stream = hda_dspless_setup_hext_stream, + .codec_dai_set_stream = hda_codec_dai_set_stream, }; #endif diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 3d89c1923b03..0c018644347e 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -192,7 +192,8 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream, snd_hdac_ext_bus_link_set_stream_id(hlink, stream_tag); /* set the hdac_stream in the codec dai */ - snd_soc_dai_set_stream(codec_dai, hdac_stream(hext_stream), substream->stream); + if (ops->codec_dai_set_stream) + ops->codec_dai_set_stream(sdev, substream, hstream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) link_bps = codec_dai->driver->playback.sig_bits; diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 5b3dad2dadf4..02d935daab28 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -919,6 +919,7 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev, * @pre_trigger: Function pointer for DAI DMA pre-trigger actions * @trigger: Function pointer for DAI DMA trigger actions * @post_trigger: Function pointer for DAI DMA post-trigger actions + * @codec_dai_set_stream: Function pointer to set codec-side stream information */ struct hda_dai_widget_dma_ops { struct hdac_ext_stream *(*get_hext_stream)(struct snd_sof_dev *sdev, @@ -938,6 +939,9 @@ struct hda_dai_widget_dma_ops { struct snd_pcm_substream *substream, int cmd); int (*post_trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, struct snd_pcm_substream *substream, int cmd); + void (*codec_dai_set_stream)(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream, + struct hdac_stream *hstream); }; const struct hda_dai_widget_dma_ops * From patchwork Fri Jun 2 20:56:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 688238 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 61E18C77B7A for ; Fri, 2 Jun 2023 20:58:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 652C1847; Fri, 2 Jun 2023 22:58:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 652C1847 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739533; bh=ucw2vAtS9Y9TO+J0+PxaCqYqbPNawSbbv/OS3KCN9Qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=aDM3j1zAs/4AXRlJHBLv39YzGW0ZoiFxkJCp8VcU8bp6pZGFaps9tx9MWzIIeJRO1 F1+8k6wrKbqptevxMl49OBjxLPQFm4xw9VJxYYpr/rDedh1YX7Jwzf2NAtZqyMXIg9 tApzMbzSPAE2pO70jm1rfPI8nbABiLNxbHmDlF9k= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2C348F8057E; Fri, 2 Jun 2023 22:56:52 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 88903F8057C; Fri, 2 Jun 2023 22:56:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 208F8F80132; Fri, 2 Jun 2023 22:56:41 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 D72AAF800ED for ; Fri, 2 Jun 2023 22:56:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D72AAF800ED Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=niqIxSYZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739400; x=1717275400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ucw2vAtS9Y9TO+J0+PxaCqYqbPNawSbbv/OS3KCN9Qk=; b=niqIxSYZ4xxMGcnFnabtowme+Tz8imT5smE6kjCC/2ynE0Wx4aYsfnbO 5SpQ/qDzwsO5dAzQL7YKs5DSa9gbCTqIvwD4ShYW24+3laxowp7+tBvqq 5drr3vokrG5nEVA6nxr60+Wa+bA1MazlNArzNnWEbXfnJwLO9aORATfX0 q6jerHqi7pmKmnv7aFAKJ5UfK+PXeUL217l0pBS8i4sGaoujU0Kzy6R+R echjsQ7jA/9e5GRfUOMiP6nJ/wCO/obJ/uM4xQPCq+Kt55jCG6TeXLNAH 5/0K7ENvigIl+DNXK9B1RmjE43MbBCOaYC6kY3PUXw55UjtJmZTarMf/d g==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272086" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272086" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092695" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092695" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:34 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , Ranjani Sridharan , =?utf-8?q?P=C3=A9ter?= =?utf-8?q?_Ujfalusi?= , Bard Liao Subject: [PATCH 3/9] ASoC: SOF: Intel: hda-dai: add calc_stream_format callback Date: Fri, 2 Jun 2023 15:56:14 -0500 Message-Id: <20230602205620.310879-4-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 7IGZWLIMKL7TPUJBG7UJVEFA7LFYMZTJ X-Message-ID-Hash: 7IGZWLIMKL7TPUJBG7UJVEFA7LFYMZTJ X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The existing code for HDAudio DAIs cannot be extended to other types of DAIs, specific programming sequences need to be abstracted away. This patch hides the stream format setup which is currently completely related to the HDaudio codec setup - not something that will work for other types of DAIs. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Bard Liao --- sound/soc/sof/intel/hda-dai-ops.c | 27 +++++++++++++++++++++++++++ sound/soc/sof/intel/hda-dai.c | 16 +++------------- sound/soc/sof/intel/hda.h | 5 +++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index 2d2953cee1d8..88fee1e256b0 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -186,6 +186,29 @@ static void hda_codec_dai_set_stream(struct snd_sof_dev *sdev, snd_soc_dai_set_stream(codec_dai, hstream, substream->stream); } +static unsigned int hda_calc_stream_format(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + unsigned int link_bps; + unsigned int format_val; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + link_bps = codec_dai->driver->playback.sig_bits; + else + link_bps = codec_dai->driver->capture.sig_bits; + + format_val = snd_hdac_calc_stream_format(params_rate(params), params_channels(params), + params_format(params), link_bps, 0); + + dev_dbg(sdev->dev, "format_val=%#x, rate=%d, ch=%d, format=%d\n", format_val, + params_rate(params), params_channels(params), params_format(params)); + + return format_val; +} + static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, struct snd_pcm_substream *substream, int cmd) { @@ -320,6 +343,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_dma_ops = { .trigger = hda_trigger, .post_trigger = hda_ipc4_post_trigger, .codec_dai_set_stream = hda_codec_dai_set_stream, + .calc_stream_format = hda_calc_stream_format, }; static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = { @@ -330,6 +354,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = { .reset_hext_stream = hda_reset_hext_stream, .trigger = hda_trigger, .codec_dai_set_stream = hda_codec_dai_set_stream, + .calc_stream_format = hda_calc_stream_format, }; static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, @@ -364,6 +389,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc3_dma_ops = { .trigger = hda_trigger, .post_trigger = hda_ipc3_post_trigger, .codec_dai_set_stream = hda_codec_dai_set_stream, + .calc_stream_format = hda_calc_stream_format, }; static struct hdac_ext_stream * @@ -391,6 +417,7 @@ static const struct hda_dai_widget_dma_ops hda_dspless_dma_ops = { .get_hext_stream = hda_dspless_get_hext_stream, .setup_hext_stream = hda_dspless_setup_hext_stream, .codec_dai_set_stream = hda_codec_dai_set_stream, + .calc_stream_format = hda_calc_stream_format, }; #endif diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 0c018644347e..d9a77a253350 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -159,8 +159,6 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream, struct hdac_ext_link *hlink; struct snd_sof_dev *sdev; struct hdac_bus *bus; - unsigned int format_val; - unsigned int link_bps; int stream_tag; if (!ops) { @@ -195,22 +193,14 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream, if (ops->codec_dai_set_stream) ops->codec_dai_set_stream(sdev, substream, hstream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - link_bps = codec_dai->driver->playback.sig_bits; - else - link_bps = codec_dai->driver->capture.sig_bits; - if (ops->reset_hext_stream) ops->reset_hext_stream(sdev, hext_stream); - format_val = snd_hdac_calc_stream_format(params_rate(params), params_channels(params), - params_format(params), link_bps, 0); + if (ops->calc_stream_format && ops->setup_hext_stream) { + unsigned int format_val = ops->calc_stream_format(sdev, substream, params); - dev_dbg(bus->dev, "format_val=%#x, rate=%d, ch=%d, format=%d\n", format_val, - params_rate(params), params_channels(params), params_format(params)); - - if (ops->setup_hext_stream) ops->setup_hext_stream(sdev, hext_stream, format_val); + } hext_stream->link_prepared = 1; diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 02d935daab28..7a3d202f970e 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -920,6 +920,8 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev, * @trigger: Function pointer for DAI DMA trigger actions * @post_trigger: Function pointer for DAI DMA post-trigger actions * @codec_dai_set_stream: Function pointer to set codec-side stream information + * @calc_stream_format: Function pointer to determine stream format from hw_params and + * for HDaudio codec DAI from the .sig bits */ struct hda_dai_widget_dma_ops { struct hdac_ext_stream *(*get_hext_stream)(struct snd_sof_dev *sdev, @@ -942,6 +944,9 @@ struct hda_dai_widget_dma_ops { void (*codec_dai_set_stream)(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, struct hdac_stream *hstream); + unsigned int (*calc_stream_format)(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params); }; const struct hda_dai_widget_dma_ops * From patchwork Fri Jun 2 20:56:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 689301 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 06420C77B7A for ; Fri, 2 Jun 2023 20:59:18 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 06E8B868; Fri, 2 Jun 2023 22:58:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 06E8B868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739556; bh=PUNzmzUck5debaFGlBrujH8YEJw7myLfV7V+Ty8IITk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=qNNewS+Ft/cxlF0uMTW2NK7u6IQo7rdBOt3bADoEV0TB42Nl6tyEH2gFnyXM6V2TX cKAQT7ZrDANo/VEJHbiFbHx8xikqogcwwYDXiS+cHXV2Z75cXibuMqeznenkzf8GjG x48j16GbiCyquhOx2lQsHu6CHRGMd3FcBA9u8KOU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C6E4DF805AF; Fri, 2 Jun 2023 22:56:55 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 66343F805AB; Fri, 2 Jun 2023 22:56:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0F158F80199; Fri, 2 Jun 2023 22:56:42 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 72A14F8016B for ; Fri, 2 Jun 2023 22:56:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 72A14F8016B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ixs7SQFm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739400; x=1717275400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PUNzmzUck5debaFGlBrujH8YEJw7myLfV7V+Ty8IITk=; b=ixs7SQFmBp9IqP/D9ew7Pk8QDKoFZH2vUUsYrpgO8gCqFm9VvdNqzDTA hHgekZxc0MmyX8OquL+Tum+/faQrBgKbvif0cW42y9KnoAMNi2lrfARiE +N8S9nWqha5D+KrIDsRNyQHTMEQ1mvLPw0OZJ5Wee1nrlqkF+M8VEu5md KSRUEcQAMmZlHNJZsEqE1iPkQU0W0kxIhEMQjRnefMos+gHRMf/1RHpSs bBVj1PYPEgi2PnJPg8qkG2+iNdS4QvxN2GVCS31ulny6Xouogy5mfLmVj jm3KMU5MB884s3UtiAyWx77Xl0/GhN5d8opeTJhmDtE1Isqa9ZKOLUaep g==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272091" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272091" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092703" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092703" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:35 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , Ranjani Sridharan , =?utf-8?q?P=C3=A9ter?= =?utf-8?q?_Ujfalusi?= , Bard Liao Subject: [PATCH 4/9] ASoC: SOF: Intel: hda-dai: add get_hlink callback Date: Fri, 2 Jun 2023 15:56:15 -0500 Message-Id: <20230602205620.310879-5-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 3L5XNRFB6BLZ3DCXZ5YILHFM3HGGNTIF X-Message-ID-Hash: 3L5XNRFB6BLZ3DCXZ5YILHFM3HGGNTIF X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The existing code for HDAudio DAIs cannot be extended to other types of DAIs, specific programming sequences need to be abstracted away. This patch hides the mechanism to determine the multi-link structure related to the DAI and program the LOSIDV register. An added benefit is that we can remove all references to the codec DAI from what should be a CPU dai configuration only. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Bard Liao --- sound/soc/sof/intel/hda-dai-ops.c | 14 ++++++++++++++ sound/soc/sof/intel/hda-dai.c | 28 ++++++---------------------- sound/soc/sof/intel/hda.h | 4 ++++ 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index 88fee1e256b0..f3513796c189 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -209,6 +209,16 @@ static unsigned int hda_calc_stream_format(struct snd_sof_dev *sdev, return format_val; } +static struct hdac_ext_link *hda_get_hlink(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + struct hdac_bus *bus = sof_to_bus(sdev); + + return snd_hdac_ext_bus_get_hlink_by_name(bus, codec_dai->component->name); +} + static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, struct snd_pcm_substream *substream, int cmd) { @@ -344,6 +354,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_dma_ops = { .post_trigger = hda_ipc4_post_trigger, .codec_dai_set_stream = hda_codec_dai_set_stream, .calc_stream_format = hda_calc_stream_format, + .get_hlink = hda_get_hlink, }; static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = { @@ -355,6 +366,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = { .trigger = hda_trigger, .codec_dai_set_stream = hda_codec_dai_set_stream, .calc_stream_format = hda_calc_stream_format, + .get_hlink = hda_get_hlink, }; static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, @@ -390,6 +402,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc3_dma_ops = { .post_trigger = hda_ipc3_post_trigger, .codec_dai_set_stream = hda_codec_dai_set_stream, .calc_stream_format = hda_calc_stream_format, + .get_hlink = hda_get_hlink, }; static struct hdac_ext_stream * @@ -418,6 +431,7 @@ static const struct hda_dai_widget_dma_ops hda_dspless_dma_ops = { .setup_hext_stream = hda_dspless_setup_hext_stream, .codec_dai_set_stream = hda_codec_dai_set_stream, .calc_stream_format = hda_calc_stream_format, + .get_hlink = hda_get_hlink, }; #endif diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index d9a77a253350..3297dea493aa 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -109,12 +109,9 @@ hda_dai_get_ops(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai static int hda_link_dma_cleanup(struct snd_pcm_substream *substream, struct hdac_ext_stream *hext_stream, - struct snd_soc_dai *cpu_dai, - struct snd_soc_dai *codec_dai) + struct snd_soc_dai *cpu_dai) { const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, cpu_dai); - struct hdac_stream *hstream = &hext_stream->hstream; - struct hdac_bus *bus = hstream->bus; struct sof_intel_hda_stream *hda_stream; struct hdac_ext_link *hlink; struct snd_sof_dev *sdev; @@ -127,7 +124,7 @@ static int hda_link_dma_cleanup(struct snd_pcm_substream *substream, sdev = dai_to_sdev(substream, cpu_dai); - hlink = snd_hdac_ext_bus_get_hlink_by_name(bus, codec_dai->component->name); + hlink = ops->get_hlink(sdev, substream); if (!hlink) return -EINVAL; @@ -152,13 +149,10 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai) { const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, cpu_dai); - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct hdac_ext_stream *hext_stream; struct hdac_stream *hstream; struct hdac_ext_link *hlink; struct snd_sof_dev *sdev; - struct hdac_bus *bus; int stream_tag; if (!ops) { @@ -167,9 +161,8 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream, } sdev = dai_to_sdev(substream, cpu_dai); - bus = sof_to_bus(sdev); - hlink = snd_hdac_ext_bus_get_hlink_by_name(bus, codec_dai->component->name); + hlink = ops->get_hlink(sdev, substream); if (!hlink) return -EINVAL; @@ -211,8 +204,6 @@ static int __maybe_unused hda_dai_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, cpu_dai); - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct hdac_ext_stream *hext_stream; struct snd_sof_dev *sdev = dai_to_sdev(substream, cpu_dai); @@ -225,7 +216,7 @@ static int __maybe_unused hda_dai_hw_free(struct snd_pcm_substream *substream, if (!hext_stream) return 0; - return hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai); + return hda_link_dma_cleanup(substream, hext_stream, cpu_dai); } static int __maybe_unused hda_dai_hw_params(struct snd_pcm_substream *substream, @@ -270,8 +261,6 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i { const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, dai); struct hdac_ext_stream *hext_stream; - struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai *codec_dai; struct snd_sof_dev *sdev; int ret; @@ -289,9 +278,6 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i if (!hext_stream) return -EINVAL; - rtd = asoc_substream_to_rtd(substream); - codec_dai = asoc_rtd_to_codec(rtd, 0); - if (ops->pre_trigger) { ret = ops->pre_trigger(sdev, dai, substream, cmd); if (ret < 0) @@ -312,7 +298,7 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i switch (cmd) { case SNDRV_PCM_TRIGGER_SUSPEND: - ret = hda_link_dma_cleanup(substream, hext_stream, dai, codec_dai); + ret = hda_link_dma_cleanup(substream, hext_stream, dai); if (ret < 0) { dev_err(sdev->dev, "%s: failed to clean up link DMA\n", __func__); return ret; @@ -366,14 +352,12 @@ static int hda_dai_suspend(struct hdac_bus *bus) const struct hda_dai_widget_dma_ops *ops; struct snd_sof_widget *swidget; struct snd_soc_dapm_widget *w; - struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai; struct snd_sof_dev *sdev; struct snd_sof_dai *sdai; rtd = asoc_substream_to_rtd(hext_stream->link_substream); cpu_dai = asoc_rtd_to_cpu(rtd, 0); - codec_dai = asoc_rtd_to_codec(rtd, 0); w = snd_soc_dai_get_widget(cpu_dai, hdac_stream(hext_stream)->direction); swidget = w->dobj.private; sdev = widget_to_sdev(w); @@ -382,7 +366,7 @@ static int hda_dai_suspend(struct hdac_bus *bus) ret = hda_link_dma_cleanup(hext_stream->link_substream, hext_stream, - cpu_dai, codec_dai); + cpu_dai); if (ret < 0) return ret; diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 7a3d202f970e..8ca43303d97f 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -922,6 +922,8 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev, * @codec_dai_set_stream: Function pointer to set codec-side stream information * @calc_stream_format: Function pointer to determine stream format from hw_params and * for HDaudio codec DAI from the .sig bits + * @get_hlink: Mandatory function pointer to retrieve hlink, mainly to program LOSIDV + * for legacy HDaudio links or program HDaudio Extended Link registers. */ struct hda_dai_widget_dma_ops { struct hdac_ext_stream *(*get_hext_stream)(struct snd_sof_dev *sdev, @@ -947,6 +949,8 @@ struct hda_dai_widget_dma_ops { unsigned int (*calc_stream_format)(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); + struct hdac_ext_link * (*get_hlink)(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream); }; const struct hda_dai_widget_dma_ops * From patchwork Fri Jun 2 20:56:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 688237 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 3F7F4C77B7A for ; Fri, 2 Jun 2023 20:59:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2C15F84B; Fri, 2 Jun 2023 22:58:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2C15F84B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739569; bh=I/s0eU8o1u/lubpKORrmfzpHfeThvB9lDiwxcFrLQBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NJzoAFSRRc3ktCrWz6NyHFSAIv7HTDSdg0gPuFhhwDldmeqcrCsGAyzLWFkjYEVJV klqG2DDxli22U/tKyKMBVd8qHfg9xWMyILwKj+T+tJCMUbGSmIsSsQ1uR5TmswyDah 8bmrEhq7yUcl6Y23rihLM/hDtQz6kvfFW6QKNSmc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BDA92F805BD; Fri, 2 Jun 2023 22:56:58 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 2E12DF805B3; Fri, 2 Jun 2023 22:56:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0E490F800BD; Fri, 2 Jun 2023 22:56:42 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 3C267F800BD for ; Fri, 2 Jun 2023 22:56:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3C267F800BD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ZwyiI4I6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739401; x=1717275401; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I/s0eU8o1u/lubpKORrmfzpHfeThvB9lDiwxcFrLQBk=; b=ZwyiI4I63iAp9mOW3mJ0MsJ7rWKf1cYPf7RmykxxtmvRhEGp+q0Otw5V UKODRqJ4gsv1I874pVm1E9nSGmSm6N1+c/+Ti3EioQTEkelleyDSKBAQv sHczWxhnq6sNab3wOL67iCE41/MXz5KKtSh/t5ZHGIu0Nogg2+6nGbD8K ra7z4phyQhGelzclf8xxXd8MMdR0Vc+UG9h56pVIc4yb0l9Aq7+iyu78w H6NcQ4YHOLp1W+BoapitKC/GozidgsLWrJ11xGVTbgtqMiPXkXwNN3Wsx j8ynrHvfNXGZ2ETkTyX1N1Lvd524smmbvI3j3UsKv4sbj02BZm8yATZCp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272098" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272098" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092711" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092711" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:36 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , Ranjani Sridharan , Bard Liao , =?utf-8?q?P=C3=A9ter_Ujfalusi?= Subject: [PATCH 5/9] ASoC: SOF: ipc4-topology: extend ALH-specific data structure Date: Fri, 2 Jun 2023 15:56:16 -0500 Message-Id: <20230602205620.310879-6-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: E4UEXLWK6IHBMGLDEDLX6FL7ZK2S2VLQ X-Message-ID-Hash: E4UEXLWK6IHBMGLDEDLX6FL7ZK2S2VLQ X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: LunarLake introduces a new TLV blob passed to the firmware for DMA configuration. This TLV structure is directly inspired by the ALH multi-gateway structure used so far. This patch suggest a transition to the more abstract structure with no references to ALH. This is an iso-functionality redefinition of structure, the TLV will be added in a follow-up patch. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Bard Liao Reviewed-by: Péter Ujfalusi --- sound/soc/sof/ipc4-topology.c | 10 +++++----- sound/soc/sof/ipc4-topology.h | 34 +++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index db64e0cb8663..31a97a4248f4 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -559,7 +559,7 @@ static int sof_ipc4_widget_setup_comp_dai(struct snd_sof_widget *swidget) strcmp(w->widget->sname, swidget->widget->sname)) continue; - blob->alh_cfg.count++; + blob->alh_cfg.device_count++; } ipc4_copier->copier_config = (uint32_t *)blob; @@ -1225,7 +1225,7 @@ static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget) unsigned int group_id; blob = (struct sof_ipc4_alh_configuration_blob *)ipc4_copier->copier_config; - if (blob->alh_cfg.count > 1) { + if (blob->alh_cfg.device_count > 1) { group_id = SOF_IPC4_NODE_INDEX(ipc4_copier->data.gtw_cfg.node_id) - ALH_MULTI_GTW_BASE; ida_free(&alh_group_ida, group_id); @@ -1609,7 +1609,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, ch_map >>= 4; } - step = ch_count / blob->alh_cfg.count; + step = ch_count / blob->alh_cfg.device_count; mask = GENMASK(step - 1, 0); /* * Set each gtw_cfg.node_id to blob->alh_cfg.mapping[] @@ -1624,7 +1624,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, dai = w->private; alh_copier = (struct sof_ipc4_copier *)dai->private; alh_data = &alh_copier->data; - blob->alh_cfg.mapping[i].alh_id = alh_data->gtw_cfg.node_id; + blob->alh_cfg.mapping[i].device = alh_data->gtw_cfg.node_id; /* * Set the same channel mask for playback as the audio data is * duplicated for all speakers. For capture, split the channels @@ -1643,7 +1643,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, i++; } - if (blob->alh_cfg.count > 1) { + if (blob->alh_cfg.device_count > 1) { int group_id; group_id = ida_alloc_max(&alh_group_ida, ALH_MULTI_GTW_COUNT - 1, diff --git a/sound/soc/sof/ipc4-topology.h b/sound/soc/sof/ipc4-topology.h index cf007282867b..6b59434fbd60 100644 --- a/sound/soc/sof/ipc4-topology.h +++ b/sound/soc/sof/ipc4-topology.h @@ -55,7 +55,7 @@ #define SOF_IPC4_GAIN_ALL_CHANNELS_MASK 0xffffffff #define SOF_IPC4_VOL_ZERO_DB 0x7fffffff -#define ALH_MAX_NUMBER_OF_GTW 16 +#define SOF_IPC4_DMA_DEVICE_MAX_COUNT 16 #define SOF_IPC4_INVALID_NODE_ID 0xffffffff @@ -220,18 +220,26 @@ struct sof_ipc4_gtw_attributes { uint32_t rsvd : 30; }; -/** struct sof_ipc4_alh_multi_gtw_cfg: ALH gateway cfg data - * @count: Number of streams (valid items in mapping array) - * @alh_id: ALH stream id of a single ALH stream aggregated - * @channel_mask: Channel mask - * @mapping: ALH streams +/** + * struct sof_ipc4_dma_device_stream_ch_map: abstract representation of + * channel mapping to DMAs + * @device: representation of hardware device address or FIFO + * @channel_mask: channels handled by @device. Channels are expected to be + * contiguous */ -struct sof_ipc4_alh_multi_gtw_cfg { - uint32_t count; - struct { - uint32_t alh_id; - uint32_t channel_mask; - } mapping[ALH_MAX_NUMBER_OF_GTW]; +struct sof_ipc4_dma_device_stream_ch_map { + uint32_t device; + uint32_t channel_mask; +}; + +/** + * struct sof_ipc4_dma_stream_ch_map: DMA configuration data + * @device_count: Number valid items in mapping array + * @mapping: device address and channel mask + */ +struct sof_ipc4_dma_stream_ch_map { + uint32_t device_count; + struct sof_ipc4_dma_device_stream_ch_map mapping[SOF_IPC4_DMA_DEVICE_MAX_COUNT]; } __packed; /** struct sof_ipc4_alh_configuration_blob: ALH blob @@ -240,7 +248,7 @@ struct sof_ipc4_alh_multi_gtw_cfg { */ struct sof_ipc4_alh_configuration_blob { struct sof_ipc4_gtw_attributes gw_attr; - struct sof_ipc4_alh_multi_gtw_cfg alh_cfg; + struct sof_ipc4_dma_stream_ch_map alh_cfg; }; /** From patchwork Fri Jun 2 20:56:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 689300 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 055A7C7EE29 for ; Fri, 2 Jun 2023 20:59:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 07613827; Fri, 2 Jun 2023 22:58:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 07613827 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739584; bh=gS9F1eL0V1y42/VkrY8wmNE50BJpgQlMvZoq+CTpZg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rLfsBlyG8mZIsSHzWthSAw9200S8DBBdV65S2Ra0yY/7Uwwu3ET0GT9Fp2/7+Xo08 RG/68/VUuSTQyHkrdDMwAWmrG8udk9klSusOf/YKB/VGOYlGm6atM4pqh+nsSuc5pE VgbuqYYB/GEqjnuT2qRu4ddjLHys947IOqAHQZKE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id DC4D0F805C9; Fri, 2 Jun 2023 22:57:02 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 306D1F805C4; Fri, 2 Jun 2023 22:57:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6D5D2F80553; Fri, 2 Jun 2023 22:56:44 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 D0003F800C1 for ; Fri, 2 Jun 2023 22:56:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D0003F800C1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=FWWSn6vi DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739402; x=1717275402; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gS9F1eL0V1y42/VkrY8wmNE50BJpgQlMvZoq+CTpZg4=; b=FWWSn6vidn4hdF7cQjB1lUgZpOcRO6NuniwdCspgKt4A3p+RSlFr+vzw svbv+NiH4enWMmyz5rJsmJftN3GgkP3Zod44nWhFBhWTkQgxVmAUP4Lx5 R3i9oKsjFtrW8zzBi+/8YYsJSAYMdPLQIRLuj6DLBf1LWw68vHVw93E/d KHzCVJkUhUr37Im0kMLHt/G1wlrXWdqMQham4H7bF5JOv9oAyXrjOkcqd KWW/h/3CIvBTwpPWEZcjxbpzoU5JtrB2/weGcrqeU60jBU0PFtP6J6PAY WbFVv8gHEqGL9LFicx9cK2RgeXbkoqdT5X8kS/KsyUxayRFlKX22+NsNA w==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272104" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272104" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092714" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092714" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:36 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , Ranjani Sridharan , Bard Liao , =?utf-8?q?P=C3=A9ter_Ujfalusi?= Subject: [PATCH 6/9] ASoC: SOF: ipc4-topology: introduce DMA config TLV Date: Fri, 2 Jun 2023 15:56:17 -0500 Message-Id: <20230602205620.310879-7-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 7JOFQ75PKN37WTMJYLG7RFNY6EZ4OLKO X-Message-ID-Hash: 7JOFQ75PKN37WTMJYLG7RFNY6EZ4OLKO X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Starting with LunarLake, the DMIC/SSP/SoundWire audio interfaces will use the HDaudio DMA. This patch adds the DMA configuration structure to be passed as a TLV appended at the end of each gateway configuration. This patch only provides the definitions for now, the TLV will be added in the actual blobs separately for each interface. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Bard Liao Reviewed-by: Péter Ujfalusi --- sound/soc/sof/ipc4-topology.h | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/sound/soc/sof/ipc4-topology.h b/sound/soc/sof/ipc4-topology.h index 6b59434fbd60..f1d26b5c21d7 100644 --- a/sound/soc/sof/ipc4-topology.h +++ b/sound/soc/sof/ipc4-topology.h @@ -242,6 +242,44 @@ struct sof_ipc4_dma_stream_ch_map { struct sof_ipc4_dma_device_stream_ch_map mapping[SOF_IPC4_DMA_DEVICE_MAX_COUNT]; } __packed; +#define SOF_IPC4_DMA_METHOD_HDA 1 +#define SOF_IPC4_DMA_METHOD_GPDMA 2 /* defined for consistency but not used */ + +/** + * struct sof_ipc4_dma_config: DMA configuration + * @dma_method: HDAudio or GPDMA + * @pre_allocated_by_host: 1 if host driver allocates DMA channels, 0 otherwise + * @dma_channel_id: for HDaudio defined as @stream_id - 1 + * @stream_id: HDaudio stream tag + * @dma_stream_channel_map: array of device/channel mappings + * @dma_priv_config_size: currently not used + * @dma_priv_config: currently not used + */ +struct sof_ipc4_dma_config { + uint8_t dma_method; + uint8_t pre_allocated_by_host; + uint16_t rsvd; + uint32_t dma_channel_id; + uint32_t stream_id; + struct sof_ipc4_dma_stream_ch_map dma_stream_channel_map; + uint32_t dma_priv_config_size; + uint8_t dma_priv_config[]; +} __packed; + +#define SOF_IPC4_GTW_DMA_CONFIG_ID 0x1000 + +/** + * struct sof_ipc4_dma_config: DMA configuration + * @type: set to SOF_IPC4_GTW_DMA_CONFIG_ID + * @length: sizeof(struct sof_ipc4_dma_config) + dma_config.dma_priv_config_size + * @dma_config: actual DMA configuration + */ +struct sof_ipc4_dma_config_tlv { + uint32_t type; + uint32_t length; + struct sof_ipc4_dma_config dma_config; +} __packed; + /** struct sof_ipc4_alh_configuration_blob: ALH blob * @gw_attr: Gateway attributes * @alh_cfg: ALH configuration data From patchwork Fri Jun 2 20:56:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 688236 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 A509AC7EE2D for ; Fri, 2 Jun 2023 21:00:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A479A857; Fri, 2 Jun 2023 22:59:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A479A857 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739606; bh=6tZT80OD9LvKjj6jgTBddSA+hm1CL820C5/hu5HzKWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KllZS0zK0g32mipxs9fEYEUUBs7lf+sHeIa7013OpoexVONaLh1/dKvDnYYqtr/1R j3JfqkHJh0BH9TQMklz+4WL0XDDuzdsKc8pp+005Poe+5WwucaPnh2E0daPEQnVn6q DEhzStIPnw6Zy2OcVH/oGV6rMVg5pcjc96UfYpTU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 949BAF805D4; Fri, 2 Jun 2023 22:57:05 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id E6328F805D4; Fri, 2 Jun 2023 22:57:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8FC2FF80552; Fri, 2 Jun 2023 22:56:45 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 6436DF80132 for ; Fri, 2 Jun 2023 22:56:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6436DF80132 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=h8TkEGzf DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739402; x=1717275402; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6tZT80OD9LvKjj6jgTBddSA+hm1CL820C5/hu5HzKWQ=; b=h8TkEGzfboZyanjk/BZq2D+HvUgkH/vcx6Tc6ku3sCQ3tu2qKkPt0oHW LUEU+K0k1WVoBUw/DkeTVoNAzMyMcoCKbiqzcmotR0eQhhKfwiirqoYXa dNFMkyk/zJbMICVQ5/ur5wVeKLSc8ZR+MIVjiSfwKt9xLpp2MDzNVyuk1 HZqFuHgAp/EVbfR8TazXY1e2jrj5kBwFZ3t5VrCbOBjEinJcEwN6brXxV BEIaBpd4I1UDZFVeUqKHqHnBV5adlSQ5XlHLxlfiZ/oQVYVMR6PYmljB6 6LIOcPqA2B7m8pLoOAt432OYnCyoDzvIGZzjuXy+lCkIABs/4tZq+qzLN g==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272108" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272108" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092719" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092719" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:37 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , Ranjani Sridharan , Bard Liao , =?utf-8?q?P=C3=A9ter_Ujfalusi?= Subject: [PATCH 7/9] ASoC: SOF: ipc4-topology: add DMA config TLV to IPC data Date: Fri, 2 Jun 2023 15:56:18 -0500 Message-Id: <20230602205620.310879-8-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: LL4H7YYT4W2O5G6N2RCBUVMFDFNHILLK X-Message-ID-Hash: LL4H7YYT4W2O5G6N2RCBUVMFDFNHILLK X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This patch adds a DMA config TLV structure and the relevant code to copy this TLV after the gateway configuration. For now this is an iso-functionality change, the TLVs are not configured just yet. Additional patches will be needed for DMIC/SSP/ALH (aka SoundWire). Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Bard Liao Reviewed-by: Péter Ujfalusi --- sound/soc/sof/ipc4-topology.c | 34 +++++++++++++++++++++++++++++++--- sound/soc/sof/ipc4-topology.h | 2 ++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index 31a97a4248f4..a4e1a70b607d 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -1383,6 +1383,8 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, struct snd_sof_dai *dai; struct snd_mask *fmt; int out_sample_valid_bits; + u32 gtw_cfg_config_length; + u32 dma_config_tlv_size = 0; void **ipc_config_data; int *ipc_config_size; u32 **data; @@ -1699,7 +1701,27 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, ipc_config_data = &ipc4_copier->ipc_config_data; /* config_length is DWORD based */ - ipc_size = sizeof(*copier_data) + copier_data->gtw_cfg.config_length * 4; + gtw_cfg_config_length = copier_data->gtw_cfg.config_length * 4; + ipc_size = sizeof(*copier_data) + gtw_cfg_config_length; + + if (ipc4_copier->dma_config_tlv.type == SOF_IPC4_GTW_DMA_CONFIG_ID && + ipc4_copier->dma_config_tlv.length) { + dma_config_tlv_size = sizeof(ipc4_copier->dma_config_tlv) + + ipc4_copier->dma_config_tlv.dma_config.dma_priv_config_size; + + /* paranoia check on TLV size/length */ + if (dma_config_tlv_size != ipc4_copier->dma_config_tlv.length + + sizeof(uint32_t) * 2) { + dev_err(sdev->dev, "Invalid configuration, TLV size %d length %d\n", + dma_config_tlv_size, ipc4_copier->dma_config_tlv.length); + return -EINVAL; + } + + ipc_size += dma_config_tlv_size; + + /* we also need to increase the size at the gtw level */ + copier_data->gtw_cfg.config_length += dma_config_tlv_size / 4; + } dev_dbg(sdev->dev, "copier %s, IPC size is %d", swidget->widget->name, ipc_size); @@ -1711,9 +1733,15 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, /* copy IPC data */ memcpy(*ipc_config_data, (void *)copier_data, sizeof(*copier_data)); - if (copier_data->gtw_cfg.config_length) + if (gtw_cfg_config_length) memcpy(*ipc_config_data + sizeof(*copier_data), - *data, copier_data->gtw_cfg.config_length * 4); + *data, gtw_cfg_config_length); + + /* add DMA Config TLV, if configured */ + if (dma_config_tlv_size) + memcpy(*ipc_config_data + sizeof(*copier_data) + + gtw_cfg_config_length, + &ipc4_copier->dma_config_tlv, dma_config_tlv_size); /* update pipeline memory usage */ sof_ipc4_update_resource_usage(sdev, swidget, &copier_data->base_config); diff --git a/sound/soc/sof/ipc4-topology.h b/sound/soc/sof/ipc4-topology.h index f1d26b5c21d7..6dcf14886e85 100644 --- a/sound/soc/sof/ipc4-topology.h +++ b/sound/soc/sof/ipc4-topology.h @@ -300,6 +300,7 @@ struct sof_ipc4_alh_configuration_blob { * @gtw_attr: Gateway attributes for copier blob * @dai_type: DAI type * @dai_index: DAI index + * @dma_config_tlv: DMA configuration */ struct sof_ipc4_copier { struct sof_ipc4_copier_data data; @@ -312,6 +313,7 @@ struct sof_ipc4_copier { struct sof_ipc4_gtw_attributes *gtw_attr; u32 dai_type; int dai_index; + struct sof_ipc4_dma_config_tlv dma_config_tlv; }; /** From patchwork Fri Jun 2 20:56:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 689299 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 DE886C7EE29 for ; Fri, 2 Jun 2023 21:00:19 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1B80584C; Fri, 2 Jun 2023 22:59:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1B80584C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739618; bh=HdKSnxgl3SAviTOBDDBA2JdFtJuxgH4j9Iq0co0z0ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eEezj0Vj5SrsLgYU8wqSXNUtIqNdadle3x+4i2En9qniB6DL5on7J0i06B+I6Plf4 fBCUlJ8yILYO/9oHsSI9R2pLLQVRSQDSfCzSpGWPBov8h7skaR42JikKKF9kUgXc0W 0jDwRLXSMGEgbYqVPgk91wjGL45cMufIfBnWAft4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C34AFF805D9; Fri, 2 Jun 2023 22:57:07 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 24EEBF805D9; Fri, 2 Jun 2023 22:57:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 967A3F80558; Fri, 2 Jun 2023 22:56:46 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 3C49CF800BD for ; Fri, 2 Jun 2023 22:56:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3C49CF800BD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=eX9GTNdX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739403; x=1717275403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HdKSnxgl3SAviTOBDDBA2JdFtJuxgH4j9Iq0co0z0ho=; b=eX9GTNdXTIoSHChXrmOedQG3o2Un/4ub+CG0Ta28xMJE+JwC6r5pQPmU Fm/6Uj1jpP6du4KHpvvGVrvE2e/1XVl0g3iNP1EQA4d5qNc2/wYk9oA9V /QzUxSX1Dc+tRltdUycNLJClV2tRgOCptOR2wsnBk1tnp8iEj6/hvu1kr /c65KESInD2ttnHfSxaqGCVr0oO3g4pKULuJN4BMDEpAJkrcniCjYYZwp oEkQWnmndavneZpZKfsZjG70P96ktav3p/KfEpY1UF0Cg8lAQ1PcfwFUE rmoM4j2c1OUU1+bvI74v4IwVfx9KbB3eMzzNC7DS3Qq/X/zINYd9HXamo w==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272115" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272115" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092723" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092723" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:38 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , =?utf-8?q?P?= =?utf-8?q?=C3=A9ter_Ujfalusi?= , Bard Liao Subject: [PATCH 8/9] ASoC: SOF: Intel: mtl: prepare for code reuse Date: Fri, 2 Jun 2023 15:56:19 -0500 Message-Id: <20230602205620.310879-9-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: GMRZOVEFNBV2ZDJCVENG6RFGFHIGOCKX X-Message-ID-Hash: GMRZOVEFNBV2ZDJCVENG6RFGFHIGOCKX X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Some functions can be used for newer LNL hardware. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi Reviewed-by: Bard Liao --- sound/soc/sof/intel/mtl.c | 12 ++++++------ sound/soc/sof/intel/mtl.h | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sound/soc/sof/intel/mtl.c b/sound/soc/sof/intel/mtl.c index 93dc2c9d8448..8ae331faca4e 100644 --- a/sound/soc/sof/intel/mtl.c +++ b/sound/soc/sof/intel/mtl.c @@ -55,7 +55,7 @@ static void mtl_ipc_dsp_done(struct snd_sof_dev *sdev) } /* Check if an IPC IRQ occurred */ -static bool mtl_dsp_check_ipc_irq(struct snd_sof_dev *sdev) +bool mtl_dsp_check_ipc_irq(struct snd_sof_dev *sdev) { u32 irq_status; u32 hfintipptr; @@ -118,7 +118,7 @@ static int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *ms return 0; } -static void mtl_enable_ipc_interrupts(struct snd_sof_dev *sdev) +void mtl_enable_ipc_interrupts(struct snd_sof_dev *sdev) { struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; const struct sof_intel_dsp_desc *chip = hda->desc; @@ -132,7 +132,7 @@ static void mtl_enable_ipc_interrupts(struct snd_sof_dev *sdev) MTL_DSP_REG_HFIPCXCTL_BUSY | MTL_DSP_REG_HFIPCXCTL_DONE); } -static void mtl_disable_ipc_interrupts(struct snd_sof_dev *sdev) +void mtl_disable_ipc_interrupts(struct snd_sof_dev *sdev) { struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; const struct sof_intel_dsp_desc *chip = hda->desc; @@ -173,7 +173,7 @@ static void mtl_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable) enable ? "enable" : "disable"); } -static int mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable) +int mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable) { u32 hfintipptr; u32 irqinten; @@ -394,7 +394,7 @@ static int mtl_dsp_core_power_down(struct snd_sof_dev *sdev, int core) return ret; } -static int mtl_power_down_dsp(struct snd_sof_dev *sdev) +int mtl_power_down_dsp(struct snd_sof_dev *sdev) { u32 dsphfdsscs, cpa; int ret; @@ -421,7 +421,7 @@ static int mtl_power_down_dsp(struct snd_sof_dev *sdev) HDA_DSP_RESET_TIMEOUT_US); } -static int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot) +int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot) { struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; const struct sof_intel_dsp_desc *chip = hda->desc; diff --git a/sound/soc/sof/intel/mtl.h b/sound/soc/sof/intel/mtl.h index 26418fb08807..2794fe6e8139 100644 --- a/sound/soc/sof/intel/mtl.h +++ b/sound/soc/sof/intel/mtl.h @@ -82,3 +82,10 @@ #define MTL_DSP_REG_HfIMRIS1 0x162088 #define MTL_DSP_REG_HfIMRIS1_IU_MASK BIT(0) +void mtl_enable_ipc_interrupts(struct snd_sof_dev *sdev); +void mtl_disable_ipc_interrupts(struct snd_sof_dev *sdev); +bool mtl_dsp_check_ipc_irq(struct snd_sof_dev *sdev); + +int mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable); +int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot); +int mtl_power_down_dsp(struct snd_sof_dev *sdev); From patchwork Fri Jun 2 20:56:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 688235 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 9E495C7EE29 for ; Fri, 2 Jun 2023 21:00:36 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BDB07A4A; Fri, 2 Jun 2023 22:59:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BDB07A4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685739634; bh=Tkkq7ODMJDQwyRFINWRZ18sHvVC9DAhFsR52IuKp6mU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=GWtWuUJpUDa9R30kCltNTsBAgSCmrM1pilgagzURNExi+O+Fwi0SJd54WnXiUq4TR OBxO504HwqPuWIOkKxUPweofJazwneR6AL5fjSq89BHTgWNyTUeloyxCeBgF8qlCqH ReaqsHGaYnW9NIgUGnqRwP6uZnOZpeaTTgTKBd8U= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 92EA4F805F0; Fri, 2 Jun 2023 22:57:10 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 1E45CF805EF; Fri, 2 Jun 2023 22:57:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0D53CF80563; Fri, 2 Jun 2023 22:56:47 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 BBF65F80527 for ; Fri, 2 Jun 2023 22:56:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BBF65F80527 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=eVT3vHcl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685739403; x=1717275403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Tkkq7ODMJDQwyRFINWRZ18sHvVC9DAhFsR52IuKp6mU=; b=eVT3vHclhabsiE+JOnVQwqaSM9+ygkxOEwPgN+eJx57yFy6M1IhOuyqY X/A/dgW5mKIiI8BasebVrspFTf6/rTxrjQH7bo50VrXmYCgmClC0h0iR9 bgow9RWFYOlvJXmrAa0t+qD6z220YdmXR+iogXyiROg3g0gCx9grajzPL 6GP8O3TZGL/LWyl09EfPSsirOu7NPQykv2v1Br5g/VXP7rPwG9YIiduaz yxEdZtzyvudVHUVL1qiItFvPOYjfk07KPHrXEOAWNFtTnpo8TUMJTrVwo sBQjjoyNakqTsXYoHkqcsnA/alUUHbVQ3+NZT5ZQ2y15T7UHZORWQMAMp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="359272122" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="359272122" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="832092728" X-IronPort-AV: E=Sophos;i="6.00,214,1681196400"; d="scan'208";a="832092728" Received: from sbalabha-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.190.110]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 13:56:38 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com, Pierre-Louis Bossart , =?utf-8?q?P?= =?utf-8?q?=C3=A9ter_Ujfalusi?= , Bard Liao Subject: [PATCH 9/9] ASoC: SOF: Intel: hda: add helper to extract SoundWire link count Date: Fri, 2 Jun 2023 15:56:20 -0500 Message-Id: <20230602205620.310879-10-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> References: <20230602205620.310879-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 37M3BXDRHDGYVVENGPCPNLFP3VV3WUAC X-Message-ID-Hash: 37M3BXDRHDGYVVENGPCPNLFP3VV3WUAC X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The register changed with the HDaudio integration, the information is present in the extended link descriptor and not in the SHIM. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi Reviewed-by: Bard Liao --- sound/soc/sof/intel/hda.c | 25 +++++++++++++++++++++++++ sound/soc/sof/intel/hda.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 94aa35f96f52..64bebe1a72bb 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -245,6 +245,31 @@ int hda_sdw_check_lcount_common(struct snd_sof_dev *sdev) return 0; } +int hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev) +{ + struct sof_intel_hda_dev *hdev; + struct sdw_intel_ctx *ctx; + struct hdac_bus *bus; + u32 slcount; + + bus = sof_to_bus(sdev); + + hdev = sdev->pdata->hw_pdata; + ctx = hdev->sdw; + + slcount = hdac_bus_eml_get_count(bus, true, AZX_REG_ML_LEPTR_ID_SDW); + + /* Check HW supported vs property value */ + if (slcount < ctx->count) { + dev_err(sdev->dev, + "%s: BIOS master count %d is larger than hardware capabilities %d\n", + __func__, ctx->count, slcount); + return -EINVAL; + } + + return 0; +} + static int hda_sdw_check_lcount(struct snd_sof_dev *sdev) { const struct sof_intel_dsp_desc *chip; diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 8ca43303d97f..3f7c6fb05e5d 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -781,6 +781,7 @@ int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd); #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) int hda_sdw_check_lcount_common(struct snd_sof_dev *sdev); +int hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev); int hda_sdw_startup(struct snd_sof_dev *sdev); void hda_common_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable); void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable); @@ -794,6 +795,11 @@ static inline int hda_sdw_check_lcount_common(struct snd_sof_dev *sdev) return 0; } +static inline int hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev) +{ + return 0; +} + static inline int hda_sdw_startup(struct snd_sof_dev *sdev) { return 0;