From patchwork Fri Sep 15 07:56:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723987 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 1F0ACEE6433 for ; Fri, 15 Sep 2023 07:51:00 +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 5BA83A4A; Fri, 15 Sep 2023 09:50:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5BA83A4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694764257; bh=DdmxDVNxkNkomWAzWGolHZ8v9RgscSRPaL+6KFrWRNM=; 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=nYF1GXdKDkbva0XbCQfnLNUHhT2xWwKLiBnR+jYl+sF+jfhQHgZ7BnNhDilnDj7lh ccsC9++x9Pmcy/X/HBDjdWwNccw/ixJ3N/lc/33gUvzMFTlbDbL7JWFRrAL94XlUyP wfb3Ut4nz9njWI7Lw09y1FXzv8THsf/btJbMkHBw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 29162F80537; Fri, 15 Sep 2023 09:49:19 +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 8CA57F80564; Fri, 15 Sep 2023 09:49:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4E363F80537; Fri, 15 Sep 2023 09:49:14 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) (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 54149F801F5 for ; Fri, 15 Sep 2023 09:49:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 54149F801F5 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=dyBTMR1H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694764144; x=1726300144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DdmxDVNxkNkomWAzWGolHZ8v9RgscSRPaL+6KFrWRNM=; b=dyBTMR1HdEQAmSaDIJ45R+Dky0XcWyW5YrjwrYko34f02yc5swpjZdS5 eolKvFo6L0NCxucFEPQVY9lXPrMhDyvEVakK0hpuRXiElTPqxxTBC9eLv QA8lqeEmE/VDoIA7B8PoFODDo+pAd9QL5fLfGxJzUGiaf+70mFMkWGIKv ZZg+/mbdcshvCl5L6JMrkT7P6URfATE7Vy7WoM04wfrpMtgshXcxS/Clp inQKeSoilUVpsBrO5QDtgDPLxCzeeN06dJiY9QiJE7xw8VElT04heAKO6 8ITbcO7nSbsQiwZke4MgPsgeQ/1jitAuNs4LpKwHNSYSSl4iin2iXpojT A==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="376527531" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="376527531" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:48:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="779998371" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="779998371" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:47:35 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, ckeepax@opensource.cirrus.com Subject: [PATCH 1/4] ASoC: intel: sof_sdw: Move sdw_pin_index into private struct Date: Fri, 15 Sep 2023 15:56:08 +0800 Message-Id: <20230915075611.1619548-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915075611.1619548-1-yung-chuan.liao@linux.intel.com> References: <20230915075611.1619548-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: NONVSW2J3GW5LZTYMTSK2I4SA7MQYQFD X-Message-ID-Hash: NONVSW2J3GW5LZTYMTSK2I4SA7MQYQFD X-MailFrom: yung-chuan.liao@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: From: Charles Keepax Whilst it should not cause any issues as only a single instance of the machine will be instantiated, it is still slightly better practice to keep working data in the private data structure, rather than a global variable. Move sdw_pin_index into the mc_private structure. Signed-off-by: Charles Keepax Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_sdw.c | 10 +++------- sound/soc/intel/boards/sof_sdw_common.h | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 961241100012..eaecdb75686c 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -22,11 +22,6 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override"); #define INC_ID(BE, CPU, LINK) do { (BE)++; (CPU)++; (LINK)++; } while (0) -#define SDW_MAX_LINKS 4 - -/* To store SDW Pin index for each SoundWire link */ -static unsigned int sdw_pin_index[SDW_MAX_LINKS]; - static void log_quirks(struct device *dev) { if (SOF_JACK_JDSRC(sof_sdw_quirk)) @@ -1331,6 +1326,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, int adr_index, int dai_index) { + struct mc_private *ctx = snd_soc_card_get_drvdata(card); struct device *dev = card->dev; const struct snd_soc_acpi_link_adr *adr_link_next; struct snd_soc_dai_link_component *codecs; @@ -1452,7 +1448,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, for (k = 0; k < cpu_dai_num; k++) { cpu_name = devm_kasprintf(dev, GFP_KERNEL, "SDW%d Pin%d", cpu_dai_id[k], - sdw_pin_index[cpu_dai_id[k]]++); + ctx->sdw_pin_index[cpu_dai_id[k]]++); if (!cpu_name) return -ENOMEM; @@ -1600,7 +1596,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) goto SSP; for (i = 0; i < SDW_MAX_LINKS; i++) - sdw_pin_index[i] = SDW_INTEL_BIDIR_PDI_BASE; + ctx->sdw_pin_index[i] = SDW_INTEL_BIDIR_PDI_BASE; for (; adr_link->num_adr; adr_link++) { /* diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h index 2f4fe6bc3d5d..270aded488e1 100644 --- a/sound/soc/intel/boards/sof_sdw_common.h +++ b/sound/soc/intel/boards/sof_sdw_common.h @@ -24,6 +24,8 @@ #define SDW_MAX_CPU_DAIS 16 #define SDW_INTEL_BIDIR_PDI_BASE 2 +#define SDW_MAX_LINKS 4 + /* 8 combinations with 4 links + unused group 0 */ #define SDW_MAX_GROUPS 9 @@ -97,6 +99,8 @@ struct mc_private { struct snd_soc_jack sdw_headset; struct device *headset_codec_dev; /* only one headset per card */ struct device *amp_dev1, *amp_dev2; + /* To store SDW Pin index for each SoundWire link */ + unsigned int sdw_pin_index[SDW_MAX_LINKS]; }; extern unsigned long sof_sdw_quirk; From patchwork Fri Sep 15 07:56:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723193 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 18CEAEE6432 for ; Fri, 15 Sep 2023 07:51: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 C74BD1F2; Fri, 15 Sep 2023 09:50:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C74BD1F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694764275; bh=uV1GM+V7j7ZFNoKi6K2H9pk3ITdQ9VRdpUb8f1F/X8A=; 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=sgUTU5skjJAknLn5N6JhWoYmwLW1LuLfqtrM7MShlzIsZPJ/TeBnbJo3qwMrhW0Hq 6jborJAINA9lzrmnIyrMNnZDFogNbNqkdCXHszAeUMmSkJMpaP90LKkR1llwExTegS drrBeRK5W81WNY0sJn/GvotfNeBNMLorMFpt5Qvg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7D83DF8055C; Fri, 15 Sep 2023 09:49:25 +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 EC897F80579; Fri, 15 Sep 2023 09:49:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B9F83F80579; Fri, 15 Sep 2023 09:49:20 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) (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 31AEDF80425 for ; Fri, 15 Sep 2023 09:49:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 31AEDF80425 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=iOxhxgbc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694764145; x=1726300145; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uV1GM+V7j7ZFNoKi6K2H9pk3ITdQ9VRdpUb8f1F/X8A=; b=iOxhxgbcCiB5luTkdFux+NxBz+YdfBw4380Jb+lZa/S64aCKdMECYBKo mDuOz4ml/zZfm3IZ7pfW55sKKEc3sGuZEQpjAdA7v7i8d8vYAyr7IpBn9 H8dVwChhAtNHJDIKuPD8hThZd1wrT85FA2dLu0eDtl0o1vo7SjbyvulDR OiCldH6iDKwtjlD+Rv+T2hDmZDOLg9Hog0zLPDwCriAB9TMAJHdOiynnd /9BFi27HyXlTtWe59hwE826EcjGf9cGj/pT5zN0nOZjPQgIg5PzE0ocRw Dp2tbiVCHNdwjeAt5M6KXOY6ZQUm80i/+VqMDS/UcHaz6aSWu1ISV05Gr w==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="376527539" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="376527539" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:48:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="779998419" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="779998419" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:47:38 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, ckeepax@opensource.cirrus.com Subject: [PATCH 2/4] ASoC: intel: sof_sdw: Add simple DAI link creation helper Date: Fri, 15 Sep 2023 15:56:09 +0800 Message-Id: <20230915075611.1619548-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915075611.1619548-1-yung-chuan.liao@linux.intel.com> References: <20230915075611.1619548-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: HZXX4PBLBVZZBFI4Z4ZSWKED63QDEQKM X-Message-ID-Hash: HZXX4PBLBVZZBFI4Z4ZSWKED63QDEQKM X-MailFrom: yung-chuan.liao@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: From: Charles Keepax The code contains a fair amount of state tracking and one part of that is keeping track of which entry in the large global cpus snd_soc_dai_link_component array is currently in use. Add a helper function to allocate a simple DAI link, this simplifies the code slightly and moves us in the direction of eliminating the need for the large global cpus array. This does slightly increase the number of allocations done, but this is probe time and the code already does a large number of allocations so this increase is small over all. Signed-off-by: Charles Keepax Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_sdw.c | 161 ++++++++++++++----------------- 1 file changed, 72 insertions(+), 89 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index eaecdb75686c..f64bf8b2377c 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -488,13 +488,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { {} }; -static struct snd_soc_dai_link_component dmic_component[] = { - { - .name = "dmic-codec", - .dai_name = "dmic-hifi", - } -}; - static struct snd_soc_dai_link_component platform_component[] = { { /* name might be overridden during probe */ @@ -1121,6 +1114,31 @@ static void init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links dai_links->ops = ops; } +static int init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links, + int be_id, char *name, int playback, int capture, + const char *cpu_dai_name, + const char *codec_name, const char *codec_dai_name, + int (*init)(struct snd_soc_pcm_runtime *rtd), + const struct snd_soc_ops *ops) +{ + struct snd_soc_dai_link_component *dlc; + + /* Allocate two DLCs one for the CPU, one for the CODEC */ + dlc = devm_kcalloc(dev, 2, sizeof(*dlc), GFP_KERNEL); + if (!dlc || !name || !cpu_dai_name || !codec_name || !codec_dai_name) + return -ENOMEM; + + dlc[0].dai_name = cpu_dai_name; + + dlc[1].name = codec_name; + dlc[1].dai_name = codec_dai_name; + + init_dai_link(dev, dai_links, be_id, name, playback, capture, + &dlc[0], 1, &dlc[1], 1, init, ops); + + return 0; +} + static bool is_unique_device(const struct snd_soc_acpi_link_adr *adr_link, unsigned int sdw_version, unsigned int mfg_id, @@ -1512,8 +1530,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) struct snd_soc_acpi_mach *mach = dev_get_platdata(card->dev); int sdw_be_num = 0, ssp_num = 0, dmic_num = 0, hdmi_num = 0, bt_num = 0; struct mc_private *ctx = snd_soc_card_get_drvdata(card); - struct snd_soc_dai_link_component *idisp_components; - struct snd_soc_dai_link_component *ssp_components; struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; const struct snd_soc_acpi_link_adr *adr_link = mach_params->links; bool aggregation = !(sof_sdw_quirk & SOF_SDW_NO_AGGREGATION); @@ -1527,7 +1543,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) int ssp_codec_index, ssp_mask; struct snd_soc_dai_link *dai_links; int num_links, link_index = 0; - char *name, *cpu_name; + char *name, *cpu_dai_name; + char *codec_name, *codec_dai_name; int total_cpu_dai_num; int sdw_cpu_dai_num; int i, j, be_id = 0; @@ -1670,43 +1687,26 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) for (i = 0, j = 0; ssp_mask; i++, ssp_mask >>= 1) { struct sof_sdw_codec_info *info; int playback, capture; - char *codec_name; if (!(ssp_mask & 0x1)) continue; - name = devm_kasprintf(dev, GFP_KERNEL, - "SSP%d-Codec", i); - if (!name) - return -ENOMEM; - - cpu_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", i); - if (!cpu_name) - return -ENOMEM; - - ssp_components = devm_kzalloc(dev, sizeof(*ssp_components), - GFP_KERNEL); - if (!ssp_components) - return -ENOMEM; - info = &codec_info_list[ssp_codec_index]; + + name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", i); + cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", i); codec_name = devm_kasprintf(dev, GFP_KERNEL, "i2c-%s:0%d", info->acpi_id, j++); - if (!codec_name) - return -ENOMEM; - - ssp_components->name = codec_name; - /* TODO: support multi codec dai on SSP when it is needed */ - ssp_components->dai_name = info->dais[0].dai_name; - cpus[cpu_id].dai_name = cpu_name; playback = info->dais[0].direction[SNDRV_PCM_STREAM_PLAYBACK]; capture = info->dais[0].direction[SNDRV_PCM_STREAM_CAPTURE]; - init_dai_link(dev, dai_links + link_index, be_id, name, - playback, capture, - cpus + cpu_id, 1, - ssp_components, 1, - NULL, info->ops); + + ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name, + playback, capture, cpu_dai_name, + codec_name, info->dais[0].dai_name, + NULL, info->ops); + if (ret) + return ret; ret = info->dais[0].init(card, NULL, dai_links + link_index, info, 0); if (ret < 0) @@ -1722,63 +1722,49 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) dev_warn(dev, "Ignoring PCH DMIC\n"); goto HDMI; } - cpus[cpu_id].dai_name = "DMIC01 Pin"; - init_dai_link(dev, dai_links + link_index, be_id, "dmic01", - 0, 1, // DMIC only supports capture - cpus + cpu_id, 1, - dmic_component, 1, - sof_sdw_dmic_init, NULL); + + ret = init_simple_dai_link(dev, dai_links + link_index, be_id, "dmic01", + 0, 1, // DMIC only supports capture + "DMIC01 Pin", "dmic-codec", "dmic-hifi", + sof_sdw_dmic_init, NULL); + if (ret) + return ret; + INC_ID(be_id, cpu_id, link_index); - cpus[cpu_id].dai_name = "DMIC16k Pin"; - init_dai_link(dev, dai_links + link_index, be_id, "dmic16k", - 0, 1, // DMIC only supports capture - cpus + cpu_id, 1, - dmic_component, 1, - /* don't call sof_sdw_dmic_init() twice */ - NULL, NULL); + ret = init_simple_dai_link(dev, dai_links + link_index, be_id, "dmic16k", + 0, 1, // DMIC only supports capture + "DMIC16k Pin", "dmic-codec", "dmic-hifi", + /* don't call sof_sdw_dmic_init() twice */ + NULL, NULL); + if (ret) + return ret; + INC_ID(be_id, cpu_id, link_index); } HDMI: /* HDMI */ - if (hdmi_num > 0) { - idisp_components = devm_kcalloc(dev, hdmi_num, - sizeof(*idisp_components), - GFP_KERNEL); - if (!idisp_components) - return -ENOMEM; - } - for (i = 0; i < hdmi_num; i++) { - name = devm_kasprintf(dev, GFP_KERNEL, - "iDisp%d", i + 1); - if (!name) - return -ENOMEM; + name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", i + 1); + cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d Pin", i + 1); if (ctx->idisp_codec) { - idisp_components[i].name = "ehdaudio0D2"; - idisp_components[i].dai_name = devm_kasprintf(dev, - GFP_KERNEL, - "intel-hdmi-hifi%d", - i + 1); - if (!idisp_components[i].dai_name) - return -ENOMEM; + codec_name = "ehdaudio0D2"; + codec_dai_name = devm_kasprintf(dev, GFP_KERNEL, + "intel-hdmi-hifi%d", i + 1); } else { - idisp_components[i] = asoc_dummy_dlc; + codec_name = "snd-soc-dummy"; + codec_dai_name = "snd-soc-dummy-dai"; } - cpu_name = devm_kasprintf(dev, GFP_KERNEL, - "iDisp%d Pin", i + 1); - if (!cpu_name) - return -ENOMEM; + ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name, + 1, 0, // HDMI only supports playback + cpu_dai_name, codec_name, codec_dai_name, + sof_sdw_hdmi_init, NULL); + if (ret) + return ret; - cpus[cpu_id].dai_name = cpu_name; - init_dai_link(dev, dai_links + link_index, be_id, name, - 1, 0, // HDMI only supports playback - cpus + cpu_id, 1, - idisp_components + i, 1, - sof_sdw_hdmi_init, NULL); INC_ID(be_id, cpu_id, link_index); } @@ -1787,16 +1773,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) SOF_BT_OFFLOAD_SSP_SHIFT; name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port); - if (!name) - return -ENOMEM; + cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port); - cpu_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port); - if (!cpu_name) - return -ENOMEM; - - cpus[cpu_id].dai_name = cpu_name; - init_dai_link(dev, dai_links + link_index, be_id, name, 1, 1, - cpus + cpu_id, 1, &asoc_dummy_dlc, 1, NULL, NULL); + ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name, + 1, 1, cpu_dai_name, asoc_dummy_dlc.name, + asoc_dummy_dlc.dai_name, NULL, NULL); + if (ret) + return ret; } card->dai_link = dai_links; From patchwork Fri Sep 15 07:56:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723192 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 55837EE6432 for ; Fri, 15 Sep 2023 07:51:50 +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 38CF2DEB; Fri, 15 Sep 2023 09:50:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 38CF2DEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694764308; bh=mw20YhJyAHc6SThIK0dBc6/8Yv71y25ywM0qfzjCdqo=; 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=RM2QvwvYymrV3LXkLPWwkJiQrTUte3ZWiFekDxujbiTsRr82aj0Mlu+FJk07YHXBV ClUdJSXVv++WtARqaK5X+cCIBGAXwZ5+DHMyAPMqRIiUpkSonYndiUPWexvI+qaYwN utMheK6kMVnyI4LAAB6aXSEWRWsj/nS5IPCwfjgI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 584B8F805B6; Fri, 15 Sep 2023 09:49:42 +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 DE5F7F805AE; Fri, 15 Sep 2023 09:49:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 93D82F805AE; Fri, 15 Sep 2023 09:49:38 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) (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 0B2FFF80431 for ; Fri, 15 Sep 2023 09:49:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0B2FFF80431 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=kuL40a44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694764147; x=1726300147; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mw20YhJyAHc6SThIK0dBc6/8Yv71y25ywM0qfzjCdqo=; b=kuL40a44BepalTUZfF3QPQlPOLlTWcI2l7CvRGxK9jfbnkpBDiIYY31F SzGVWCNk4fiLCK6CDdU0UcuoStEoJy2ItsEgKYg28nCalbXkgFUgsr9su mmqkJ5apKfvoQsuhEOqTppKAjugWasjCBiJyIS1RXZDnsEU575uz4I7+I J/z2JnuPtyvx2XmnH4kzhSKokUMbn14pU5HvjpkZhWzbhqcek9XO6hZVo 24Exs92wfQArriNKeTGN5r8jDkeRBop0ecNCC548Zu1BJhq9/4ZL8SGG6 dnAgHrFatXIbug02ITzBWfDassqkJBML95zjpCvlZnDAX4dv28sgyrukN Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="376527551" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="376527551" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:48:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="779998539" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="779998539" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:47:40 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, ckeepax@opensource.cirrus.com Subject: [PATCH 3/4] ASoC: intel: sof_sdw: Make create_sdw_dailink allocate link components Date: Fri, 15 Sep 2023 15:56:10 +0800 Message-Id: <20230915075611.1619548-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915075611.1619548-1-yung-chuan.liao@linux.intel.com> References: <20230915075611.1619548-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: F7F5R3NORYKIAFABK7IVO366WC7IC3HX X-Message-ID-Hash: F7F5R3NORYKIAFABK7IVO366WC7IC3HX X-MailFrom: yung-chuan.liao@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: From: Charles Keepax Now only the SoundWire part of the code uses the global cpus array, remove it and have create_sdw_dailink allocate its own link components. This removes a lot of state being passed around in the driver, which simplifies things a fair bit. Signed-off-by: Charles Keepax Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_sdw.c | 65 ++++++++++---------------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index f64bf8b2377c..335048dfae53 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -20,7 +20,7 @@ static int quirk_override = -1; module_param_named(quirk, quirk_override, int, 0444); MODULE_PARM_DESC(quirk, "Board-specific quirk override"); -#define INC_ID(BE, CPU, LINK) do { (BE)++; (CPU)++; (LINK)++; } while (0) +#define INC_ID(BE, LINK) do { (BE)++; (LINK)++; } while (0) static void log_quirks(struct device *dev) { @@ -1017,7 +1017,7 @@ static inline int find_codec_info_acpi(const u8 *acpi_id) */ static int get_dailink_info(struct device *dev, const struct snd_soc_acpi_link_adr *adr_link, - int *sdw_be_num, int *sdw_cpu_dai_num, int *codecs_num) + int *sdw_be_num, int *codecs_num) { bool group_visited[SDW_MAX_GROUPS]; bool no_aggregation; @@ -1025,7 +1025,6 @@ static int get_dailink_info(struct device *dev, int j; no_aggregation = sof_sdw_quirk & SOF_SDW_NO_AGGREGATION; - *sdw_cpu_dai_num = 0; *sdw_be_num = 0; if (!adr_link) @@ -1074,8 +1073,6 @@ static int get_dailink_info(struct device *dev, if (!codec_info->dais[j].direction[stream]) continue; - (*sdw_cpu_dai_num)++; - /* count BE for each non-aggregated slave or group */ if (!endpoint->aggregated || no_aggregation || !group_visited[endpoint->group_id]) @@ -1332,11 +1329,9 @@ static void set_dailink_map(struct snd_soc_dai_link_codec_ch_map *sdw_codec_ch_m static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"}; static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, - struct snd_soc_dai_link *dai_links, - int sdw_be_num, int sdw_cpu_dai_num, - struct snd_soc_dai_link_component *cpus, + struct snd_soc_dai_link *dai_links, int sdw_be_num, const struct snd_soc_acpi_link_adr *adr_link, - int *cpu_id, struct snd_soc_codec_conf *codec_conf, + struct snd_soc_codec_conf *codec_conf, int codec_count, int *be_id, int *codec_conf_index, bool *ignore_pch_dmic, @@ -1348,9 +1343,10 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, struct device *dev = card->dev; const struct snd_soc_acpi_link_adr *adr_link_next; struct snd_soc_dai_link_component *codecs; + struct snd_soc_dai_link_component *cpus; struct sof_sdw_codec_info *codec_info; int cpu_dai_id[SDW_MAX_CPU_DAIS]; - int cpu_dai_num, cpu_dai_index; + int cpu_dai_num; unsigned int group_id; int codec_dlc_index = 0; int codec_index; @@ -1421,7 +1417,6 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, if (codec_info->ignore_pch_dmic) *ignore_pch_dmic = true; - cpu_dai_index = *cpu_id; for_each_pcm_streams(stream) { struct snd_soc_dai_link_codec_ch_map *sdw_codec_ch_maps; char *name, *cpu_name; @@ -1459,6 +1454,10 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, if (!name) return -ENOMEM; + cpus = devm_kcalloc(dev, cpu_dai_num, sizeof(*cpus), GFP_KERNEL); + if (!cpus) + return -ENOMEM; + /* * generate CPU DAI name base on the sdw link ID and * PIN ID with offset of 2 according to sdw dai driver. @@ -1470,13 +1469,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, if (!cpu_name) return -ENOMEM; - if (cpu_dai_index >= sdw_cpu_dai_num) { - dev_err(dev, "invalid cpu dai index %d\n", - cpu_dai_index); - return -EINVAL; - } - - cpus[cpu_dai_index++].dai_name = cpu_name; + cpus[k].dai_name = cpu_name; } /* @@ -1488,17 +1481,11 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, return -EINVAL; } - if (*cpu_id >= sdw_cpu_dai_num) { - dev_err(dev, "invalid cpu dai index %d\n", *cpu_id); - return -EINVAL; - } - playback = (stream == SNDRV_PCM_STREAM_PLAYBACK); capture = (stream == SNDRV_PCM_STREAM_CAPTURE); + init_dai_link(dev, dai_links + *link_index, (*be_id)++, name, - playback, capture, - cpus + *cpu_id, cpu_dai_num, - codecs, codec_num, + playback, capture, cpus, cpu_dai_num, codecs, codec_num, NULL, &sdw_ops); /* @@ -1515,8 +1502,6 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, dev_err(dev, "failed to init codec %d\n", codec_index); return ret; } - - *cpu_id += cpu_dai_num; } return 0; @@ -1533,7 +1518,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; const struct snd_soc_acpi_link_adr *adr_link = mach_params->links; bool aggregation = !(sof_sdw_quirk & SOF_SDW_NO_AGGREGATION); - struct snd_soc_dai_link_component *cpus; struct snd_soc_codec_conf *codec_conf; bool append_dai_type = false; bool ignore_pch_dmic = false; @@ -1545,15 +1529,11 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) int num_links, link_index = 0; char *name, *cpu_dai_name; char *codec_name, *codec_dai_name; - int total_cpu_dai_num; - int sdw_cpu_dai_num; int i, j, be_id = 0; int codec_index; - int cpu_id = 0; int ret; - ret = get_dailink_info(dev, adr_link, &sdw_be_num, &sdw_cpu_dai_num, - &codec_conf_num); + ret = get_dailink_info(dev, adr_link, &sdw_be_num, &codec_conf_num); if (ret < 0) { dev_err(dev, "failed to get sdw link info %d\n", ret); return ret; @@ -1596,12 +1576,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) if (!dai_links) return -ENOMEM; - /* allocated CPU DAIs */ - total_cpu_dai_num = sdw_cpu_dai_num + ssp_num + dmic_num + hdmi_num + bt_num; - cpus = devm_kcalloc(dev, total_cpu_dai_num, sizeof(*cpus), GFP_KERNEL); - if (!cpus) - return -ENOMEM; - /* allocate codec conf, will be populated when dailinks are created */ codec_conf = devm_kcalloc(dev, codec_conf_num, sizeof(*codec_conf), GFP_KERNEL); @@ -1663,8 +1637,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) for (j = 0; j < codec_info_list[codec_index].dai_num ; j++) { ret = create_sdw_dailink(card, &link_index, dai_links, - sdw_be_num, sdw_cpu_dai_num, cpus, - adr_link, &cpu_id, + sdw_be_num, adr_link, codec_conf, codec_conf_num, &be_id, &codec_conf_index, &ignore_pch_dmic, append_dai_type, i, j); @@ -1712,7 +1685,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) if (ret < 0) return ret; - INC_ID(be_id, cpu_id, link_index); + INC_ID(be_id, link_index); } DMIC: @@ -1730,7 +1703,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) if (ret) return ret; - INC_ID(be_id, cpu_id, link_index); + INC_ID(be_id, link_index); ret = init_simple_dai_link(dev, dai_links + link_index, be_id, "dmic16k", 0, 1, // DMIC only supports capture @@ -1740,7 +1713,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) if (ret) return ret; - INC_ID(be_id, cpu_id, link_index); + INC_ID(be_id, link_index); } HDMI: @@ -1765,7 +1738,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) if (ret) return ret; - INC_ID(be_id, cpu_id, link_index); + INC_ID(be_id, link_index); } if (sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) { From patchwork Fri Sep 15 07:56:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723986 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 C05ACEE6432 for ; Fri, 15 Sep 2023 07:51:21 +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 AFB99DF4; Fri, 15 Sep 2023 09:50:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AFB99DF4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694764279; bh=YV7wiUPxH40qX3QFyXronw880qBrpYFVzzX3+75uL5k=; 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=b2g7f68MRuw2yN+WkSmepXjpLXqSFj27ozMy6f33elGjNsYr1iwNK+0ZP2r7VNqIi L2n/vIYVJbjTgKkZjl/SXLLwkUKUjWwWeOjUUqwlrFDlGb7/w3X8dgcrzNUjzQF11t lx2nQv2eTQzdYsGDswViL7y1w8K1cQVnNqpMN8Kw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D8FEAF805B0; Fri, 15 Sep 2023 09:49:37 +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 80D08F8059F; Fri, 15 Sep 2023 09:49:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8A0BDF8059F; Fri, 15 Sep 2023 09:49:34 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) (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 0B4C4F8047D for ; Fri, 15 Sep 2023 09:49:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0B4C4F8047D 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=Y1+5JXAS DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694764147; x=1726300147; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YV7wiUPxH40qX3QFyXronw880qBrpYFVzzX3+75uL5k=; b=Y1+5JXAS1IexVSr2/DxXpfjO9GayEOj3mBTID4wFw726D1SogQCxbBWR zMCpNbyssVZn6W0ALC1r9ECIomPplK25Ld7OLn9ZzEBzKoJUSB/XMgm3r mPHjk3L5I4VGwOZjUHnjpucNU8yOB6Ot4IKCPd8kR0UtgCnE4EQ4xqS/d EeiSGhICJ8Z4WL7l8pbRFp6GkiXAoj3XRBjwkMVL2S+B71hFx2flHWpe6 iqSOeFGH3SRgx2edLHNp0034efFxowf8TRp1pwftqXPBJUQy5qSxr4T8S llMo2Ptt0LpOJ/3Vmpj8kII+vpspXiaIATzJy+AfHnIF2t6hjzLm0qzKH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="376527562" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="376527562" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:48:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="779998602" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="779998602" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:47:44 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, ckeepax@opensource.cirrus.com Subject: [PATCH 4/4] ASoC: intel: sof_sdw: Increment be_id in init_dai_link Date: Fri, 15 Sep 2023 15:56:11 +0800 Message-Id: <20230915075611.1619548-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915075611.1619548-1-yung-chuan.liao@linux.intel.com> References: <20230915075611.1619548-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: UKCV7DAB7L37SMXXGNM5W4REHWSCQPW3 X-Message-ID-Hash: UKCV7DAB7L37SMXXGNM5W4REHWSCQPW3 X-MailFrom: yung-chuan.liao@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: From: Charles Keepax Rather than incrementing the ID for the dai_links in many places throughout the code, just increment it each time we initialise a new DAI link. Signed-off-by: Charles Keepax Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_sdw.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 335048dfae53..752bfce1ea01 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -20,8 +20,6 @@ static int quirk_override = -1; module_param_named(quirk, quirk_override, int, 0444); MODULE_PARM_DESC(quirk, "Board-specific quirk override"); -#define INC_ID(BE, LINK) do { (BE)++; (LINK)++; } while (0) - static void log_quirks(struct device *dev) { if (SOF_JACK_JDSRC(sof_sdw_quirk)) @@ -1089,14 +1087,14 @@ static int get_dailink_info(struct device *dev, } static void init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links, - int be_id, char *name, int playback, int capture, + int *be_id, char *name, int playback, int capture, struct snd_soc_dai_link_component *cpus, int cpus_num, struct snd_soc_dai_link_component *codecs, int codecs_num, int (*init)(struct snd_soc_pcm_runtime *rtd), const struct snd_soc_ops *ops) { - dev_dbg(dev, "create dai link %s, id %d\n", name, be_id); - dai_links->id = be_id; + dev_dbg(dev, "create dai link %s, id %d\n", name, *be_id); + dai_links->id = (*be_id)++; dai_links->name = name; dai_links->platforms = platform_component; dai_links->num_platforms = ARRAY_SIZE(platform_component); @@ -1112,7 +1110,7 @@ static void init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links } static int init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links, - int be_id, char *name, int playback, int capture, + int *be_id, char *name, int playback, int capture, const char *cpu_dai_name, const char *codec_name, const char *codec_dai_name, int (*init)(struct snd_soc_pcm_runtime *rtd), @@ -1484,7 +1482,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, playback = (stream == SNDRV_PCM_STREAM_PLAYBACK); capture = (stream == SNDRV_PCM_STREAM_CAPTURE); - init_dai_link(dev, dai_links + *link_index, (*be_id)++, name, + init_dai_link(dev, dai_links + *link_index, be_id, name, playback, capture, cpus, cpu_dai_num, codecs, codec_num, NULL, &sdw_ops); @@ -1674,7 +1672,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) playback = info->dais[0].direction[SNDRV_PCM_STREAM_PLAYBACK]; capture = info->dais[0].direction[SNDRV_PCM_STREAM_CAPTURE]; - ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name, + ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, name, playback, capture, cpu_dai_name, codec_name, info->dais[0].dai_name, NULL, info->ops); @@ -1685,7 +1683,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) if (ret < 0) return ret; - INC_ID(be_id, link_index); + link_index++; } DMIC: @@ -1696,16 +1694,16 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) goto HDMI; } - ret = init_simple_dai_link(dev, dai_links + link_index, be_id, "dmic01", + ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, "dmic01", 0, 1, // DMIC only supports capture "DMIC01 Pin", "dmic-codec", "dmic-hifi", sof_sdw_dmic_init, NULL); if (ret) return ret; - INC_ID(be_id, link_index); + link_index++; - ret = init_simple_dai_link(dev, dai_links + link_index, be_id, "dmic16k", + ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, "dmic16k", 0, 1, // DMIC only supports capture "DMIC16k Pin", "dmic-codec", "dmic-hifi", /* don't call sof_sdw_dmic_init() twice */ @@ -1713,7 +1711,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) if (ret) return ret; - INC_ID(be_id, link_index); + link_index++; } HDMI: @@ -1731,14 +1729,14 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) codec_dai_name = "snd-soc-dummy-dai"; } - ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name, + ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, name, 1, 0, // HDMI only supports playback cpu_dai_name, codec_name, codec_dai_name, sof_sdw_hdmi_init, NULL); if (ret) return ret; - INC_ID(be_id, link_index); + link_index++; } if (sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) { @@ -1748,7 +1746,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port); cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port); - ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name, + ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, name, 1, 1, cpu_dai_name, asoc_dummy_dlc.name, asoc_dummy_dlc.dai_name, NULL, NULL); if (ret)