Commit 3bf29db7 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: hda/sigmatel - Use common helper for mic mute LED



To simplify the code and to get the mic-mute LED behavior control, use
the new helper function for controlling the mic mute LED instead of
open-codes.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c647f806
Loading
Loading
Loading
Loading
+6 −25
Original line number Diff line number Diff line
@@ -332,33 +332,15 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
}

/* hook for controlling mic-mute LED GPIO */
static void stac_capture_led_hook(struct hda_codec *codec,
				  struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
static void stac_capture_led_update(struct hda_codec *codec)
{
	struct sigmatel_spec *spec = codec->spec;
	unsigned int mask;
	bool cur_mute, prev_mute;

	if (!kcontrol || !ucontrol)
		return;

	mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
	prev_mute = !spec->mic_enabled;
	if (ucontrol->value.integer.value[0] ||
	    ucontrol->value.integer.value[1])
		spec->mic_enabled |= mask;
	else
		spec->mic_enabled &= ~mask;
	cur_mute = !spec->mic_enabled;
	if (cur_mute != prev_mute) {
		if (cur_mute)
	if (spec->gen.micmute_led.led_value)
		spec->gpio_data |= spec->mic_mute_led_gpio;
	else
		spec->gpio_data &= ~spec->mic_mute_led_gpio;
		stac_gpio_set(codec, spec->gpio_mask,
			      spec->gpio_dir, spec->gpio_data);
	}
	stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
}

static int stac_vrefout_set(struct hda_codec *codec,
@@ -4656,8 +4638,7 @@ static void stac_setup_gpio(struct hda_codec *codec)
		spec->gpio_dir |= spec->mic_mute_led_gpio;
		spec->mic_enabled = 0;
		spec->gpio_data |= spec->mic_mute_led_gpio;

		spec->gen.cap_sync_hook = stac_capture_led_hook;
		snd_hda_gen_add_micmute_led(codec, stac_capture_led_update);
	}
}