]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: cs35l56: Add calibration command to store into UEFI
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Tue, 21 Oct 2025 10:50:20 +0000 (11:50 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 27 Oct 2025 14:07:49 +0000 (14:07 +0000)
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>
include/sound/cs35l56.h
sound/soc/codecs/cs35l56-shared.c

index 349b896ee7373c2c54e2f1a8e6f25e5e79b80017..82559be0f24943fb4880acad2e30014bf1a755c9 100644 (file)
@@ -321,6 +321,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;
index eeb830e3f7437d14fb0bdad584f7b7c7626c7351..bbacac6bda81578bcbe2f7d6a4839d31addbdecd 100644 (file)
@@ -1105,9 +1105,9 @@ ssize_t cs35l56_calibrate_debugfs_write(struct cs35l56_base *cs35l56_base,
                                        const char __user *from, size_t count,
                                        loff_t *ppos)
 {
-       static const char * const options[] = { "factory" };
-       char buf[8] = { 0 };
-       int ret;
+       static const char * const options[] = { "factory", "store_uefi" };
+       char buf[11] = { 0 };
+       int num_amps, ret;
 
        if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON))
                return -ENXIO;
@@ -1125,6 +1125,21 @@ ssize_t cs35l56_calibrate_debugfs_write(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;
        }