[PATCH v1 2/2] ASoC: cs35l41: Read System Name from ACPI _SUB to identify firmware

Stefan Binding sbinding at opensource.cirrus.com
Wed Jun 22 15:07:30 CEST 2022


When loading firmware, wm_adsp uses a number of parameters to
determine the path of the firmware and tuning files to load.
One of these parameters is system_name.
Add support in cs35l41 to read this system name from the ACPI
_SUB ID in order to uniquely identify the firmware and tuning
mapped to a particular system.

Signed-off-by: Stefan Binding <sbinding at opensource.cirrus.com>
---
 sound/soc/codecs/cs35l41.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index 8766e19d85f1..5df04a2ab5a3 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -6,6 +6,7 @@
 //
 // Author: David Rhodes <david.rhodes at cirrus.com>
 
+#include <linux/acpi.h>
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/init.h>
@@ -1142,6 +1143,28 @@ static int cs35l41_dsp_init(struct cs35l41_private *cs35l41)
 	return ret;
 }
 
+static int cs35l41_probe_acpi(struct cs35l41_private *cs35l41)
+{
+	struct acpi_device *adev;
+	int ret;
+	char sub[ACPI_MAX_SUB_BUF_SIZE];
+
+	adev = ACPI_COMPANION(cs35l41->dev);
+	/* If there is no ACPI_COMPANION, there is no ACPI for this system, return 0 */
+	if (!adev)
+		return 0;
+
+	ret = acpi_get_sub(adev->handle, sub, sizeof(sub));
+	if (ret < 0)
+		return ret;
+
+	cs35l41->dsp.system_name = devm_kstrdup(cs35l41->dev, sub, GFP_KERNEL);
+	if (!cs35l41->dsp.system_name)
+		return -ENOMEM;
+
+	return 0;
+}
+
 int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg)
 {
 	u32 regid, reg_revid, i, mtl_revid, int_status, chipid_match;
@@ -1270,6 +1293,10 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *
 		goto err;
 	}
 
+	ret = cs35l41_probe_acpi(cs35l41);
+	if (ret < 0)
+		goto err;
+
 	ret = cs35l41_dsp_init(cs35l41);
 	if (ret < 0)
 		goto err;
-- 
2.25.1



More information about the Alsa-devel mailing list