diff mbox series

[14/28] ASoC: Intel: sof_sdw: increase sdw pin index for each sdw link

Message ID 20230602202225.249209-15-pierre-louis.bossart@linux.intel.com
State New
Headers show
Series ASoC: Intel: machine driver updates for 6.5 | expand

Commit Message

Pierre-Louis Bossart June 2, 2023, 8:22 p.m. UTC
From: Bard Liao <yung-chuan.liao@linux.intel.com>

To support multiple codecs per SoundWire link, we have to assign multiple
CPU DAIs to different DAI links sharing the same physical link. This is
not possible with the existing code since we assume that only 'Pin2' is
used for playback and 'Pin3' used for capture - additional DAIs cannot
be handled.

This patch enables more CPU DAIs to be used, e.g. "SDW0 Pin2",
"SDW0 Pin3", and "SDW0 Pin4" for SDW0-Playback-SimpleJack,
SDW0-Capture-SimpleJack, and SDW0-Playback-SmartAmp DAI links on physical
link #0.

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/sof_sdw.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 73e5a6aed776..a032628f8925 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -22,6 +22,11 @@  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))
@@ -1247,10 +1252,10 @@  static int create_sdw_dailink(struct snd_soc_card *card,
 	int cpu_dai_num, cpu_dai_index;
 	unsigned int group_id;
 	int codec_idx = 0;
-	int i = 0, j = 0;
 	int codec_index;
 	int codec_num;
 	int stream;
+	int i = 0;
 	int ret;
 	int k;
 
@@ -1336,7 +1341,7 @@  static int create_sdw_dailink(struct snd_soc_card *card,
 		for (k = 0; k < cpu_dai_num; k++) {
 			cpu_name = devm_kasprintf(dev, GFP_KERNEL,
 						  "SDW%d Pin%d", cpu_dai_id[k],
-						  j + SDW_INTEL_BIDIR_PDI_BASE);
+						  sdw_pin_index[cpu_dai_id[k]]++);
 			if (!cpu_name)
 				return -ENOMEM;
 
@@ -1385,7 +1390,6 @@  static int create_sdw_dailink(struct snd_soc_card *card,
 		}
 
 		*cpu_id += cpu_dai_num;
-		j++;
 	}
 
 	return 0;
@@ -1538,6 +1542,9 @@  static int sof_card_dai_links_create(struct device *dev,
 	for (i = 0; i < SDW_MAX_GROUPS; i++)
 		group_generated[i] = false;
 
+	for (i = 0; i < SDW_MAX_LINKS; i++)
+		sdw_pin_index[i] = SDW_INTEL_BIDIR_PDI_BASE;
+
 	for (; adr_link->num_adr; adr_link++) {
 		/*
 		 * If there are two or more different devices on the same sdw link, we have to