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 09/11] ASoC: cs35l56: Add calibration command to store into UEFI
Date: Thu, 16 Oct 2025 11:42:40 +0100 [thread overview]
Message-ID: <20251016104242.157325-10-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20251016104242.157325-1-rf@opensource.cirrus.com>
Add a new command 'store_uefi' to the calibrate sysfs file.
Writing this command will call cs_amp_set_efi_calibration_data()
to save the new data into an EFI variable. This is intended to
be used after a successful factory calibration to save the data
into EFI.
On systems without EFI it will return an error.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
include/sound/cs35l56.h | 1 +
sound/soc/codecs/cs35l56-shared.c | 19 +++++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h
index 4ed738615021..b3770285261c 100644
--- a/include/sound/cs35l56.h
+++ b/include/sound/cs35l56.h
@@ -314,6 +314,7 @@ struct cs35l56_base {
bool can_hibernate;
bool cal_data_valid;
s8 cal_index;
+ u8 num_amps;
struct cirrus_amp_cal_data cal_data;
struct gpio_desc *reset_gpio;
struct cs35l56_spi_payload *spi_payload_buf;
diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c
index dc6e49e3421a..27fb2f9b83c5 100644
--- a/sound/soc/codecs/cs35l56-shared.c
+++ b/sound/soc/codecs/cs35l56-shared.c
@@ -1101,8 +1101,8 @@ static int cs35l56_perform_calibration(struct cs35l56_base *cs35l56_base)
ssize_t cs35l56_calibrate_sysfs_store(struct cs35l56_base *cs35l56_base,
const char *buf, size_t count)
{
- static const char * const options[] = { "factory" };
- int ret;
+ static const char * const options[] = { "factory", "store_uefi" };
+ int num_amps, ret;
if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_SYSFS_COMMON))
return -ENXIO;
@@ -1113,6 +1113,21 @@ ssize_t cs35l56_calibrate_sysfs_store(struct cs35l56_base *cs35l56_base,
if (ret < 0)
return ret;
break;
+ case 1:
+ if (!cs35l56_base->cal_data_valid)
+ return -ENODATA;
+
+ num_amps = cs35l56_base->num_amps;
+ if (num_amps == 0)
+ num_amps = -1;
+
+ ret = cs_amp_set_efi_calibration_data(cs35l56_base->dev,
+ cs35l56_base->cal_index,
+ num_amps,
+ &cs35l56_base->cal_data);
+ if (ret < 0)
+ return ret;
+ break;
default:
return -ENXIO;
}
--
2.47.3
next prev parent reply other threads:[~2025-10-16 10:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 10:42 [PATCH 00/11] ALSA: cs35l56: Add support for factory calibration Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 01/11] ASoC: cs35l56: Read silicon ID during initialization and save it Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 02/11] ASoC: cs-amp-lib: Add helpers for factory calibration Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 03/11] ASoC: cs35l56: Add common code " Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 04/11] ASoC: cs35l56: Create sysfs files " Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 05/11] ALSA: hda/cs35l56: " Richard Fitzgerald
2025-10-16 11:01 ` Takashi Iwai
2025-10-16 11:27 ` Mark Brown
2025-10-16 11:58 ` Richard Fitzgerald
2025-10-16 12:13 ` Mark Brown
2025-10-16 12:45 ` Takashi Iwai
2025-10-16 10:42 ` [PATCH 06/11] ASoC: cs-amp-lib-test: Add cases for factory calibration helpers Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 07/11] ASoC: cs-amp-lib: Return attributes from cs_amp_get_efi_variable() Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 08/11] ASoC: cs-amp-lib: Add function to write calibration to EFI Richard Fitzgerald
2025-10-16 10:42 ` Richard Fitzgerald [this message]
2025-10-16 10:42 ` [PATCH 10/11] ALSA: hda/cs35l56: Set cal_index to the amp index Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 11/11] ASoC: cs-amp-lib-test: Add test cases for cs_amp_set_efi_calibration_data() Richard Fitzgerald
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=20251016104242.157325-10-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