ASoC: cs35l56: Allow restoring factory calibration through ALSA control
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Tue, 11 Nov 2025 13:08:50 +0000 (13:08 +0000)
committerMark Brown <broonie@kernel.org>
Tue, 11 Nov 2025 13:52:49 +0000 (13:52 +0000)
commit32172cf3cb543a04c41a1677c97a38e60cad05b6
treebdc5f0d04e67288cf5676e28522f81c67e25c019
parent69f3474a01e9867dd99fc4b703fa834ea1835c7d
ASoC: cs35l56: Allow restoring factory calibration through ALSA control

Add an ALSA control (CAL_DATA) that can be used to restore amp calibration,
instead of using debugfs. A readback control (CAL_DATA_RB) is also added
for factory testing.

On ChromeOS the process that restores amp calibration from NVRAM has
limited permissions and cannot access debugfs. It requires an ALSA control
that it can write the calibration blob into. ChromeOS also restricts access
to ALSA controls, which avoids the risk of accidental or malicious
overwriting of good calibration data with bad data. As this control is not
needed for normal Linux-based distros it is a Kconfig option.

A separate control, CAL_DATA_RB, provides a readback of the current
calibration data, which could be either from a write to CAL_DATA or the
result of factory production-line calibration.

The write and read are intentionally separate controls to defeat "dumb"
save-and-restore tools like alsa-restore that assume it is safe to save
all control values and write them back in any order at some undefined
future time. Such behavior carries the risk of restoring stale or bad data
over the top of good data.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20251111130850.513969-3-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/cs35l56.h
sound/soc/codecs/Kconfig
sound/soc/codecs/cs35l56-shared.c
sound/soc/codecs/cs35l56.c