ALSA: hda - Use the common helper for thinkpad_acpi mic mute LED handling
authorTakashi Iwai <tiwai@suse.de>
Mon, 18 Jun 2018 15:28:45 +0000 (17:28 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 21 Jun 2018 11:52:24 +0000 (13:52 +0200)
Use the new common helper for setting up and controlling the mic mute
LED over thinkpad_acpi.  This also provides a new mixer enum "Mic
Mute-LED Mode" (that was present only for Dell models), which allows
user to choose the mic mute LED behavior.  For example, if you want
the mic mute LED turned on only while mic is on, choose "Follow
Capture" there.

Tested-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/thinkpad_helper.c

index 65bb3ac..97f49b7 100644 (file)
@@ -27,17 +27,11 @@ static void update_tpacpi_mute_led(void *private_data, int enabled)
                led_set_func(TPACPI_LED_MUTE, !enabled);
 }
 
-static void update_tpacpi_micmute_led(struct hda_codec *codec,
-                                     struct snd_kcontrol *kcontrol,
-                                     struct snd_ctl_elem_value *ucontrol)
+static void update_tpacpi_micmute(struct hda_codec *codec)
 {
-       if (!ucontrol || !led_set_func)
-               return;
-       if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) {
-               /* TODO: How do I verify if it's a mono or stereo here? */
-               bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1];
-               led_set_func(TPACPI_LED_MICMUTE, !val);
-       }
+       struct hda_gen_spec *spec = codec->spec;
+
+       led_set_func(TPACPI_LED_MICMUTE, spec->micmute_led.led_value);
 }
 
 static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
@@ -63,15 +57,10 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
                        spec->vmaster_mute.hook = update_tpacpi_mute_led;
                        removefunc = false;
                }
-               if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
-                       if (spec->num_adc_nids > 1 && !spec->dyn_adc_switch)
-                               codec_dbg(codec,
-                                         "Skipping micmute LED control due to several ADCs");
-                       else {
-                               spec->cap_sync_hook = update_tpacpi_micmute_led;
-                               removefunc = false;
-                       }
-               }
+               if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0 &&
+                   snd_hda_gen_add_micmute_led(codec,
+                                               update_tpacpi_micmute) > 0)
+                       removefunc = false;
        }
 
        if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) {