Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: cs35l56: Add calibration command to store into UEFI

Add a new command 'store_uefi' to the calibrate debugfs file.
Writing this command will call cs_amp_set_efi_calibration_data()
to save the new data into a UEFI variable. This is intended to
be used after a successful factory calibration.

On systems without UEFI the write to the debugfs file will
return an error.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20251021105022.1013685-10-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Richard Fitzgerald and committed by
Mark Brown
ef24466e 2b62e666

+19 -3
+1
include/sound/cs35l56.h
··· 321 321 bool can_hibernate; 322 322 bool cal_data_valid; 323 323 s8 cal_index; 324 + u8 num_amps; 324 325 struct cirrus_amp_cal_data cal_data; 325 326 struct gpio_desc *reset_gpio; 326 327 struct cs35l56_spi_payload *spi_payload_buf;
+18 -3
sound/soc/codecs/cs35l56-shared.c
··· 1105 1105 const char __user *from, size_t count, 1106 1106 loff_t *ppos) 1107 1107 { 1108 - static const char * const options[] = { "factory" }; 1109 - char buf[8] = { 0 }; 1110 - int ret; 1108 + static const char * const options[] = { "factory", "store_uefi" }; 1109 + char buf[11] = { 0 }; 1110 + int num_amps, ret; 1111 1111 1112 1112 if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON)) 1113 1113 return -ENXIO; ··· 1122 1122 switch (sysfs_match_string(options, buf)) { 1123 1123 case 0: 1124 1124 ret = cs35l56_perform_calibration(cs35l56_base); 1125 + if (ret < 0) 1126 + return ret; 1127 + break; 1128 + case 1: 1129 + if (!cs35l56_base->cal_data_valid) 1130 + return -ENODATA; 1131 + 1132 + num_amps = cs35l56_base->num_amps; 1133 + if (num_amps == 0) 1134 + num_amps = -1; 1135 + 1136 + ret = cs_amp_set_efi_calibration_data(cs35l56_base->dev, 1137 + cs35l56_base->cal_index, 1138 + num_amps, 1139 + &cs35l56_base->cal_data); 1125 1140 if (ret < 0) 1126 1141 return ret; 1127 1142 break;