summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/cs35l56-shared-test.c
AgeCommit message (Collapse)AuthorFilesLines
2026-03-05ASoC: cs35l56: KUnit tests for reading speaker ID from host GPIOsRichard Fitzgerald1-0/+197
Add test cases for the spk-id-gpios property used to read an integer speaker ID value from a set of GPIO inputs. There is a single parameterized test function, cs35l56_shared_test_get_speaker_id_from_host_gpio() that does the following: - Create a mock GPIO driver to simulate real GPIO inputs. - Create an array of struct software_node_ref_args to provide the content of the spk-id-gpios property. Each entry is a reference to a GPIO on the mock GPIO driver. The GPIO indexes are taken from test case parameterization. - Create a software node containing the spk-id-gpios property and set this as the node of the pseudo codec driver device. - Call cs35l56_get_speaker_id() and assert that the returned value matches the expected value defined in the test case parameterization. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20260304162402.1714759-4-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-05ASoC: cs35l56: Some KUnit testing of cs35l56_get_speaker_id()Richard Fitzgerald1-0/+43
Add some KUnit tests for cs35l56_get_speaker_id(). These only test the simpler cases of reading the speaker ID from cs_amp_get_vendor_spkid() or the "cirrus,speaker-id" property. The untested case is reading it from GPIOs, which would require a dummy implementation of a GPIO driver. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20260304162402.1714759-3-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2026-02-05ASoC: cs35l56-shared: KUnit tests for onchip speaker ID gpiosRichard Fitzgerald1-0/+680
Add 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. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20260205164838.1611295-3-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>