Skip to contentSkip to conversation

ASoC: cs35l56: Add module parameter to allow factory calibration

PATCH In review Richard Fitzgerald 2 participants 2 messages Dec 2

Subsystems (3)
lore
Share & tools
lore

Richard Fitzgerald

author maintainer
#0 lore raw

PATCH 1/1 ASoC: cs35l56: Add module parameter to allow factory calibration

Always build the calibration debugfs support into the driver, but only create the debugfs files if the new module parameter 'allow_factory_cal' is true, or the existing CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS Kconfig is enabled. This allows manufacturers to perform factory calibration on the production line without the need to build and install a custom kernel.

If the kernel has been built with CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS, the module parameter can be forced to 0 to disable calibration.

A small change is needed to the Kconfig for the HDA driver to delete the select of SND_SOC_CS35L56_CAL_DEBUGFS_COMMON, as that Kconfig symbol is now removed.

The CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS Kconfig is retained to prevent changing the behaviour of existing downstream products that depend on it enabling the debugfs.

Factory calibration is disabled by default to prevent accidental use of this feature in non-factory conditions, which could result in the speakers being under-protected.

---
Takashi/Mark: There is a trivial change to the Kconfig for the HDA driver. We don't have any other changes planned to that Kconfig so should be safe to take this patch through the ASoC tree.

 sound/hda/codecs/side-codecs/Kconfig |  1 -
 sound/soc/codecs/Kconfig             |  6 ------
 sound/soc/codecs/cs35l56-shared.c    | 15 ---------------
 sound/soc/codecs/cs35l56.c           |  6 +++++-
 4 files changed, 5 insertions(+), 23 deletions(-)
sound/hda/codecs/side-codecs/Kconfig +0 -1
index b7e2a6fa4258..3c36c82fe0a7 100644
@@ -116,7 +116,6 @@ menu "CS35L56 driver options"
 config SND_HDA_SCODEC_CS35L56_CAL_DEBUGFS
 	bool "CS35L56 create debugfs for factory calibration"
 	depends on DEBUG_FS
-	select SND_SOC_CS35L56_CAL_DEBUGFS_COMMON
 	help
 	  Create debugfs entries used during factory-line manufacture
 	  for factory calibration.
sound/soc/codecs/Kconfig +0 -6
index c353c54465d3..169427d43898 100644
@@ -911,16 +911,12 @@ config SND_SOC_CS35L56_SDW
 	help
 	  Enable support for Cirrus Logic CS35L56 boosted amplifier with SoundWire control
 
-config SND_SOC_CS35L56_CAL_DEBUGFS_COMMON
-	bool
-
 menu "CS35L56 driver options"
 	depends on SND_SOC_CS35L56
 
 config SND_SOC_CS35L56_CAL_DEBUGFS
 	bool "CS35L56 create debugfs for factory calibration"
 	depends on DEBUG_FS
-	select SND_SOC_CS35L56_CAL_DEBUGFS_COMMON
 	help
 	  Create debugfs entries used during factory-line manufacture
 	  for factory calibration.
@@ -929,7 +925,6 @@ config SND_SOC_CS35L56_CAL_DEBUGFS
 
 config SND_SOC_CS35L56_CAL_SET_CTRL
 	bool "CS35L56 ALSA control to restore factory calibration"
-	select SND_SOC_CS35L56_CAL_DEBUGFS_COMMON
 	help
 	  Allow restoring factory calibration data through an ALSA
 	  control. This is only needed on platforms without UEFI or
@@ -942,7 +937,6 @@ config SND_SOC_CS35L56_CAL_SET_CTRL
 
 config SND_SOC_CS35L56_CAL_PERFORM_CTRL
 	bool "CS35L56 ALSA control to perform factory calibration"
-	select SND_SOC_CS35L56_CAL_DEBUGFS_COMMON
 	help
 	  Allow performing factory calibration data through an ALSA
 	  control. It is recommended to use the debugfs method instead
sound/soc/codecs/cs35l56-shared.c +0 -15
index 329351de32b1..f7374afb7097 100644
@@ -1084,9 +1084,6 @@ ssize_t cs35l56_calibrate_debugfs_write(struct cs35l56_base *cs35l56_base,
 	char buf[11] = { 0 };
 	int num_amps, ret;
 
-	if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON))
-		return -ENXIO;
-
 	if (*ppos)
 		return -EINVAL;
 
@@ -1139,9 +1136,6 @@ ssize_t cs35l56_cal_ambient_debugfs_write(struct cs35l56_base *cs35l56_base,
 	unsigned long val;
 	int ret;
 
-	if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON))
-		return -ENXIO;
-
 	if (*ppos)
 		return -EINVAL;
 
@@ -1170,9 +1164,6 @@ ssize_t cs35l56_cal_data_debugfs_read(struct cs35l56_base *cs35l56_base,
 				      char __user *to, size_t count,
 				      loff_t *ppos)
 {
-	if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON))
-		return -ENXIO;
-
 	if (!cs35l56_base->cal_data_valid)
 		return 0;
 
@@ -1188,9 +1179,6 @@ ssize_t cs35l56_cal_data_debugfs_write(struct cs35l56_base *cs35l56_base,
 	struct cirrus_amp_cal_data cal_data;
 	int ret;
 
-	if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON))
-		return -ENXIO;
-
 	/* Only allow a full blob to be written */
 	if (*ppos || (count != sizeof(cal_data)))
 		return -EMSGSIZE;
@@ -1210,9 +1198,6 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_cal_data_debugfs_write, "SND_SOC_CS35L56_SHARED");
 void cs35l56_create_cal_debugfs(struct cs35l56_base *cs35l56_base,
 				const struct cs35l56_cal_debugfs_fops *fops)
 {
-	if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON))
-		return;
-
 	cs35l56_base->debugfs = cs_amp_create_debugfs(cs35l56_base->dev);
 
 	debugfs_create_file("calibrate",
sound/soc/codecs/cs35l56.c +5 -1
index 0ea8c69d93fc..34588245a8f3 100644
@@ -43,6 +43,10 @@
 #include "wm_adsp.h"
 #include "cs35l56.h"
 
+static bool cs35l56_allow_factory_cal = IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS);
+module_param_named(allow_factory_cal, cs35l56_allow_factory_cal, bool, 0444);
+MODULE_PARM_DESC(allow_factory_cal, "Enable support for factory calibration");
+
 /*
  * snd_soc_register_component() can call component_probe() on all instances
  * in a card, so deferred registration must be protected across all instances.
@@ -1532,7 +1536,7 @@ static int _cs35l56_component_probe(struct snd_soc_component *component)
 	if (ret)
 		return ret;
 
-	if (IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS))
+	if (cs35l56_allow_factory_cal)
 		cs35l56_create_cal_debugfs(&cs35l56->base, &cs35l56_cal_debugfs_fops);
 
 	queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work);
Signature · 1 line
2.47.3
maintainer
#1 lore raw
Quoted 1 line · Richard Fitzgerald

ASoC: cs35l56: Add module parameter to allow factory calibration

Applied to

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

Thanks!

[1/1] ASoC: cs35l56: Add module parameter to allow factory calibration

      https://git.kernel.org/broonie/sound/c/d8d4f9e00b06

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