Skip to contentSkip to conversation

ASoC: cs35l56: Add support for new Dell laptops

PATCH In review Richard Fitzgerald 4 participants 10 messages Jan 21 – Jan 22

Subsystems (3)
lore
Share & tools
lore

Richard Fitzgerald

author maintainer
#0 lore raw

cover ASoC: cs35l56: Add support for new Dell laptops

On new Dell models the driver must read a UEFI variable to get a variant identifier for the audio hardware. Without this, the driver cannot know which firmware file to load to the amps.

Patch #1 and #2 are the new support.
The other patches are for KUnit testing.

Richard Fitzgerald (5):
ASoC: cs-amp-lib: Support Dell SSIDExV2 UEFI variable
ASoC: cs35l56: Use vendor-specific qualifier in firmware file search
ASoC: cs-amp-lib-test: Tests for reading SSIDExV2
ASoC: cs-amp-lib: Add a Kconfig symbol for enabling test hooks
ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()

 include/sound/cs-amp-lib.h         |   3 +
 sound/soc/codecs/Kconfig           |  18 ++
 sound/soc/codecs/Makefile          |   2 +
 sound/soc/codecs/cs-amp-lib-test.c | 169 +++++++++++++
 sound/soc/codecs/cs-amp-lib.c      | 131 ++++++++++-
 sound/soc/codecs/cs35l56-test.c    | 365 +++++++++++++++++++++++++++++
 sound/soc/codecs/cs35l56.c         |  74 ++++--
 sound/soc/codecs/cs35l56.h         |   4 +
 8 files changed, 741 insertions(+), 25 deletions(-)
 create mode 100644 sound/soc/codecs/cs35l56-test.c
Signature · 1 line
2.47.3
author maintainer
#1 lore raw

PATCH 1/5 ASoC: cs-amp-lib: Support Dell SSIDExV2 UEFI variable

Add a function cs_amp_devm_get_vendor_specific_variant_id() to return a vendor-specific hardware identifier string (if there is one) and use it to fetch an identifier from Dell SSIDExV2 UEFI variable content.

Dell use the same PCI SSID on multiple products that might have different audio hardware and thus need different firmware for the amplifier DSP. The SSIDExV2 string contains additional system identifiers, and the second field is a 2-character audio hardware identifier.

There are older Dell models with Cirrus Logic amplifiers that have the SSIDExV2 UEFI variable but do not have the 2-character audio ID in the second field. The SSIDExV2 is ignored if the second field is not 2 characters.

---
 include/sound/cs-amp-lib.h    |   3 +
 sound/soc/codecs/cs-amp-lib.c | 111 ++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+)
include/sound/cs-amp-lib.h +3 -0
index 61e00017c9aa..e9aa86d76049 100644
@@ -58,6 +58,9 @@ int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_
 int cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, int num_amps,
 				    const struct cirrus_amp_cal_data *in_data);
 int cs_amp_get_vendor_spkid(struct device *dev);
+const char *cs_amp_devm_get_vendor_specific_variant_id(struct device *dev,
+						       int ssid_vendor,
+						       int ssid_device);
 struct dentry *cs_amp_create_debugfs(struct device *dev);
 
 static inline u64 cs_amp_cal_target_u64(const struct cirrus_amp_cal_data *data)
sound/soc/codecs/cs-amp-lib.c +111 -0

135 lines not on this page · raw message

Signature · 1 line
2.47.3
author maintainer
#2 lore raw

PATCH 2/5 ASoC: cs35l56: Use vendor-specific qualifier in firmware file search

In reply to Richard Fitzgerald

If cs_amp_devm_get_vendor_specific_variant_id() returns a string, use it as part of the firmware filename. If this firmware isn't found, fall back to the standard firmware name.

This re-uses the fwf_suffix fallback mechanism that was introduced in commit e5d5b3aebdc8 ("ASoC: cs35l56: Use SoundWire address as alternate firmware suffix on L56 B0").

This is for handling vendors that use the same PCI SSID on systems with various audio hardware and have a custom vendor-specific way to identify the hardware variant.

This is currently used on Dell laptops. Dell create a UEFI variable that indicates varations to the base hardware. This variance can be any part of the hardware (not necessarily affecting the audio). It would be impractical to publish many aliases for the same firmware files to match every possible variance to that base hardware. Hence the fallback to the standard firmware name. This allows alternate firmware files to be published only for variants that need it. For all other variants the fallback will load the firmware for the base SSID.

This is not done for CS35L56 B0 because the fallback mechanism is already used for a different purpose for these parts. None of the products with the older L56 B0 silicon revision need the additional vendor-specific descriptor.

For SoundWire the resulting firmware searches with a variant descriptor will be:
1. cs35l??-dsp1-misc-SSID-VARIANT-l?u?.wmfw
2. cs35l??-dsp1-misc-SSID-VARIANT.wmfw
3. cs35l??-dsp1-misc-SSID-VARIANT-l?u?.bin
4. cs35l??-dsp1-misc-SSID-VARIANT.bin

If this doesn't find a wmfw and bin file it will then fallback to:
5. cs35l??-dsp1-misc-SSID-l?u?.wmfw
6. cs35l??-dsp1-misc-SSID.wmfw
7. cs35l??-dsp1-misc-SSID-l?u?.bin
8. cs35l??-dsp1-misc-SSID.bin

With the typical published firmware names and qualifiers (a single wmfw but amp-specific bin file) this will load either:

cs35l??-dsp1-misc-SSID-VARIANT.wmfw
and cs35l??-dsp1-misc-SSID-VARIANT-l?u?.bin

or

cs35l??-dsp1-misc-SSID.wmfw
and cs35l??-dsp1-misc-SSID-l?u?.bin

For non-Soundwire (I2S/TDM) systems the searches and fallbacks are as above except that the "l?u?" component of the name is instead the ALSA name prefix, usually of the form "AMPn".

---
 sound/soc/codecs/cs35l56.c | 69 ++++++++++++++++++++++++++++++--------
 1 file changed, 55 insertions(+), 14 deletions(-)
sound/soc/codecs/cs35l56.c +55 -14
index 55b4d0d55712..abea782bcd3f 100644
@@ -1109,27 +1109,68 @@ static const struct snd_kcontrol_new cs35l56_cal_data_restore_controls[] = {
 
 static int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56)
 {
+	unsigned short vendor, device;
+	const char *vendor_id;
+	int ret;
+
 	if (cs35l56->dsp.fwf_suffix)
 		return 0;
 
-	if (!cs35l56->sdw_peripheral)
-		return 0;
+	if (cs35l56->sdw_peripheral) {
+		cs35l56->dsp.fwf_suffix = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL,
+							 "l%uu%u",
+							 cs35l56->sdw_link_num,
+							 cs35l56->sdw_unique_id);
+		if (!cs35l56->dsp.fwf_suffix)
+			return -ENOMEM;
 
-	cs35l56->dsp.fwf_suffix = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL,
-						 "l%uu%u",
-						 cs35l56->sdw_link_num,
-						 cs35l56->sdw_unique_id);
-	if (!cs35l56->dsp.fwf_suffix)
-		return -ENOMEM;
+		/*
+		 * There are published firmware files for L56 B0 silicon using
+		 * the ALSA prefix as the filename suffix. Default to trying these
+		 * first, with the new SoundWire suffix as a fallback.
+		 * None of these older systems use a vendor-specific ID.
+		 */
+		if ((cs35l56->base.type == 0x56) && (cs35l56->base.rev == 0xb0)) {
+			cs35l56->fallback_fw_suffix = cs35l56->dsp.fwf_suffix;
+			cs35l56->dsp.fwf_suffix = cs35l56->component->name_prefix;
+
+			return 0;
+		}
+	}
 
 	/*
-	 * There are published firmware files for L56 B0 silicon using
-	 * the ALSA prefix as the filename suffix. Default to trying these
-	 * first, with the new name as an alternate.
+	 * Some manufacturers use the same SSID on multiple products and have
+	 * a vendor-specific qualifier to distinguish different models.
+	 * Models with the same SSID but different qualifier might require
+	 * different audio firmware, or they might all have the same audio
+	 * firmware.
+	 * Try searching for a firmware with this qualifier first, else
+	 * fallback to standard naming.
 	 */
-	if ((cs35l56->base.type == 0x56) && (cs35l56->base.rev == 0xb0)) {
-		cs35l56->fallback_fw_suffix = cs35l56->dsp.fwf_suffix;
-		cs35l56->dsp.fwf_suffix = cs35l56->component->name_prefix;
+	if (snd_soc_card_get_pci_ssid(cs35l56->component->card, &vendor, &device) < 0) {
+		vendor_id = cs_amp_devm_get_vendor_specific_variant_id(cs35l56->base.dev, -1, -1);
+	} else {
+		vendor_id = cs_amp_devm_get_vendor_specific_variant_id(cs35l56->base.dev,
+								       vendor, device);
+	}
+	ret = PTR_ERR_OR_ZERO(vendor_id);
+	if (ret == -ENOENT)
+		return 0;
+	else if (ret)
+		return ret;
+
+	if (vendor_id) {
+		if (cs35l56->dsp.fwf_suffix)
+			cs35l56->fallback_fw_suffix = cs35l56->dsp.fwf_suffix;
+		else
+			cs35l56->fallback_fw_suffix = cs35l56->component->name_prefix;
+
+		cs35l56->dsp.fwf_suffix = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL,
+							 "%s-%s",
+							 vendor_id,
+							 cs35l56->fallback_fw_suffix);
+		if (!cs35l56->dsp.fwf_suffix)
+			return -ENOMEM;
 	}
 
 	return 0;
Signature · 1 line
2.47.3
author maintainer
#3 lore raw

PATCH 3/5 ASoC: cs-amp-lib-test: Tests for reading SSIDExV2

In reply to Richard Fitzgerald

Adds test cases for getting a Dell SSIDExV2 string by calling cs_amp_devm_get_vendor_specific_variant_id().

This is a fairly simple test harness, the redirected call to cs_amp_get_efi_variable() returns a test string to simulate reading a string from UEFI. The returned string should be the second field in the SSIDExV2 string (if valid).

---
 sound/soc/codecs/cs-amp-lib-test.c | 169 +++++++++++++++++++++++++++++
 1 file changed, 169 insertions(+)
sound/soc/codecs/cs-amp-lib-test.c +169 -0
index 923f1857e45b..2b1529343f11 100644
@@ -16,6 +16,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/overflow.h>
+#include <linux/pci_ids.h>
 #include <linux/platform_device.h>
 #include <linux/random.h>
 #include <sound/cs-amp-lib.h>
@@ -56,6 +57,8 @@ struct cs_amp_lib_test_ctl_write_entry {
 struct cs_amp_lib_test_param {
 	int num_amps;
 	int amp_index;
+	char *vendor_sysid;
+	char *expected_sysid;
 };
 
 static struct cirrus_amp_efi_data *cs_amp_lib_test_cal_blob_dup(struct kunit *test)
@@ -2305,6 +2308,98 @@ static void cs_amp_lib_test_spkid_hp_31(struct kunit *test)
 	KUNIT_EXPECT_EQ(test, 1, cs_amp_get_vendor_spkid(dev));
 }
 
+static efi_status_t cs_amp_lib_test_get_efi_vendor_sysid(efi_char16_t *name,
+							 efi_guid_t *guid,
+							 u32 *returned_attr,
+							 unsigned long *size,
+							 void *buf)
+{
+	struct kunit *test = kunit_get_current_test();
+	const struct cs_amp_lib_test_param *param = test->param_value;
+	unsigned int len;
+
+	KUNIT_ASSERT_NOT_NULL(test, param->vendor_sysid);
+	len = strlen(param->vendor_sysid);
+
+	if (*size < len) {
+		*size = len;
+		return EFI_BUFFER_TOO_SMALL;
+	}
+
+	KUNIT_ASSERT_NOT_NULL(test, buf);
+	memcpy(buf, param->vendor_sysid, len);
+
+	return EFI_SUCCESS;
+}
+
+/* Fetch SSIDExV2 string from UEFI */
+static void cs_amp_lib_test_ssidexv2_fetch(struct kunit *test)
+{
+	const struct cs_amp_lib_test_param *param = test->param_value;
+	struct cs_amp_lib_test_priv *priv = test->priv;
+	struct device *dev = &priv->amp_dev->dev;
+	const char *got;
+
+	kunit_activate_static_stub(test,
+				   cs_amp_test_hooks->get_efi_variable,
+				   cs_amp_lib_test_get_efi_vendor_sysid);
+
+	got = cs_amp_devm_get_vendor_specific_variant_id(dev, PCI_VENDOR_ID_DELL, 0xabcd);
+	KUNIT_EXPECT_NOT_ERR_OR_NULL(test, got);
+	KUNIT_EXPECT_STREQ(test, got, param->expected_sysid);
+}
+
+/* Invalid SSIDExV2 string should be ignored */
+static void cs_amp_lib_test_ssidexv2_fetch_invalid(struct kunit *test)
+{
+	struct cs_amp_lib_test_priv *priv = test->priv;
+	struct device *dev = &priv->amp_dev->dev;
+	const char *got;
+
+	kunit_activate_static_stub(test,
+				   cs_amp_test_hooks->get_efi_variable,
+				   cs_amp_lib_test_get_efi_vendor_sysid);
+
+	got = cs_amp_devm_get_vendor_specific_variant_id(dev, PCI_VENDOR_ID_DELL, 0xabcd);
+	KUNIT_EXPECT_NOT_NULL(test, got);
+	KUNIT_EXPECT_EQ(test, PTR_ERR_OR_ZERO(got), -ENOENT);
+}
+
+static void cs_amp_lib_test_ssidexv2_not_dell(struct kunit *test)
+{
+	struct cs_amp_lib_test_priv *priv = test->priv;
+	struct device *dev = &priv->amp_dev->dev;
+	const char *got;
+
+	kunit_activate_static_stub(test,
+				   cs_amp_test_hooks->get_efi_variable,
+				   cs_amp_lib_test_get_efi_vendor_sysid);
+
+	/* Not returned if SSID vendor is not Dell */
+	got = cs_amp_devm_get_vendor_specific_variant_id(dev, PCI_VENDOR_ID_CIRRUS, 0xabcd);
+	KUNIT_EXPECT_NOT_NULL(test, got);
+	KUNIT_EXPECT_EQ(test, PTR_ERR_OR_ZERO(got), -ENOENT);
+}
+
+static void cs_amp_lib_test_vendor_variant_id_not_found(struct kunit *test)
+{
+	struct cs_amp_lib_test_priv *priv = test->priv;
+	struct device *dev = &priv->amp_dev->dev;
+	const char *got;
+
+	kunit_activate_static_stub(test,
+				   cs_amp_test_hooks->get_efi_variable,
+				   cs_amp_lib_test_get_efi_variable_none);
+
+	got = cs_amp_devm_get_vendor_specific_variant_id(dev, PCI_VENDOR_ID_DELL, 0xabcd);
+	KUNIT_EXPECT_NOT_NULL(test, got);
+	KUNIT_EXPECT_EQ(test, PTR_ERR_OR_ZERO(got), -ENOENT);
+
+	got = cs_amp_devm_get_vendor_specific_variant_id(dev, -1, -1);
+	KUNIT_EXPECT_NOT_NULL(test, got);
+	KUNIT_EXPECT_EQ(test, PTR_ERR_OR_ZERO(got), -ENOENT);
+}
+
 static int cs_amp_lib_test_case_init(struct kunit *test)
 {
 	struct cs_amp_lib_test_priv *priv;
@@ -2375,6 +2470,71 @@ static void cs_amp_lib_test_get_cal_param_desc(const struct cs_amp_lib_test_para
 KUNIT_ARRAY_PARAM(cs_amp_lib_test_get_cal, cs_amp_lib_test_get_cal_param_cases,
 		  cs_amp_lib_test_get_cal_param_desc);
 
+static const struct cs_amp_lib_test_param cs_amp_lib_test_ssidexv2_param_cases[] = {
+	{ .vendor_sysid = "abcd_00",		.expected_sysid = "00" },
+	{ .vendor_sysid = "abcd_01",		.expected_sysid = "01" },
+	{ .vendor_sysid = "abcd_XY",		.expected_sysid = "XY" },
+
+	{ .vendor_sysid = "1028abcd_00",	.expected_sysid = "00" },
+	{ .vendor_sysid = "1028abcd_01",	.expected_sysid = "01" },
+	{ .vendor_sysid = "1028abcd_XY",	.expected_sysid = "XY" },
+
+	{ .vendor_sysid = "abcd_00_WF",		.expected_sysid = "00" },
+	{ .vendor_sysid = "abcd_01_WF",		.expected_sysid = "01" },
+	{ .vendor_sysid = "abcd_XY_WF",		.expected_sysid = "XY" },
+
+	{ .vendor_sysid = "1028abcd_00_WF",	.expected_sysid = "00" },
+	{ .vendor_sysid = "1028abcd_01_WF",	.expected_sysid = "01" },
+	{ .vendor_sysid = "1028abcd_XY_WF",	.expected_sysid = "XY" },
+
+	{ .vendor_sysid = "abcd_00_AA_BB",	.expected_sysid = "00" },
+	{ .vendor_sysid = "abcd_01_AA_BB",	.expected_sysid = "01" },
+	{ .vendor_sysid = "abcd_XY_AA_BB",	.expected_sysid = "XY" },
+
+	{ .vendor_sysid = "1028abcd_00_AA_BB",	.expected_sysid = "00" },
+	{ .vendor_sysid = "1028abcd_01_AA_BB",	.expected_sysid = "01" },
+	{ .vendor_sysid = "1028abcd_XY_A_BB",	.expected_sysid = "XY" },
+};
+
+static void cs_amp_lib_test_ssidexv2_param_desc(const struct cs_amp_lib_test_param *param,
+						char *desc)
+{
+	snprintf(desc, KUNIT_PARAM_DESC_SIZE, "vendor_sysid:'%s' expected_sysid:'%s'",
+		 param->vendor_sysid, param->expected_sysid);
+}
+
+KUNIT_ARRAY_PARAM(cs_amp_lib_test_ssidexv2, cs_amp_lib_test_ssidexv2_param_cases,
+		  cs_amp_lib_test_ssidexv2_param_desc);
+
+static const struct cs_amp_lib_test_param cs_amp_lib_test_ssidexv2_invalid_param_cases[] = {
+	{ .vendor_sysid = "abcd" },
+	{ .vendor_sysid = "abcd_0" },
+	{ .vendor_sysid = "abcd_1" },
+	{ .vendor_sysid = "abcd_0_1" },
+	{ .vendor_sysid = "abcd_1_1" },
+	{ .vendor_sysid = "abcd_1_X" },
+	{ .vendor_sysid = "abcd_1_X" },
+	{ .vendor_sysid = "abcd_000" },
+	{ .vendor_sysid = "abcd_010" },
+	{ .vendor_sysid = "abcd_000_01" },
+	{ .vendor_sysid = "abcd_000_01" },
+
+	{ .vendor_sysid = "1234abcd" },
+	{ .vendor_sysid = "1234abcd_0" },
+	{ .vendor_sysid = "1234abcd_1" },
+	{ .vendor_sysid = "1234abcd_0_1" },
+	{ .vendor_sysid = "1234abcd_1_1" },
+	{ .vendor_sysid = "1234abcd_1_X" },
+	{ .vendor_sysid = "1234abcd_1_X" },
+	{ .vendor_sysid = "1234abcd_000" },
+	{ .vendor_sysid = "1234abcd_010" },
+	{ .vendor_sysid = "1234abcd_000_01" },
+	{ .vendor_sysid = "1234abcd_000_01" },
+};
+
+KUNIT_ARRAY_PARAM(cs_amp_lib_test_ssidexv2_invalid, cs_amp_lib_test_ssidexv2_invalid_param_cases,
+		  cs_amp_lib_test_ssidexv2_param_desc);
+
 static struct kunit_case cs_amp_lib_test_cases[] = {
 	/* Tests for getting calibration data from EFI */
 	KUNIT_CASE(cs_amp_lib_test_cal_data_too_short_test),
@@ -2434,6 +2594,15 @@ static struct kunit_case cs_amp_lib_test_cases[] = {
 	KUNIT_CASE(cs_amp_lib_test_spkid_hp_30),
 	KUNIT_CASE(cs_amp_lib_test_spkid_hp_31),
 
+	/* Test cases for SSIDExV2 */
+	KUNIT_CASE_PARAM(cs_amp_lib_test_ssidexv2_fetch,
+			 cs_amp_lib_test_ssidexv2_gen_params),
+	KUNIT_CASE_PARAM(cs_amp_lib_test_ssidexv2_fetch_invalid,
+			 cs_amp_lib_test_ssidexv2_invalid_gen_params),
+	KUNIT_CASE_PARAM(cs_amp_lib_test_ssidexv2_not_dell,
+			 cs_amp_lib_test_ssidexv2_gen_params),
+	KUNIT_CASE(cs_amp_lib_test_vendor_variant_id_not_found),
+
 	{ } /* terminator */
 };
 
Signature · 1 line
2.47.3
author maintainer
#4 lore raw

PATCH 4/5 ASoC: cs-amp-lib: Add a Kconfig symbol for enabling test hooks

In reply to Richard Fitzgerald

Add Kconfig symbol CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS to enable calling into functions that would normally abort because of missing EFI functionality. Before this the code paths were only enabled if the KUnit test for cs-amp-lib was enabled.

This change allows KUnit tests for clients of cs-amp-lib to install redirection hooks in cs-amp-lib.

---
 sound/soc/codecs/Kconfig      |  5 +++++
 sound/soc/codecs/cs-amp-lib.c | 19 ++++++++-----------
 2 files changed, 13 insertions(+), 11 deletions(-)
sound/soc/codecs/Kconfig +5 -0
index 90f09d4bdf8e..21d5b79f079d 100644
@@ -786,9 +786,14 @@ config SND_SOC_CROS_EC_CODEC
 config SND_SOC_CS_AMP_LIB
 	tristate
 
+config SND_SOC_CS_AMP_LIB_TEST_HOOKS
+	bool
+	depends on SND_SOC_CS_AMP_LIB
+
 config SND_SOC_CS_AMP_LIB_TEST
 	tristate "KUnit test for Cirrus Logic cs-amp-lib" if !KUNIT_ALL_TESTS
 	depends on SND_SOC_CS_AMP_LIB && KUNIT
+	select SND_SOC_CS_AMP_LIB_TEST_HOOKS
 	default KUNIT_ALL_TESTS
 	help
 	  This builds KUnit tests for the Cirrus Logic common
sound/soc/codecs/cs-amp-lib.c +8 -11
index 9f8c99dfb798..f8c7f594d54a 100644
@@ -211,7 +211,7 @@ int cs_amp_write_cal_coeffs(struct cs_dsp *dsp,
 			    const struct cirrus_amp_cal_controls *controls,
 			    const struct cirrus_amp_cal_data *data)
 {
-	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return _cs_amp_write_cal_coeffs(dsp, controls, data);
 	else
 		return -ENODEV;
@@ -230,7 +230,7 @@ int cs_amp_read_cal_coeffs(struct cs_dsp *dsp,
 			   const struct cirrus_amp_cal_controls *controls,
 			   struct cirrus_amp_cal_data *data)
 {
-	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return _cs_amp_read_cal_coeffs(dsp, controls, data);
 	else
 		return -ENODEV;
@@ -249,10 +249,7 @@ int cs_amp_write_ambient_temp(struct cs_dsp *dsp,
 			      const struct cirrus_amp_cal_controls *controls,
 			      u32 temp)
 {
-	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
-		return cs_amp_write_cal_coeff(dsp, controls, controls->ambient, temp);
-	else
-		return -ENODEV;
+	return cs_amp_write_cal_coeff(dsp, controls, controls->ambient, temp);
 }
 EXPORT_SYMBOL_NS_GPL(cs_amp_write_ambient_temp, "SND_SOC_CS_AMP_LIB");
 
@@ -611,7 +608,7 @@ static int _cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, i
 int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_index,
 				    struct cirrus_amp_cal_data *out_data)
 {
-	if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return _cs_amp_get_efi_calibration_data(dev, target_uid, amp_index, out_data);
 	else
 		return -ENOENT;
@@ -647,7 +644,7 @@ EXPORT_SYMBOL_NS_GPL(cs_amp_get_efi_calibration_data, "SND_SOC_CS_AMP_LIB");
 int cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, int num_amps,
 				    const struct cirrus_amp_cal_data *in_data)
 {
-	if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST)) {
+	if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS)) {
 		scoped_guard(mutex, &cs_amp_efi_cal_write_lock) {
 			return _cs_amp_set_efi_calibration_data(dev, amp_index,
 								num_amps, in_data);
@@ -720,7 +717,7 @@ int cs_amp_get_vendor_spkid(struct device *dev)
 	int i, ret;
 
 	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE) &&
-	    !IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	    !IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return -ENOENT;
 
 	for (i = 0; i < ARRAY_SIZE(cs_amp_spkid_byte_types); i++) {
@@ -743,7 +740,7 @@ static const char *cs_amp_devm_get_dell_ssidex(struct device *dev,
 	int ret;
 
 	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE) &&
-	    !IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	    !IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return ERR_PTR(-ENOENT);
 
 	char *ssidex_buf __free(kfree) = cs_amp_alloc_get_efi_variable(DELL_SSIDEXV2_EFI_NAME,
@@ -849,7 +846,7 @@ static const struct cs_amp_test_hooks cs_amp_test_hook_ptrs = {
 };
 
 const struct cs_amp_test_hooks * const cs_amp_test_hooks =
-	PTR_IF(IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST), &cs_amp_test_hook_ptrs);
+	PTR_IF(IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS), &cs_amp_test_hook_ptrs);
 EXPORT_SYMBOL_NS_GPL(cs_amp_test_hooks, "SND_SOC_CS_AMP_LIB");
 
 MODULE_DESCRIPTION("Cirrus Logic amplifier library");
Signature · 1 line
2.47.3
author maintainer
#5 lore raw

PATCH 5/5 ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()

In reply to Richard Fitzgerald

Add a new KUnit test for testing the creation of firmware name qualifiers in the cs35l56 driver. The initial set of test cases are for cs35l56_set_fw_suffix().

---
 sound/soc/codecs/Kconfig        |  13 ++
 sound/soc/codecs/Makefile       |   2 +
 sound/soc/codecs/cs-amp-lib.c   |   3 +
 sound/soc/codecs/cs35l56-test.c | 365 ++++++++++++++++++++++++++++++++
 sound/soc/codecs/cs35l56.c      |   5 +-
 sound/soc/codecs/cs35l56.h      |   4 +
 6 files changed, 391 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/codecs/cs35l56-test.c
sound/soc/codecs/Kconfig +13 -0
index 21d5b79f079d..d09de0ff5f22 100644
@@ -933,6 +933,19 @@ config SND_SOC_CS35L56_CAL_SET_CTRL
 	  On most platforms this is not needed.
 
 	  If unsure select "N".
+
+config SND_SOC_CS35L56_TEST
+	tristate "KUnit test for Cirrus Logic cs35l56 driver" if !KUNIT_ALL_TESTS
+	depends on SND_SOC_CS35L56 && KUNIT
+	default KUNIT_ALL_TESTS
+	select SND_SOC_CS_AMP_LIB_TEST_HOOKS
+	help
+	  This builds KUnit tests for the Cirrus Logic cs35l56
+	  codec driver.
+	  For more information on KUnit and unit tests in general,
+	  please refer to the KUnit documentation in
+	  Documentation/dev-tools/kunit/.
+	  If in doubt, say "N".
 endmenu
 
 config SND_SOC_CS40L50
sound/soc/codecs/Makefile +2 -0
index a6406bc907a9..c3568de5e0c9 100644
@@ -81,6 +81,7 @@ snd-soc-cs35l56-shared-y := cs35l56-shared.o
 snd-soc-cs35l56-i2c-y := cs35l56-i2c.o
 snd-soc-cs35l56-spi-y := cs35l56-spi.o
 snd-soc-cs35l56-sdw-y := cs35l56-sdw.o
+snd-soc-cs35l56-test-y := cs35l56-test.o
 snd-soc-cs40l50-y := cs40l50-codec.o
 snd-soc-cs42l42-y := cs42l42.o
 snd-soc-cs42l42-i2c-y := cs42l42-i2c.o
@@ -516,6 +517,7 @@ obj-$(CONFIG_SND_SOC_CS35L56_SHARED)	+= snd-soc-cs35l56-shared.o
 obj-$(CONFIG_SND_SOC_CS35L56_I2C)	+= snd-soc-cs35l56-i2c.o
 obj-$(CONFIG_SND_SOC_CS35L56_SPI)	+= snd-soc-cs35l56-spi.o
 obj-$(CONFIG_SND_SOC_CS35L56_SDW)	+= snd-soc-cs35l56-sdw.o
+obj-$(CONFIG_SND_SOC_CS35L56_TEST)	+= snd-soc-cs35l56-test.o
 obj-$(CONFIG_SND_SOC_CS40L50)		+= snd-soc-cs40l50.o
 obj-$(CONFIG_SND_SOC_CS42L42_CORE)	+= snd-soc-cs42l42.o
 obj-$(CONFIG_SND_SOC_CS42L42)	+= snd-soc-cs42l42-i2c.o
sound/soc/codecs/cs-amp-lib.c +3 -0
index f8c7f594d54a..8b131975143d 100644
@@ -806,6 +806,9 @@ const char *cs_amp_devm_get_vendor_specific_variant_id(struct device *dev,
 						       int ssid_vendor,
 						       int ssid_device)
 {
+	KUNIT_STATIC_STUB_REDIRECT(cs_amp_devm_get_vendor_specific_variant_id,
+				   dev, ssid_vendor, ssid_device);
+
 	if ((ssid_vendor == PCI_VENDOR_ID_DELL) || (ssid_vendor < 0))
 		return cs_amp_devm_get_dell_ssidex(dev, ssid_vendor, ssid_device);
 
sound/soc/codecs/cs35l56-test.c new file +365 -0

365 lines not on this page · raw message

sound/soc/codecs/cs35l56.c +4 -1
index abea782bcd3f..31dd2f7b2858 100644
@@ -5,6 +5,8 @@
 // Copyright (C) 2023 Cirrus Logic, Inc. and
 //                    Cirrus Logic International Semiconductor Ltd.
 
+#include <kunit/static_stub.h>
+#include <kunit/visibility.h>
 #include <linux/acpi.h>
 #include <linux/array_size.h>
 #include <linux/completion.h>
@@ -1107,7 +1109,7 @@ static const struct snd_kcontrol_new cs35l56_cal_data_restore_controls[] = {
 			SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE),
 };
 
-static int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56)
+VISIBLE_IF_KUNIT int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56)
 {
 	unsigned short vendor, device;
 	const char *vendor_id;
@@ -1175,6 +1177,7 @@ static int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56)
 
 	return 0;
 }
+EXPORT_SYMBOL_IF_KUNIT(cs35l56_set_fw_suffix);
 
 static int cs35l56_component_probe(struct snd_soc_component *component)
 {
sound/soc/codecs/cs35l56.h +4 -0
index 4c59f92f3206..7187885a13c1 100644
@@ -74,4 +74,8 @@ int cs35l56_common_probe(struct cs35l56_private *cs35l56);
 int cs35l56_init(struct cs35l56_private *cs35l56);
 void cs35l56_remove(struct cs35l56_private *cs35l56);
 
+#if IS_ENABLED(CONFIG_KUNIT)
+int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56);
+#endif
+
 #endif /* ifndef CS35L56_H */
Signature · 1 line
2.47.3
#6 lore raw

Re: [PATCH 5/5] ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()

kernel test robot noticed the following build warnings:

Hi Richard,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v6.19-rc6 next-20260121] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Richard-Fitzgerald/ASoC-cs-amp-lib-Support-Dell-SSIDExV2-UEFI-variable/20260121-220028
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20260121132243.1256019-6-rf%40opensource.cirrus.com
patch subject: [PATCH 5/5] ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()
config: arm64-randconfig-003-20260122 (https://download.01.org/0day-ci/archive/20260122/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260122/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> WARNING: modpost: module snd-soc-cs35l56-test uses symbol cs35l56_set_fw_suffix from namespace EXPORTED_FOR_KUNIT_TESTING, but does not import it.
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#7 lore raw

Re: [PATCH 5/5] ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()

Quoted 18 lines · kernel test robot

Hi Richard,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v6.19-rc6 next-20260121] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Richard-Fitzgerald/ASoC-cs-amp-lib-Support-Dell-SSIDExV2-UEFI-variable/20260121-220028
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20260121132243.1256019-6-rf%40opensource.cirrus.com
patch subject: [PATCH 5/5] ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()
config: arm64-randconfig-003-20260122 (https://download.01.org/0day-ci/archive/20260122/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260122/[email protected]/reproduce)
Quoted 9 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>, old ones prefixed by <<):

Quoted 1 line
Quoted 1 line

WARNING: modpost: module snd-soc-cs35l56-test uses symbol cs35l56_set_fw_suffix from namespace EXPORTED_FOR_KUNIT_TESTING, but does not import it.

Please reply to all people on a thread. And as a minimum include people who were To: on the original patch email. Otherwise people who matter won't see this report.

#8 lore raw

Re: [PATCH 5/5] ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()

Quoted 24 lines · Richard Fitzgerald
Quoted 23 lines · kernel test robot

Hi Richard,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v6.19-rc6 next-20260121] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Richard-Fitzgerald/ASoC-cs-amp-lib-Support-Dell-SSIDExV2-UEFI-variable/20260121-220028
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20260121132243.1256019-6-rf%40opensource.cirrus.com
patch subject: [PATCH 5/5] ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()
config: arm64-randconfig-003-20260122 (https://download.01.org/0day-ci/archive/20260122/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260122/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 7 lines
Quoted 4 lines

All warnings (new ones prefixed by >>, old ones prefixed by <<):

Quoted 1 line
Quoted 1 line

WARNING: modpost: module snd-soc-cs35l56-test uses symbol cs35l56_set_fw_suffix from namespace EXPORTED_FOR_KUNIT_TESTING, but does not import it.

Please reply to all people on a thread. And as a minimum include people who were To: on the original patch email. Otherwise people who matter won't see this report.

Sorry about this, it's an issue in the bot that it has a logic to try to reduce the report number to public for same issue, but the detection is not reliable. We will disable the logic to let all reports behaves the same to send to related persons.

Quoted 1 line
maintainer
#9 lore raw
In reply to Richard Fitzgerald
Quoted 8 lines · Richard Fitzgerald

On new Dell models the driver must read a UEFI variable to get a variant identifier for the audio hardware. Without this, the driver cannot know which firmware file to load to the amps.

Patch #1 and #2 are the new support.
The other patches are for KUnit testing.

[...]

Applied to

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

Thanks!

[1/5] ASoC: cs-amp-lib: Support Dell SSIDExV2 UEFI variable

      commit: 00fd40bc7acecf9f41d645aa0b35ddc7fd7679b6
[2/5] ASoC: cs35l56: Use vendor-specific qualifier in firmware file search
      commit: 51b069172a4ef2c6278c64c603a41a7f20329921
[3/5] ASoC: cs-amp-lib-test: Tests for reading SSIDExV2
      commit: d70fa6b569a95e71cc25b86ac3cc221bea541f53
[4/5] ASoC: cs-amp-lib: Add a Kconfig symbol for enabling test hooks
      commit: 3f086a4f277af799467af6c74902000461e60a33
[5/5] ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix()
      commit: d0ab89951197f0fc509a0cd732d830880e79c2d4

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