Add another enum control to allow user explicitly enabling/disabling the automatic capture source selection via jack detection. This is a pretty similar like Auto-Mute Mode, but for inputs.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/patch_realtek.c | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 909a623..aa32dd9 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -924,6 +924,57 @@ static const struct snd_kcontrol_new alc_automute_mode_enum = { .put = alc_automute_mode_put, };
+/* + * Auto-Mic mode mixer enum support + */ +static int alc_automic_mode_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static const char * const texts[] = { + "Disabled", "Enabled" + }; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 2; + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + return 0; +} + +static int alc_automic_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct alc_spec *spec = codec->spec; + ucontrol->value.enumerated.item[0] = spec->auto_mic; + return 0; +} + +static int alc_automic_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct alc_spec *spec = codec->spec; + unsigned int val = !!ucontrol->value.enumerated.item[0]; + + if (spec->auto_mic == val) + return 0; + spec->auto_mic = val; + alc_mic_automute(codec, NULL); + return 1; +} + +static const struct snd_kcontrol_new alc_automic_mode_enum = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Auto-Mic Mode", + .info = alc_automic_mode_info, + .get = alc_automic_mode_get, + .put = alc_automic_mode_put, +}; + static struct snd_kcontrol_new * alc_kcontrol_new(struct alc_spec *spec, const char *name, const struct snd_kcontrol_new *temp) @@ -1185,6 +1236,8 @@ static void alc_init_auto_mic(struct hda_codec *codec) spec->am_entry[0].pin, spec->am_entry[1].pin, spec->am_entry[2].pin); + + alc_kcontrol_new(spec, "Auto-Mic Mode", &alc_automic_mode_enum); }
/* check the availabilities of auto-mute and auto-mic switches */