diff mbox series

[11/34] ASoC: Intel: sof_sdw: Factor out DMIC DAI creation.

Message ID 20240326160429.13560-12-pierre-louis.bossart@linux.intel.com
State New
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>

Factor out the creation of the DMIC DAI links into a helper function.
No functional change.

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 | 53 +++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 9980652c901b..5571c9e85dd7 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -1659,6 +1659,34 @@  static int create_ssp_dailinks(struct snd_soc_card *card,
 	return 0;
 }
 
+static int create_dmic_dailinks(struct snd_soc_card *card,
+				struct snd_soc_dai_link **dai_links, int *be_id)
+{
+	struct device *dev = card->dev;
+	int ret;
+
+	ret = init_simple_dai_link(dev, *dai_links, be_id, "dmic01",
+				   0, 1, // DMIC only supports capture
+				   "DMIC01 Pin", "dmic-codec", "dmic-hifi",
+				   sof_sdw_dmic_init, NULL);
+	if (ret)
+		return ret;
+
+	(*dai_links)++;
+
+	ret = init_simple_dai_link(dev, *dai_links, 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;
+
+	(*dai_links)++;
+
+	return 0;
+}
+
 static int sof_card_dai_links_create(struct snd_soc_card *card)
 {
 	struct device *dev = card->dev;
@@ -1825,30 +1853,13 @@  static int sof_card_dai_links_create(struct snd_soc_card *card)
 	if (dmic_num > 0) {
 		if (ctx->ignore_pch_dmic) {
 			dev_warn(dev, "Ignoring PCH DMIC\n");
-			goto HDMI;
+		} else {
+			ret = create_dmic_dailinks(card, &dai_links, &be_id);
+			if (ret)
+				return ret;
 		}
-
-		ret = init_simple_dai_link(dev, dai_links, &be_id, "dmic01",
-					   0, 1, // DMIC only supports capture
-					   "DMIC01 Pin", "dmic-codec", "dmic-hifi",
-					   sof_sdw_dmic_init, NULL);
-		if (ret)
-			return ret;
-
-		dai_links++;
-
-		ret = init_simple_dai_link(dev, dai_links, &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;
-
-		dai_links++;
 	}
 
-HDMI:
 	/* HDMI */
 	for (i = 0; i < hdmi_num; i++) {
 		name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", i + 1);