Skip to content

Commit 08b613b

Browse files
Vitaly Rodionovtiwai
authored andcommitted
ALSA: hda/cirrus: Correct the full scale volume set logic
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. Fixes: 342b6b6 ("ALSA: hda/cs8409: Fix Full Scale Volume setting for all variants") Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Link: https://patch.msgid.link/20250214210736.30814-1-vitalyr@opensource.cirrus.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 362ff1e commit 08b613b

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

sound/pci/hda/patch_cs8409-tables.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = {
121121
{ CS42L42_MIXER_CHA_VOL, 0x3F },
122122
{ CS42L42_MIXER_CHB_VOL, 0x3F },
123123
{ CS42L42_MIXER_ADC_VOL, 0x3f },
124-
{ CS42L42_HP_CTL, 0x03 },
124+
{ CS42L42_HP_CTL, 0x0D },
125125
{ CS42L42_MIC_DET_CTL1, 0xB6 },
126126
{ CS42L42_TIPSENSE_CTL, 0xC2 },
127127
{ CS42L42_HS_CLAMP_DISABLE, 0x01 },
@@ -315,7 +315,7 @@ static const struct cs8409_i2c_param dolphin_c0_init_reg_seq[] = {
315315
{ CS42L42_ASP_TX_SZ_EN, 0x01 },
316316
{ CS42L42_PWR_CTL1, 0x0A },
317317
{ CS42L42_PWR_CTL2, 0x84 },
318-
{ CS42L42_HP_CTL, 0x03 },
318+
{ CS42L42_HP_CTL, 0x0D },
319319
{ CS42L42_MIXER_CHA_VOL, 0x3F },
320320
{ CS42L42_MIXER_CHB_VOL, 0x3F },
321321
{ CS42L42_MIXER_ADC_VOL, 0x3f },
@@ -371,7 +371,7 @@ static const struct cs8409_i2c_param dolphin_c1_init_reg_seq[] = {
371371
{ CS42L42_ASP_TX_SZ_EN, 0x00 },
372372
{ CS42L42_PWR_CTL1, 0x0E },
373373
{ CS42L42_PWR_CTL2, 0x84 },
374-
{ CS42L42_HP_CTL, 0x01 },
374+
{ CS42L42_HP_CTL, 0x0D },
375375
{ CS42L42_MIXER_CHA_VOL, 0x3F },
376376
{ CS42L42_MIXER_CHB_VOL, 0x3F },
377377
{ CS42L42_MIXER_ADC_VOL, 0x3f },

sound/pci/hda/patch_cs8409.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
876876
{ CS42L42_DET_INT_STATUS2, 0x00 },
877877
{ CS42L42_TSRS_PLUG_STATUS, 0x00 },
878878
};
879-
int fsv_old, fsv_new;
879+
unsigned int fsv;
880880

881881
/* Bring CS42L42 out of Reset */
882882
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)
893893
/* Clear interrupts, by reading interrupt status registers */
894894
cs8409_i2c_bulk_read(cs42l42, irq_regs, ARRAY_SIZE(irq_regs));
895895

896-
fsv_old = cs8409_i2c_read(cs42l42, CS42L42_HP_CTL);
897-
if (cs42l42->full_scale_vol == CS42L42_FULL_SCALE_VOL_0DB)
898-
fsv_new = fsv_old & ~CS42L42_FULL_SCALE_VOL_MASK;
899-
else
900-
fsv_new = fsv_old & CS42L42_FULL_SCALE_VOL_MASK;
901-
if (fsv_new != fsv_old)
902-
cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv_new);
896+
fsv = cs8409_i2c_read(cs42l42, CS42L42_HP_CTL);
897+
if (cs42l42->full_scale_vol) {
898+
// Set the full scale volume bit
899+
fsv |= CS42L42_FULL_SCALE_VOL_MASK;
900+
cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv);
901+
}
902+
// Unmute analog channels A and B
903+
fsv = (fsv & ~CS42L42_ANA_MUTE_AB);
904+
cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv);
903905

904906
/* we have to explicitly allow unsol event handling even during the
905907
* resume phase so that the jack event is processed properly
@@ -920,7 +922,7 @@ static void cs42l42_suspend(struct sub_codec *cs42l42)
920922
{ CS42L42_MIXER_CHA_VOL, 0x3F },
921923
{ CS42L42_MIXER_ADC_VOL, 0x3F },
922924
{ CS42L42_MIXER_CHB_VOL, 0x3F },
923-
{ CS42L42_HP_CTL, 0x0F },
925+
{ CS42L42_HP_CTL, 0x0D },
924926
{ CS42L42_ASP_RX_DAI0_EN, 0x00 },
925927
{ CS42L42_ASP_CLK_CFG, 0x00 },
926928
{ CS42L42_PWR_CTL1, 0xFE },

sound/pci/hda/patch_cs8409.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ enum cs8409_coefficient_index_registers {
230230
#define CS42L42_PDN_TIMEOUT_US (250000)
231231
#define CS42L42_PDN_SLEEP_US (2000)
232232
#define CS42L42_INIT_TIMEOUT_MS (45)
233+
#define CS42L42_ANA_MUTE_AB (0x0C)
233234
#define CS42L42_FULL_SCALE_VOL_MASK (2)
234-
#define CS42L42_FULL_SCALE_VOL_0DB (1)
235-
#define CS42L42_FULL_SCALE_VOL_MINUS6DB (0)
235+
#define CS42L42_FULL_SCALE_VOL_0DB (0)
236+
#define CS42L42_FULL_SCALE_VOL_MINUS6DB (1)
236237

237238
/* Dell BULLSEYE / WARLOCK / CYBORG Specific Definitions */
238239

0 commit comments

Comments
 (0)