]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: hda/realtek - Introduce polarity for micmute LED GPIO
authorKai-Heng Feng <kai.heng.feng@canonical.com>
Thu, 30 Apr 2020 08:32:51 +0000 (16:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:48:20 +0000 (17:48 +0200)
[ Upstream commit dbd13179780555ecd3c992dea1222ca31920e892 ]

Currently mute LED and micmute LED share the same GPIO polarity.

So split the polarity for mute and micmute, in case they have different
polarities.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20200430083255.5093-1-kai.heng.feng@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/pci/hda/patch_realtek.c

index 2c457590944173feb5c5082dc982ea7ebacd6940..e057ecb5a9045f8ccbeadde25e634e787aafd4ae 100644 (file)
@@ -81,6 +81,7 @@ struct alc_spec {
 
        /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
        int mute_led_polarity;
+       int micmute_led_polarity;
        hda_nid_t mute_led_nid;
        hda_nid_t cap_mute_led_nid;
 
@@ -4080,11 +4081,9 @@ static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
 
 /* update LED status via GPIO */
 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
-                               bool enabled)
+                               int polarity, bool enabled)
 {
-       struct alc_spec *spec = codec->spec;
-
-       if (spec->mute_led_polarity)
+       if (polarity)
                enabled = !enabled;
        alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
 }
@@ -4095,7 +4094,8 @@ static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
        struct hda_codec *codec = private_data;
        struct alc_spec *spec = codec->spec;
 
-       alc_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
+       alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
+                           spec->mute_led_polarity, enabled);
 }
 
 /* turn on/off mic-mute LED via GPIO per capture hook */
@@ -4104,6 +4104,7 @@ static void alc_gpio_micmute_update(struct hda_codec *codec)
        struct alc_spec *spec = codec->spec;
 
        alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
+                           spec->micmute_led_polarity,
                            spec->gen.micmute_led.led_value);
 }
 
@@ -5808,7 +5809,8 @@ static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
 
        snd_hda_gen_hp_automute(codec, jack);
        /* mute_led_polarity is set to 0, so we pass inverted value here */
-       alc_update_gpio_led(codec, 0x10, !spec->gen.hp_jack_present);
+       alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
+                           !spec->gen.hp_jack_present);
 }
 
 /* Manage GPIOs for HP EliteBook Folio 9480m.