ASoC: cs35l56: More support for new Dell laptops
Subsystems (3)
Richard Fitzgerald
maintainercover ASoC: cs35l56: More support for new Dell laptops
Some new Dell models use spare pins on the amp as a binary integer value to indicate the speaker type. The driver must use this to select the correct firmware files for the hardware.
Patch #1 is the new support.
The other patches are for KUnit testing.
Richard Fitzgerald (3):
ASoC: cs35l56: Support for reading speaker ID from on-chip GPIOs
ASoC: cs35l56-shared: KUnit tests for onchip speaker ID gpios
ASoC: cs35l56: KUnit tests for parsing and using onchip GPIOs
include/sound/cs35l56.h | 37 ++ sound/soc/codecs/Kconfig | 14 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/cs35l56-shared-test.c | 680 +++++++++++++++++++++++++ sound/soc/codecs/cs35l56-shared.c | 172 +++++++ sound/soc/codecs/cs35l56-test.c | 273 ++++++++++ sound/soc/codecs/cs35l56.c | 141 ++++- sound/soc/codecs/cs35l56.h | 2 + 8 files changed, 1317 insertions(+), 4 deletions(-) create mode 100644 sound/soc/codecs/cs35l56-shared-test.c
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH 1/3 ASoC: cs35l56: Support for reading speaker ID from on-chip GPIOs
Add support for using the state of pins on the amplifier to indicate the type of speaker fitted.
Previously, where there were alternate speaker vendors, this was indicated using host CPU GPIOs.
Some new Dell models use spare pins on the CS35L63 as GPIOs for the speaker ID detection.
Cirrus-specific SDCA Disco properties provide a list of the pins to be used, and pull-up/down settings for the pads. This list is ordered, MSbit to LSbit.
The code to set the firmware filename has been modified to check for using chip pins for speaker ID. The entire block of code to set firmware name has been moved out of cs35l56_component_probe() into its own function to make it easier to KUnit test.
--- include/sound/cs35l56.h | 37 +++++++ sound/soc/codecs/cs35l56-shared.c | 167 ++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l56.c | 141 ++++++++++++++++++++++++- sound/soc/codecs/cs35l56.h | 2 + 4 files changed, 343 insertions(+), 4 deletions(-)
include/sound/cs35l56.h +37 -0
@@ -9,6 +9,7 @@#ifndef __CS35L56_H#define __CS35L56_H +#include <linux/bits.h> #include <linux/debugfs.h> #include <linux/firmware/cirrus/cs_dsp.h> #include <linux/regulator/consumer.h>
@@ -26,6 +27,9 @@ struct snd_ctl_elem_value;#define CS35L56_GLOBAL_ENABLES 0x0002014#define CS35L56_BLOCK_ENABLES 0x0002018#define CS35L56_BLOCK_ENABLES2 0x000201C +#define CS35L56_SYNC_GPIO1_CFG 0x0002410 +#define CS35L56_ASP2_DIO_GPIO13_CFG 0x0002440 +#define CS35L56_UPDATE_REGS 0x0002A0C#define CS35L56_REFCLK_INPUT 0x0002C04#define CS35L56_GLOBAL_SAMPLE_RATE 0x0002C0C#define CS35L56_OTP_MEM_53 0x00300D4
@@ -65,6 +69,9 @@ struct snd_ctl_elem_value;#define CS35L56_IRQ1_MASK_8 0x000E0AC#define CS35L56_IRQ1_MASK_18 0x000E0D4#define CS35L56_IRQ1_MASK_20 0x000E0DC +#define CS35L56_GPIO_STATUS1 0x000F000 +#define CS35L56_GPIO1_CTRL1 0x000F008 +#define CS35L56_GPIO13_CTRL1 0x000F038#define CS35L56_MIXER_NGATE_CH1_CFG 0x0010004#define CS35L56_MIXER_NGATE_CH2_CFG 0x0010008#define CS35L56_DSP_MBOX_1_RAW 0x0011000
@@ -130,6 +137,17 @@ struct snd_ctl_elem_value;#define CS35L56_MTLREVID_MASK 0x0000000F#define CS35L56_REVID_B0 0x000000B0 +/* PAD_INTF */ +#define CS35L56_PAD_GPIO_PULL_MASK GENMASK(3, 2) +#define CS35L56_PAD_GPIO_IE BIT(0) + +#define CS35L56_PAD_PULL_NONE 0 +#define CS35L56_PAD_PULL_UP 1 +#define CS35L56_PAD_PULL_DOWN 2 + +/* UPDATE_REGS */ +#define CS35L56_UPDT_GPIO_PRES BIT(6) +/* ASP_ENABLES1 */ #define CS35L56_ASP_RX2_EN_SHIFT 17#define CS35L56_ASP_RX1_EN_SHIFT 16
@@ -185,6 +203,12 @@ struct snd_ctl_elem_value;/* MIXER_NGATE_CHn_CFG */ #define CS35L56_AUX_NGATE_CHn_EN 0x00000001 +/* GPIOn_CTRL1 */ +#define CS35L56_GPIO_DIR_MASK BIT(31) +#define CS35L56_GPIO_FN_MASK GENMASK(2, 0) + +#define CS35L56_GPIO_FN_GPIO 0x00000001 +/* Mixer input sources */ #define CS35L56_INPUT_SRC_NONE 0x00#define CS35L56_INPUT_SRC_ASP1RX1 0x08
@@ -279,6 +303,7 @@ struct snd_ctl_elem_value;#define CS35L56_HALO_STATE_TIMEOUT_US 250000#define CS35L56_RESET_PULSE_MIN_US 1100#define CS35L56_WAKE_HOLD_TIME_US 1000 +#define CS35L56_PAD_PULL_SETTLE_US 10#define CS35L56_CALIBRATION_POLL_US (100 * USEC_PER_MSEC)#define CS35L56_CALIBRATION_TIMEOUT_US (5 * USEC_PER_SEC)
@@ -289,6 +314,9 @@ struct snd_ctl_elem_value;#define CS35L56_NUM_BULK_SUPPLIES 3#define CS35L56_NUM_DSP_REGIONS 5 +#define CS35L56_MAX_GPIO 13 +#define CS35L63_MAX_GPIO 9 +/* Additional margin for SYSTEM_RESET to control port ready on SPI */ #define CS35L56_SPI_RESET_TO_PORT_READY_US (CS35L56_CONTROL_PORT_READY_US + 2500)
@@ -338,6 +366,10 @@ struct cs35l56_base {const struct cirrus_amp_cal_controls *calibration_controls;struct dentry *debugfs;u64 silicon_uid; +u8 onchip_spkid_gpios[5 ]; +u8 num_onchip_spkid_gpios; +u8 onchip_spkid_pulls[5 ]; +u8 num_onchip_spkid_pulls; };static inline bool cs35l56_is_otp_register (unsigned int reg)
@@ -413,6 +445,11 @@ void cs35l56_warn_if_firmware_missing(struct cs35l56_base *cs35l56_base);void cs35l56_log_tuning (struct cs35l56_base *cs35l56_base,struct cs_dsp *cs_dsp);int cs35l56_hw_init (struct cs35l56_base *cs35l56_base);int cs35l56_get_speaker_id (struct cs35l56_base *cs35l56_base); +int cs35l56_check_and_save_onchip_spkid_gpios (struct cs35l56_base *cs35l56_base, +const u32 *gpios,int num_gpios, +const u32 *pulls,int num_pulls); +int cs35l56_configure_onchip_spkid_pads (struct cs35l56_base *cs35l56_base); +int cs35l56_read_onchip_spkid (struct cs35l56_base *cs35l56_base);int cs35l56_get_bclk_freq_id (unsigned int freq);void cs35l56_fill_supply_names (struct regulator_bulk_data *data);
sound/soc/codecs/cs35l56-shared.c +167 -0
209 lines not on this page · raw message
sound/soc/codecs/cs35l56.c +137 -4
176 lines not on this page · raw message
sound/soc/codecs/cs35l56.h +2 -0
@@ -76,6 +76,8 @@ void cs35l56_remove(struct cs35l56_private *cs35l56);#if IS_ENABLED (CONFIG_KUNIT )int cs35l56_set_fw_suffix (struct cs35l56_private *cs35l56); +int cs35l56_set_fw_name (struct snd_soc_component *component); +int cs35l56_process_xu_properties (struct cs35l56_private *cs35l56);#endif #endif /* ifndef CS35L56_H */
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH 2/3 ASoC: cs35l56-shared: KUnit tests for onchip speaker ID gpios
In reply to Richard FitzgeraldAdd KUnit testing of:
cs35l56_check_and_save_onchip_spkid_gpios()
cs35l56_configure_onchip_spkid_pads()
cs35l56_read_onchip_spkid()
The test consists of:
- A mock regmap that simulates the pad and pin config registers.
- Parameterization of the pin list, pulls list, a simulated value for each pin and the speaker ID value that this should produce.
- A self-test of the simulated pin and GPIO registers.
- A test that the value returned by cs35l56_read_onchip_spkid() is correct.
- A test that the pin pull-up/down are set correctly by cs35l56_configure_onchip_spkid_pads()
- A test that cs35l56_configure_onchip_spkid_pads() and cs35l56_read_onchip_spkid(0 return the expected values if cs35l56_base->num_onchip_spkid_gpios == 0.
- A test that cs35l56_check_and_save_onchip_spkid_gpios() saves the configuration.
- A test that cs35l56_check_and_save_onchip_spkid_gpios() rejects illegal GPIO numbers.
- A test that cs35l56_check_and_save_onchip_spkid_gpios() rejects illegal pull types.
--- sound/soc/codecs/Kconfig | 14 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/cs35l56-shared-test.c | 680 +++++++++++++++++++++++++ sound/soc/codecs/cs35l56-shared.c | 5 + 4 files changed, 701 insertions(+) create mode 100644 sound/soc/codecs/cs35l56-shared-test.c
sound/soc/codecs/Kconfig +14 -0
@@ -936,6 +936,20 @@ config SND_SOC_CS35L56_TEST 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". + +config SND_SOC_CS35L56_SHARED_TEST + tristate "KUnit test for Cirrus Logic cs35l56-shared" if !KUNIT_ALL_TESTS + depends on SND_SOC_CS35L56_SHARED && KUNIT + default KUNIT_ALL_TESTS + help + This builds KUnit tests for the Cirrus Logic cs35l56-shared + module. + For more information on KUnit and unit tests in general, please refer to the KUnit documentation in Documentation/dev-tools/kunit/.
sound/soc/codecs/Makefile +2 -0
@@ -77,6 +77,7 @@ snd-soc-cs35l45-spi-y := cs35l45-spi.o snd-soc-cs35l45-i2c-y := cs35l45-i2c.o snd-soc-cs35l56-y := cs35l56.o snd-soc-cs35l56-shared-y := cs35l56-shared.o +snd-soc-cs35l56-shared-test-y := cs35l56-shared-test.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
@@ -512,6 +513,7 @@ obj-$(CONFIG_SND_SOC_CS35L45_SPI) += snd-soc-cs35l45-spi.o obj-$(CONFIG_SND_SOC_CS35L45_I2C) += snd-soc-cs35l45-i2c.o obj-$(CONFIG_SND_SOC_CS35L56) += snd-soc-cs35l56.o obj-$(CONFIG_SND_SOC_CS35L56_SHARED) += snd-soc-cs35l56-shared.o +obj-$(CONFIG_SND_SOC_CS35L56_SHARED_TEST) += snd-soc-cs35l56-shared-test.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
sound/soc/codecs/cs35l56-shared-test.c new file +680 -0
680 lines not on this page · raw message
sound/soc/codecs/cs35l56-shared.c +5 -0
@@ -5,6 +5,7 @@// Copyright (C) 2023 Cirrus Logic, Inc. and // Cirrus Logic International Semiconductor Ltd. +#include <kunit/static_stub.h> #include <linux/array_size.h> #include <linux/bitfield.h> #include <linux/cleanup.h>
@@ -1630,6 +1631,8 @@ int cs35l56_configure_onchip_spkid_pads(struct cs35l56_base *cs35l56_base)int num_gpios, num_pulls;int i, ret; +KUNIT_STATIC_STUB_REDIRECT (cs35l56_configure_onchip_spkid_pads, cs35l56_base); +if (cs35l56_base->num_onchip_spkid_gpios ==0 )return 0 ;
@@ -1680,6 +1683,8 @@ int cs35l56_read_onchip_spkid(struct cs35l56_base *cs35l56_base)int speaker_id =0 ;int i, ret; +KUNIT_STATIC_STUB_REDIRECT (cs35l56_read_onchip_spkid, cs35l56_base); +if (cs35l56_base->num_onchip_spkid_gpios ==0 )return -ENOENT ;
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH 3/3 ASoC: cs35l56: KUnit tests for parsing and using onchip GPIOs
In reply to Richard FitzgeraldAdd KUnit test cases for:
- cs35l56_process_xu_properties() which reads the onchip GPIO definitions.
- cs35l56_set_fw_name() calls functions to configure and set the GPIOs.
- cs35l56_set_fw_name() saves the ID value in cs35l56_priv.speaker_id.
- cs35l56_set_fw_name() does not overwrite a speaker ID that was already found some other way.
--- sound/soc/codecs/cs35l56-test.c | 273 ++++++++++++++++++++++++++++++++ 1 file changed, 273 insertions(+)
sound/soc/codecs/cs35l56-test.c +273 -0
@@ -15,6 +15,8 @@#include <linux/module.h> #include <linux/overflow.h> #include <linux/pci_ids.h> +#include <linux/property.h> +#include <linux/seq_buf.h> #include <linux/soundwire/sdw.h> #include <sound/cs35l56.h> #include <sound/cs-amp-lib.h>
@@ -23,16 +25,46 @@ KUNIT_DEFINE_ACTION_WRAPPER(faux_device_destroy_wrapper, faux_device_destroy, struct faux_device *) +KUNIT_DEFINE_ACTION_WRAPPER(software_node_unregister_node_group_wrapper, + software_node_unregister_node_group, + const struct software_node * const *) + +KUNIT_DEFINE_ACTION_WRAPPER(software_node_unregister_wrapper, + software_node_unregister, + const struct software_node *) + +KUNIT_DEFINE_ACTION_WRAPPER(device_remove_software_node_wrapper, + device_remove_software_node, + struct device *) + struct cs35l56_test_priv { struct faux_device *amp_dev; struct cs35l56_private *cs35l56_priv; const char *ssidexv2; + + bool read_onchip_spkid_called; + bool configure_onchip_spkid_pads_called; }; struct cs35l56_test_param { u8 type; u8 rev; + + s32 spkid_gpios[4]; + s32 spkid_pulls[4]; +}; + +static const struct software_node cs35l56_test_dev_sw_node = + SOFTWARE_NODE("SWD1", NULL, NULL); + +static const struct software_node cs35l56_test_af01_sw_node = + SOFTWARE_NODE("AF01", NULL, &cs35l56_test_dev_sw_node); + +static const struct software_node *cs35l56_test_dev_and_af01_node_group[] = { + &cs35l56_test_dev_sw_node, + &cs35l56_test_af01_sw_node, + NULL }; static const char *cs35l56_test_devm_get_vendor_specific_variant_id_none(struct device *dev,
@@ -232,6 +264,190 @@ static void cs35l56_test_l56_b0_ssidexv2_ignored_suffix_sdw(struct kunit *test)KUNIT_EXPECT_STREQ (test, cs35l56->fallback_fw_suffix,"l1u5" ); } +/* +* Test that cs35l56_process_xu_properties() correctly parses the GPIO and +* pull values from properties into the arrays in struct cs35l56_base. +* +* This test creates the node tree: +* +* Node("SWD1") { // top-level device node +* Node("AF01") { +* Node("mipi-sdca-function-expansion-subproperties") { +* property: "01fa-spk-id-gpios-onchip" +* property: 01fa-spk-id-gpios-onchip-pull +* } +* } +* } +* +* Note that in ACPI "mipi-sdca-function-expansion-subproperties" is +* a special _DSD property that points to a Device(EXT0) node but behaves +* as an alias of the EXT0 node. The equivalent in software nodes is to +* create a Node named "mipi-sdca-function-expansion-subproperties" with +* the properties. +* +*/ +static void cs35l56_test_parse_xu_onchip_spkid (struct kunit *test) +{ +const struct cs35l56_test_param *param = test->param_value; +struct cs35l56_test_priv *priv = test->priv; +struct cs35l56_private *cs35l56 = priv->cs35l56_priv; +struct software_node *ext0_node; +int num_gpios =0 ; +int num_pulls =0 ; +int i; + +for (i =0 ; i <ARRAY_SIZE (param->spkid_gpios); i++, num_gpios++) { +if (param->spkid_gpios[i] <0 ) +break ; + } +KUNIT_ASSERT_LE (test, num_gpios,ARRAY_SIZE (cs35l56->base.onchip_spkid_gpios)); + +for (i =0 ; i <ARRAY_SIZE (param->spkid_pulls); i++, num_pulls++) { +if (param->spkid_pulls[i] <0 ) +break ; + } +KUNIT_ASSERT_LE (test, num_pulls,ARRAY_SIZE (cs35l56->base.onchip_spkid_pulls)); + +const struct property_entry ext0_props[] = { +PROPERTY_ENTRY_U32_ARRAY_LEN ("01fa-spk-id-gpios-onchip" , + param->spkid_gpios, num_gpios), +PROPERTY_ENTRY_U32_ARRAY_LEN ("01fa-spk-id-gpios-onchip-pull" , + param->spkid_pulls, num_pulls), + { } + }; + +KUNIT_ASSERT_EQ (test, +software_node_register_node_group (cs35l56_test_dev_and_af01_node_group), +0 ); +KUNIT_ASSERT_EQ (test, +kunit_add_action_or_reset (test, + software_node_unregister_node_group_wrapper, + cs35l56_test_dev_and_af01_node_group), +0 ); + + ext0_node =kunit_kzalloc (test,sizeof (*ext0_node),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, ext0_node); + *ext0_node =SOFTWARE_NODE ("mipi-sdca-function-expansion-subproperties" , + ext0_props, &cs35l56_test_af01_sw_node); + +KUNIT_ASSERT_EQ (test,software_node_register (ext0_node),0 ); +KUNIT_ASSERT_EQ (test, +kunit_add_action_or_reset (test, + software_node_unregister_wrapper, + ext0_node), +0 ); + +KUNIT_ASSERT_EQ (test, +device_add_software_node (cs35l56->base.dev, &cs35l56_test_dev_sw_node),0 ); +KUNIT_ASSERT_EQ (test,0 , +kunit_add_action_or_reset (test, + device_remove_software_node_wrapper, + cs35l56->base.dev)); + +KUNIT_EXPECT_EQ (test,cs35l56_process_xu_properties (cs35l56),0 ); + +KUNIT_EXPECT_EQ (test, cs35l56->base.num_onchip_spkid_gpios, num_gpios); +KUNIT_EXPECT_EQ (test, cs35l56->base.num_onchip_spkid_pulls, num_pulls); + +for (i =0 ; i <ARRAY_SIZE (param->spkid_gpios); i++) { +if (param->spkid_gpios[i] <0 ) +break ; + +/* +* cs35l56_process_xu_properties() stores the GPIO numbers +* zero-based, which is one less than the value in the property. +*/ +KUNIT_EXPECT_EQ_MSG (test, cs35l56->base.onchip_spkid_gpios[i], + param->spkid_gpios[i] -1 , +"i=%d" , i); + } + +for (i =0 ; i <ARRAY_SIZE (param->spkid_pulls); i++) { +if (param->spkid_pulls[i] <0 ) +break ; + +KUNIT_EXPECT_EQ_MSG (test, cs35l56->base.onchip_spkid_pulls[i], + param->spkid_pulls[i],"i=%d" , i); + } +} + +static int cs35l56_test_dummy_read_onchip_spkid (struct cs35l56_base *cs35l56_base) +{ +struct kunit *test =kunit_get_current_test (); +struct cs35l56_test_priv *priv = test->priv; + + priv->read_onchip_spkid_called = true; + +return 4 ; +} + +static int cs35l56_test_dummy_configure_onchip_spkid_pads (struct cs35l56_base *cs35l56_base) +{ +struct kunit *test =kunit_get_current_test (); +struct cs35l56_test_priv *priv = test->priv; + + priv->configure_onchip_spkid_pads_called = true; + +return 0 ; +} + +static void cs35l56_test_set_fw_name_reads_onchip_spkid (struct kunit *test) +{ +struct cs35l56_test_priv *priv = test->priv; +struct cs35l56_private *cs35l56 = priv->cs35l56_priv; + +/* Provide some on-chip GPIOs for spkid */ + cs35l56->base.onchip_spkid_gpios[0 ] =1 ; + cs35l56->base.num_onchip_spkid_gpios =1 ; + + cs35l56->speaker_id = -ENOENT ; + +kunit_activate_static_stub (test, + cs35l56_configure_onchip_spkid_pads, + cs35l56_test_dummy_configure_onchip_spkid_pads); +kunit_activate_static_stub (test, + cs35l56_read_onchip_spkid, + cs35l56_test_dummy_read_onchip_spkid); + + priv->configure_onchip_spkid_pads_called = false; + priv->read_onchip_spkid_called = false; +KUNIT_EXPECT_EQ (test,cs35l56_set_fw_name (cs35l56->component),0 ); +KUNIT_EXPECT_TRUE (test, priv->configure_onchip_spkid_pads_called); +KUNIT_EXPECT_TRUE (test, priv->read_onchip_spkid_called); +KUNIT_EXPECT_EQ (test, cs35l56->speaker_id, +cs35l56_test_dummy_read_onchip_spkid (&cs35l56->base)); +} + +static void cs35l56_test_set_fw_name_preserves_spkid_with_onchip_gpios (struct kunit *test) +{ +struct cs35l56_test_priv *priv = test->priv; +struct cs35l56_private *cs35l56 = priv->cs35l56_priv; + +/* Provide some on-chip GPIOs for spkid */ + cs35l56->base.onchip_spkid_gpios[0 ] =1 ; + cs35l56->base.num_onchip_spkid_gpios =1 ; + +/* Simulate that the driver already got a spkid from somewhere */ + cs35l56->speaker_id =15 ; + +KUNIT_EXPECT_EQ (test,cs35l56_set_fw_name (cs35l56->component),0 ); +KUNIT_EXPECT_EQ (test, cs35l56->speaker_id,15 ); +} + +static void cs35l56_test_set_fw_name_preserves_spkid_without_onchip_gpios (struct kunit *test) +{ +struct cs35l56_test_priv *priv = test->priv; +struct cs35l56_private *cs35l56 = priv->cs35l56_priv; + + cs35l56->base.num_onchip_spkid_gpios =0 ; + +/* Simulate that the driver already got a spkid from somewhere */ + cs35l56->speaker_id =15 ; + +KUNIT_EXPECT_EQ (test,cs35l56_set_fw_name (cs35l56->component),0 ); +KUNIT_EXPECT_EQ (test, cs35l56->speaker_id,15 ); +} +static int cs35l56_test_case_init_common (struct kunit *test) {struct cs35l56_test_priv *priv;
@@ -263,6 +479,7 @@ static int cs35l56_test_case_init_common(struct kunit *test) cs35l56->component =kunit_kzalloc (test,sizeof (*cs35l56->component),GFP_KERNEL );KUNIT_ASSERT_NOT_NULL (test, cs35l56->component); cs35l56->component->dev = cs35l56->base.dev; +snd_soc_component_set_drvdata (cs35l56->component, cs35l56); cs35l56->component->card =kunit_kzalloc (test,sizeof (*cs35l56->component->card),GFP_KERNEL );
@@ -299,6 +516,50 @@ static int cs35l56_test_case_init_soundwire(struct kunit *test)return 0 ; } +static void cs35l56_test_gpio_param_desc (const struct cs35l56_test_param *param,char *desc) +{ +DECLARE_SEQ_BUF (gpios,1 + (2 *ARRAY_SIZE (param->spkid_gpios))); +DECLARE_SEQ_BUF (pulls,1 + (2 *ARRAY_SIZE (param->spkid_pulls))); +int i; + +for (i =0 ; i <ARRAY_SIZE (param->spkid_gpios); i++) { +if (param->spkid_gpios[i] <0 ) +break ; + +seq_buf_printf (&gpios,"%s%d" , (i ==0 ) ?"" :"," , param->spkid_gpios[i]); + } + +for (i =0 ; i <ARRAY_SIZE (param->spkid_pulls); i++) { +if (param->spkid_pulls[i] <0 ) +break ; + +seq_buf_printf (&pulls,"%s%d" , (i ==0 ) ?"" :"," , param->spkid_pulls[i]); + } + +snprintf (desc,KUNIT_PARAM_DESC_SIZE ,"gpios:{%s} pulls:{%s}" , +seq_buf_str (&gpios),seq_buf_str (&pulls)); +} + +static const struct cs35l56_test_param cs35l56_test_onchip_spkid_cases[] = { + { .spkid_gpios = {1 ,-1 }, .spkid_pulls = {1 ,-1 }, }, + { .spkid_gpios = {1 ,-1 }, .spkid_pulls = {2 ,-1 }, }, + + { .spkid_gpios = {7 ,-1 }, .spkid_pulls = {1 ,-1 }, }, + { .spkid_gpios = {7 ,-1 }, .spkid_pulls = {2 ,-1 }, }, + + { .spkid_gpios = {1 ,7 ,-1 }, .spkid_pulls = {1 ,1 ,-1 }, }, + { .spkid_gpios = {1 ,7 ,-1 }, .spkid_pulls = {2 ,2 ,-1 }, }, + + { .spkid_gpios = {7 ,1 ,-1 }, .spkid_pulls = {1 ,1 ,-1 }, }, + { .spkid_gpios = {7 ,1 ,-1 }, .spkid_pulls = {2 ,2 ,-1 }, }, + + { .spkid_gpios = {3 ,7 ,1 ,-1 }, .spkid_pulls = {1 ,1 ,1 ,-1 }, }, + { .spkid_gpios = {3 ,7 ,1 ,-1 }, .spkid_pulls = {2 ,2 ,2 ,-1 }, }, +}; +KUNIT_ARRAY_PARAM (cs35l56_test_onchip_spkid, + cs35l56_test_onchip_spkid_cases, + cs35l56_test_gpio_param_desc); +static void cs35l56_test_type_rev_param_desc (const struct cs35l56_test_param *param,char *desc) {
@@ -331,6 +592,13 @@ static struct kunit_case cs35l56_test_cases_soundwire[] = { cs35l56_test_type_rev_ex_b0_gen_params),KUNIT_CASE (cs35l56_test_l56_b0_ssidexv2_ignored_suffix_sdw), +KUNIT_CASE_PARAM (cs35l56_test_parse_xu_onchip_spkid, + cs35l56_test_onchip_spkid_gen_params), + +KUNIT_CASE (cs35l56_test_set_fw_name_reads_onchip_spkid), +KUNIT_CASE (cs35l56_test_set_fw_name_preserves_spkid_with_onchip_gpios), + KUNIT_CASE(cs35l56_test_set_fw_name_preserves_spkid_without_onchip_gpios), + { } /* terminator */ };
@@ -339,6 +607,10 @@ static struct kunit_case cs35l56_test_cases_not_soundwire[] = {KUNIT_CASE_PARAM (cs35l56_test_ssidexv2_suffix_i2cspi, cs35l56_test_type_rev_all_gen_params), +KUNIT_CASE (cs35l56_test_set_fw_name_reads_onchip_spkid), +KUNIT_CASE (cs35l56_test_set_fw_name_preserves_spkid_with_onchip_gpios), + KUNIT_CASE(cs35l56_test_set_fw_name_preserves_spkid_without_onchip_gpios), + { } /* terminator */ };
@@ -360,6 +632,7 @@ kunit_test_suites( );MODULE_IMPORT_NS ("SND_SOC_CS_AMP_LIB" ); +MODULE_IMPORT_NS ("SND_SOC_CS35L56_SHARED" );MODULE_IMPORT_NS ("EXPORTED_FOR_KUNIT_TESTING" );MODULE_DESCRIPTION ("KUnit test for Cirrus Logic cs35l56 codec driver" );MODULE_AUTHOR ("Richard Fitzgerald <[email protected]>" );
Signature · 1 line
2.47.3
Mark Brown
maintainerQuoted 8 lines · Richard Fitzgerald
Some new Dell models use spare pins on the amp as a binary integer value to indicate the speaker type. The driver must use this to select the correct firmware files for the hardware.
Patch #1 is 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/3] ASoC: cs35l56: Support for reading speaker ID from on-chip GPIOs
commit: 4d1e3e2c404dc30e039d81ba7396c8bb82ade991
[2/3] ASoC: cs35l56-shared: KUnit tests for onchip speaker ID gpios
commit: 9bca0f05cea49ad11b464672ccdf6efd6a814a45
[3/3] ASoC: cs35l56: KUnit tests for parsing and using onchip GPIOs
commit: 6f220440399afba29165e0597fa2c3aa836191d7All 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