Skip to contentSkip to conversation

ASoC: Intel: sdw machine driver updates for 5.10

PATCH Superseded Kai Vehmanen 4 participants 14 messages Sep 23, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kai Vehmanen

author maintainer
#0 lore raw

cover ASoC: Intel: sdw machine driver updates for 5.10

Series including fixes and improvements for Intel SoundWire machine drivers.

Bard Liao (1):
ASoC: Intel: add support for new SoundWire hardware layout on TGL

Pierre-Louis Bossart (4):
ASoC: Intel: sof_sdw: remove ternary operator
ASoC: Intel: add codec name prefix to ACPI machine description
ASoC: Intel: sof_sdw: remove hard-coded codec_conf table
ASoC: Intel: sof_sdw_rt700: add codec prefix

Rander Wang (1):
ASOC: Intel: sof_sdw: restore playback functionality with max98373
amps

 include/sound/soc-acpi.h                      |   2 +
 sound/soc/intel/boards/sof_sdw.c              | 170 +++++++++---------
 sound/soc/intel/boards/sof_sdw_common.h       |   3 +
 sound/soc/intel/boards/sof_sdw_max98373.c     |  36 +++-
 sound/soc/intel/boards/sof_sdw_rt700.c        |   6 +-
 .../intel/common/soc-acpi-intel-cml-match.c   |  10 ++
 .../intel/common/soc-acpi-intel-cnl-match.c   |   1 +
 .../intel/common/soc-acpi-intel-icl-match.c   |   6 +
 .../intel/common/soc-acpi-intel-tgl-match.c   |  67 +++++++
 9 files changed, 216 insertions(+), 85 deletions(-)
Signature · 1 line
2.27.0
author maintainer
#1 lore raw

PATCH 1/6 ASOC: Intel: sof_sdw: restore playback functionality with max98373 amps

From: Rander Wang <[email protected]>

The Max98373 amplifier provides I/V feedback information, which keeps a DAPM path active even when there is no playback happening. This prevents entry in low-power mode. Rather than adding new controls and require UCM/user interaction, the method previously applied is to enable/disable the Speaker pin during the dailink trigger operations.

Recent changes in the SoundWire stream management moved the stream trigger to the dailink trigger. This change removed the Maxim-specific pin handling and resulted in a regression. This patch restores functionality by combining the SoundWire stream trigger with the pin enable/disable.

Fixes 7eec07f389a60 ('ASOC: Intel: sof_sdw: add dailink .trigger callback')
Fixes 5595f95c32650 ('ASOC: Intel: sof_sdw: add dailink .prepare and .hw_free callback').
---
 sound/soc/intel/boards/sof_sdw.c          |  6 ++--
 sound/soc/intel/boards/sof_sdw_common.h   |  3 ++
 sound/soc/intel/boards/sof_sdw_max98373.c | 36 ++++++++++++++++++++++-
 3 files changed, 41 insertions(+), 4 deletions(-)
sound/soc/intel/boards/sof_sdw.c +3 -3
index 210b66d1f9a2..efd96c9c6e39 100644
@@ -225,7 +225,7 @@ int sdw_startup(struct snd_pcm_substream *substream)
 	return sdw_startup_stream(substream);
 }
 
-static int sdw_prepare(struct snd_pcm_substream *substream)
+int sdw_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 	struct sdw_stream_runtime *sdw_stream;
@@ -244,7 +244,7 @@ static int sdw_prepare(struct snd_pcm_substream *substream)
 	return sdw_prepare_stream(sdw_stream);
 }
 
-static int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
+int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 	struct sdw_stream_runtime *sdw_stream;
@@ -284,7 +284,7 @@ static int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
 	return ret;
 }
 
-static int sdw_hw_free(struct snd_pcm_substream *substream)
+int sdw_hw_free(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 	struct sdw_stream_runtime *sdw_stream;
sound/soc/intel/boards/sof_sdw_common.h +3 -0
index 6a5d46589baf..f3cb6796363e 100644
@@ -79,6 +79,9 @@ struct mc_private {
 extern unsigned long sof_sdw_quirk;
 
 int sdw_startup(struct snd_pcm_substream *substream);
+int sdw_prepare(struct snd_pcm_substream *substream);
+int sdw_trigger(struct snd_pcm_substream *substream, int cmd);
+int sdw_hw_free(struct snd_pcm_substream *substream);
 void sdw_shutdown(struct snd_pcm_substream *substream);
 
 /* generic HDMI support */
sound/soc/intel/boards/sof_sdw_max98373.c +35 -1
index 905582aaf58c..cfdf970c5800 100644
@@ -55,9 +55,43 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd)
 	return ret;
 }
 
+static int max98373_sdw_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+	int ret;
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+		/* enable max98373 first */
+		ret = max98373_trigger(substream, cmd);
+		if (ret < 0)
+			break;
+
+		ret = sdw_trigger(substream, cmd);
+		break;
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		ret = sdw_trigger(substream, cmd);
+		if (ret < 0)
+			break;
+
+		ret = max98373_trigger(substream, cmd);
+		break;
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
 static const struct snd_soc_ops max_98373_sdw_ops = {
 	.startup = sdw_startup,
-	.trigger = max98373_trigger,
+	.prepare = sdw_prepare,
+	.trigger = max98373_sdw_trigger,
+	.hw_free = sdw_hw_free,
 	.shutdown = sdw_shutdown,
 };
 
Signature · 1 line
2.27.0
maintainer
#2 lore raw

Re: [PATCH 1/6] ASOC: Intel: sof_sdw: restore playback functionality with max98373 amps

Quoted 2 lines · Kai Vehmanen
Fixes 7eec07f389a60 ('ASOC: Intel: sof_sdw: add dailink .trigger callback')
Fixes 5595f95c32650 ('ASOC: Intel: sof_sdw: add dailink .prepare and .hw_free callback').

I don't seem to have either of these commits, I think you meant ae3a3918edf57b and 06998d49bcac8a9 respectively?

author maintainer
#3 lore raw

Re: [PATCH 1/6] ASOC: Intel: sof_sdw: restore playback functionality with max98373 amps

Hi,

Quoted 7 lines · Mark Brown
Quoted 2 lines · Kai Vehmanen
Fixes 7eec07f389a60 ('ASOC: Intel: sof_sdw: add dailink .trigger callback')
Fixes 5595f95c32650 ('ASOC: Intel: sof_sdw: add dailink .prepare and .hw_free callback').

I don't seem to have either of these commits, I think you meant ae3a3918edf57b and 06998d49bcac8a9 respectively?

d'oh, indeed, the patches had sof-dev commit-ids. Let me resend v2 with the correct commits.

Br, Kai

author maintainer
#4 lore raw

PATCH 2/6 ASoC: Intel: sof_sdw: remove ternary operator

In reply to Kai Vehmanen

From: Pierre-Louis Bossart <[email protected]>

cppcheck reports the following warning:

sound/soc/intel/boards/sof_sdw.c:866:46: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
hdmi_num = sof_sdw_quirk & SOF_SDW_TGL_HDMI ?

                                             ^

There's no reason to use the ternary operator here, we might as well use a regular if-else construct.

---
 sound/soc/intel/boards/sof_sdw.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/intel/boards/sof_sdw.c +4 -2
index efd96c9c6e39..4b1cd3011d37 100644
@@ -863,8 +863,10 @@ static int sof_card_dai_links_create(struct device *dev,
 	for (i = 0; i < ARRAY_SIZE(codec_info_list); i++)
 		codec_info_list[i].amp_num = 0;
 
-	hdmi_num = sof_sdw_quirk & SOF_SDW_TGL_HDMI ?
-				SOF_TGL_HDMI_COUNT : SOF_PRE_TGL_HDMI_COUNT;
+	if (sof_sdw_quirk & SOF_SDW_TGL_HDMI)
+		hdmi_num = SOF_TGL_HDMI_COUNT;
+	else
+		hdmi_num = SOF_PRE_TGL_HDMI_COUNT;
 
 	ssp_mask = SOF_SSP_GET_PORT(sof_sdw_quirk);
 	/*
Signature · 1 line
2.27.0
author maintainer
#5 lore raw

PATCH 3/6 ASoC: Intel: add codec name prefix to ACPI machine description

In reply to Kai Vehmanen

From: Pierre-Louis Bossart <[email protected]>

The current SOF machine driver adds a name prefix for each codec, mainly to differentiate ALSA controls for left and right amplifiers.

This is a good idea, but the machine driver duplicates some of the information that already exists in ACPI descriptors, so add those prefixes there. Follow-up patches will make use of the information encoded in these tables and remove duplication.

---
 include/sound/soc-acpi.h                          |  2 ++
 sound/soc/intel/common/soc-acpi-intel-cml-match.c | 10 ++++++++++
 sound/soc/intel/common/soc-acpi-intel-cnl-match.c |  1 +
 sound/soc/intel/common/soc-acpi-intel-icl-match.c |  6 ++++++
 sound/soc/intel/common/soc-acpi-intel-tgl-match.c | 14 ++++++++++++++
 5 files changed, 33 insertions(+)
include/sound/soc-acpi.h +2 -0
index b77b05c413a3..b16a844d16ef 100644
@@ -93,11 +93,13 @@ struct snd_soc_acpi_endpoint {
  * @adr: 64 bit ACPI _ADR value
  * @num_endpoints: number of endpoints for this device
  * @endpoints: array of endpoints
+ * @name_prefix: string used for codec controls
  */
 struct snd_soc_acpi_adr_device {
 	const u64 adr;
 	const u8 num_endpoints;
 	const struct snd_soc_acpi_endpoint *endpoints;
+	const char *name_prefix;
 };
 
 /**
sound/soc/intel/common/soc-acpi-intel-cml-match.c +10 -0
index ec01884ef93d..26dde88bb227 100644
@@ -98,6 +98,7 @@ static const struct snd_soc_acpi_adr_device rt700_1_adr[] = {
 		.adr = 0x000110025D070000,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt700"
 	}
 };
 
@@ -115,6 +116,7 @@ static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
 		.adr = 0x000020025D071100,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt711"
 	}
 };
 
@@ -123,6 +125,7 @@ static const struct snd_soc_acpi_adr_device rt1308_1_single_adr[] = {
 		.adr = 0x000120025D130800,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt1308-1"
 	}
 };
 
@@ -131,6 +134,7 @@ static const struct snd_soc_acpi_adr_device rt1308_1_group1_adr[] = {
 		.adr = 0x000120025D130800,
 		.num_endpoints = 1,
 		.endpoints = &spk_l_endpoint,
+		.name_prefix = "rt1308-1"
 	}
 };
 
@@ -139,6 +143,7 @@ static const struct snd_soc_acpi_adr_device rt1308_2_group1_adr[] = {
 		.adr = 0x000220025D130800,
 		.num_endpoints = 1,
 		.endpoints = &spk_r_endpoint,
+		.name_prefix = "rt1308-2"
 	}
 };
 
@@ -147,6 +152,7 @@ static const struct snd_soc_acpi_adr_device rt715_3_adr[] = {
 		.adr = 0x000320025D071500,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt715"
 	}
 };
 
@@ -155,6 +161,7 @@ static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
 		.adr = 0x000030025D071101,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt711"
 	}
 };
 
@@ -163,6 +170,7 @@ static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
 		.adr = 0x000131025D131601, /* unique ID is set for some reason */
 		.num_endpoints = 1,
 		.endpoints = &spk_l_endpoint,
+		.name_prefix = "rt1316-1"
 	}
 };
 
@@ -171,6 +179,7 @@ static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
 		.adr = 0x000230025D131601,
 		.num_endpoints = 1,
 		.endpoints = &spk_r_endpoint,
+		.name_prefix = "rt1316-2"
 	}
 };
 
@@ -179,6 +188,7 @@ static const struct snd_soc_acpi_adr_device rt714_3_adr[] = {
 		.adr = 0x000330025D071401,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt714"
 	}
 };
 
sound/soc/intel/common/soc-acpi-intel-cnl-match.c +1 -0
index 7d61e0da808b..b80f032a8b76 100644
@@ -39,6 +39,7 @@ static const struct snd_soc_acpi_adr_device rt5682_2_adr[] = {
 		.adr = 0x000220025D568200,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt5682"
 	}
 };
 
sound/soc/intel/common/soc-acpi-intel-icl-match.c +6 -0
index ebe13197410f..9a529a785288 100644
@@ -59,6 +59,7 @@ static const struct snd_soc_acpi_adr_device rt700_0_adr[] = {
 		.adr = 0x000010025D070000,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt700"
 	}
 };
 
@@ -76,6 +77,7 @@ static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
 		.adr = 0x000020025D071100,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt711"
 	}
 };
 
@@ -84,6 +86,7 @@ static const struct snd_soc_acpi_adr_device rt1308_1_adr[] = {
 		.adr = 0x000120025D130800,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt1308-1"
 	}
 };
 
@@ -92,6 +95,7 @@ static const struct snd_soc_acpi_adr_device rt1308_1_group1_adr[] = {
 		.adr = 0x000120025D130800,
 		.num_endpoints = 1,
 		.endpoints = &spk_l_endpoint,
+		.name_prefix = "rt1308-1"
 	}
 };
 
@@ -100,6 +104,7 @@ static const struct snd_soc_acpi_adr_device rt1308_2_group1_adr[] = {
 		.adr = 0x000220025D130800,
 		.num_endpoints = 1,
 		.endpoints = &spk_r_endpoint,
+		.name_prefix = "rt1308-2"
 	}
 };
 
@@ -108,6 +113,7 @@ static const struct snd_soc_acpi_adr_device rt715_3_adr[] = {
 		.adr = 0x000320025D071500,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt715"
 	}
 };
 
sound/soc/intel/common/soc-acpi-intel-tgl-match.c +14 -0
index 6816847bee40..76f4eaf684b0 100644
@@ -40,6 +40,7 @@ static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
 		.adr = 0x000020025D071100,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt711"
 	}
 };
 
@@ -48,11 +49,13 @@ static const struct snd_soc_acpi_adr_device rt1308_1_dual_adr[] = {
 		.adr = 0x000120025D130800,
 		.num_endpoints = 1,
 		.endpoints = &spk_l_endpoint,
+		.name_prefix = "rt1308-1"
 	},
 	{
 		.adr = 0x000122025D130800,
 		.num_endpoints = 1,
 		.endpoints = &spk_r_endpoint,
+		.name_prefix = "rt1308-2"
 	}
 };
 
@@ -61,6 +64,7 @@ static const struct snd_soc_acpi_adr_device rt1308_1_single_adr[] = {
 		.adr = 0x000120025D130800,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt1308-1"
 	}
 };
 
@@ -69,6 +73,7 @@ static const struct snd_soc_acpi_adr_device rt1308_1_group1_adr[] = {
 		.adr = 0x000120025D130800,
 		.num_endpoints = 1,
 		.endpoints = &spk_l_endpoint,
+		.name_prefix = "rt1308-1"
 	}
 };
 
@@ -77,6 +82,7 @@ static const struct snd_soc_acpi_adr_device rt1308_2_group1_adr[] = {
 		.adr = 0x000220025D130800,
 		.num_endpoints = 1,
 		.endpoints = &spk_r_endpoint,
+		.name_prefix = "rt1308-2"
 	}
 };
 
@@ -85,6 +91,7 @@ static const struct snd_soc_acpi_adr_device rt715_3_adr[] = {
 		.adr = 0x000320025D071500,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt715"
 	}
 };
 
@@ -93,11 +100,13 @@ static const struct snd_soc_acpi_adr_device mx8373_1_adr[] = {
 		.adr = 0x000123019F837300,
 		.num_endpoints = 1,
 		.endpoints = &spk_l_endpoint,
+		.name_prefix = "Right"
 	},
 	{
 		.adr = 0x000127019F837300,
 		.num_endpoints = 1,
 		.endpoints = &spk_r_endpoint,
+		.name_prefix = "Left"
 	}
 };
 
@@ -106,6 +115,7 @@ static const struct snd_soc_acpi_adr_device rt5682_0_adr[] = {
 		.adr = 0x000021025D568200,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt5682"
 	}
 };
 
@@ -114,6 +124,7 @@ static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
 		.adr = 0x000030025D071101,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt711"
 	}
 };
 
@@ -122,6 +133,7 @@ static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
 		.adr = 0x000131025D131601, /* unique ID is set for some reason */
 		.num_endpoints = 1,
 		.endpoints = &spk_l_endpoint,
+		.name_prefix = "rt1316-1"
 	}
 };
 
@@ -130,6 +142,7 @@ static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
 		.adr = 0x000230025D131601,
 		.num_endpoints = 1,
 		.endpoints = &spk_r_endpoint,
+		.name_prefix = "rt1316-2"
 	}
 };
 
@@ -138,6 +151,7 @@ static const struct snd_soc_acpi_adr_device rt714_3_adr[] = {
 		.adr = 0x000330025D071401,
 		.num_endpoints = 1,
 		.endpoints = &single_endpoint,
+		.name_prefix = "rt714"
 	}
 };
 
Signature · 1 line
2.27.0
author maintainer
#6 lore raw

PATCH 4/6 ASoC: Intel: sof_sdw: remove hard-coded codec_conf table

In reply to Kai Vehmanen

From: Pierre-Louis Bossart <[email protected]>

Now that the ACPI machine params provide all the information needed, allocate the card codec_conf dynamically and set .dlc and .prefix_name.

---
 sound/soc/intel/boards/sof_sdw.c | 149 +++++++++++++++----------------
 1 file changed, 73 insertions(+), 76 deletions(-)
sound/soc/intel/boards/sof_sdw.c +73 -76
index 4b1cd3011d37..8e191a8d5dc5 100644
@@ -136,75 +136,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = {
 	{}
 };
 
-static struct snd_soc_codec_conf codec_conf[] = {
-	{
-		.dlc = COMP_CODEC_CONF("sdw:0:25d:711:0"),
-		.name_prefix = "rt711",
-	},
-	{
-		.dlc = COMP_CODEC_CONF("sdw:0:25d:711:1"),
-		.name_prefix = "rt711",
-	},
-	/* rt1308 w/ I2S connection */
-	{
-		.dlc = COMP_CODEC_CONF("i2c-10EC1308:00"),
-		.name_prefix = "rt1308-1",
-	},
-	/* rt1308 left on link 1 */
-	{
-		.dlc = COMP_CODEC_CONF("sdw:1:25d:1308:0"),
-		.name_prefix = "rt1308-1",
-	},
-	/* two 1308s on link1 with different unique id */
-	{
-		.dlc = COMP_CODEC_CONF("sdw:1:25d:1308:0:0"),
-		.name_prefix = "rt1308-1",
-	},
-	{
-		.dlc = COMP_CODEC_CONF("sdw:1:25d:1308:0:2"),
-		.name_prefix = "rt1308-2",
-	},
-	/* rt1308 right on link 2 */
-	{
-		.dlc = COMP_CODEC_CONF("sdw:2:25d:1308:0"),
-		.name_prefix = "rt1308-2",
-	},
-	{
-		.dlc = COMP_CODEC_CONF("sdw:3:25d:715:0"),
-		.name_prefix = "rt715",
-	},
-	/* two MAX98373s on link1 with different unique id */
-	{
-		.dlc = COMP_CODEC_CONF("sdw:1:19f:8373:0:3"),
-		.name_prefix = "Right",
-	},
-	{
-		.dlc = COMP_CODEC_CONF("sdw:1:19f:8373:0:7"),
-		.name_prefix = "Left",
-	},
-	{
-		.dlc = COMP_CODEC_CONF("sdw:0:25d:5682:0"),
-		.name_prefix = "rt5682",
-	},
-	/* rt5682 on link2 */
-	{
-		.dlc = COMP_CODEC_CONF("sdw:2:25d:5682:0"),
-		.name_prefix = "rt5682",
-	},
-	{
-		.dlc = COMP_CODEC_CONF("sdw:1:25d:1316:1"),
-		.name_prefix = "rt1316-1",
-	},
-	{
-		.dlc = COMP_CODEC_CONF("sdw:2:25d:1316:1"),
-		.name_prefix = "rt1316-2",
-	},
-	{
-		.dlc = COMP_CODEC_CONF("sdw:3:25d:714:1"),
-		.name_prefix = "rt714",
-	},
-};
-
 static struct snd_soc_dai_link_component dmic_component[] = {
 	{
 		.name = "dmic-codec",
@@ -538,10 +469,19 @@ static bool is_unique_device(const struct snd_soc_acpi_link_adr *link,
 static int create_codec_dai_name(struct device *dev,
 				 const struct snd_soc_acpi_link_adr *link,
 				 struct snd_soc_dai_link_component *codec,
-				 int offset)
+				 int offset,
+				 struct snd_soc_codec_conf *codec_conf,
+				 int codec_count,
+				 int *codec_conf_index)
 {
 	int i;
 
+	/* sanity check */
+	if (*codec_conf_index + link->num_adr > codec_count) {
+		dev_err(dev, "codec_conf: out-of-bounds access requested\n");
+		return -EINVAL;
+	}
+
 	for (i = 0; i < link->num_adr; i++) {
 		unsigned int sdw_version, unique_id, mfg_id;
 		unsigned int link_id, part_id, class_id;
@@ -583,6 +523,11 @@ static int create_codec_dai_name(struct device *dev,
 
 		codec[comp_index].dai_name =
 			codec_info_list[codec_index].dai_name;
+
+		codec_conf[*codec_conf_index].dlc = codec[comp_index];
+		codec_conf[*codec_conf_index].name_prefix = link->adr_d[i].name_prefix;
+
+		++*codec_conf_index;
 	}
 
 	return 0;
@@ -701,7 +646,10 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
 			      int sdw_be_num, int sdw_cpu_dai_num,
 			      struct snd_soc_dai_link_component *cpus,
 			      const struct snd_soc_acpi_link_adr *link,
-			      int *cpu_id, bool *group_generated)
+			      int *cpu_id, bool *group_generated,
+			      struct snd_soc_codec_conf *codec_conf,
+			      int codec_count,
+			      int *codec_conf_index)
 {
 	const struct snd_soc_acpi_link_adr *link_next;
 	struct snd_soc_dai_link_component *codecs;
@@ -739,7 +687,8 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
 		if (cpu_dai_id[i] != ffs(link_next->mask) - 1)
 			continue;
 
-		ret = create_codec_dai_name(dev, link_next, codecs, codec_idx);
+		ret = create_codec_dai_name(dev, link_next, codecs, codec_idx,
+					    codec_conf, codec_count, codec_conf_index);
 		if (ret < 0)
 			return ret;
 
@@ -836,6 +785,42 @@ static inline int get_next_be_id(struct snd_soc_dai_link *links,
 
 #define IDISP_CODEC_MASK	0x4
 
+static int sof_card_codec_conf_alloc(struct device *dev,
+				     struct snd_soc_acpi_mach_params *mach_params,
+				     struct snd_soc_codec_conf **codec_conf,
+				     int *codec_conf_count)
+{
+	const struct snd_soc_acpi_link_adr *adr_link;
+	struct snd_soc_codec_conf *c_conf;
+	int num_codecs = 0;
+	int i;
+
+	adr_link = mach_params->links;
+	if (!adr_link)
+		return -EINVAL;
+
+	/* generate DAI links by each sdw link */
+	for (; adr_link->num_adr; adr_link++) {
+		for (i = 0; i < adr_link->num_adr; i++) {
+			if (!adr_link->adr_d[i].name_prefix) {
+				dev_err(dev, "codec 0x%llx does not have a name prefix\n",
+					adr_link->adr_d[i].adr);
+				return -EINVAL;
+			}
+		}
+		num_codecs += adr_link->num_adr;
+	}
+
+	c_conf = devm_kzalloc(dev, num_codecs * sizeof(*c_conf), GFP_KERNEL);
+	if (!c_conf)
+		return -ENOMEM;
+
+	*codec_conf = c_conf;
+	*codec_conf_count = num_codecs;
+
+	return 0;
+}
+
 static int sof_card_dai_links_create(struct device *dev,
 				     struct snd_soc_acpi_mach *mach,
 				     struct snd_soc_card *card)
@@ -847,6 +832,9 @@ static int sof_card_dai_links_create(struct device *dev,
 	struct snd_soc_acpi_mach_params *mach_params;
 	const struct snd_soc_acpi_link_adr *adr_link;
 	struct snd_soc_dai_link_component *cpus;
+	struct snd_soc_codec_conf *codec_conf;
+	int codec_conf_count;
+	int codec_conf_index = 0;
 	bool group_generated[SDW_MAX_GROUPS];
 	int ssp_codec_index, ssp_mask;
 	struct snd_soc_dai_link *links;
@@ -859,6 +847,13 @@ static int sof_card_dai_links_create(struct device *dev,
 	int comp_num;
 	int ret;
 
+	mach_params = &mach->mach_params;
+
+	/* allocate codec conf, will be populated when dailinks are created */
+	ret = sof_card_codec_conf_alloc(dev, mach_params, &codec_conf, &codec_conf_count);
+	if (ret < 0)
+		return ret;
+
 	/* reset amp_num to ensure amp_num++ starts from 0 in each probe */
 	for (i = 0; i < ARRAY_SIZE(codec_info_list); i++)
 		codec_info_list[i].amp_num = 0;
@@ -879,7 +874,6 @@ static int sof_card_dai_links_create(struct device *dev,
 	ssp_num = ssp_codec_index >= 0 ? hweight_long(ssp_mask) : 0;
 	comp_num = hdmi_num + ssp_num;
 
-	mach_params = &mach->mach_params;
 	ret = get_sdw_dailink_info(mach_params->links,
 				   &sdw_be_num, &sdw_cpu_dai_num);
 	if (ret < 0) {
@@ -943,7 +937,9 @@ static int sof_card_dai_links_create(struct device *dev,
 
 		ret = create_sdw_dailink(dev, &be_id, links, sdw_be_num,
 					 sdw_cpu_dai_num, cpus, adr_link,
-					 &cpu_id, group_generated);
+					 &cpu_id, group_generated,
+					 codec_conf, codec_conf_count,
+					 &codec_conf_index);
 		if (ret < 0) {
 			dev_err(dev, "failed to create dai link %d", be_id);
 			return -ENOMEM;
@@ -1074,6 +1070,9 @@ static int sof_card_dai_links_create(struct device *dev,
 	card->dai_link = links;
 	card->num_links = num_links;
 
+	card->codec_conf = codec_conf;
+	card->num_configs = codec_conf_count;
+
 	return 0;
 }
 
@@ -1100,8 +1099,6 @@ static struct snd_soc_card card_sof_sdw = {
 	.name = "soundwire",
 	.owner = THIS_MODULE,
 	.late_probe = sof_sdw_card_late_probe,
-	.codec_conf = codec_conf,
-	.num_configs = ARRAY_SIZE(codec_conf),
 };
 
 static int mc_probe(struct platform_device *pdev)
Signature · 1 line
2.27.0
author maintainer
#7 lore raw

PATCH 5/6 ASoC: Intel: sof_sdw_rt700: add codec prefix

In reply to Kai Vehmanen

From: Pierre-Louis Bossart <[email protected]>

Somehow for this codec we never used any prefix for the controls, likely because the test platform has a single SoundWire device.

Follow the convention and use the codec prefix across the board to avoid possible conflicts.

---
 sound/soc/intel/boards/sof_sdw_rt700.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/boards/sof_sdw_rt700.c +3 -3
index bff69cfe27f4..21e7e4a81779 100644
@@ -23,9 +23,9 @@ static const struct snd_soc_dapm_widget rt700_widgets[] = {
 
 static const struct snd_soc_dapm_route rt700_map[] = {
 	/* Headphones */
-	{ "Headphones", NULL, "HP" },
-	{ "Speaker", NULL, "SPK" },
-	{ "MIC2", NULL, "AMIC" },
+	{ "Headphones", NULL, "rt700 HP" },
+	{ "Speaker", NULL, "rt700 SPK" },
+	{ "rt700 MIC2", NULL, "AMIC" },
 };
 
 static const struct snd_kcontrol_new rt700_controls[] = {
Signature · 1 line
2.27.0
maintainer
#8 lore raw

Re: [PATCH 5/6] ASoC: Intel: sof_sdw_rt700: add codec prefix

Dne 23. 09. 20 v 10:05 Kai Vehmanen napsal(a):

Quoted 21 lines

From: Pierre-Louis Bossart <[email protected]>

Somehow for this codec we never used any prefix for the controls, likely because the test platform has a single SoundWire device.

Follow the convention and use the codec prefix across the board to avoid possible conflicts.

---
 sound/soc/intel/boards/sof_sdw_rt700.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/boards/sof_sdw_rt700.c +0 -0
index bff69cfe27f4..21e7e4a81779 100644

sound/soc/intel/boards/sof_sdw_rt700.c static const struct snd_soc_dapm_widget rt700_widgets[] = { · line 29

Quoted 10 lines
sound/soc/intel/boards/sof_sdw_rt700.c +3 -3
@@ -23,9 +23,9 @@ static const struct snd_soc_dapm_widget rt700_widgets[] = {
 
 static const struct snd_soc_dapm_route rt700_map[] = {
 	/* Headphones */
-	{ "Headphones", NULL, "HP" },
-	{ "Speaker", NULL, "SPK" },
-	{ "MIC2", NULL, "AMIC" },
+	{ "Headphones", NULL, "rt700 HP" },
+	{ "Speaker", NULL, "rt700 SPK" },
 
+	{ "rt700 MIC2", NULL, "AMIC" },

This line looks suspicious. Perhaps, the prefix should be added before AMIC ?

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
author maintainer
#9 lore raw

Re: [PATCH 5/6] ASoC: Intel: sof_sdw_rt700: add codec prefix

Hi,

Quoted 14 lines · Jaroslav Kysela

Dne 23. 09. 20 v 10:05 Kai Vehmanen napsal(a):

Quoted 12 lines

From: Pierre-Louis Bossart <[email protected]>

sound/soc/intel/boards/sof_sdw_rt700.c +2 -3
@@ -23,9 +23,9 @@ static const struct snd_soc_dapm_widget rt700_widgets[] = {
 
 static const struct snd_soc_dapm_route rt700_map[] = {
 	/* Headphones */
-	{ "Headphones", NULL, "HP" },
-	{ "Speaker", NULL, "SPK" },
-	{ "MIC2", NULL, "AMIC" },
+	{ "Headphones", NULL, "rt700 HP" },
+	{ "Speaker", NULL, "rt700 SPK" },
Quoted 3 lines

sound/soc/intel/boards/sof_sdw_rt700.c static const struct snd_soc_dapm_widget rt700_widgets[] = { · line 28

Quoted 1 line
sound/soc/intel/boards/sof_sdw_rt700.c +1 -0
+	{ "rt700 MIC2", NULL, "AMIC" },

This line looks suspicious. Perhaps, the prefix should be added before AMIC ?

I believe this is still correct. We prefix the codec-side entry of the dapm routes with codec string and here MIC2 is the codec. This is aligned with existing code for 711 in sof_sdw_rt711.c:

static const struct snd_soc_dapm_route rt711_map[] = {

»       /* Headphones */
»       { "Headphone", NULL, "rt711 HP" },
»       { "rt711 MIC2", NULL, "Headset Mic" },

};

Br, Kai

maintainer
#10 lore raw

Re: [PATCH 5/6] ASoC: Intel: sof_sdw_rt700: add codec prefix

Dne 23. 09. 20 v 11:25 Kai Vehmanen napsal(a):

Quoted 26 lines

Hi,

Quoted 14 lines · Jaroslav Kysela

Dne 23. 09. 20 v 10:05 Kai Vehmanen napsal(a):

Quoted 12 lines

From: Pierre-Louis Bossart <[email protected]>

sound/soc/intel/boards/sof_sdw_rt700.c +2 -3
@@ -23,9 +23,9 @@ static const struct snd_soc_dapm_widget rt700_widgets[] = {
 
 static const struct snd_soc_dapm_route rt700_map[] = {
 	/* Headphones */
-	{ "Headphones", NULL, "HP" },
-	{ "Speaker", NULL, "SPK" },
-	{ "MIC2", NULL, "AMIC" },
+	{ "Headphones", NULL, "rt700 HP" },
+	{ "Speaker", NULL, "rt700 SPK" },
Quoted 3 lines

sound/soc/intel/boards/sof_sdw_rt700.c static const struct snd_soc_dapm_widget rt700_widgets[] = { · line 28

Quoted 1 line
sound/soc/intel/boards/sof_sdw_rt700.c +1 -0
+	{ "rt700 MIC2", NULL, "AMIC" },

This line looks suspicious. Perhaps, the prefix should be added before AMIC ?

I believe this is still correct. We prefix the codec-side entry of the dapm routes with codec string and here MIC2 is the codec. This is aligned with existing code for 711 in sof_sdw_rt711.c:

Quoted 8 lines

static const struct snd_soc_dapm_route rt711_map[] = {

»       /* Headphones */
»       { "Headphone", NULL, "rt711 HP" },
»       { "rt711 MIC2", NULL, "Headset Mic" },

};

Br, Kai

Ok, thanks for the clarification.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
maintainer
#11 lore raw

Re: [PATCH 5/6] ASoC: Intel: sof_sdw_rt700: add codec prefix

In reply to Jaroslav Kysela
Quoted 23 lines · Jaroslav Kysela

Dne 23. 09. 20 v 10:05 Kai Vehmanen napsal(a):

Quoted 22 lines

From: Pierre-Louis Bossart <[email protected]>

Somehow for this codec we never used any prefix for the controls, likely because the test platform has a single SoundWire device.

Follow the convention and use the codec prefix across the board to avoid possible conflicts.

---
  sound/soc/intel/boards/sof_sdw_rt700.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/boards/sof_sdw_rt700.c +0 -0
index bff69cfe27f4..21e7e4a81779 100644
@@ -23,9 +23,9 @@ static const struct snd_soc_dapm_widget rt700_widgets[] = {
 
Quoted 9 lines

sound/soc/intel/boards/sof_sdw_rt700.c static const struct snd_soc_dapm_widget rt700_widgets[] = { · line 28

Quoted 8 lines
sound/soc/intel/boards/sof_sdw_rt700.c +3 -3
  static const struct snd_soc_dapm_route rt700_map[] = {
  	/* Headphones */
-	{ "Headphones", NULL, "HP" },
-	{ "Speaker", NULL, "SPK" },
-	{ "MIC2", NULL, "AMIC" },
+	{ "Headphones", NULL, "rt700 HP" },
+	{ "Speaker", NULL, "rt700 SPK" },
+	{ "rt700 MIC2", NULL, "AMIC" },

This line looks suspicious. Perhaps, the prefix should be added before AMIC ?

The "rt700" is a prefix for rt700 codec and the "MIC2" is one of rt700's

widget and "AMIC" is machine driver's widget. So "rt700 MIC2" looks correct

to me.

Quoted 3 lines

Jaroslav

author maintainer
#12 lore raw

PATCH 6/6 ASoC: Intel: add support for new SoundWire hardware layout on TGL

In reply to Kai Vehmanen

From: Bard Liao <[email protected]>

The creativity of hardware folks is endless, with a complete permutation of rt711 (was link0 now link1), rt1308 (was link1 now link2) and rt715 (was link3 now link0).

Someday we will get all this information from platform firmware, for now let's add the mapping table.

---
 sound/soc/intel/boards/sof_sdw.c              |  9 ++++
 .../intel/common/soc-acpi-intel-tgl-match.c   | 53 +++++++++++++++++++
 2 files changed, 62 insertions(+)
sound/soc/intel/boards/sof_sdw.c +9 -0
index 8e191a8d5dc5..b56df04775c2 100644
@@ -48,6 +48,15 @@ static int sof_sdw_quirk_cb(const struct dmi_system_id *id)
 }
 
 static const struct dmi_system_id sof_sdw_quirk_table[] = {
+	{
+		.callback = sof_sdw_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
+			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A3E")
+		},
+		.driver_data = (void *)(SOF_RT711_JD_SRC_JD2 |
+					SOF_RT715_DAI_ID_FIX),
+	},
 	{
 		.callback = sof_sdw_quirk_cb,
 		.matches = {
sound/soc/intel/common/soc-acpi-intel-tgl-match.c +53 -0

83 lines not on this page · raw message

Signature · 1 line
2.27.0
maintainer
#13 lore raw
In reply to Kai Vehmanen
Quoted 6 lines · Kai Vehmanen

Series including fixes and improvements for Intel SoundWire machine drivers.

Bard Liao (1):
ASoC: Intel: add support for new SoundWire hardware layout on TGL

Quoted 7 lines

Pierre-Louis Bossart (4):
ASoC: Intel: sof_sdw: remove ternary operator
ASoC: Intel: add codec name prefix to ACPI machine description
ASoC: Intel: sof_sdw: remove hard-coded codec_conf table
ASoC: Intel: sof_sdw_rt700: add codec prefix

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/6] ASOC: Intel: sof_sdw: restore playback functionality with max98373 amps

      commit: 7cc3b56f7324ae120cf3ce57cf0366398eb02f60
[2/6] ASoC: Intel: sof_sdw: remove ternary operator
      commit: f1bf9a6b4e5ed3a764c1f5715a02f438b7c2889f
[3/6] ASoC: Intel: add codec name prefix to ACPI machine description
      commit: f93808308aab34071259fa8cffbda273bc346ea7
[4/6] ASoC: Intel: sof_sdw: remove hard-coded codec_conf table
      commit: 23c8aa3ebabf0008c1d05c38e9723e5deb720ba0
[5/6] ASoC: Intel: sof_sdw_rt700: add codec prefix
      commit: fbcc27d18115f5e2bdad15a087831190c3f05d9b
[6/6] ASoC: Intel: add support for new SoundWire hardware layout on TGL
      commit: e787f5b5b14061bf76518d780b9bc0e9e7dd2739

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark