ALSA: hda - Replace the rest of jack-detections with snd_hda_jack_detect()
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
83d605fd63
commit
d56757abc1
5 changed files with 45 additions and 95 deletions
|
@ -720,10 +720,10 @@ static struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = {
|
|||
static void ad1986a_automic(struct hda_codec *codec)
|
||||
{
|
||||
unsigned int present;
|
||||
present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0);
|
||||
present = snd_hda_jack_detect(codec, 0x1f);
|
||||
/* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
|
||||
snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL,
|
||||
(present & AC_PINSENSE_PRESENCE) ? 0 : 2);
|
||||
present ? 0 : 2);
|
||||
}
|
||||
|
||||
#define AD1986A_MIC_EVENT 0x36
|
||||
|
@ -762,10 +762,8 @@ static void ad1986a_update_hp(struct hda_codec *codec)
|
|||
static void ad1986a_hp_automute(struct hda_codec *codec)
|
||||
{
|
||||
struct ad198x_spec *spec = codec->spec;
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
|
||||
spec->jack_present = !!(present & 0x80000000);
|
||||
spec->jack_present = snd_hda_jack_detect(codec, 0x1a);
|
||||
if (spec->inv_jack_detect)
|
||||
spec->jack_present = !spec->jack_present;
|
||||
ad1986a_update_hp(codec);
|
||||
|
@ -1555,8 +1553,7 @@ static void ad1981_hp_automute(struct hda_codec *codec)
|
|||
{
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x06, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x06);
|
||||
snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0,
|
||||
HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
|
||||
}
|
||||
|
@ -1576,8 +1573,7 @@ static void ad1981_hp_automic(struct hda_codec *codec)
|
|||
};
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x08, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x08);
|
||||
if (present)
|
||||
snd_hda_sequence_write(codec, mic_jack_on);
|
||||
else
|
||||
|
@ -2532,7 +2528,7 @@ static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
|
|||
{
|
||||
if ((res >> 26) != AD1988_HP_EVENT)
|
||||
return;
|
||||
if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31))
|
||||
if (snd_hda_jack_detect(codec, 0x11))
|
||||
snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
|
||||
else
|
||||
snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
|
||||
|
@ -3778,8 +3774,7 @@ static void ad1884a_hp_automute(struct hda_codec *codec)
|
|||
{
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x11, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x11);
|
||||
snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
|
||||
HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
|
||||
snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
|
||||
|
@ -3791,8 +3786,7 @@ static void ad1884a_hp_automic(struct hda_codec *codec)
|
|||
{
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x14, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x14);
|
||||
snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL,
|
||||
present ? 0 : 1);
|
||||
}
|
||||
|
@ -3827,13 +3821,9 @@ static void ad1884a_laptop_automute(struct hda_codec *codec)
|
|||
{
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0);
|
||||
present &= AC_PINSENSE_PRESENCE;
|
||||
if (!present) {
|
||||
present = snd_hda_codec_read(codec, 0x12, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0);
|
||||
present &= AC_PINSENSE_PRESENCE;
|
||||
}
|
||||
present = snd_hda_jack_detect(codec, 0x11);
|
||||
if (!present)
|
||||
present = snd_hda_jack_detect(codec, 0x12);
|
||||
snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
|
||||
HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
|
||||
snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
|
||||
|
@ -3845,11 +3835,9 @@ static void ad1884a_laptop_automic(struct hda_codec *codec)
|
|||
{
|
||||
unsigned int idx;
|
||||
|
||||
if (snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) &
|
||||
AC_PINSENSE_PRESENCE)
|
||||
if (snd_hda_jack_detect(codec, 0x14))
|
||||
idx = 0;
|
||||
else if (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) &
|
||||
AC_PINSENSE_PRESENCE)
|
||||
else if (snd_hda_jack_detect(codec, 0x1c))
|
||||
idx = 4;
|
||||
else
|
||||
idx = 1;
|
||||
|
@ -4018,8 +4006,7 @@ static void ad1984a_thinkpad_automute(struct hda_codec *codec)
|
|||
{
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0)
|
||||
& AC_PINSENSE_PRESENCE;
|
||||
present = snd_hda_jack_detect(codec, 0x11);
|
||||
snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0,
|
||||
HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
|
||||
}
|
||||
|
@ -4127,14 +4114,12 @@ static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = {
|
|||
/* switch to external mic if plugged */
|
||||
static void ad1984a_touchsmart_automic(struct hda_codec *codec)
|
||||
{
|
||||
if (snd_hda_codec_read(codec, 0x1c, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000) {
|
||||
if (snd_hda_jack_detect(codec, 0x1c))
|
||||
snd_hda_codec_write(codec, 0x0c, 0,
|
||||
AC_VERB_SET_CONNECT_SEL, 0x4);
|
||||
} else {
|
||||
else
|
||||
snd_hda_codec_write(codec, 0x0c, 0,
|
||||
AC_VERB_SET_CONNECT_SEL, 0x5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -397,9 +397,7 @@ static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
|
|||
for (i = 0; i < spec->jacks.used; i++) {
|
||||
if (jacks->nid == nid) {
|
||||
unsigned int present;
|
||||
present = snd_hda_codec_read(codec, nid, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) &
|
||||
AC_PINSENSE_PRESENCE;
|
||||
present = snd_hda_jack_detect(codec, nid);
|
||||
|
||||
present = (present) ? jacks->type : 0 ;
|
||||
|
||||
|
@ -750,8 +748,7 @@ static void cxt5045_hp_automic(struct hda_codec *codec)
|
|||
};
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x12, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x12);
|
||||
if (present)
|
||||
snd_hda_sequence_write(codec, mic_jack_on);
|
||||
else
|
||||
|
@ -765,8 +762,7 @@ static void cxt5045_hp_automute(struct hda_codec *codec)
|
|||
struct conexant_spec *spec = codec->spec;
|
||||
unsigned int bits;
|
||||
|
||||
spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
spec->hp_present = snd_hda_jack_detect(codec, 0x11);
|
||||
|
||||
bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
|
||||
snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
|
||||
|
@ -1243,8 +1239,7 @@ static void cxt5047_hp_automute(struct hda_codec *codec)
|
|||
struct conexant_spec *spec = codec->spec;
|
||||
unsigned int bits;
|
||||
|
||||
spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
spec->hp_present = snd_hda_jack_detect(codec, 0x13);
|
||||
|
||||
bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
|
||||
/* See the note in cxt5047_hp_master_sw_put */
|
||||
|
@ -1267,8 +1262,7 @@ static void cxt5047_hp_automic(struct hda_codec *codec)
|
|||
};
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x15, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x15);
|
||||
if (present)
|
||||
snd_hda_sequence_write(codec, mic_jack_on);
|
||||
else
|
||||
|
@ -1621,9 +1615,7 @@ static void cxt5051_portb_automic(struct hda_codec *codec)
|
|||
|
||||
if (spec->no_auto_mic)
|
||||
return;
|
||||
present = snd_hda_codec_read(codec, 0x17, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) &
|
||||
AC_PINSENSE_PRESENCE;
|
||||
present = snd_hda_jack_detect(codec, 0x17);
|
||||
snd_hda_codec_write(codec, 0x14, 0,
|
||||
AC_VERB_SET_CONNECT_SEL,
|
||||
present ? 0x01 : 0x00);
|
||||
|
@ -1638,9 +1630,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec)
|
|||
|
||||
if (spec->no_auto_mic)
|
||||
return;
|
||||
present = snd_hda_codec_read(codec, 0x18, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) &
|
||||
AC_PINSENSE_PRESENCE;
|
||||
present = snd_hda_jack_detect(codec, 0x18);
|
||||
if (present)
|
||||
spec->cur_adc_idx = 1;
|
||||
else
|
||||
|
@ -1661,9 +1651,7 @@ static void cxt5051_hp_automute(struct hda_codec *codec)
|
|||
{
|
||||
struct conexant_spec *spec = codec->spec;
|
||||
|
||||
spec->hp_present = snd_hda_codec_read(codec, 0x16, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) &
|
||||
AC_PINSENSE_PRESENCE;
|
||||
spec->hp_present = snd_hda_jack_detect(codec, 0x16);
|
||||
cxt5051_update_speaker(codec);
|
||||
}
|
||||
|
||||
|
@ -2011,8 +1999,7 @@ static void cxt5066_automic(struct hda_codec *codec)
|
|||
};
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x1a, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x1a);
|
||||
if (present) {
|
||||
snd_printdd("CXT5066: external microphone detected\n");
|
||||
snd_hda_sequence_write(codec, ext_mic_present);
|
||||
|
@ -2029,12 +2016,10 @@ static void cxt5066_hp_automute(struct hda_codec *codec)
|
|||
unsigned int portA, portD;
|
||||
|
||||
/* Port A */
|
||||
portA = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0)
|
||||
& AC_PINSENSE_PRESENCE;
|
||||
portA = snd_hda_jack_detect(codec, 0x19);
|
||||
|
||||
/* Port D */
|
||||
portD = (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0)
|
||||
& AC_PINSENSE_PRESENCE) << 1;
|
||||
portD = snd_hda_jack_detect(codec, 0x1c);
|
||||
|
||||
spec->hp_present = !!(portA | portD);
|
||||
snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
|
||||
|
|
|
@ -8446,8 +8446,7 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
|
|||
{
|
||||
unsigned int present;
|
||||
|
||||
present = snd_hda_codec_read(codec, 0x18, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x18);
|
||||
snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
|
||||
HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
|
||||
}
|
||||
|
|
|
@ -4413,14 +4413,11 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
|
|||
pin_ctl & ~flag);
|
||||
}
|
||||
|
||||
static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
|
||||
static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
if (!nid)
|
||||
return 0;
|
||||
if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
|
||||
& (1 << 31))
|
||||
return 1;
|
||||
return 0;
|
||||
return snd_hda_jack_detect(codec, nid);
|
||||
}
|
||||
|
||||
static void stac92xx_line_out_detect(struct hda_codec *codec,
|
||||
|
|
|
@ -547,8 +547,7 @@ static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid,
|
|||
unsigned no_presence = (def_conf & AC_DEFCFG_MISC)
|
||||
>> AC_DEFCFG_MISC_SHIFT
|
||||
& AC_DEFCFG_MISC_NO_PRESENCE; /* do not support pin sense */
|
||||
unsigned present = snd_hda_codec_read(codec, nid, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) >> 31;
|
||||
unsigned present = snd_hda_jack_detect(codec, nid);
|
||||
struct via_spec *spec = codec->spec;
|
||||
if ((spec->smart51_enabled && is_smart51_pins(spec, nid))
|
||||
|| ((no_presence || present)
|
||||
|
@ -786,14 +785,11 @@ static void set_jack_power_state(struct hda_codec *codec)
|
|||
|
||||
/* Mono out */
|
||||
/* SW4(28h)->MW1(29h)-> PW12 (2ah)*/
|
||||
present = snd_hda_codec_read(
|
||||
codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x1c);
|
||||
if (present)
|
||||
mono_out = 0;
|
||||
else {
|
||||
present = snd_hda_codec_read(
|
||||
codec, 0x1d, 0, AC_VERB_GET_PIN_SENSE, 0)
|
||||
& 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x1d);
|
||||
if (!spec->hp_independent_mode && present)
|
||||
mono_out = 0;
|
||||
else
|
||||
|
@ -872,8 +868,7 @@ static void set_jack_power_state(struct hda_codec *codec)
|
|||
|
||||
/* Class-D */
|
||||
/* PW0 (24h), MW0(18h), MUX0(34h) */
|
||||
present = snd_hda_codec_read(
|
||||
codec, 0x25, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x25);
|
||||
parm = AC_PWRST_D3;
|
||||
set_pin_power_state(codec, 0x24, &parm);
|
||||
if (present) {
|
||||
|
@ -894,8 +889,7 @@ static void set_jack_power_state(struct hda_codec *codec)
|
|||
|
||||
/* Mono Out */
|
||||
/* PW15 (31h), MW8(17h), MUX8(3bh) */
|
||||
present = snd_hda_codec_read(
|
||||
codec, 0x26, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x26);
|
||||
parm = AC_PWRST_D3;
|
||||
set_pin_power_state(codec, 0x31, &parm);
|
||||
if (present) {
|
||||
|
@ -973,8 +967,7 @@ static void set_jack_power_state(struct hda_codec *codec)
|
|||
|
||||
/* Internal Speaker */
|
||||
/* PW0 (24h), MW0(14h), MUX0(34h) */
|
||||
present = snd_hda_codec_read(
|
||||
codec, 0x25, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x25);
|
||||
parm = AC_PWRST_D3;
|
||||
set_pin_power_state(codec, 0x24, &parm);
|
||||
if (present) {
|
||||
|
@ -994,8 +987,7 @@ static void set_jack_power_state(struct hda_codec *codec)
|
|||
}
|
||||
/* Mono Out */
|
||||
/* PW13 (31h), MW13(1ch), MUX13(3ch), MW14(3eh) */
|
||||
present = snd_hda_codec_read(
|
||||
codec, 0x28, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, 0x28);
|
||||
parm = AC_PWRST_D3;
|
||||
set_pin_power_state(codec, 0x31, &parm);
|
||||
if (present) {
|
||||
|
@ -1920,8 +1912,7 @@ static void via_hp_automute(struct hda_codec *codec)
|
|||
unsigned int present = 0;
|
||||
struct via_spec *spec = codec->spec;
|
||||
|
||||
present = snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
|
||||
|
||||
if (!spec->hp_independent_mode) {
|
||||
struct snd_ctl_elem_id id;
|
||||
|
@ -1947,9 +1938,8 @@ static void via_mono_automute(struct hda_codec *codec)
|
|||
if (spec->codec_type != VT1716S)
|
||||
return;
|
||||
|
||||
lineout_present = snd_hda_codec_read(
|
||||
codec, spec->autocfg.line_out_pins[0], 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
lineout_present = snd_hda_jack_detect(codec,
|
||||
spec->autocfg.line_out_pins[0]);
|
||||
|
||||
/* Mute Mono Out if Line Out is plugged */
|
||||
if (lineout_present) {
|
||||
|
@ -1958,9 +1948,7 @@ static void via_mono_automute(struct hda_codec *codec)
|
|||
return;
|
||||
}
|
||||
|
||||
hp_present = snd_hda_codec_read(
|
||||
codec, spec->autocfg.hp_pins[0], 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
|
||||
|
||||
if (!spec->hp_independent_mode)
|
||||
snd_hda_codec_amp_stereo(
|
||||
|
@ -2025,8 +2013,7 @@ static void via_speaker_automute(struct hda_codec *codec)
|
|||
if (spec->codec_type != VT2002P && spec->codec_type != VT1812)
|
||||
return;
|
||||
|
||||
hp_present = snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
|
||||
|
||||
if (!spec->hp_independent_mode) {
|
||||
struct snd_ctl_elem_id id;
|
||||
|
@ -2055,11 +2042,9 @@ static void via_hp_bind_automute(struct hda_codec *codec)
|
|||
if (!spec->autocfg.hp_pins[0] || !spec->autocfg.line_out_pins[0])
|
||||
return;
|
||||
|
||||
hp_present = snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
|
||||
|
||||
present = snd_hda_codec_read(codec, spec->autocfg.line_out_pins[0], 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
|
||||
present = snd_hda_jack_detect(codec, spec->autocfg.line_out_pins[0]);
|
||||
|
||||
if (!spec->hp_independent_mode) {
|
||||
/* Mute Line-Outs */
|
||||
|
@ -2529,8 +2514,7 @@ static void vt1708_update_hp_jack_state(struct work_struct *work)
|
|||
return;
|
||||
/* if jack state toggled */
|
||||
if (spec->vt1708_hp_present
|
||||
!= (snd_hda_codec_read(spec->codec, spec->autocfg.hp_pins[0], 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0) >> 31)) {
|
||||
!= snd_hda_jack_detect(spec->codec, spec->autocfg.hp_pins[0])) {
|
||||
spec->vt1708_hp_present ^= 1;
|
||||
via_hp_automute(spec->codec);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue