From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: broonie@kernel.org, tiwai@suse.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: [PATCH] ASoC: cs35l56: Add module parameter to allow factory calibration
Date: Wed, 2 Dec 2026 11:43:33 +0000 [thread overview]
Message-ID: <20261202114333.816138-1-rf@opensource.cirrus.com> (raw)
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.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
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(-)
diff --git a/sound/hda/codecs/side-codecs/Kconfig b/sound/hda/codecs/side-codecs/Kconfig
index b7e2a6fa4258..3c36c82fe0a7 100644
--- a/sound/hda/codecs/side-codecs/Kconfig
+++ b/sound/hda/codecs/side-codecs/Kconfig
@@ -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.
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index c353c54465d3..169427d43898 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -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
diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c
index 329351de32b1..f7374afb7097 100644
--- a/sound/soc/codecs/cs35l56-shared.c
+++ b/sound/soc/codecs/cs35l56-shared.c
@@ -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",
diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 0ea8c69d93fc..34588245a8f3 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -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);
--
2.47.3
reply other threads:[~2026-12-02 11:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202114333.816138-1-rf@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®