* [PATCH 1/2] ALSA: hda/cirrus: Correct the full scale volume set logic
@ 2025-02-14 16:23 Vitaly Rodionov
2025-02-14 16:23 ` [PATCH 2/2] ALSA: hda/cirrus: Reduce codec resume time Vitaly Rodionov
2025-02-14 16:50 ` [PATCH 1/2] ALSA: hda/cirrus: Correct the full scale volume set logic Takashi Iwai
0 siblings, 2 replies; 4+ messages in thread
From: Vitaly Rodionov @ 2025-02-14 16:23 UTC (permalink / raw)
To: Takashi Iwai, Jaroslav Kysela
Cc: linux-sound, linux-kernel, patches, Vitaly Rodionov
This patch corrects the full-scale volume setting logic. On certain
platforms, the full-scale volume bit is required. The current logic
mistakenly sets this bit and incorrectly clears reserved bit 0, causing
the headphone output to be muted.
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
---
sound/pci/hda/patch_cs8409-tables.c | 6 +++---
sound/pci/hda/patch_cs8409.c | 20 +++++++++++---------
sound/pci/hda/patch_cs8409.h | 5 +++--
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/sound/pci/hda/patch_cs8409-tables.c b/sound/pci/hda/patch_cs8409-tables.c
index 759f48038273..621f947e3817 100644
--- a/sound/pci/hda/patch_cs8409-tables.c
+++ b/sound/pci/hda/patch_cs8409-tables.c
@@ -121,7 +121,7 @@ static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = {
{ CS42L42_MIXER_CHA_VOL, 0x3F },
{ CS42L42_MIXER_CHB_VOL, 0x3F },
{ CS42L42_MIXER_ADC_VOL, 0x3f },
- { CS42L42_HP_CTL, 0x03 },
+ { CS42L42_HP_CTL, 0x0D },
{ CS42L42_MIC_DET_CTL1, 0xB6 },
{ CS42L42_TIPSENSE_CTL, 0xC2 },
{ CS42L42_HS_CLAMP_DISABLE, 0x01 },
@@ -315,7 +315,7 @@ static const struct cs8409_i2c_param dolphin_c0_init_reg_seq[] = {
{ CS42L42_ASP_TX_SZ_EN, 0x01 },
{ CS42L42_PWR_CTL1, 0x0A },
{ CS42L42_PWR_CTL2, 0x84 },
- { CS42L42_HP_CTL, 0x03 },
+ { CS42L42_HP_CTL, 0x0D },
{ CS42L42_MIXER_CHA_VOL, 0x3F },
{ CS42L42_MIXER_CHB_VOL, 0x3F },
{ CS42L42_MIXER_ADC_VOL, 0x3f },
@@ -371,7 +371,7 @@ static const struct cs8409_i2c_param dolphin_c1_init_reg_seq[] = {
{ CS42L42_ASP_TX_SZ_EN, 0x00 },
{ CS42L42_PWR_CTL1, 0x0E },
{ CS42L42_PWR_CTL2, 0x84 },
- { CS42L42_HP_CTL, 0x01 },
+ { CS42L42_HP_CTL, 0x0D },
{ CS42L42_MIXER_CHA_VOL, 0x3F },
{ CS42L42_MIXER_CHB_VOL, 0x3F },
{ CS42L42_MIXER_ADC_VOL, 0x3f },
diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c
index 614327218634..b760332a4e35 100644
--- a/sound/pci/hda/patch_cs8409.c
+++ b/sound/pci/hda/patch_cs8409.c
@@ -876,7 +876,7 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
{ CS42L42_DET_INT_STATUS2, 0x00 },
{ CS42L42_TSRS_PLUG_STATUS, 0x00 },
};
- int fsv_old, fsv_new;
+ unsigned int fsv;
/* Bring CS42L42 out of Reset */
spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0);
@@ -893,13 +893,15 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
/* Clear interrupts, by reading interrupt status registers */
cs8409_i2c_bulk_read(cs42l42, irq_regs, ARRAY_SIZE(irq_regs));
- fsv_old = cs8409_i2c_read(cs42l42, CS42L42_HP_CTL);
- if (cs42l42->full_scale_vol == CS42L42_FULL_SCALE_VOL_0DB)
- fsv_new = fsv_old & ~CS42L42_FULL_SCALE_VOL_MASK;
- else
- fsv_new = fsv_old & CS42L42_FULL_SCALE_VOL_MASK;
- if (fsv_new != fsv_old)
- cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv_new);
+ fsv = cs8409_i2c_read(cs42l42, CS42L42_HP_CTL);
+ if (cs42l42->full_scale_vol) {
+ // Set the full scale volume bit
+ fsv |= CS42L42_FULL_SCALE_VOL_MASK;
+ cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv);
+ }
+ // Unmute analog channels A and B
+ fsv = (fsv & ~CS42L42_ANA_MUTE_AB);
+ cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv);
/* we have to explicitly allow unsol event handling even during the
* resume phase so that the jack event is processed properly
@@ -920,7 +922,7 @@ static void cs42l42_suspend(struct sub_codec *cs42l42)
{ CS42L42_MIXER_CHA_VOL, 0x3F },
{ CS42L42_MIXER_ADC_VOL, 0x3F },
{ CS42L42_MIXER_CHB_VOL, 0x3F },
- { CS42L42_HP_CTL, 0x0F },
+ { CS42L42_HP_CTL, 0x0D },
{ CS42L42_ASP_RX_DAI0_EN, 0x00 },
{ CS42L42_ASP_CLK_CFG, 0x00 },
{ CS42L42_PWR_CTL1, 0xFE },
diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h
index 5e48115caf09..14645d25e70f 100644
--- a/sound/pci/hda/patch_cs8409.h
+++ b/sound/pci/hda/patch_cs8409.h
@@ -230,9 +230,10 @@ enum cs8409_coefficient_index_registers {
#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 (1)
-#define CS42L42_FULL_SCALE_VOL_MINUS6DB (0)
+#define CS42L42_FULL_SCALE_VOL_0DB (0)
+#define CS42L42_FULL_SCALE_VOL_MINUS6DB (1)
/* Dell BULLSEYE / WARLOCK / CYBORG Specific Definitions */
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ALSA: hda/cirrus: Reduce codec resume time
2025-02-14 16:23 [PATCH 1/2] ALSA: hda/cirrus: Correct the full scale volume set logic Vitaly Rodionov
@ 2025-02-14 16:23 ` Vitaly Rodionov
2025-02-15 7:40 ` Takashi Iwai
2025-02-14 16:50 ` [PATCH 1/2] ALSA: hda/cirrus: Correct the full scale volume set logic Takashi Iwai
1 sibling, 1 reply; 4+ messages in thread
From: Vitaly Rodionov @ 2025-02-14 16:23 UTC (permalink / raw)
To: Takashi Iwai, Jaroslav Kysela
Cc: linux-sound, linux-kernel, patches, Vitaly Rodionov
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>
---
sound/pci/hda/patch_cs8409-tables.c | 6 +++---
sound/pci/hda/patch_cs8409.c | 6 +++++-
sound/pci/hda/patch_cs8409.h | 2 +-
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/sound/pci/hda/patch_cs8409-tables.c b/sound/pci/hda/patch_cs8409-tables.c
index 621f947e3817..09240138e087 100644
--- a/sound/pci/hda/patch_cs8409-tables.c
+++ b/sound/pci/hda/patch_cs8409-tables.c
@@ -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 },
diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c
index b760332a4e35..e50006757a2c 100644
--- a/sound/pci/hda/patch_cs8409.c
+++ b/sound/pci/hda/patch_cs8409.c
@@ -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));
diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h
index 14645d25e70f..e4bd2e12110b 100644
--- a/sound/pci/hda/patch_cs8409.h
+++ b/sound/pci/hda/patch_cs8409.h
@@ -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 {
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ALSA: hda/cirrus: Correct the full scale volume set logic
2025-02-14 16:23 [PATCH 1/2] ALSA: hda/cirrus: Correct the full scale volume set logic Vitaly Rodionov
2025-02-14 16:23 ` [PATCH 2/2] ALSA: hda/cirrus: Reduce codec resume time Vitaly Rodionov
@ 2025-02-14 16:50 ` Takashi Iwai
1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2025-02-14 16:50 UTC (permalink / raw)
To: Vitaly Rodionov
Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, patches
On Fri, 14 Feb 2025 17:23:25 +0100,
Vitaly Rodionov wrote:
>
> This patch corrects the full-scale volume setting logic. On certain
> platforms, the full-scale volume bit is required. The current logic
> mistakenly sets this bit and incorrectly clears reserved bit 0, causing
> the headphone output to be muted.
>
> Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Can we have a Fixes tag?
thanks,
Takashi
> ---
> sound/pci/hda/patch_cs8409-tables.c | 6 +++---
> sound/pci/hda/patch_cs8409.c | 20 +++++++++++---------
> sound/pci/hda/patch_cs8409.h | 5 +++--
> 3 files changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/sound/pci/hda/patch_cs8409-tables.c b/sound/pci/hda/patch_cs8409-tables.c
> index 759f48038273..621f947e3817 100644
> --- a/sound/pci/hda/patch_cs8409-tables.c
> +++ b/sound/pci/hda/patch_cs8409-tables.c
> @@ -121,7 +121,7 @@ static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = {
> { CS42L42_MIXER_CHA_VOL, 0x3F },
> { CS42L42_MIXER_CHB_VOL, 0x3F },
> { CS42L42_MIXER_ADC_VOL, 0x3f },
> - { CS42L42_HP_CTL, 0x03 },
> + { CS42L42_HP_CTL, 0x0D },
> { CS42L42_MIC_DET_CTL1, 0xB6 },
> { CS42L42_TIPSENSE_CTL, 0xC2 },
> { CS42L42_HS_CLAMP_DISABLE, 0x01 },
> @@ -315,7 +315,7 @@ static const struct cs8409_i2c_param dolphin_c0_init_reg_seq[] = {
> { CS42L42_ASP_TX_SZ_EN, 0x01 },
> { CS42L42_PWR_CTL1, 0x0A },
> { CS42L42_PWR_CTL2, 0x84 },
> - { CS42L42_HP_CTL, 0x03 },
> + { CS42L42_HP_CTL, 0x0D },
> { CS42L42_MIXER_CHA_VOL, 0x3F },
> { CS42L42_MIXER_CHB_VOL, 0x3F },
> { CS42L42_MIXER_ADC_VOL, 0x3f },
> @@ -371,7 +371,7 @@ static const struct cs8409_i2c_param dolphin_c1_init_reg_seq[] = {
> { CS42L42_ASP_TX_SZ_EN, 0x00 },
> { CS42L42_PWR_CTL1, 0x0E },
> { CS42L42_PWR_CTL2, 0x84 },
> - { CS42L42_HP_CTL, 0x01 },
> + { CS42L42_HP_CTL, 0x0D },
> { CS42L42_MIXER_CHA_VOL, 0x3F },
> { CS42L42_MIXER_CHB_VOL, 0x3F },
> { CS42L42_MIXER_ADC_VOL, 0x3f },
> diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c
> index 614327218634..b760332a4e35 100644
> --- a/sound/pci/hda/patch_cs8409.c
> +++ b/sound/pci/hda/patch_cs8409.c
> @@ -876,7 +876,7 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
> { CS42L42_DET_INT_STATUS2, 0x00 },
> { CS42L42_TSRS_PLUG_STATUS, 0x00 },
> };
> - int fsv_old, fsv_new;
> + unsigned int fsv;
>
> /* Bring CS42L42 out of Reset */
> spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0);
> @@ -893,13 +893,15 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
> /* Clear interrupts, by reading interrupt status registers */
> cs8409_i2c_bulk_read(cs42l42, irq_regs, ARRAY_SIZE(irq_regs));
>
> - fsv_old = cs8409_i2c_read(cs42l42, CS42L42_HP_CTL);
> - if (cs42l42->full_scale_vol == CS42L42_FULL_SCALE_VOL_0DB)
> - fsv_new = fsv_old & ~CS42L42_FULL_SCALE_VOL_MASK;
> - else
> - fsv_new = fsv_old & CS42L42_FULL_SCALE_VOL_MASK;
> - if (fsv_new != fsv_old)
> - cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv_new);
> + fsv = cs8409_i2c_read(cs42l42, CS42L42_HP_CTL);
> + if (cs42l42->full_scale_vol) {
> + // Set the full scale volume bit
> + fsv |= CS42L42_FULL_SCALE_VOL_MASK;
> + cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv);
> + }
> + // Unmute analog channels A and B
> + fsv = (fsv & ~CS42L42_ANA_MUTE_AB);
> + cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv);
>
> /* we have to explicitly allow unsol event handling even during the
> * resume phase so that the jack event is processed properly
> @@ -920,7 +922,7 @@ static void cs42l42_suspend(struct sub_codec *cs42l42)
> { CS42L42_MIXER_CHA_VOL, 0x3F },
> { CS42L42_MIXER_ADC_VOL, 0x3F },
> { CS42L42_MIXER_CHB_VOL, 0x3F },
> - { CS42L42_HP_CTL, 0x0F },
> + { CS42L42_HP_CTL, 0x0D },
> { CS42L42_ASP_RX_DAI0_EN, 0x00 },
> { CS42L42_ASP_CLK_CFG, 0x00 },
> { CS42L42_PWR_CTL1, 0xFE },
> diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h
> index 5e48115caf09..14645d25e70f 100644
> --- a/sound/pci/hda/patch_cs8409.h
> +++ b/sound/pci/hda/patch_cs8409.h
> @@ -230,9 +230,10 @@ enum cs8409_coefficient_index_registers {
> #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 (1)
> -#define CS42L42_FULL_SCALE_VOL_MINUS6DB (0)
> +#define CS42L42_FULL_SCALE_VOL_0DB (0)
> +#define CS42L42_FULL_SCALE_VOL_MINUS6DB (1)
>
> /* Dell BULLSEYE / WARLOCK / CYBORG Specific Definitions */
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ALSA: hda/cirrus: Reduce codec resume time
2025-02-14 16:23 ` [PATCH 2/2] ALSA: hda/cirrus: Reduce codec resume time Vitaly Rodionov
@ 2025-02-15 7:40 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2025-02-15 7:40 UTC (permalink / raw)
To: Vitaly Rodionov
Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, patches
On Fri, 14 Feb 2025 17:23:26 +0100,
Vitaly Rodionov wrote:
>
> 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>
Applied now. Thanks.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-15 7:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14 16:23 [PATCH 1/2] ALSA: hda/cirrus: Correct the full scale volume set logic Vitaly Rodionov
2025-02-14 16:23 ` [PATCH 2/2] ALSA: hda/cirrus: Reduce codec resume time Vitaly Rodionov
2025-02-15 7:40 ` Takashi Iwai
2025-02-14 16:50 ` [PATCH 1/2] ALSA: hda/cirrus: Correct the full scale volume set logic Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox