]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: hda/cirrus: Reduce codec resume time
authorVitaly Rodionov <vitalyr@opensource.cirrus.com>
Fri, 14 Feb 2025 16:23:26 +0000 (16:23 +0000)
committerTakashi Iwai <tiwai@suse.de>
Sat, 15 Feb 2025 07:39:05 +0000 (08:39 +0100)
This patch reduces the resume time by half and introduces an option to
include a delay after a single write operation before continuing.

Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://patch.msgid.link/20250214162354.2675652-2-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/patch_cs8409-tables.c
sound/pci/hda/patch_cs8409.c
sound/pci/hda/patch_cs8409.h

index 621f947e38174d99917b2626dcbcbf3d629ea2da..09240138e0871a6e6d91d43f1d193ff8dbeb70ac 100644 (file)
@@ -131,7 +131,7 @@ static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = {
        { CS42L42_RSENSE_CTL3, 0x00 },
        { CS42L42_TSENSE_CTL, 0x80 },
        { CS42L42_HS_BIAS_CTL, 0xC0 },
-       { CS42L42_PWR_CTL1, 0x02 },
+       { CS42L42_PWR_CTL1, 0x02, 10000 },
        { CS42L42_ADC_OVFL_INT_MASK, 0xff },
        { CS42L42_MIXER_INT_MASK, 0xff },
        { CS42L42_SRC_INT_MASK, 0xff },
@@ -328,7 +328,7 @@ static const struct cs8409_i2c_param dolphin_c0_init_reg_seq[] = {
        { CS42L42_RSENSE_CTL3, 0x00 },
        { CS42L42_TSENSE_CTL, 0x80 },
        { CS42L42_HS_BIAS_CTL, 0xC0 },
-       { CS42L42_PWR_CTL1, 0x02 },
+       { CS42L42_PWR_CTL1, 0x02, 10000 },
        { CS42L42_ADC_OVFL_INT_MASK, 0xff },
        { CS42L42_MIXER_INT_MASK, 0xff },
        { CS42L42_SRC_INT_MASK, 0xff },
@@ -384,7 +384,7 @@ static const struct cs8409_i2c_param dolphin_c1_init_reg_seq[] = {
        { CS42L42_RSENSE_CTL3, 0x00 },
        { CS42L42_TSENSE_CTL, 0x80 },
        { CS42L42_HS_BIAS_CTL, 0xC0 },
-       { CS42L42_PWR_CTL1, 0x06 },
+       { CS42L42_PWR_CTL1, 0x06, 10000 },
        { CS42L42_ADC_OVFL_INT_MASK, 0xff },
        { CS42L42_MIXER_INT_MASK, 0xff },
        { CS42L42_SRC_INT_MASK, 0xff },
index b760332a4e3577d022d45e626d87d1dcdcbe2f0b..e50006757a2c85753d818da2f29e88d86d79bad7 100644 (file)
@@ -346,6 +346,11 @@ static int cs8409_i2c_bulk_write(struct sub_codec *scodec, const struct cs8409_i
 
                if (cs8409_i2c_wait_complete(codec) < 0)
                        goto error;
+               /* Certain use cases may require a delay
+                * after a write operation before proceeding.
+                */
+               if (seq[i].delay)
+                       fsleep(seq[i].delay);
        }
 
        mutex_unlock(&spec->i2c_mux);
@@ -888,7 +893,6 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
 
        /* Initialize CS42L42 companion codec */
        cs8409_i2c_bulk_write(cs42l42, cs42l42->init_seq, cs42l42->init_seq_num);
-       msleep(CS42L42_INIT_TIMEOUT_MS);
 
        /* Clear interrupts, by reading interrupt status registers */
        cs8409_i2c_bulk_read(cs42l42, irq_regs, ARRAY_SIZE(irq_regs));
index 14645d25e70fd2ddb93c6dc42d05508a89fb68ee..e4bd2e12110bc4ab5875a8660b5f54ed80bed613 100644 (file)
@@ -229,7 +229,6 @@ enum cs8409_coefficient_index_registers {
 #define CS42L42_I2C_SLEEP_US                   (2000)
 #define CS42L42_PDN_TIMEOUT_US                 (250000)
 #define CS42L42_PDN_SLEEP_US                   (2000)
-#define CS42L42_INIT_TIMEOUT_MS                        (45)
 #define CS42L42_ANA_MUTE_AB                    (0x0C)
 #define CS42L42_FULL_SCALE_VOL_MASK            (2)
 #define CS42L42_FULL_SCALE_VOL_0DB             (0)
@@ -291,6 +290,7 @@ enum {
 struct cs8409_i2c_param {
        unsigned int addr;
        unsigned int value;
+       unsigned int delay;
 };
 
 struct cs8409_cir_param {