Skip to contentSkip to conversation

ASoC: Intel: boards: add max98390 2/4 speakers support

PATCH Superseded Mac Chiang 2 participants 5 messages Sep 7, 2021 – Sep 9, 2021

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Mac Chiang

author
#0 lore raw

PATCH 1/1 ASoC: Intel: boards: add max98390 2/4 speakers support

Left/Right speakers and 4ch tdm playback
add echo reference capture
add bt offload support
add DMI_OEM_STRING for board varients

---
 sound/soc/intel/boards/Kconfig                |   1 +
 sound/soc/intel/boards/sof_maxim_common.c     | 155 ++++++++++++++++++
 sound/soc/intel/boards/sof_maxim_common.h     |  16 ++
 sound/soc/intel/boards/sof_rt5682.c           |  69 ++++++++
 .../intel/common/soc-acpi-intel-adl-match.c   |  13 ++
 sound/soc/sof/sof-pci-dev.c                   |   9 +
 6 files changed, 263 insertions(+)
sound/soc/intel/boards/Kconfig +1 -0
index 61b71d6c44cf..2c24d8a929a2 100644
@@ -470,6 +470,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
 	select SND_SOC_RT1015
 	select SND_SOC_RT1015P
 	select SND_SOC_RT5682_I2C
+	select SND_SOC_MAX98390
 	select SND_SOC_DMIC
 	select SND_SOC_HDAC_HDMI
 	select SND_SOC_INTEL_HDA_DSP_COMMON
sound/soc/intel/boards/sof_maxim_common.c +155 -0

161 lines not on this page · raw message

sound/soc/intel/boards/sof_maxim_common.h +16 -0
index 3ff5e8fec4de..412b9dd06bad 100644
@@ -24,6 +24,22 @@ int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd);
 void max_98373_set_codec_conf(struct snd_soc_card *card);
 int max_98373_trigger(struct snd_pcm_substream *substream, int cmd);
 
+/*
+ * Maxim MAX98390
+ */
+#define MAX_98390_CODEC_DAI     "max98390-aif1"
+#define MAX_98390_DEV0_NAME     "i2c-MX98390:00"
+#define MAX_98390_DEV1_NAME     "i2c-MX98390:01"
+#define MAX_98390_DEV2_NAME     "i2c-MX98390:02"
+#define MAX_98390_DEV3_NAME     "i2c-MX98390:03"
+
+extern struct snd_soc_dai_link_component max_98390_components[2];
+extern struct snd_soc_dai_link_component max_98390_4spk_components[4];
+extern struct snd_soc_ops max_98390_ops;
+extern const struct snd_soc_dapm_route max_98390_dapm_routes[];
+void max_98390_set_codec_conf(struct snd_soc_card *card, int ch);
+int max_98390_spk_codec_init(struct snd_soc_pcm_runtime *rtd);
+
 /*
  * Maxim MAX98357A/MAX98360A
  */
sound/soc/intel/boards/sof_rt5682.c +69 -0

111 lines not on this page · raw message

sound/soc/intel/common/soc-acpi-intel-adl-match.c +13 -0
index a0f6a69c7038..2db152998e4a 100644
@@ -280,6 +280,11 @@ static const struct snd_soc_acpi_codecs adl_max98357a_amp = {
 	.codecs = {"MX98357A"}
 };
 
+static const struct snd_soc_acpi_codecs adl_max98390_amp = {
+	.num_codecs = 1,
+	.codecs = {"MX98390"}
+};
+
 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
 	{
 		.id = "10EC5682",
@@ -297,6 +302,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
 		.sof_fw_filename = "sof-adl.ri",
 		.sof_tplg_filename = "sof-adl-max98357a-rt5682.tplg",
 	},
+	{
+		.id = "10EC5682",
+		.drv_name = "adl_max98390_rt5682",
+		.machine_quirk = snd_soc_acpi_codec_list,
+		.quirk_data = &adl_max98390_amp,
+		.sof_fw_filename = "sof-adl.ri",
+		.sof_tplg_filename = "sof-adl-max98390-rt5682.tplg",
+	},
 	{},
 };
 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);
sound/soc/sof/sof-pci-dev.c +9 -0
index bc9e70765678..eee73a91b7ff 100644
@@ -59,6 +59,15 @@ static const struct dmi_system_id sof_tplg_table[] = {
 		},
 		.driver_data = "sof-adl-rt5682-ssp0-max98373-ssp2.tplg",
 	},
+	{
+		.callback = sof_tplg_cb,
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
+			DMI_MATCH(DMI_OEM_STRING, "AUDIO-ADL_MAX98390_ALC5682I_I2S"),
+		},
+		.driver_data = "sof-adl-rt5682-ssp0-max98390-ssp2.tplg",
+	},
+
 	{}
 };
 
Signature · 1 line
2.20.1
#1 lore raw

Fixed Bard's address.

Quik summary: there are multiple issues below with rather unclear handling of two separate configurations.

Quoted 14 lines · Mac Chiang

Left/Right speakers and 4ch tdm playback
add echo reference capture
add bt offload support
add DMI_OEM_STRING for board varients

sound/soc/intel/boards/Kconfig +0 -0
index 61b71d6c44cf..2c24d8a929a2 100644

sound/soc/intel/boards/Kconfig config SND_SOC_INTEL_SOF_RT5682_MACH · line 473

Quoted 4 lines
sound/soc/intel/boards/Kconfig +1 -0
@@ -470,6 +470,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
 	select SND_SOC_RT1015
 	select SND_SOC_RT1015P
 	select SND_SOC_RT5682_I2C
+	select SND_SOC_MAX98390

can you move this up below the select SND_SOC_MAX98373_I2C

Quoted 3 lines
sound/soc/intel/boards/Kconfig +0 -0
 	select SND_SOC_DMIC
 	select SND_SOC_HDAC_HDMI
 	select SND_SOC_INTEL_HDA_DSP_COMMON

[...]

Quoted 51 lines
sound/soc/intel/boards/Kconfig +51 -0
+static struct snd_soc_codec_conf max_98390_codec_conf[] = {
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
+		.name_prefix = "Right",
+	},
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME),
+		.name_prefix = "Left",
+	},
+};
+
+static struct snd_soc_codec_conf max_98390_4spk_codec_conf[] = {
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
+		.name_prefix = "Right",
+	},
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME),
+		.name_prefix = "Left",
+	},
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV2_NAME),
+		.name_prefix = "Tweeter Right",
+	},
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV3_NAME),
+		.name_prefix = "Tweeter Left",
+	},
+};
+
+struct snd_soc_dai_link_component max_98390_components[] = {
+	{
+		.name = MAX_98390_DEV0_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+	{
+		.name = MAX_98390_DEV1_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+};
+EXPORT_SYMBOL_NS(max_98390_components, SND_SOC_INTEL_SOF_MAXIM_COMMON);
+
+struct snd_soc_dai_link_component max_98390_4spk_components[] = {
+	{
+		.name = MAX_98390_DEV0_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+	{
+		.name = MAX_98390_DEV1_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},

sound/soc/intel/boards/Kconfig

Quoted 10 lines
sound/soc/intel/boards/Kconfig +10 -0
+	{
+		.name = MAX_98390_DEV2_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+	{
+		.name = MAX_98390_DEV3_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+};
+EXPORT_SYMBOL_NS(max_98390_4spk_components, SND_SOC_INTEL_SOF_MAXIM_COMMON);

so until now you've described two possible configurations with 2 or 4 speakers, but below you assume 4?

Quoted 9 lines
sound/soc/intel/boards/Kconfig +9 -0
+static int max_98390_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+	struct snd_soc_dai *codec_dai;
+	int j;
+
+	for_each_rtd_codec_dais(rtd, j, codec_dai) {
+		if (!strcmp(codec_dai->component->name, MAX_98390_DEV0_NAME) ||

sound/soc/intel/boards/Kconfig

Quoted 10 lines
sound/soc/intel/boards/Kconfig +10 -0
+			!strcmp(codec_dai->component->name, MAX_98390_DEV2_NAME)) {
+			snd_soc_dai_set_tdm_slot(codec_dai, 0x03, 3, 4, 32);
+		}
+		if (!strcmp(codec_dai->component->name, MAX_98390_DEV1_NAME) ||
+			!strcmp(codec_dai->component->name, MAX_98390_DEV3_NAME)) {
+			snd_soc_dai_set_tdm_slot(codec_dai, 0x0C, 3, 4, 32);
+		}
+	}
+	return 0;
+}

what happens here if you only have 2 devices in the hardware configuration?

This seems different to what was done e.g. in cml_rt1011_rt5682 where the tdm slots were conditional on the quirk.

Quoted 26 lines
sound/soc/intel/boards/Kconfig +26 -0
+
+int max_98390_spk_codec_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_card *card = rtd->card;
+	int ret;
+
+	ret = snd_soc_dapm_new_controls(&card->dapm, max_98390_tt_dapm_widgets,
+						ARRAY_SIZE(max_98390_tt_dapm_widgets));
+	if (ret) {
+		dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret);
+		/* Don't need to add routes if widget addition failed */
+		return ret;
+	}
+
+	ret = snd_soc_add_card_controls(card, max_98390_tt_kcontrols,
+						ARRAY_SIZE(max_98390_tt_kcontrols));
+	if (ret) {
+		dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm, max_98373_dapm_routes,
+					ARRAY_SIZE(max_98373_dapm_routes));
+	if (ret) {
+		dev_err(rtd->dev, "Speaker Left, Right  map addition failed: %d\n", ret);
+		return ret;

sound/soc/intel/boards/Kconfig

Quoted 10 lines
sound/soc/intel/boards/Kconfig +10 -0
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm, max_98390_tt_dapm_routes,
+						ARRAY_SIZE(max_98390_tt_dapm_routes));
+	if (ret)
+		dev_err(rtd->dev, "Tweeter Speaker Left, Right map addition failed: %d\n", ret);
+
+	return ret;
+}
+EXPORT_SYMBOL_NS(max_98390_spk_codec_init, SND_SOC_INTEL_SOF_MAXIM_COMMON);

again what happens if you don't have tweeters in the configuration? Why would you add DAPM routes to a non-existent codec?

Quoted 85 lines
sound/soc/intel/boards/Kconfig +18 -0
+
+struct snd_soc_ops max_98390_ops = {
+	.hw_params = max_98390_hw_params,
+};
+EXPORT_SYMBOL_NS(max_98390_ops, SND_SOC_INTEL_SOF_MAXIM_COMMON);
+
+void max_98390_set_codec_conf(struct snd_soc_card *card, int ch)
+{
+	if (ch == ARRAY_SIZE(max_98390_4spk_codec_conf)) {
+		card->codec_conf = max_98390_4spk_codec_conf;
+		card->num_configs = ARRAY_SIZE(max_98390_4spk_codec_conf);
+	} else {
+		card->codec_conf = max_98390_codec_conf;
+		card->num_configs = ARRAY_SIZE(max_98390_codec_conf);
+	}
+}
+EXPORT_SYMBOL_NS(max_98390_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON);
+
 /*
  * Maxim MAX98357A/MAX98360A
  */
sound/soc/intel/boards/sof_maxim_common.h +16 -0
index 3ff5e8fec4de..412b9dd06bad 100644
@@ -24,6 +24,22 @@ int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd);
 void max_98373_set_codec_conf(struct snd_soc_card *card);
 int max_98373_trigger(struct snd_pcm_substream *substream, int cmd);
 
+/*
+ * Maxim MAX98390
+ */
+#define MAX_98390_CODEC_DAI     "max98390-aif1"
+#define MAX_98390_DEV0_NAME     "i2c-MX98390:00"
+#define MAX_98390_DEV1_NAME     "i2c-MX98390:01"
+#define MAX_98390_DEV2_NAME     "i2c-MX98390:02"
+#define MAX_98390_DEV3_NAME     "i2c-MX98390:03"
+
+extern struct snd_soc_dai_link_component max_98390_components[2];
+extern struct snd_soc_dai_link_component max_98390_4spk_components[4];
+extern struct snd_soc_ops max_98390_ops;
+extern const struct snd_soc_dapm_route max_98390_dapm_routes[];
+void max_98390_set_codec_conf(struct snd_soc_card *card, int ch);
+int max_98390_spk_codec_init(struct snd_soc_pcm_runtime *rtd);
+
 /*
  * Maxim MAX98357A/MAX98360A
  */
sound/soc/intel/boards/sof_rt5682.c +22 -0
index f096bd6d69be..e46438cca643 100644
@@ -49,6 +49,8 @@
 #define SOF_RT1015P_SPEAKER_AMP_PRESENT		BIT(16)
 #define SOF_MAX98373_SPEAKER_AMP_PRESENT	BIT(17)
 #define SOF_MAX98360A_SPEAKER_AMP_PRESENT	BIT(18)
+#define SOF_MAX98390_SPEAKER_AMP_PRESENT	BIT(23)
+#define SOF_MAX98390_TWEETER_SPEAKER_PRESENT	BIT(24)
 
 /* BT audio offload: reserve 3 bits for future */
 #define SOF_BT_OFFLOAD_SSP_SHIFT		19
@@ -176,6 +178,36 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
 					SOF_RT5682_SSP_AMP(2) |
 					SOF_RT5682_NUM_HDMIDEV(4)),
 	},
+	{
+		.callback = sof_rt5682_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
+			DMI_MATCH(DMI_OEM_STRING, "AUDIO-ADL_MAX98390_ALC5682I_I2S"),
+		},
+		.driver_data = (void *)(SOF_RT5682_MCLK_EN |
+					SOF_RT5682_SSP_CODEC(0) |
+					SOF_SPEAKER_AMP_PRESENT |
+					SOF_MAX98373_SPEAKER_AMP_PRESENT |
+					SOF_RT5682_SSP_AMP(2) |
+					SOF_RT5682_NUM_HDMIDEV(4)),
+	},
+	{
+		.callback = sof_rt5682_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
+			DMI_MATCH(DMI_OEM_STRING, "AUDIO-ADL_MAX98390_ALC5682I_I2S_4SPK"),
+		},
+		.driver_data = (void *)(SOF_RT5682_MCLK_EN |

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id sof_rt5682_quirk_table[] = { · line 210

Quoted 10 lines
sound/soc/intel/boards/sof_rt5682.c +10 -0
+					SOF_RT5682_SSP_CODEC(0) |
+					SOF_SPEAKER_AMP_PRESENT |
+					SOF_MAX98390_SPEAKER_AMP_PRESENT |
+					SOF_MAX98390_TWEETER_SPEAKER_PRESENT |
+					SOF_RT5682_SSP_AMP(1) |
+					SOF_RT5682_NUM_HDMIDEV(4) |
+					SOF_BT_OFFLOAD_SSP(2) |
+					SOF_SSP_BT_OFFLOAD_PRESENT),
+
+	},

so here the interesting part is that the amplifiers are not present on the same link, which means you need different topologies.

Quoted 16 lines
sound/soc/intel/boards/sof_rt5682.c +2 -0
 	{}
 };
 
@@ -459,6 +491,7 @@ static int sof_card_late_probe(struct snd_soc_card *card)
 		if (err < 0)
 			return err;
 	}
+
 	return hdac_hdmi_jack_port_init(component, &card->dapm);
 }
 
@@ -745,6 +778,21 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
 		} else if (sof_rt5682_quirk &
 				SOF_RT1011_SPEAKER_AMP_PRESENT) {
 			sof_rt1011_dai_link(&links[id]);
+		} else if (sof_rt5682_quirk &

sound/soc/intel/boards/sof_rt5682.c static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, · line 791

Quoted 10 lines
sound/soc/intel/boards/sof_rt5682.c +10 -0
+				SOF_MAX98390_SPEAKER_AMP_PRESENT) {
+			if (sof_rt5682_quirk &
+				SOF_MAX98390_TWEETER_SPEAKER_PRESENT) {
+				links[id].codecs = max_98390_4spk_components;
+				links[id].num_codecs = ARRAY_SIZE(max_98390_4spk_components);
+				links[id].init = max_98390_spk_codec_init;
+			} else {
+				links[id].codecs = max_98390_components;
+				links[id].num_codecs = ARRAY_SIZE(max_98390_components);
+				links[id].init = max_98373_spk_codec_init;

Not sure again how this works since you are using the same init function that internally does not check how many speakers there are.

Quoted 67 lines
sound/soc/intel/boards/sof_rt5682.c +25 -0
+			}
+			links[id].ops = &max_98390_ops;
+			links[id].dpcm_capture = 1;
+
 		} else {
 			max_98357a_dai_link(&links[id]);
 		}
@@ -881,6 +929,14 @@ static int sof_audio_probe(struct platform_device *pdev)
 		sof_rt1011_codec_conf(&sof_audio_card_rt5682);
 	else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT)
 		sof_rt1015p_codec_conf(&sof_audio_card_rt5682);
+	else if (sof_rt5682_quirk & SOF_MAX98390_SPEAKER_AMP_PRESENT) {
+		if (sof_rt5682_quirk & SOF_MAX98390_TWEETER_SPEAKER_PRESENT)
+			max_98390_set_codec_conf(&sof_audio_card_rt5682,
+						ARRAY_SIZE(max_98390_4spk_components));
+		else
+			max_98390_set_codec_conf(&sof_audio_card_rt5682,
+						ARRAY_SIZE(max_98390_components));
+	}
 
 	if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
 		sof_audio_card_rt5682.num_links++;
@@ -1007,6 +1063,18 @@ static const struct platform_device_id board_ids[] = {
 					SOF_RT5682_SSP_AMP(2) |
 					SOF_RT5682_NUM_HDMIDEV(4)),
 	},
+	{
+		.name = "adl_max98390_rt5682",
+		.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
+					SOF_RT5682_SSP_CODEC(0) |
+					SOF_SPEAKER_AMP_PRESENT |
+					SOF_MAX98390_SPEAKER_AMP_PRESENT |
+					SOF_RT5682_SSP_AMP(1) |
+					SOF_RT5682_NUM_HDMIDEV(4) |
+					SOF_BT_OFFLOAD_SSP(2) |
+					SOF_SSP_BT_OFFLOAD_PRESENT),
+	},
+
 	{ }
 };
 MODULE_DEVICE_TABLE(platform, board_ids);
@@ -1026,6 +1094,7 @@ MODULE_DESCRIPTION("SOF Audio Machine driver");
 MODULE_AUTHOR("Bard Liao <[email protected]>");
 MODULE_AUTHOR("Sathya Prakash M R <[email protected]>");
 MODULE_AUTHOR("Brent Lu <[email protected]>");
+MODULE_AUTHOR("Mac Chiang <[email protected]>");
 MODULE_LICENSE("GPL v2");
 MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
 MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
sound/soc/intel/common/soc-acpi-intel-adl-match.c +5 -0
index a0f6a69c7038..2db152998e4a 100644
@@ -280,6 +280,11 @@ static const struct snd_soc_acpi_codecs adl_max98357a_amp = {
 	.codecs = {"MX98357A"}
 };
 
+static const struct snd_soc_acpi_codecs adl_max98390_amp = {
+	.num_codecs = 1,
+	.codecs = {"MX98390"}
+};
+
 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
 	{
 		.id = "10EC5682",
@@ -297,6 +302,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
 		.sof_fw_filename = "sof-adl.ri",

sound/soc/intel/common/soc-acpi-intel-adl-match.c struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { · line 312

Quoted 10 lines
sound/soc/intel/common/soc-acpi-intel-adl-match.c +8 -0
 		.sof_tplg_filename = "sof-adl-max98357a-rt5682.tplg",
 	},
+	{
+		.id = "10EC5682",
+		.drv_name = "adl_max98390_rt5682",
+		.machine_quirk = snd_soc_acpi_codec_list,
+		.quirk_data = &adl_max98390_amp,
+		.sof_fw_filename = "sof-adl.ri",
+		.sof_tplg_filename = "sof-adl-max98390-rt5682.tplg",
+	},

that seems to be problematic, you are using the *same* topology for two different hardware configurations, where the amplifiers can be on SSP 1 or SSP2.

This entry will be selected no matter how many MAX98390 amps are present on the board.

How does this work?

Quoted 10 lines
sound/soc/intel/common/soc-acpi-intel-adl-match.c +0 -0
 	{},
 };
 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);
sound/soc/sof/sof-pci-dev.c +0 -0
index bc9e70765678..eee73a91b7ff 100644
@@ -59,6 +59,15 @@ static const struct dmi_system_id sof_tplg_table[] = {
 		},
 		.driver_data = "sof-adl-rt5682-ssp0-max98373-ssp2.tplg",

sound/soc/sof/sof-pci-dev.c static const struct dmi_system_id sof_tplg_table[] = { · line 70

Quoted 10 lines
sound/soc/sof/sof-pci-dev.c +9 -0
 	},
+	{
+		.callback = sof_tplg_cb,
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
+			DMI_MATCH(DMI_OEM_STRING, "AUDIO-ADL_MAX98390_ALC5682I_I2S"),
+		},
+		.driver_data = "sof-adl-rt5682-ssp0-max98390-ssp2.tplg",
+	},
+

And here you don't have a quirk to select the 4-channel version?

sound/soc/sof/sof-pci-dev.c static const struct dmi_system_id sof_tplg_table[] = { · line 73

Quoted 4 lines
sound/soc/sof/sof-pci-dev.c +0 -0
 	{}
 };
 

It really feels like part of the code is a placeholder that was never tested...

#2 lore raw
Quoted 4 lines

Fixed Bard's address.

Quik summary: there are multiple issues below with rather unclear handling of two separate configurations.

There are 3 hw boards support, I summarize as below:
1. SSP2 connects 98390, with 2 speakers.
2. SSP1 connects 98390, with 2 speakers or 4 speakers. Thanks Piere. Please review my comments if I misunderstand.

Quoted 10 lines · Mac Chiang
Quoted 4 lines

Left/Right speakers and 4ch tdm playback add echo reference capture add bt offload support add DMI_OEM_STRING for board varients

partner.google.com>

Quoted 2 lines
Quoted 12 lines

sound/soc/intel/boards/Kconfig config SND_SOC_INTEL_SOF_RT5682_MACH · line 473

Quoted 10 lines
(quoted diff) +0 -0

b/sound/soc/intel/boards/Kconfig index 61b71d6c44cf..2c24d8a929a2 100644

sound/soc/intel/boards/Kconfig +1 -0
@@ -470,6 +470,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
 	select SND_SOC_RT1015
 	select SND_SOC_RT1015P
 	select SND_SOC_RT5682_I2C
+	select SND_SOC_MAX98390

can you move this up below the select SND_SOC_MAX98373_I2C

Ok.

Quoted 65 lines
Quoted 4 lines
sound/soc/intel/boards/Kconfig +0 -0
 	select SND_SOC_DMIC
 	select SND_SOC_HDAC_HDMI
 	select SND_SOC_INTEL_HDA_DSP_COMMON

[...]

Quoted 58 lines
sound/soc/intel/boards/Kconfig +58 -0
+static struct snd_soc_codec_conf max_98390_codec_conf[] = {
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
+		.name_prefix = "Right",
+	},
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME),
+		.name_prefix = "Left",
+	},
+};
+
+static struct snd_soc_codec_conf max_98390_4spk_codec_conf[] = {
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
+		.name_prefix = "Right",
+	},
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME),
+		.name_prefix = "Left",
+	},
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV2_NAME),
+		.name_prefix = "Tweeter Right",
+	},
+	{
+		.dlc = COMP_CODEC_CONF(MAX_98390_DEV3_NAME),
+		.name_prefix = "Tweeter Left",
+	},
+};
+
+struct snd_soc_dai_link_component max_98390_components[] = {
+	{
+		.name = MAX_98390_DEV0_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+	{
+		.name = MAX_98390_DEV1_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+};
+EXPORT_SYMBOL_NS(max_98390_components,
+SND_SOC_INTEL_SOF_MAXIM_COMMON);
+
+struct snd_soc_dai_link_component max_98390_4spk_components[] = {
+	{
+		.name = MAX_98390_DEV0_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+	{
+		.name = MAX_98390_DEV1_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+	{
+		.name = MAX_98390_DEV2_NAME,
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+	{
+		.name = MAX_98390_DEV3_NAME,
Quoted 8 lines

sound/soc/intel/boards/Kconfig

Quoted 5 lines
sound/soc/intel/boards/Kconfig +5 -0
+		.dai_name = MAX_98390_CODEC_DAI,
+	},
+};
+EXPORT_SYMBOL_NS(max_98390_4spk_components,
+SND_SOC_INTEL_SOF_MAXIM_COMMON);

so until now you've described two possible configurations with 2 or 4 speakers, but below you assume 4?

Should check 2 or 4 quirk separately.

if (sof_rt1011_quirk & (SOF_MAX98390_SPEAKER_PRESENT)) {
	if (!strcmp(codec_dai->component->name, MAX_98390_DEV0_NAME)) {
	if (!strcmp(codec_dai->component->name, MAX_98390_DEV1_NAME)) {
Quoted 27 lines

sound/soc/intel/boards/Kconfig

Quoted 4 lines
sound/soc/intel/boards/Kconfig +3 -0
+static int max_98390_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params) {
+	struct snd_soc_pcm_runtime *rtd =

asoc_substream_to_rtd(substream);

sound/soc/intel/boards/Kconfig

Quoted 5 lines
sound/soc/intel/boards/Kconfig +5 -0
+	struct snd_soc_dai *codec_dai;
+	int j;
+
+	for_each_rtd_codec_dais(rtd, j, codec_dai) {
+		if (!strcmp(codec_dai->component->name,

MAX_98390_DEV0_NAME) ||

sound/soc/intel/boards/Kconfig

Quoted 1 line
sound/soc/intel/boards/Kconfig +1 -0
+			!strcmp(codec_dai->component->name,

MAX_98390_DEV2_NAME)) {

sound/soc/intel/boards/Kconfig

Quoted 3 lines
sound/soc/intel/boards/Kconfig +3 -0
+			snd_soc_dai_set_tdm_slot(codec_dai, 0x03, 3, 4, 32);
+		}
+		if (!strcmp(codec_dai->component->name,

MAX_98390_DEV1_NAME) ||

sound/soc/intel/boards/Kconfig

Quoted 1 line
sound/soc/intel/boards/Kconfig +1 -0
+			!strcmp(codec_dai->component->name,

MAX_98390_DEV3_NAME)) {

sound/soc/intel/boards/Kconfig

Quoted 5 lines
sound/soc/intel/boards/Kconfig +5 -0
+			snd_soc_dai_set_tdm_slot(codec_dai, 0x0C, 3, 4, 32);
+		}
+	}
+	return 0;
+}

what happens here if you only have 2 devices in the hardware configuration?

Quoted 2 lines

This seems different to what was done e.g. in cml_rt1011_rt5682 where the tdm slots were conditional on the quirk.

Thanks, I should check by 2 or 4 quirk separately.

Quoted 43 lines

sound/soc/intel/boards/Kconfig

Quoted 7 lines
sound/soc/intel/boards/Kconfig +6 -0
+
+int max_98390_spk_codec_init(struct snd_soc_pcm_runtime *rtd) {
+	struct snd_soc_card *card = rtd->card;
+	int ret;
+
+	ret = snd_soc_dapm_new_controls(&card->dapm,

max_98390_tt_dapm_widgets,

Quoted 1 line

+

	ARRAY_SIZE(max_98390_tt_dapm_widgets));

sound/soc/intel/boards/Kconfig

Quoted 2 lines
sound/soc/intel/boards/Kconfig +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "unable to add dapm controls, ret %d\n",

ret);

sound/soc/intel/boards/Kconfig

Quoted 6 lines
sound/soc/intel/boards/Kconfig +6 -0
+		/* Don't need to add routes if widget addition failed */
+		return ret;
+	}
+
+	ret = snd_soc_add_card_controls(card, max_98390_tt_kcontrols,
+
	ARRAY_SIZE(max_98390_tt_kcontrols));

sound/soc/intel/boards/Kconfig

Quoted 2 lines
sound/soc/intel/boards/Kconfig +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "unable to add card controls, ret %d\n",

ret);

sound/soc/intel/boards/Kconfig

Quoted 4 lines
sound/soc/intel/boards/Kconfig +4 -0
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm,

max_98373_dapm_routes,

Quoted 1 line

+

	ARRAY_SIZE(max_98373_dapm_routes));

sound/soc/intel/boards/Kconfig

Quoted 2 lines
sound/soc/intel/boards/Kconfig +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "Speaker Left, Right  map addition failed:

%d\n", ret);

sound/soc/intel/boards/Kconfig

Quoted 4 lines
sound/soc/intel/boards/Kconfig +4 -0
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm,

max_98390_tt_dapm_routes,

Quoted 1 line

+

	ARRAY_SIZE(max_98390_tt_dapm_routes));

sound/soc/intel/boards/Kconfig

Quoted 2 lines
sound/soc/intel/boards/Kconfig +2 -0
+	if (ret)
+		dev_err(rtd->dev, "Tweeter Speaker Left, Right map addition

failed:

Quoted 9 lines

sound/soc/intel/boards/Kconfig

Quoted 6 lines

+%d\n", ret);

sound/soc/intel/boards/Kconfig +5 -0
+
+	return ret;
+}
+EXPORT_SYMBOL_NS(max_98390_spk_codec_init,
+SND_SOC_INTEL_SOF_MAXIM_COMMON);

again what happens if you don't have tweeters in the configuration? Why would you add DAPM routes to a non-existent codec?

Without tweeter quirk, it goes to apply max_98390_codec_conf from max_98390_set_codec_conf() With tweeter quirk, it goes to apply max_98390_4spk_codec_conf from max_98390_set_codec_conf()

Quoted 78 lines

sound/soc/intel/boards/Kconfig

Quoted 6 lines
sound/soc/intel/boards/Kconfig +5 -0
+
+struct snd_soc_ops max_98390_ops = {
+	.hw_params = max_98390_hw_params,
+};
+EXPORT_SYMBOL_NS(max_98390_ops,

SND_SOC_INTEL_SOF_MAXIM_COMMON);

sound/soc/intel/boards/Kconfig

Quoted 5 lines
sound/soc/intel/boards/Kconfig +5 -0
+
+void max_98390_set_codec_conf(struct snd_soc_card *card, int ch) {
+	if (ch == ARRAY_SIZE(max_98390_4spk_codec_conf)) {
+		card->codec_conf = max_98390_4spk_codec_conf;
+		card->num_configs =

ARRAY_SIZE(max_98390_4spk_codec_conf);

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id

Quoted 56 lines
sound/soc/intel/boards/Kconfig +8 -0
+	} else {
+		card->codec_conf = max_98390_codec_conf;
+		card->num_configs = ARRAY_SIZE(max_98390_codec_conf);
+	}
+}
+EXPORT_SYMBOL_NS(max_98390_set_codec_conf,
+SND_SOC_INTEL_SOF_MAXIM_COMMON);
+
 /*
  * Maxim MAX98357A/MAX98360A
  */
sound/soc/intel/boards/sof_maxim_common.h +0 -0
index 3ff5e8fec4de..412b9dd06bad 100644
@@ -24,6 +24,22 @@ int max_98373_spk_codec_init(struct

snd_soc_pcm_runtime *rtd); void max_98373_set_codec_conf(struct snd_soc_card *card); int max_98373_trigger(struct snd_pcm_substream *substream, int cmd);

sound/soc/intel/boards/sof_maxim_common.h +17 -0
+/*
+ * Maxim MAX98390
+ */
+#define MAX_98390_CODEC_DAI     "max98390-aif1"
+#define MAX_98390_DEV0_NAME     "i2c-MX98390:00"
+#define MAX_98390_DEV1_NAME     "i2c-MX98390:01"
+#define MAX_98390_DEV2_NAME     "i2c-MX98390:02"
+#define MAX_98390_DEV3_NAME     "i2c-MX98390:03"
+
+extern struct snd_soc_dai_link_component max_98390_components[2];
+extern struct snd_soc_dai_link_component
+max_98390_4spk_components[4]; extern struct snd_soc_ops
+max_98390_ops; extern const struct snd_soc_dapm_route
+max_98390_dapm_routes[]; void max_98390_set_codec_conf(struct
+snd_soc_card *card, int ch); int max_98390_spk_codec_init(struct
+snd_soc_pcm_runtime *rtd);
+
 /*
  * Maxim MAX98357A/MAX98360A
  */
sound/soc/intel/boards/sof_rt5682.c +2 -0
index f096bd6d69be..e46438cca643 100644
@@ -49,6 +49,8 @@
 #define SOF_RT1015P_SPEAKER_AMP_PRESENT		BIT(16)
 #define SOF_MAX98373_SPEAKER_AMP_PRESENT	BIT(17)
 #define SOF_MAX98360A_SPEAKER_AMP_PRESENT	BIT(18)
+#define SOF_MAX98390_SPEAKER_AMP_PRESENT	BIT(23)
+#define SOF_MAX98390_TWEETER_SPEAKER_PRESENT	BIT(24)
 
 /* BT audio offload: reserve 3 bits for future */
 #define SOF_BT_OFFLOAD_SSP_SHIFT		19
@@ -176,6 +178,36 @@ static const struct dmi_system_id

sof_rt5682_quirk_table[] = {

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id sof_rt5682_quirk_table[] = {

Quoted 7 lines
sound/soc/intel/boards/sof_rt5682.c +4 -0
 					SOF_RT5682_SSP_AMP(2) |
 					SOF_RT5682_NUM_HDMIDEV(4)),
 	},
+	{
+		.callback = sof_rt5682_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_FAMILY,

"Google_Brya"),

Quoted 8 lines

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id · line 185

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+			DMI_MATCH(DMI_OEM_STRING, "AUDIO-

ADL_MAX98390_ALC5682I_I2S"),

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id sof_rt5682_quirk_table[] = { · line 209

Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +5 -0
+		},
+		.driver_data = (void *)(SOF_RT5682_MCLK_EN |
+					SOF_RT5682_SSP_CODEC(0) |
+					SOF_SPEAKER_AMP_PRESENT |
+
	SOF_MAX98373_SPEAKER_AMP_PRESENT |

My bad. Should modify to SOF_MAX98390_SPEAKER_AMP_PRESENT

Quoted 18 lines

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id sof_rt5682_quirk_table[] = {

Quoted 7 lines
sound/soc/intel/boards/sof_rt5682.c +7 -0
+					SOF_RT5682_SSP_AMP(2) |
+					SOF_RT5682_NUM_HDMIDEV(4)),
+	},
+	{
+		.callback = sof_rt5682_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_FAMILY,

"Google_Brya"),

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id · line 198

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+			DMI_MATCH(DMI_OEM_STRING, "AUDIO-

ADL_MAX98390_ALC5682I_I2S_4SPK"),

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id sof_rt5682_quirk_table[] = { · line 209

Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +5 -0
+		},
+		.driver_data = (void *)(SOF_RT5682_MCLK_EN |
+					SOF_RT5682_SSP_CODEC(0) |
+					SOF_SPEAKER_AMP_PRESENT |
+
	SOF_MAX98390_SPEAKER_AMP_PRESENT |

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id · line 204

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+
	SOF_MAX98390_TWEETER_SPEAKER_PRESENT |
Quoted 9 lines

sound/soc/intel/boards/sof_rt5682.c static const struct dmi_system_id sof_rt5682_quirk_table[] = { · line 210

Quoted 6 lines
sound/soc/intel/boards/sof_rt5682.c +6 -0
+					SOF_RT5682_SSP_AMP(1) |
+					SOF_RT5682_NUM_HDMIDEV(4) |
+					SOF_BT_OFFLOAD_SSP(2) |
+					SOF_SSP_BT_OFFLOAD_PRESENT),
+
+	},

so here the interesting part is that the amplifiers are not present on the same link, which means you need different topologies.

Yes, you are right by loading different topology name.

Quoted 31 lines

sound/soc/intel/boards/sof_rt5682.c static int sof_card_late_probe(struct snd_soc_card

Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +0 -0
 	{}
 };
 
@@ -459,6 +491,7 @@ static int sof_card_late_probe(struct snd_soc_card

*card)

sound/soc/intel/boards/sof_rt5682.c static struct snd_soc_dai_link

Quoted 7 lines
sound/soc/intel/boards/sof_rt5682.c +1 -0
 		if (err < 0)
 			return err;
 	}
+
 	return hdac_hdmi_jack_port_init(component, &card->dapm);  }
 
@@ -745,6 +778,21 @@ static struct snd_soc_dai_link

*sof_card_dai_links_create(struct device *dev,

sound/soc/intel/boards/sof_rt5682.c static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, · line 795

Quoted 7 lines
sound/soc/intel/boards/sof_rt5682.c +4 -0
 		} else if (sof_rt5682_quirk &
 				SOF_RT1011_SPEAKER_AMP_PRESENT) {
 			sof_rt1011_dai_link(&links[id]);
+		} else if (sof_rt5682_quirk &
+				SOF_MAX98390_SPEAKER_AMP_PRESENT) {
+			if (sof_rt5682_quirk &
+
	SOF_MAX98390_TWEETER_SPEAKER_PRESENT) {

sound/soc/intel/boards/sof_rt5682.c static struct snd_soc_dai_link · line 785

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+				links[id].codecs =

max_98390_4spk_components;

sound/soc/intel/boards/sof_rt5682.c static struct snd_soc_dai_link · line 786

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+				links[id].num_codecs =

ARRAY_SIZE(max_98390_4spk_components);

sound/soc/intel/boards/sof_rt5682.c static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,

Quoted 4 lines
sound/soc/intel/boards/sof_rt5682.c +4 -0
+				links[id].init = max_98390_spk_codec_init;
+			} else {
+				links[id].codecs = max_98390_components;
+				links[id].num_codecs =

ARRAY_SIZE(max_98390_components);

Quoted 4 lines

sound/soc/intel/boards/sof_rt5682.c static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, · line 791

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+				links[id].init = max_98373_spk_codec_init;

Not sure again how this works since you are using the same init function that internally does not check how many speakers there are.

2 speakers initially reuse the max_98373_spk_codec_init, because the dapm routes is identical "Left/Right Spk" 4 speakers apply new init for dapm "Left/Right Spk" and "Tweeter Left/ Right Spk" together

Quoted 96 lines

sound/soc/intel/boards/sof_rt5682.c static int sof_audio_probe(struct platform_device

Quoted 9 lines
sound/soc/intel/boards/sof_rt5682.c +4 -0
+			}
+			links[id].ops = &max_98390_ops;
+			links[id].dpcm_capture = 1;
+
 		} else {
 			max_98357a_dai_link(&links[id]);
 		}
@@ -881,6 +929,14 @@ static int sof_audio_probe(struct platform_device

*pdev)

sound/soc/intel/boards/sof_rt5682.c static int sof_audio_probe(struct platform_device *pdev)

Quoted 4 lines
sound/soc/intel/boards/sof_rt5682.c +1 -0
 		sof_rt1011_codec_conf(&sof_audio_card_rt5682);
 	else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT)
 		sof_rt1015p_codec_conf(&sof_audio_card_rt5682);
+	else if (sof_rt5682_quirk &

SOF_MAX98390_SPEAKER_AMP_PRESENT) {

sound/soc/intel/boards/sof_rt5682.c static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, · line 783

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+		if (sof_rt5682_quirk &

SOF_MAX98390_TWEETER_SPEAKER_PRESENT)

sound/soc/intel/boards/sof_rt5682.c static int sof_audio_probe(struct platform_device · line 934

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+
	max_98390_set_codec_conf(&sof_audio_card_rt5682,

sound/soc/intel/boards/sof_rt5682.c static int sof_audio_probe(struct platform_device · line 935

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+
	ARRAY_SIZE(max_98390_4spk_components));

sound/soc/intel/boards/sof_rt5682.c static int sof_audio_probe(struct platform_device · line 937

Quoted 2 lines
sound/soc/intel/boards/sof_rt5682.c +2 -0
+		else
+
	max_98390_set_codec_conf(&sof_audio_card_rt5682,

sound/soc/intel/boards/sof_rt5682.c static int sof_audio_probe(struct platform_device · line 938

Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1 -0
+
	ARRAY_SIZE(max_98390_components));

sound/soc/intel/boards/sof_rt5682.c static const struct platform_device_id

Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +1 -0
+	}
 
 	if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
 		sof_audio_card_rt5682.num_links++;
@@ -1007,6 +1063,18 @@ static const struct platform_device_id

board_ids[] = {

sound/soc/intel/boards/sof_rt5682.c static const struct platform_device_id board_ids[] = { · line 1077

Quoted 9 lines
sound/soc/intel/boards/sof_rt5682.c +6 -0
 					SOF_RT5682_SSP_AMP(2) |
 					SOF_RT5682_NUM_HDMIDEV(4)),
 	},
+	{
+		.name = "adl_max98390_rt5682",
+		.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
+					SOF_RT5682_SSP_CODEC(0) |
+					SOF_SPEAKER_AMP_PRESENT |
+
	SOF_MAX98390_SPEAKER_AMP_PRESENT |
Quoted 10 lines
sound/soc/intel/boards/sof_rt5682.c +6 -0
+					SOF_RT5682_SSP_AMP(1) |
+					SOF_RT5682_NUM_HDMIDEV(4) |
+					SOF_BT_OFFLOAD_SSP(2) |
+					SOF_SSP_BT_OFFLOAD_PRESENT),
+	},
+
 	{ }
 };
 MODULE_DEVICE_TABLE(platform, board_ids); @@ -1026,6 +1094,7 @@

MODULE_DESCRIPTION("SOF Audio Machine driver");

MODULE_AUTHOR("Bard

sound/soc/intel/common/soc-acpi-intel-adl-match.c static const struct snd_soc_acpi_codecs

Quoted 13 lines

Liao <[email protected]>"); MODULE_AUTHOR("Sathya Prakash M R <[email protected]>"); MODULE_AUTHOR("Brent Lu <[email protected]>");

sound/soc/intel/boards/sof_rt5682.c +1 -0
+MODULE_AUTHOR("Mac Chiang <[email protected]>");
 MODULE_LICENSE("GPL v2");
 MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
 MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
sound/soc/intel/common/soc-acpi-intel-adl-match.c +0 -0
index a0f6a69c7038..2db152998e4a 100644
@@ -280,6 +280,11 @@ static const struct snd_soc_acpi_codecs

adl_max98357a_amp = {

sound/soc/intel/common/soc-acpi-intel-adl-match.c struct snd_soc_acpi_mach

Quoted 12 lines
sound/soc/intel/common/soc-acpi-intel-adl-match.c +5 -0
 	.codecs = {"MX98357A"}
 };
 
+static const struct snd_soc_acpi_codecs adl_max98390_amp = {
+	.num_codecs = 1,
+	.codecs = {"MX98390"}
+};
+
 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
 	{
 		.id = "10EC5682",
@@ -297,6 +302,14 @@ struct snd_soc_acpi_mach

snd_soc_acpi_intel_adl_machines[] = {

sound/soc/intel/common/soc-acpi-intel-adl-match.c struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { · line 312

Quoted 11 lines
sound/soc/intel/common/soc-acpi-intel-adl-match.c +8 -0
 		.sof_fw_filename = "sof-adl.ri",
 		.sof_tplg_filename = "sof-adl-max98357a-rt5682.tplg",
 	},
+	{
+		.id = "10EC5682",
+		.drv_name = "adl_max98390_rt5682",
+		.machine_quirk = snd_soc_acpi_codec_list,
+		.quirk_data = &adl_max98390_amp,
+		.sof_fw_filename = "sof-adl.ri",
+		.sof_tplg_filename = "sof-adl-max98390-rt5682.tplg",
+	},

that seems to be problematic, you are using the *same* topology for two different hardware configurations, where the amplifiers can be on SSP 1 or SSP2.

Quoted 4 lines

This entry will be selected no matter how many MAX98390 amps are present on the board.

How does this work?

Thanks, you are right. Two separate tplgs require. sof-adl-max98390-rt5682.tplg and sof-adl-max98390-4ch-rt5682.tplg.

Quoted 17 lines
Quoted 9 lines
sound/soc/intel/common/soc-acpi-intel-adl-match.c +0 -0
 	{},
 };
 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);
sound/soc/sof/sof-pci-dev.c +0 -0
index bc9e70765678..eee73a91b7ff 100644

sound/soc/sof/sof-pci-dev.c static const struct dmi_system_id sof_tplg_table[] = { · line 65

Quoted 7 lines
sound/soc/sof/sof-pci-dev.c +4 -0
@@ -59,6 +59,15 @@ static const struct dmi_system_id sof_tplg_table[] = {
 		},
 		.driver_data = "sof-adl-rt5682-ssp0-max98373-ssp2.tplg",
 	},
+	{
+		.callback = sof_tplg_cb,
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_FAMILY,

"Google_Brya"),

Quoted 8 lines

sound/soc/sof/sof-pci-dev.c static const struct dmi_system_id sof_tplg_table[] = { · line 66

Quoted 1 line
sound/soc/sof/sof-pci-dev.c +1 -0
+			DMI_MATCH(DMI_OEM_STRING, "AUDIO-

ADL_MAX98390_ALC5682I_I2S"),

sound/soc/sof/sof-pci-dev.c static const struct dmi_system_id sof_tplg_table[] = { · line 70

Quoted 4 lines
sound/soc/sof/sof-pci-dev.c +4 -0
+		},
+		.driver_data = "sof-adl-rt5682-ssp0-max98390-ssp2.tplg",
+	},
+

And here you don't have a quirk to select the 4-channel version?

I lost the 4 speakers tplg version here. Will add it.

Quoted 7 lines

sound/soc/sof/sof-pci-dev.c static const struct dmi_system_id sof_tplg_table[] = { · line 73

Quoted 5 lines
sound/soc/sof/sof-pci-dev.c +0 -0
 	{}
 };
 

It really feels like part of the code is a placeholder that was never tested...

We verified the 4 speakers board and SSP2 2 speakers board. To be verified on new EVT SSP1 2 speakers.

#3 lore raw
Quoted 8 lines · Mac
Quoted 4 lines

Fixed Bard's address.

Quik summary: there are multiple issues below with rather unclear handling of two separate configurations.

There are 3 hw boards support, I summarize as below:
1. SSP2 connects 98390, with 2 speakers.
2. SSP1 connects 98390, with 2 speakers or 4 speakers. Thanks Piere. Please review my comments if I misunderstand.

Please clearly identify these configurations in the next revision, thanks!

Quoted 50 lines
Quoted 41 lines

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card)

Quoted 5 lines
sound/soc/intel/boards/sof_maxim_common.c +5 -0
+int max_98390_spk_codec_init(struct snd_soc_pcm_runtime *rtd) {
+	struct snd_soc_card *card = rtd->card;
+	int ret;
+
+	ret = snd_soc_dapm_new_controls(&card->dapm,

max_98390_tt_dapm_widgets,

Quoted 1 line

+

	ARRAY_SIZE(max_98390_tt_dapm_widgets));

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "unable to add dapm controls, ret %d\n",

ret);

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card) · line 257

Quoted 6 lines
sound/soc/intel/boards/sof_maxim_common.c +6 -0
+		/* Don't need to add routes if widget addition failed */
+		return ret;
+	}
+
+	ret = snd_soc_add_card_controls(card, max_98390_tt_kcontrols,
+
	ARRAY_SIZE(max_98390_tt_kcontrols));

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "unable to add card controls, ret %d\n",

ret);

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card)

Quoted 4 lines
sound/soc/intel/boards/sof_maxim_common.c +4 -0
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm,

max_98373_dapm_routes,

Quoted 1 line

+

	ARRAY_SIZE(max_98373_dapm_routes));

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "Speaker Left, Right  map addition failed:

%d\n", ret);

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card)

Quoted 4 lines
sound/soc/intel/boards/sof_maxim_common.c +4 -0
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm,

max_98390_tt_dapm_routes,

Quoted 1 line

+

	ARRAY_SIZE(max_98390_tt_dapm_routes));

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret)
+		dev_err(rtd->dev, "Tweeter Speaker Left, Right map addition

failed:

Quoted 9 lines

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card)

Quoted 6 lines

+%d\n", ret);

sound/soc/intel/boards/sof_maxim_common.c +5 -0
+
+	return ret;
+}
+EXPORT_SYMBOL_NS(max_98390_spk_codec_init,
+SND_SOC_INTEL_SOF_MAXIM_COMMON);

again what happens if you don't have tweeters in the configuration? Why would you add DAPM routes to a non-existent codec?

Quoted 2 lines

Without tweeter quirk, it goes to apply max_98390_codec_conf from max_98390_set_codec_conf() With tweeter quirk, it goes to apply max_98390_4spk_codec_conf from max_98390_set_codec_conf()

what I meant here is that you will add the max_98390_tt_dapm_routes even in the two speaker case. That doesn't seem right?

#4 lore raw
Quoted 11 lines · Mac
Quoted 8 lines
Quoted 4 lines

Fixed Bard's address.

Quik summary: there are multiple issues below with rather unclear handling of two separate configurations.

There are 3 hw boards support, I summarize as below:
1. SSP2 connects 98390, with 2 speakers.
2. SSP1 connects 98390, with 2 speakers or 4 speakers. Thanks Piere. Please review my comments if I misunderstand.

Please clearly identify these configurations in the next revision, thanks!

Ok.

Quoted 52 lines
Quoted 52 lines
Quoted 52 lines

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card)

Quoted 7 lines
sound/soc/intel/boards/sof_maxim_common.c +5 -0
+int max_98390_spk_codec_init(struct snd_soc_pcm_runtime *rtd) {
+	struct snd_soc_card *card = rtd->card;
+	int ret;
+
+	ret = snd_soc_dapm_new_controls(&card->dapm,

max_98390_tt_dapm_widgets,

Quoted 1 line

+

	ARRAY_SIZE(max_98390_tt_dapm_widgets));

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "unable to add dapm controls, ret %d\n",

ret);

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card) · line 257

Quoted 6 lines
sound/soc/intel/boards/sof_maxim_common.c +6 -0
+		/* Don't need to add routes if widget addition failed */
+		return ret;
+	}
+
+	ret = snd_soc_add_card_controls(card, max_98390_tt_kcontrols,
+
	ARRAY_SIZE(max_98390_tt_kcontrols));

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "unable to add card controls, ret %d\n",

ret);

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card)

Quoted 4 lines
sound/soc/intel/boards/sof_maxim_common.c +4 -0
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm,

max_98373_dapm_routes,

Quoted 1 line

+

	ARRAY_SIZE(max_98373_dapm_routes));

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret) {
+		dev_err(rtd->dev, "Speaker Left, Right  map addition failed:

%d\n", ret);

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card)

Quoted 4 lines
sound/soc/intel/boards/sof_maxim_common.c +4 -0
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm,

max_98390_tt_dapm_routes,

Quoted 1 line

+

	ARRAY_SIZE(max_98390_tt_dapm_routes));

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret)
+		dev_err(rtd->dev, "Tweeter Speaker Left, Right map addition

failed:

sound/soc/intel/boards/sof_maxim_common.c void max_98373_set_codec_conf(struct snd_soc_card *card)

Quoted 6 lines

+%d\n", ret);

sound/soc/intel/boards/sof_maxim_common.c +5 -0
+
+	return ret;
+}
+EXPORT_SYMBOL_NS(max_98390_spk_codec_init,
+SND_SOC_INTEL_SOF_MAXIM_COMMON);

again what happens if you don't have tweeters in the configuration? Why would you add DAPM routes to a non-existent codec?

Quoted 6 lines
Quoted 3 lines

Without tweeter quirk, it goes to apply max_98390_codec_conf from max_98390_set_codec_conf() With tweeter quirk, it goes to apply max_98390_4spk_codec_conf from max_98390_set_codec_conf()

what I meant here is that you will add the max_98390_tt_dapm_routes even in the two speaker case. That doesn't seem right?

max_98390_tt_dapm_routes will be apply only when 4SPK quirk. In two speakers quirk. the .init reuse the max_98373_spk_codec_init, so it added the max_98373_dapm_routes "Left/Right Spk" alone.