Commit 47fd830a authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] hda-codec - add snd_hda_codec_stereo() function

Added snd_hda_codec_amp_stereo() function that changes both of stereo
channels with the same mask and value bits.  It simplifies most of
amp-handling codes.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 82beb8fd
...@@ -842,6 +842,19 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, ...@@ -842,6 +842,19 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
return 1; return 1;
} }
/*
* update the AMP stereo with the same mask and value
*/
int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
int direction, int idx, int mask, int val)
{
int ch, ret = 0;
for (ch = 0; ch < 2; ch++)
ret |= snd_hda_codec_amp_update(codec, nid, ch, direction,
idx, mask, val);
return ret;
}
#ifdef CONFIG_PM #ifdef CONFIG_PM
/* resume the all amp commands from the cache */ /* resume the all amp commands from the cache */
void snd_hda_codec_resume_amp(struct hda_codec *codec) void snd_hda_codec_resume_amp(struct hda_codec *codec)
...@@ -913,9 +926,11 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, ...@@ -913,9 +926,11 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
long *valp = ucontrol->value.integer.value; long *valp = ucontrol->value.integer.value;
if (chs & 1) if (chs & 1)
*valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x7f; *valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx)
& HDA_AMP_VOLMASK;
if (chs & 2) if (chs & 2)
*valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x7f; *valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx)
& HDA_AMP_VOLMASK;
return 0; return 0;
} }
...@@ -992,10 +1007,10 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, ...@@ -992,10 +1007,10 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
if (chs & 1) if (chs & 1)
*valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) &
0x80) ? 0 : 1; HDA_AMP_MUTE) ? 0 : 1;
if (chs & 2) if (chs & 2)
*valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) &
0x80) ? 0 : 1; HDA_AMP_MUTE) ? 0 : 1;
return 0; return 0;
} }
...@@ -1012,12 +1027,14 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, ...@@ -1012,12 +1027,14 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
if (chs & 1) { if (chs & 1) {
change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
0x80, *valp ? 0 : 0x80); HDA_AMP_MUTE,
*valp ? 0 : HDA_AMP_MUTE);
valp++; valp++;
} }
if (chs & 2) if (chs & 2)
change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
0x80, *valp ? 0 : 0x80); HDA_AMP_MUTE,
*valp ? 0 : HDA_AMP_MUTE);
return change; return change;
} }
...@@ -1318,12 +1335,9 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, ...@@ -1318,12 +1335,9 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
val & 0xff); val & 0xff);
/* unmute amp switch (if any) */ /* unmute amp switch (if any) */
if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) && if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
(val & AC_DIG1_ENABLE)) { (val & AC_DIG1_ENABLE))
snd_hda_codec_amp_update(codec, nid, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
0x80, 0x00); HDA_AMP_MUTE, 0);
snd_hda_codec_amp_update(codec, nid, 1, HDA_OUTPUT, 0,
0x80, 0x00);
}
} }
mutex_unlock(&codec->spdif_mutex); mutex_unlock(&codec->spdif_mutex);
return change; return change;
......
...@@ -218,8 +218,7 @@ static int unmute_output(struct hda_codec *codec, struct hda_gnode *node) ...@@ -218,8 +218,7 @@ static int unmute_output(struct hda_codec *codec, struct hda_gnode *node)
ofs = (node->amp_out_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; ofs = (node->amp_out_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
if (val >= ofs) if (val >= ofs)
val -= ofs; val -= ofs;
snd_hda_codec_amp_update(codec, node->nid, 0, HDA_OUTPUT, 0, 0xff, val); snd_hda_codec_amp_stereo(codec, node->nid, HDA_OUTPUT, 0, 0xff, val);
snd_hda_codec_amp_update(codec, node->nid, 0, HDA_OUTPUT, 1, 0xff, val);
return 0; return 0;
} }
...@@ -234,10 +233,7 @@ static int unmute_input(struct hda_codec *codec, struct hda_gnode *node, unsigne ...@@ -234,10 +233,7 @@ static int unmute_input(struct hda_codec *codec, struct hda_gnode *node, unsigne
ofs = (node->amp_in_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; ofs = (node->amp_in_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
if (val >= ofs) if (val >= ofs)
val -= ofs; val -= ofs;
snd_hda_codec_amp_update(codec, node->nid, 0, HDA_INPUT, index, snd_hda_codec_amp_stereo(codec, node->nid, HDA_INPUT, index, 0xff, val);
0xff, val);
snd_hda_codec_amp_update(codec, node->nid, 1, HDA_INPUT, index,
0xff, val);
return 0; return 0;
} }
......
...@@ -84,10 +84,17 @@ int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, ...@@ -84,10 +84,17 @@ int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
int direction, int index); int direction, int index);
int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
int direction, int idx, int mask, int val); int direction, int idx, int mask, int val);
int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
int dir, int idx, int mask, int val);
#ifdef CONFIG_PM #ifdef CONFIG_PM
void snd_hda_codec_resume_amp(struct hda_codec *codec); void snd_hda_codec_resume_amp(struct hda_codec *codec);
#endif #endif
/* amp value bits */
#define HDA_AMP_MUTE 0x80
#define HDA_AMP_UNMUTE 0x00
#define HDA_AMP_VOLMASK 0x7f
/* mono switch binding multiple inputs */ /* mono switch binding multiple inputs */
#define HDA_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \ #define HDA_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
......
...@@ -1120,10 +1120,9 @@ static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, ...@@ -1120,10 +1120,9 @@ static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
return 0; return 0;
/* toggle HP mute appropriately */ /* toggle HP mute appropriately */
snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
0x80, spec->cur_eapd ? 0 : 0x80); HDA_AMP_MUTE,
snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, spec->cur_eapd ? 0 : HDA_AMP_MUTE);
0x80, spec->cur_eapd ? 0 : 0x80);
return 1; return 1;
} }
...@@ -1136,13 +1135,13 @@ static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol, ...@@ -1136,13 +1135,13 @@ static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol,
int change; int change;
change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
return change; return change;
} }
...@@ -1153,10 +1152,8 @@ static void ad1981_hp_automute(struct hda_codec *codec) ...@@ -1153,10 +1152,8 @@ static void ad1981_hp_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x06, 0, present = snd_hda_codec_read(codec, 0x06, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
} }
/* toggle input of built-in and mic jack appropriately */ /* toggle input of built-in and mic jack appropriately */
......
...@@ -472,13 +472,13 @@ static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, ...@@ -472,13 +472,13 @@ static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
/* toggle internal speakers mute depending of presence of /* toggle internal speakers mute depending of presence of
* the headphone jack * the headphone jack
*/ */
bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80; bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
bits = spec->cur_eapd ? 0 : 0x80; bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
return 1; return 1;
} }
...@@ -491,13 +491,13 @@ static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol, ...@@ -491,13 +491,13 @@ static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
int change; int change;
change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
return change; return change;
} }
...@@ -534,9 +534,9 @@ static void cxt5045_hp_automute(struct hda_codec *codec) ...@@ -534,9 +534,9 @@ static void cxt5045_hp_automute(struct hda_codec *codec)
spec->hp_present = snd_hda_codec_read(codec, 0x11, 0, spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
} }
/* unsolicited event for HP jack sensing */ /* unsolicited event for HP jack sensing */
...@@ -887,12 +887,12 @@ static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, ...@@ -887,12 +887,12 @@ static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
/* toggle internal speakers mute depending of presence of /* toggle internal speakers mute depending of presence of
* the headphone jack * the headphone jack
*/ */
bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80; bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
bits = spec->cur_eapd ? 0 : 0x80; bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
return 1; return 1;
} }
...@@ -905,13 +905,13 @@ static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol, ...@@ -905,13 +905,13 @@ static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol,
int change; int change;
change = snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, change = snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, change |= snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
return change; return change;
} }
...@@ -924,12 +924,12 @@ static void cxt5047_hp_automute(struct hda_codec *codec) ...@@ -924,12 +924,12 @@ static void cxt5047_hp_automute(struct hda_codec *codec)
spec->hp_present = snd_hda_codec_read(codec, 0x13, 0, spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
/* Mute/Unmute PCM 2 for good measure - some systems need this */ /* Mute/Unmute PCM 2 for good measure - some systems need this */
snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
} }
/* mute internal speaker if HP is plugged */ /* mute internal speaker if HP is plugged */
...@@ -941,12 +941,12 @@ static void cxt5047_hp2_automute(struct hda_codec *codec) ...@@ -941,12 +941,12 @@ static void cxt5047_hp2_automute(struct hda_codec *codec)
spec->hp_present = snd_hda_codec_read(codec, 0x13, 0, spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = spec->hp_present ? 0x80 : 0; bits = spec->hp_present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
/* Mute/Unmute PCM 2 for good measure - some systems need this */ /* Mute/Unmute PCM 2 for good measure - some systems need this */
snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits); HDA_AMP_MUTE, bits);
} }
/* toggle input of built-in and mic jack appropriately */ /* toggle input of built-in and mic jack appropriately */
......
...@@ -457,23 +457,15 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, ...@@ -457,23 +457,15 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
* this turns out to be necessary in the future. * this turns out to be necessary in the future.
*/ */
if (val <= 2) { if (val <= 2) {
snd_hda_codec_amp_update(codec, nid, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
0x80, 0x80); HDA_AMP_MUTE, HDA_AMP_MUTE);
snd_hda_codec_amp_update(codec, nid, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
0x80, 0x80); HDA_AMP_MUTE, 0);
snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, 0,
0x80, 0x00);
snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT, 0,
0x80, 0x00);
} else { } else {
snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, 0, snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
0x80, 0x80); HDA_AMP_MUTE, HDA_AMP_MUTE);
snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT, 0, snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
0x80, 0x80); HDA_AMP_MUTE, 0);
snd_hda_codec_amp_update(codec, nid, 0, HDA_OUTPUT, 0,
0x80, 0x00);
snd_hda_codec_amp_update(codec, nid, 1, HDA_OUTPUT, 0,
0x80, 0x00);
} }
} }
return change; return change;
...@@ -1559,15 +1551,11 @@ static void alc880_uniwill_hp_automute(struct hda_codec *codec) ...@@ -1559,15 +1551,11 @@ static void alc880_uniwill_hp_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
0x80, bits);
snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
0x80, bits);
} }
/* auto-toggle front mic */ /* auto-toggle front mic */
...@@ -1578,11 +1566,8 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec) ...@@ -1578,11 +1566,8 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x18, 0, present = snd_hda_codec_read(codec, 0x18, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1, snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
0x80, bits);
snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
0x80, bits);
} }
static void alc880_uniwill_automute(struct hda_codec *codec) static void alc880_uniwill_automute(struct hda_codec *codec)
...@@ -1614,11 +1599,8 @@ static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) ...@@ -1614,11 +1599,8 @@ static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
0x80, bits);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
0x80, bits);
} }
static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
...@@ -1626,19 +1608,14 @@ static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) ...@@ -1626,19 +1608,14 @@ static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
unsigned int present; unsigned int present;
present = snd_hda_codec_read(codec, 0x21, 0, present = snd_hda_codec_read(codec, 0x21, 0,
AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f; AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
present &= HDA_AMP_VOLMASK;
snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
0x7f, present); HDA_AMP_VOLMASK, present);
snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
0x7f, present); HDA_AMP_VOLMASK, present);
snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
0x7f, present);
snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
0x7f, present);
} }
static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
unsigned int res) unsigned int res)
{ {
...@@ -1891,11 +1868,9 @@ static void alc880_lg_automute(struct hda_codec *codec) ...@@ -1891,11 +1868,9 @@ static void alc880_lg_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x1b, 0, present = snd_hda_codec_read(codec, 0x1b, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
0x80, bits);
} }
static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
...@@ -1990,11 +1965,9 @@ static void alc880_lg_lw_automute(struct hda_codec *codec) ...@@ -1990,11 +1965,9 @@ static void alc880_lg_lw_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x1b, 0, present = snd_hda_codec_read(codec, 0x1b, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, bits);
} }
static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
...@@ -2363,11 +2336,10 @@ static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, ...@@ -2363,11 +2336,10 @@ static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
snd_hda_codec_write_cache(codec, nid, 0, snd_hda_codec_write_cache(codec, nid, 0,
AC_VERB_SET_PIN_WIDGET_CONTROL, AC_VERB_SET_PIN_WIDGET_CONTROL,
new_ctl); new_ctl);
val = ucontrol->value.enumerated.item[0] >= 3 ? 0x80 : 0x00; val = ucontrol->value.enumerated.item[0] >= 3 ?
snd_hda_codec_amp_update(codec, nid, 0, HDA_OUTPUT, 0, HDA_AMP_MUTE : 0;
0x80, val); snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
snd_hda_codec_amp_update(codec, nid, 1, HDA_OUTPUT, 0, HDA_AMP_MUTE, val);
0x80, val);
return 1; return 1;
} }
return 0; return 0;
...@@ -4791,13 +4763,10 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, ...@@ -4791,13 +4763,10 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
if (*cur_val == idx) if (*cur_val == idx)
return 0; return 0;
for (i = 0; i < imux->num_items; i++) { for (i = 0; i < imux->num_items; i++) {
unsigned int v = (i == idx) ? 0x00 : 0x80; unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
imux->items[i].index,
0x80, v);
snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT,
imux->items[i].index, imux->items[i].index,
0x80, v); HDA_AMP_MUTE, v);
} }
*cur_val = idx; *cur_val = idx;
return 1; return 1;
...@@ -5134,14 +5103,10 @@ static void alc885_imac24_automute(struct hda_codec *codec) ...@@ -5134,14 +5103,10 @@ static void alc885_imac24_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
} }
/* Processes unsolicited events. */ /* Processes unsolicited events. */
...@@ -5178,10 +5143,8 @@ static void alc882_targa_automute(struct hda_codec *codec) ...@@ -5178,10 +5143,8 @@ static void alc882_targa_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
present ? 1 : 3); present ? 1 : 3);
} }
...@@ -5776,13 +5739,10 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, ...@@ -5776,13 +5739,10 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
if (*cur_val == idx) if (*cur_val == idx)
return 0; return 0;
for (i = 0; i < imux->num_items; i++) { for (i = 0; i < imux->num_items; i++) {
unsigned int v = (i == idx) ? 0x00 : 0x80; unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
imux->items[i].index, imux->items[i].index,
0x80, v); HDA_AMP_MUTE, v);
snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT,
imux->items[i].index,
0x80, v);
} }
*cur_val = idx; *cur_val = idx;
return 1; return 1;
...@@ -6421,15 +6381,10 @@ static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) ...@@ -6421,15 +6381,10 @@ static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x1b, 0, present = snd_hda_codec_read(codec, 0x1b, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
} }
/* toggle RCA according to the front-jack state */ /* toggle RCA according to the front-jack state */
...@@ -6439,12 +6394,10 @@ static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) ...@@ -6439,12 +6394,10 @@ static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
} }
static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
unsigned int res) unsigned int res)
{ {
...@@ -6483,10 +6436,8 @@ static void alc883_medion_md2_automute(struct hda_codec *codec) ...@@ -6483,10 +6436,8 @@ static void alc883_medion_md2_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
} }
static void alc883_medion_md2_unsol_event(struct hda_codec *codec, static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
...@@ -6504,11 +6455,9 @@ static void alc883_tagra_automute(struct hda_codec *codec) ...@@ -6504,11 +6455,9 @@ static void alc883_tagra_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
0x80, bits);
snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
present ? 1 : 3); present ? 1 : 3);
} }
...@@ -6526,11 +6475,9 @@ static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) ...@@ -6526,11 +6475,9 @@ static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
0x80, bits);
} }
static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
...@@ -6540,15 +6487,11 @@ static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) ...@@ -6540,15 +6487,11 @@ static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x1b, 0, present = snd_hda_codec_read(codec, 0x1b, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
0x80, bits);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, bits);
} }
static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
...@@ -7347,18 +7290,13 @@ static void alc262_hippo_automute(struct hda_codec *codec) ...@@ -7347,18 +7290,13 @@ static void alc262_hippo_automute(struct hda_codec *codec)
spec->jack_present = (present & 0x80000000) != 0; spec->jack_present = (present & 0x80000000) != 0;
if (spec->jack_present) { if (spec->jack_present) {
/* mute internal speaker */ /* mute internal speaker */
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, 0x80); HDA_AMP_MUTE, HDA_AMP_MUTE);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, 0x80);
} else { } else {
/* unmute internal speaker if necessary */ /* unmute internal speaker if necessary */
mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, mute & 0x80); HDA_AMP_MUTE, mute);
mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, mute & 0x80);
} }
} }
...@@ -7382,18 +7320,13 @@ static void alc262_hippo1_automute(struct hda_codec *codec) ...@@ -7382,18 +7320,13 @@ static void alc262_hippo1_automute(struct hda_codec *codec)
present = (present & 0x80000000) != 0; present = (present & 0x80000000) != 0;
if (present) { if (present) {
/* mute internal speaker */ /* mute internal speaker */
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, 0x80); HDA_AMP_MUTE, HDA_AMP_MUTE);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, 0x80);
} else { } else {
/* unmute internal speaker if necessary */ /* unmute internal speaker if necessary */
mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, mute & 0x80); HDA_AMP_MUTE, mute);
mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, mute & 0x80);
} }
} }
...@@ -7455,18 +7388,13 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force) ...@@ -7455,18 +7388,13 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
} }
if (spec->jack_present) { if (spec->jack_present) {
/* mute internal speaker */ /* mute internal speaker */
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, 0x80); HDA_AMP_MUTE, HDA_AMP_MUTE);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
0x80, 0x80);
} else { } else {
/* unmute internal speaker if necessary */ /* unmute internal speaker if necessary */
mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, mute & 0x80); HDA_AMP_MUTE, mute);
mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
0x80, mute & 0x80);
} }
} }
...@@ -7488,13 +7416,13 @@ static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol, ...@@ -7488,13 +7416,13 @@ static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
int change; int change;
change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
return change; return change;
} }
...@@ -7507,9 +7435,11 @@ static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, ...@@ -7507,9 +7435,11 @@ static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
int change; int change;
change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
0x80, valp[0] ? 0 : 0x80); HDA_AMP_MUTE,
valp[0] ? 0 : HDA_AMP_MUTE);
change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, valp[1] ? 0 : 0x80); HDA_AMP_MUTE,
valp[1] ? 0 : HDA_AMP_MUTE);
if (change) if (change)
alc262_fujitsu_automute(codec, 0); alc262_fujitsu_automute(codec, 0);
return change; return change;
...@@ -8331,11 +8261,10 @@ static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol, ...@@ -8331,11 +8261,10 @@ static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
if (*cur_val == idx) if (*cur_val == idx)
return 0; return 0;
for (i = 0; i < imux->num_items; i++) { for (i = 0; i < imux->num_items; i++) {
unsigned int v = (i == idx) ? 0x00 : 0x80; unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
imux->items[i].index, 0x80, v); imux->items[i].index,
snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT, HDA_AMP_MUTE, v);
imux->items[i].index, 0x80, v);
snd_hda_codec_write_cache(codec, nid, 0, snd_hda_codec_write_cache(codec, nid, 0,
AC_VERB_SET_CONNECT_SEL, AC_VERB_SET_CONNECT_SEL,
idx ); idx );
...@@ -9328,14 +9257,10 @@ static void alc861_toshiba_automute(struct hda_codec *codec) ...@@ -9328,14 +9257,10 @@ static void alc861_toshiba_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x0f, 0, present = snd_hda_codec_read(codec, 0x0f, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0, snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0, snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
0x80, present ? 0 : 0x80);
snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
0x80, present ? 0 : 0x80);
} }
static void alc861_toshiba_unsol_event(struct hda_codec *codec, static void alc861_toshiba_unsol_event(struct hda_codec *codec,
...@@ -9922,11 +9847,10 @@ static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol, ...@@ -9922,11 +9847,10 @@ static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
if (*cur_val == idx) if (*cur_val == idx)
return 0; return 0;
for (i = 0; i < imux->num_items; i++) { for (i = 0; i < imux->num_items; i++) {
unsigned int v = (i == idx) ? 0x00 : 0x80; unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
imux->items[i].index, 0x80, v); imux->items[i].index,
snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT, HDA_AMP_MUTE, v);
imux->items[i].index, 0x80, v);
} }
*cur_val = idx; *cur_val = idx;
return 1; return 1;
...@@ -10261,11 +10185,9 @@ static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) ...@@ -10261,11 +10185,9 @@ static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x1b, 0, present = snd_hda_codec_read(codec, 0x1b, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, bits);
} }
static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
...@@ -10275,11 +10197,9 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) ...@@ -10275,11 +10197,9 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x18, 0, present = snd_hda_codec_read(codec, 0x18, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1, snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
0x80, bits);
} }
static void alc861vd_lenovo_automute(struct hda_codec *codec) static void alc861vd_lenovo_automute(struct hda_codec *codec)
...@@ -10353,10 +10273,8 @@ static void alc861vd_dallas_automute(struct hda_codec *codec) ...@@ -10353,10 +10273,8 @@ static void alc861vd_dallas_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x15, 0, present = snd_hda_codec_read(codec, 0x15, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0); HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, present ? 0x80 : 0);
} }
static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
...@@ -10855,11 +10773,10 @@ static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol, ...@@ -10855,11 +10773,10 @@ static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
if (*cur_val == idx) if (*cur_val == idx)
return 0; return 0;
for (i = 0; i < imux->num_items; i++) { for (i = 0; i < imux->num_items; i++) {
unsigned int v = (i == idx) ? 0x00 : 0x80; unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
imux->items[i].index, 0x80, v); imux->items[i].index,
snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT, HDA_AMP_MUTE, v);
imux->items[i].index, 0x80, v);
} }
*cur_val = idx; *cur_val = idx;
return 1; return 1;
...@@ -11204,11 +11121,9 @@ static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) ...@@ -11204,11 +11121,9 @@ static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x14, 0, present = snd_hda_codec_read(codec, 0x14, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
0x80, bits);
} }
static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
...@@ -11218,15 +11133,11 @@ static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) ...@@ -11218,15 +11133,11 @@ static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
present = snd_hda_codec_read(codec, 0x1b, 0, present = snd_hda_codec_read(codec, 0x1b, 0,
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
bits = present ? 0x80 : 0; bits = present ? HDA_AMP_MUTE : 0;
snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
0x80, bits); HDA_AMP_MUTE, bits);
snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
0x80, bits);
snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
0x80, bits);
} }
static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
......
...@@ -2408,13 +2408,13 @@ static int vaio_master_vol_put(struct snd_kcontrol *kcontrol, ...@@ -2408,13 +2408,13 @@ static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
int change; int change;
change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0, change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
0x7f, valp[0] & 0x7f); HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
0x7f, valp[1] & 0x7f); HDA_AMP_VOLMASK, valp[1]);
return change; return change;
} }
...@@ -2427,13 +2427,15 @@ static int vaio_master_sw_put(struct snd_kcontrol *kcontrol, ...@@ -2427,13 +2427,15 @@ static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
int change; int change;
change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
0x80, (valp[0] ? 0 : 0x80)); HDA_AMP_MUTE,
(valp[0] ? 0 : HDA_AMP_MUTE));
change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0, change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
0x80, (valp[1] ? 0 : 0x80)); HDA_AMP_MUTE,
(valp[1] ? 0 : HDA_AMP_MUTE));
snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
0x80, (valp[0] ? 0 : 0x80)); HDA_AMP_MUTE, (valp[0] ? 0 : HDA_AMP_MUTE));
snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
0x80, (valp[1] ? 0 : 0x80)); HDA_AMP_MUTE, (valp[1] ? 0 : HDA_AMP_MUTE));
return change; return change;
} }
......
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