diff mbox series

[07/34] ASoC: Intel: sof_sdw: Move flags to private struct

Message ID 20240326160429.13560-8-pierre-louis.bossart@linux.intel.com (mailing list archive)
State Accepted
Commit d36bfa329ae6d94e435d11960936023c03df0d64
Headers show
Series ASoC: Intel: boards: updates for 6.10 - part2 | expand

Commit Message

Pierre-Louis Bossart March 26, 2024, 4:04 p.m. UTC
From: Charles Keepax <ckeepax@opensource.cirrus.com>

Move the flags ignore_pch_dmic and append_dai_type into the drivers
private structure rather than passing them around between functions.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/sof_sdw.c        | 21 +++++++--------------
 sound/soc/intel/boards/sof_sdw_common.h |  2 ++
 2 files changed, 9 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 45732884e310..5557db68a002 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -1463,10 +1463,7 @@  static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
 			      struct snd_soc_dai_link *dai_links, int sdw_be_num,
 			      const struct snd_soc_acpi_link_adr *adr_link,
 			      struct snd_soc_codec_conf **codec_conf,
-			      int *be_id, bool *ignore_pch_dmic,
-			      bool append_dai_type,
-			      int adr_index,
-			      int dai_index)
+			      int *be_id, int adr_index, int dai_index)
 {
 	struct mc_private *ctx = snd_soc_card_get_drvdata(card);
 	struct device *dev = card->dev;
@@ -1549,8 +1546,7 @@  static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
 	if (!codec_info)
 		return -EINVAL;
 
-	if (codec_info->ignore_pch_dmic)
-		*ignore_pch_dmic = true;
+	ctx->ignore_pch_dmic |= codec_info->ignore_pch_dmic;
 
 	for_each_pcm_streams(stream) {
 		char *name, *cpu_name;
@@ -1572,7 +1568,7 @@  static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
 		}
 
 		/* create stream name according to first link id */
-		if (append_dai_type) {
+		if (ctx->append_dai_type) {
 			name = devm_kasprintf(dev, GFP_KERNEL,
 					      sdw_stream_name[stream + 2], cpu_dai_id[0],
 					      type_strings[codec_info->dais[dai_index].dai_type]);
@@ -1647,8 +1643,6 @@  static int sof_card_dai_links_create(struct snd_soc_card *card)
 	struct snd_soc_codec_conf *codec_conf;
 	struct sof_sdw_codec_info *codec_info;
 	struct sof_sdw_codec_info *ssp_info;
-	bool append_dai_type = false;
-	bool ignore_pch_dmic = false;
 	int codec_conf_num = 0;
 	bool group_generated[SDW_MAX_GROUPS] = { };
 	struct snd_soc_dai_link *dai_links;
@@ -1732,7 +1726,7 @@  static int sof_card_dai_links_create(struct snd_soc_card *card)
 			if (!codec_info)
 				return -EINVAL;
 			if (codec_info->dai_num > 1) {
-				append_dai_type = true;
+				ctx->append_dai_type = true;
 				goto out;
 			}
 			for (j = 0; j < i; j++) {
@@ -1740,7 +1734,7 @@  static int sof_card_dai_links_create(struct snd_soc_card *card)
 				    SDW_PART_ID(adr_link->adr_d[j].adr)) ||
 				    (SDW_MFG_ID(adr_link->adr_d[i].adr) !=
 				    SDW_MFG_ID(adr_link->adr_d[j].adr))) {
-					append_dai_type = true;
+					ctx->append_dai_type = true;
 					goto out;
 				}
 			}
@@ -1771,8 +1765,7 @@  static int sof_card_dai_links_create(struct snd_soc_card *card)
 				ret = create_sdw_dailink(card, &link_index, dai_links,
 							 sdw_be_num, adr_link,
 							 &codec_conf, &current_be_id,
-							 &ignore_pch_dmic,
-							 append_dai_type, i, j);
+							 i, j);
 				if (ret < 0) {
 					dev_err(dev, "failed to create dai link %d\n", link_index);
 					return ret;
@@ -1825,7 +1818,7 @@  static int sof_card_dai_links_create(struct snd_soc_card *card)
 DMIC:
 	/* dmic */
 	if (dmic_num > 0) {
-		if (ignore_pch_dmic) {
+		if (ctx->ignore_pch_dmic) {
 			dev_warn(dev, "Ignoring PCH DMIC\n");
 			goto HDMI;
 		}
diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h
index a04cbab9bc70..1daf98a5849f 100644
--- a/sound/soc/intel/boards/sof_sdw_common.h
+++ b/sound/soc/intel/boards/sof_sdw_common.h
@@ -103,6 +103,8 @@  struct mc_private {
 	struct device *amp_dev1, *amp_dev2;
 	/* To store SDW Pin index for each SoundWire link */
 	unsigned int sdw_pin_index[SDW_MAX_LINKS];
+	bool append_dai_type;
+	bool ignore_pch_dmic;
 };
 
 extern unsigned long sof_sdw_quirk;