Skip to content

Commit 342b6b6

Browse files
Stefan Bindingtiwai
authored andcommitted
ALSA: hda/cs8409: Fix Full Scale Volume setting for all variants
All current variants (Bullseye/Warlock/Cyborg) should be using reduced volume (-6dB) for better speaker protection. Refactor to make more explicit the meaning and setting of Full Scale Volume setting to avoid future confusion. Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220328115614.15761-4-vitalyr@opensource.cirrus.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent bdc159d commit 342b6b6

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

sound/pci/hda/patch_cs8409.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
733733
{ 0x130A, 0x00 },
734734
{ 0x130F, 0x00 },
735735
};
736+
int fsv_old, fsv_new;
736737

737738
/* Bring CS42L42 out of Reset */
738739
gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0);
@@ -749,8 +750,13 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
749750
/* Clear interrupts, by reading interrupt status registers */
750751
cs8409_i2c_bulk_read(cs42l42, irq_regs, ARRAY_SIZE(irq_regs));
751752

752-
if (cs42l42->full_scale_vol)
753-
cs8409_i2c_write(cs42l42, 0x2001, 0x01);
753+
fsv_old = cs8409_i2c_read(cs42l42, 0x2001);
754+
if (cs42l42->full_scale_vol == CS42L42_FULL_SCALE_VOL_0DB)
755+
fsv_new = fsv_old & ~CS42L42_FULL_SCALE_VOL_MASK;
756+
else
757+
fsv_new = fsv_old & CS42L42_FULL_SCALE_VOL_MASK;
758+
if (fsv_new != fsv_old)
759+
cs8409_i2c_write(cs42l42, 0x2001, fsv_new);
754760

755761
/* we have to explicitly allow unsol event handling even during the
756762
* resume phase so that the jack event is processed properly
@@ -997,21 +1003,15 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
9971003
* Additionally set HSBIAS_SENSE_EN and Full Scale volume for some variants.
9981004
*/
9991005
switch (codec->fixup_id) {
1000-
case CS8409_WARLOCK:
1001-
spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0020;
1002-
spec->scodecs[CS8409_CODEC0]->full_scale_vol = 1;
1003-
break;
1004-
case CS8409_BULLSEYE:
1005-
spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0020;
1006-
spec->scodecs[CS8409_CODEC0]->full_scale_vol = 0;
1007-
break;
10081006
case CS8409_CYBORG:
10091007
spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x00a0;
1010-
spec->scodecs[CS8409_CODEC0]->full_scale_vol = 1;
1008+
spec->scodecs[CS8409_CODEC0]->full_scale_vol =
1009+
CS42L42_FULL_SCALE_VOL_MINUS6DB;
10111010
break;
10121011
default:
1013-
spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0003;
1014-
spec->scodecs[CS8409_CODEC0]->full_scale_vol = 1;
1012+
spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0020;
1013+
spec->scodecs[CS8409_CODEC0]->full_scale_vol =
1014+
CS42L42_FULL_SCALE_VOL_MINUS6DB;
10151015
break;
10161016
}
10171017

@@ -1222,6 +1222,9 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
12221222
cs8409_fix_caps(codec, DOLPHIN_LO_PIN_NID);
12231223
cs8409_fix_caps(codec, DOLPHIN_AMIC_PIN_NID);
12241224

1225+
spec->scodecs[CS8409_CODEC0]->full_scale_vol = CS42L42_FULL_SCALE_VOL_MINUS6DB;
1226+
spec->scodecs[CS8409_CODEC1]->full_scale_vol = CS42L42_FULL_SCALE_VOL_MINUS6DB;
1227+
12251228
break;
12261229
case HDA_FIXUP_ACT_PROBE:
12271230
/* Fix Sample Rate to 48kHz */

sound/pci/hda/patch_cs8409.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ enum cs8409_coefficient_index_registers {
235235
#define CS42L42_I2C_SLEEP_US (2000)
236236
#define CS42L42_PDN_TIMEOUT_US (250000)
237237
#define CS42L42_PDN_SLEEP_US (2000)
238+
#define CS42L42_FULL_SCALE_VOL_MASK (2)
239+
#define CS42L42_FULL_SCALE_VOL_0DB (1)
240+
#define CS42L42_FULL_SCALE_VOL_MINUS6DB (0)
238241

239242
/* Dell BULLSEYE / WARLOCK / CYBORG Specific Definitions */
240243

0 commit comments

Comments
 (0)