Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: sn624x: honor ACPI DisCo when MIC SDCA function is absent
@ 2026-11-17  1:35 Qianghua Wang
  2026-11-17  1:51 ` sashiko-bot
  2026-11-17  2:46 ` [PATCH v2] ASoC: sn624x: skip DMIC when ACPI DisCo has no MIC function Qianghua Wang
  0 siblings, 2 replies; 4+ messages in thread
From: Qianghua Wang @ 2026-11-17  1:35 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-sound, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Cezary Rojewski, Peter Ujfalusi, Bard Liao, Kai Vehmanen,
	Pierre-Louis Bossart, Qianghua Wang

Some laptops ship ACPI _DSD DisCo for Senary SN624x with jack and
speaker amp SDCA functions only, omitting the MIC array function even
though the codec might otherwise expose a DMIC. The driver always
advertised the DMIC capture port and ran DMIC function init against
registers not described in DisCo, which breaks bring-up on platforms
that use a minimal function list (for example some Panther Lake
designs).

Look at the parsed DisCo function list before exposing the DMIC port
and before running DMIC init. Apply AMP function init from the ACPI
init tables when an amp function is present, using the same pattern as
the jack and DMIC paths.

Link: https://github.com/thesofproject/linux/issues/6012
Signed-off-by: Qianghua Wang <qianghua.wang@senarytech.com>
---
 sound/soc/codecs/sn624x-sdca-sdw.c | 96 ++++++++++++++++++++++++++++--
 1 file changed, 92 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/sn624x-sdca-sdw.c b/sound/soc/codecs/sn624x-sdca-sdw.c
index 1d4e5f27a..f201ff38c 100644
--- a/sound/soc/codecs/sn624x-sdca-sdw.c
+++ b/sound/soc/codecs/sn624x-sdca-sdw.c
@@ -176,6 +176,9 @@ static int sn624x_uaj_ge35_apply_detected_mode(struct device *dev,
 	SDW_SDCA_CTL(SN624X_FUNC_NUM_MIC_ARRAY, SN624X_SDCA_ENT_ENTITY0, \
 		     SN624X_SDCA_CTL_FUNCTION_STATUS, 0)
 
+#define SN624X_REG_AMP_FUN_STATUS_CTL \
+	SDW_SDCA_CTL(SN624X_FUNC_NUM_SPEAKER_AMP, SN624X_SDCA_ENT_ENTITY0, \
+		     SN624X_SDCA_CTL_FUNCTION_STATUS, 0)
 /*
  * Write REQUESTED_PS then poll ACTUAL_PS with the shared SDCA helper
  * (sdca_asoc_pde_poll_actual_ps). Caller must not hand-roll ACTUAL_PS waits.
@@ -1055,6 +1058,43 @@ static int sn624x_dmic_apply_defaults(struct device *dev,
 	return sn624x_dmic_oem_fallback_init(dev, sn624x);
 }
 
+static bool sn624x_sdca_disco_has_mic(const struct sdw_slave *slave)
+{
+	int i;
+
+	if (!slave->sdca_data.interface_revision || !slave->sdca_data.num_functions)
+		return false;
+	for (i = 0; i < slave->sdca_data.num_functions; i++) {
+		const struct sdca_function_desc *desc = &slave->sdca_data.function[i];
+
+		if (desc->adr == SN624X_FUNC_NUM_MIC_ARRAY)
+			return true;
+		switch (desc->type) {
+		case SDCA_FUNCTION_TYPE_SMART_MIC:
+		case SDCA_FUNCTION_TYPE_SIMPLE_MIC:
+			return true;
+		default:
+			break;
+		}
+	}
+	return false;
+}
+
+static int sn624x_amp_apply_defaults(struct device *dev,
+				     struct sn624x_sdca_priv *sn624x)
+{
+	int ret;
+
+	if (!sn624x || !sn624x->regmap || !sn624x->slave)
+		return -ENODEV;
+	if (!sn624x->amp_func)
+		return -ENOENT;
+	ret = sn624x_write_sdca_init_table(dev, sn624x, sn624x->amp_func, "amp");
+	if (ret == 0)
+		usleep_range(1000, 1500);
+	return ret;
+}
+
 static int sn624x_sdca_jack_function_init(struct device *dev,
 					  struct sn624x_sdca_priv *sn624x)
 {
@@ -1088,11 +1128,18 @@ static int sn624x_sdca_jack_function_init(struct device *dev,
 static int sn624x_sdca_dmic_function_init(struct device *dev,
 					  struct sn624x_sdca_priv *sn624x)
 {
+	struct sdw_slave *slave = sn624x->slave;
 	unsigned int dmic_func_status;
 	const struct reg_sequence clear_status =
 		REG_SEQ0(SN624X_REG_DMIC_FUN_STATUS_CTL, 0x61);
 	int ret;
 
+	if (!sn624x_sdca_disco_has_mic(slave)) {
+		dev_dbg(dev,
+			"sn624x: no MIC SDCA function in ACPI DisCo, skip DMIC init\n");
+		return 0;
+	}
+
 	ret = regmap_read_bypassed(sn624x->regmap,
 				   SN624X_REG_DMIC_FUN_STATUS_CTL,
 				   &dmic_func_status);
@@ -1104,6 +1151,40 @@ static int sn624x_sdca_dmic_function_init(struct device *dev,
 		return 0;
 
 	ret = sn624x_dmic_apply_defaults(dev, sn624x);
+	if (ret < 0)
+		return ret;
+	ret = regmap_multi_reg_write_bypassed(sn624x->regmap, &clear_status, 1);
+	if (ret < 0)
+		return ret;
+	usleep_range(1000, 1500);
+	return 0;
+}
+
+static int sn624x_sdca_amp_function_init(struct device *dev,
+					 struct sn624x_sdca_priv *sn624x)
+{
+	unsigned int amp_func_status;
+	const struct reg_sequence clear_status =
+		REG_SEQ0(SN624X_REG_AMP_FUN_STATUS_CTL, 0x61);
+	int ret;
+
+	if (!sn624x->amp_func)
+		return 0;
+	ret = regmap_read_bypassed(sn624x->regmap,
+				   SN624X_REG_AMP_FUN_STATUS_CTL,
+				   &amp_func_status);
+	if (ret < 0)
+		return ret;
+	if (!(amp_func_status & (SN624X_JACK_FUN_NEEDS_INIT |
+				 SN624X_JACK_FUN_HAS_BEEN_RESET))) {
+		if (!sn624x->first_hw_init && sn624x->amp_func->num_init_table)
+			dev_dbg(dev,
+				"sn624x: amp FUN STATUS 0x%x, apply ACPI init table anyway\n",
+				amp_func_status);
+		else
+			return 0;
+	}
+	ret = sn624x_amp_apply_defaults(dev, sn624x);
 	if (ret < 0)
 		return ret;
 
@@ -1161,6 +1242,11 @@ static int sn624x_sdca_io_init(struct device *dev, struct sdw_slave *slave)
 		dev_err(dev, "sn624x: jack function init failed (%d)\n", ret);
 		goto err;
 	}
+	ret = sn624x_sdca_amp_function_init(dev, sn624x);
+	if (ret < 0) {
+		dev_err(dev, "sn624x: amp function init failed (%d)\n", ret);
+		goto err;
+	}
 
 	ret = sn624x_sdca_dmic_function_init(dev, sn624x);
 	if (ret < 0) {
@@ -1253,8 +1339,9 @@ static int sn624x_sdca_read_prop(struct sdw_slave *slave)
 	prop->use_domain_irq = true;
 	prop->wake_capable = true;
 
-	prop->source_ports = BIT(SN624X_PORT_JACK_CAPTURE) |
-			     BIT(SN624X_PORT_DMIC_CAPTURE);
+	prop->source_ports = BIT(SN624X_PORT_JACK_CAPTURE);
+	if (sn624x_sdca_disco_has_mic(slave))
+		prop->source_ports |= BIT(SN624X_PORT_DMIC_CAPTURE);
 	prop->sink_ports = BIT(SN624X_PORT_JACK_PLAYBACK) |
 			   BIT(SN624X_PORT_SPEAKER_PLAYBACK);
 
@@ -1292,8 +1379,9 @@ static int sn624x_sdca_read_prop(struct sdw_slave *slave)
 	prop->simple_clk_stop_capable = true;
 	prop->lane_control_support = true;
 	SN624X_DBG(&slave->dev,
-		   "read_prop: src_ports=0x%x sink_ports=0x%x lane irq paging\n",
-		   prop->source_ports, prop->sink_ports);
+		   "read_prop: src_ports=0x%x sink_ports=0x%x mic_disco=%d lane irq paging\n",
+		   prop->source_ports, prop->sink_ports,
+		   sn624x_sdca_disco_has_mic(slave));
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-17  3:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17  1:35 [PATCH] ASoC: sn624x: honor ACPI DisCo when MIC SDCA function is absent Qianghua Wang
2026-11-17  1:51 ` sashiko-bot
2026-11-17  2:46 ` [PATCH v2] ASoC: sn624x: skip DMIC when ACPI DisCo has no MIC function Qianghua Wang
2026-11-17  3:02   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox