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

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
...@@ -332,33 +332,15 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, ...@@ -332,33 +332,15 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
} }
/* hook for controlling mic-mute LED GPIO */ /* hook for controlling mic-mute LED GPIO */
static void stac_capture_led_hook(struct hda_codec *codec, static void stac_capture_led_update(struct hda_codec *codec)
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ {
struct sigmatel_spec *spec = codec->spec; struct sigmatel_spec *spec = codec->spec;
unsigned int mask;
bool cur_mute, prev_mute;
if (!kcontrol || !ucontrol) if (spec->gen.micmute_led.led_value)
return; spec->gpio_data |= spec->mic_mute_led_gpio;
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 else
spec->mic_enabled &= ~mask; spec->gpio_data &= ~spec->mic_mute_led_gpio;
cur_mute = !spec->mic_enabled; stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
if (cur_mute != prev_mute) {
if (cur_mute)
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);
}
} }
static int stac_vrefout_set(struct hda_codec *codec, static int stac_vrefout_set(struct hda_codec *codec,
...@@ -4656,8 +4638,7 @@ static void stac_setup_gpio(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->gpio_dir |= spec->mic_mute_led_gpio;
spec->mic_enabled = 0; spec->mic_enabled = 0;
spec->gpio_data |= spec->mic_mute_led_gpio; spec->gpio_data |= spec->mic_mute_led_gpio;
snd_hda_gen_add_micmute_led(codec, stac_capture_led_update);
spec->gen.cap_sync_hook = stac_capture_led_hook;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment