aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-01-28 12:17:43 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:30:20 -0500
commitce875f079efcfdcf693de89c7ab0ca7f71a9bdce (patch)
treed2d5d18dca2d9d7b86151e9aca822d141f6b1607 /sound/pci
parentbec15c3a5a1814019424228cd8127e9c82965ae1 (diff)
[ALSA] hda-codec - Add speaker automute to ALC262 HP models
Added the speaker-automute function to ALC262 HP models. Also, 'Mono' mixer elements are renamed as more intuitive 'Speaker'. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/patch_realtek.c117
1 files changed, 111 insertions, 6 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 764b32ba3636..8621c9f2eafd 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -8125,13 +8125,99 @@ static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8125 { } /* end */ 8125 { } /* end */
8126}; 8126};
8127 8127
8128/* update HP, line and mono-out pins according to the master switch */
8129static void alc262_hp_master_update(struct hda_codec *codec)
8130{
8131 struct alc_spec *spec = codec->spec;
8132 int val = spec->master_sw;
8133
8134 /* HP & line-out */
8135 snd_hda_codec_write_cache(codec, 0x1b, 0,
8136 AC_VERB_SET_PIN_WIDGET_CONTROL,
8137 val ? PIN_HP : 0);
8138 snd_hda_codec_write_cache(codec, 0x15, 0,
8139 AC_VERB_SET_PIN_WIDGET_CONTROL,
8140 val ? PIN_HP : 0);
8141 /* mono (speaker) depending on the HP jack sense */
8142 val = val && !spec->jack_present;
8143 snd_hda_codec_write_cache(codec, 0x16, 0,
8144 AC_VERB_SET_PIN_WIDGET_CONTROL,
8145 val ? PIN_OUT : 0);
8146}
8147
8148static void alc262_hp_bpc_automute(struct hda_codec *codec)
8149{
8150 struct alc_spec *spec = codec->spec;
8151 unsigned int presence;
8152 presence = snd_hda_codec_read(codec, 0x1b, 0,
8153 AC_VERB_GET_PIN_SENSE, 0);
8154 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8155 alc262_hp_master_update(codec);
8156}
8157
8158static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8159{
8160 if ((res >> 26) != ALC880_HP_EVENT)
8161 return;
8162 alc262_hp_bpc_automute(codec);
8163}
8164
8165static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8166{
8167 struct alc_spec *spec = codec->spec;
8168 unsigned int presence;
8169 presence = snd_hda_codec_read(codec, 0x15, 0,
8170 AC_VERB_GET_PIN_SENSE, 0);
8171 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8172 alc262_hp_master_update(codec);
8173}
8174
8175static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8176 unsigned int res)
8177{
8178 if ((res >> 26) != ALC880_HP_EVENT)
8179 return;
8180 alc262_hp_wildwest_automute(codec);
8181}
8182
8183static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8184 struct snd_ctl_elem_value *ucontrol)
8185{
8186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8187 struct alc_spec *spec = codec->spec;
8188 *ucontrol->value.integer.value = spec->master_sw;
8189 return 0;
8190}
8191
8192static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8193 struct snd_ctl_elem_value *ucontrol)
8194{
8195 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8196 struct alc_spec *spec = codec->spec;
8197 int val = !!*ucontrol->value.integer.value;
8198
8199 if (val == spec->master_sw)
8200 return 0;
8201 spec->master_sw = val;
8202 alc262_hp_master_update(codec);
8203 return 1;
8204}
8205
8128static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { 8206static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8207 {
8208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8209 .name = "Master Playback Switch",
8210 .info = snd_ctl_boolean_mono_info,
8211 .get = alc262_hp_master_sw_get,
8212 .put = alc262_hp_master_sw_put,
8213 },
8129 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8214 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8130 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8215 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8216 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8132 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 8217 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8133 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 8218 HDA_OUTPUT),
8134 8219 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8220 HDA_OUTPUT),
8135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8223 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
@@ -8150,12 +8236,21 @@ static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8150}; 8236};
8151 8237
8152static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { 8238static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8239 {
8240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8241 .name = "Master Playback Switch",
8242 .info = snd_ctl_boolean_mono_info,
8243 .get = alc262_hp_master_sw_get,
8244 .put = alc262_hp_master_sw_put,
8245 },
8153 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8246 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8154 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8247 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8155 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 8248 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8249 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8157 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 8250 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8158 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 8251 HDA_OUTPUT),
8252 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8253 HDA_OUTPUT),
8159 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), 8254 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8160 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), 8255 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
8161 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), 8256 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
@@ -8880,7 +8975,7 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8880 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8975 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8881 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8976 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8882 8977
8883 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 8978 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 8979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8885 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 8980 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8886 8981
@@ -8922,6 +9017,8 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 9017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 9018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8924 9019
9020 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9021
8925 { } 9022 { }
8926}; 9023};
8927 9024
@@ -9016,6 +9113,8 @@ static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9016 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ 9113 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, 9114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9018 9115
9116 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9117
9019 { } 9118 { }
9020}; 9119};
9021 9120
@@ -9200,6 +9299,8 @@ static struct alc_config_preset alc262_presets[] = {
9200 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9299 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9201 .channel_mode = alc262_modes, 9300 .channel_mode = alc262_modes,
9202 .input_mux = &alc262_HP_capture_source, 9301 .input_mux = &alc262_HP_capture_source,
9302 .unsol_event = alc262_hp_bpc_unsol_event,
9303 .init_hook = alc262_hp_bpc_automute,
9203 }, 9304 },
9204 [ALC262_HP_BPC_D7000_WF] = { 9305 [ALC262_HP_BPC_D7000_WF] = {
9205 .mixers = { alc262_HP_BPC_WildWest_mixer }, 9306 .mixers = { alc262_HP_BPC_WildWest_mixer },
@@ -9210,6 +9311,8 @@ static struct alc_config_preset alc262_presets[] = {
9210 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9311 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9211 .channel_mode = alc262_modes, 9312 .channel_mode = alc262_modes,
9212 .input_mux = &alc262_HP_D7000_capture_source, 9313 .input_mux = &alc262_HP_D7000_capture_source,
9314 .unsol_event = alc262_hp_wildwest_unsol_event,
9315 .init_hook = alc262_hp_wildwest_automute,
9213 }, 9316 },
9214 [ALC262_HP_BPC_D7000_WL] = { 9317 [ALC262_HP_BPC_D7000_WL] = {
9215 .mixers = { alc262_HP_BPC_WildWest_mixer, 9318 .mixers = { alc262_HP_BPC_WildWest_mixer,
@@ -9221,6 +9324,8 @@ static struct alc_config_preset alc262_presets[] = {
9221 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9324 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9222 .channel_mode = alc262_modes, 9325 .channel_mode = alc262_modes,
9223 .input_mux = &alc262_HP_D7000_capture_source, 9326 .input_mux = &alc262_HP_D7000_capture_source,
9327 .unsol_event = alc262_hp_wildwest_unsol_event,
9328 .init_hook = alc262_hp_wildwest_automute,
9224 }, 9329 },
9225 [ALC262_HP_TC_T5735] = { 9330 [ALC262_HP_TC_T5735] = {
9226 .mixers = { alc262_hp_t5735_mixer }, 9331 .mixers = { alc262_hp_t5735_mixer },