Skip to content

Commit 431e76c

Browse files
KailangYangtiwai
authored andcommitted
ALSA: hda/realtek - Add supported new mute Led for HP
HP Note Book supported new mute Led. Hardware PIN was not enough to meet old LED rule. JD2 to control playback mute led. GPO3 to control capture mute led. (ALC285 didn't control GPO3 via verb command) This two PIN just could control by COEF registers. [ corrected typos by tiwai ] Signed-off-by: Kailang Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent fd60e06 commit 431e76c

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

sound/pci/hda/patch_realtek.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ struct alc_spec {
8686

8787
unsigned int gpio_mute_led_mask;
8888
unsigned int gpio_mic_led_mask;
89+
unsigned int mute_led_coef_idx;
90+
unsigned int mute_led_coefbit_mask;
91+
unsigned int mute_led_coefbit_on;
92+
unsigned int mute_led_coefbit_off;
93+
unsigned int mic_led_coef_idx;
94+
unsigned int mic_led_coefbit_mask;
95+
unsigned int mic_led_coefbit_on;
96+
unsigned int mic_led_coefbit_off;
8997

9098
hda_nid_t headset_mic_pin;
9199
hda_nid_t headphone_mic_pin;
@@ -4178,6 +4186,73 @@ static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
41784186
}
41794187
}
41804188

4189+
/* update mute-LED according to the speaker mute state via COEF bit */
4190+
static void alc_fixup_mute_led_coefbit_hook(void *private_data, int enabled)
4191+
{
4192+
struct hda_codec *codec = private_data;
4193+
struct alc_spec *spec = codec->spec;
4194+
4195+
if (spec->mute_led_polarity)
4196+
enabled = !enabled;
4197+
4198+
/* temporarily power up/down for setting COEF bit */
4199+
enabled ? alc_update_coef_idx(codec, spec->mute_led_coef_idx,
4200+
spec->mute_led_coefbit_mask, spec->mute_led_coefbit_off) :
4201+
alc_update_coef_idx(codec, spec->mute_led_coef_idx,
4202+
spec->mute_led_coefbit_mask, spec->mute_led_coefbit_on);
4203+
}
4204+
4205+
static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4206+
const struct hda_fixup *fix,
4207+
int action)
4208+
{
4209+
struct alc_spec *spec = codec->spec;
4210+
4211+
if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4212+
spec->mute_led_polarity = 0;
4213+
spec->mute_led_coef_idx = 0x0b;
4214+
spec->mute_led_coefbit_mask = 1<<3;
4215+
spec->mute_led_coefbit_on = 1<<3;
4216+
spec->mute_led_coefbit_off = 0;
4217+
spec->gen.vmaster_mute.hook = alc_fixup_mute_led_coefbit_hook;
4218+
spec->gen.vmaster_mute_enum = 1;
4219+
}
4220+
}
4221+
4222+
/* turn on/off mic-mute LED per capture hook by coef bit */
4223+
static void alc_hp_cap_micmute_update(struct hda_codec *codec)
4224+
{
4225+
struct alc_spec *spec = codec->spec;
4226+
4227+
if (spec->gen.micmute_led.led_value)
4228+
alc_update_coef_idx(codec, spec->mic_led_coef_idx,
4229+
spec->mic_led_coefbit_mask, spec->mic_led_coefbit_on);
4230+
else
4231+
alc_update_coef_idx(codec, spec->mic_led_coef_idx,
4232+
spec->mic_led_coefbit_mask, spec->mic_led_coefbit_off);
4233+
}
4234+
4235+
static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4236+
const struct hda_fixup *fix, int action)
4237+
{
4238+
struct alc_spec *spec = codec->spec;
4239+
4240+
if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4241+
spec->mic_led_coef_idx = 0x19;
4242+
spec->mic_led_coefbit_mask = 1<<13;
4243+
spec->mic_led_coefbit_on = 1<<13;
4244+
spec->mic_led_coefbit_off = 0;
4245+
snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update);
4246+
}
4247+
}
4248+
4249+
static void alc285_fixup_hp_mute_led(struct hda_codec *codec,
4250+
const struct hda_fixup *fix, int action)
4251+
{
4252+
alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4253+
alc285_fixup_hp_coef_micmute_led(codec, fix, action);
4254+
}
4255+
41814256
#if IS_REACHABLE(CONFIG_INPUT)
41824257
static void gpio2_mic_hotkey_event(struct hda_codec *codec,
41834258
struct hda_jack_callback *event)
@@ -5964,6 +6039,7 @@ enum {
59646039
ALC285_FIXUP_THINKPAD_HEADSET_JACK,
59656040
ALC294_FIXUP_ASUS_HPE,
59666041
ALC285_FIXUP_HP_GPIO_LED,
6042+
ALC285_FIXUP_HP_MUTE_LED,
59676043
};
59686044

59696045
static const struct hda_fixup alc269_fixups[] = {
@@ -7089,6 +7165,10 @@ static const struct hda_fixup alc269_fixups[] = {
70897165
.type = HDA_FIXUP_FUNC,
70907166
.v.func = alc285_fixup_hp_gpio_led,
70917167
},
7168+
[ALC285_FIXUP_HP_MUTE_LED] = {
7169+
.type = HDA_FIXUP_FUNC,
7170+
.v.func = alc285_fixup_hp_mute_led,
7171+
},
70927172
};
70937173

70947174
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -7234,6 +7314,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
72347314
SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
72357315
SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
72367316
SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_LED),
7317+
SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
72377318
SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
72387319
SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
72397320
SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),

0 commit comments

Comments
 (0)