ALSA: hda - Improved MacBook (Pro) 5,1 / 5,2 support

This patch adds support for automatically muting the speakers when headphones
are inserted, as well as relabelling the headphone widgets from the
non-standard "HP" to the standard "Headphone" for the mb5 model.

Signed-off-by: Alex Murray <murray.alex@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by Alex Murray and committed by Takashi Iwai a76221d4 4dee8baa

+26 -2
+26 -2
sound/pci/hda/patch_realtek.c
··· 7094 7094 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT), 7095 7095 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT), 7096 7096 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT), 7097 - HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT), 7098 - HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT), 7097 + HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT), 7098 + HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT), 7099 7099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7100 7100 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7101 7101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), ··· 7496 7496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7497 7497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7498 7498 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03}, 7499 + {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7499 7500 /* Front Mic pin: input vref at 80% */ 7500 7501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 7501 7502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, ··· 7679 7678 7680 7679 spec->autocfg.hp_pins[0] = 0x15; 7681 7680 spec->autocfg.speaker_pins[0] = 0x14; 7681 + } 7682 + 7683 + static void alc885_mb5_automute(struct hda_codec *codec) 7684 + { 7685 + unsigned int present; 7686 + 7687 + present = snd_hda_codec_read(codec, 0x14, 0, 7688 + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7689 + snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, 7690 + HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7691 + snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, 7692 + HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7693 + 7694 + } 7695 + 7696 + static void alc885_mb5_unsol_event(struct hda_codec *codec, 7697 + unsigned int res) 7698 + { 7699 + /* Headphone insertion or removal. */ 7700 + if ((res >> 26) == ALC880_HP_EVENT) 7701 + alc885_mb5_automute(codec); 7682 7702 } 7683 7703 7684 7704 static void alc885_imac91_automute(struct hda_codec *codec) ··· 9148 9126 .input_mux = &mb5_capture_source, 9149 9127 .dig_out_nid = ALC882_DIGOUT_NID, 9150 9128 .dig_in_nid = ALC882_DIGIN_NID, 9129 + .unsol_event = alc885_mb5_unsol_event, 9130 + .init_hook = alc885_mb5_automute, 9151 9131 }, 9152 9132 [ALC885_MACPRO] = { 9153 9133 .mixers = { alc882_macpro_mixer },