diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-11-18 02:00:14 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-11-18 02:00:14 -0500 |
commit | d56757abc11a21996d9839c0d4e3b2c3666cd318 (patch) | |
tree | 831cc331f8901ed17c3294a31dc545d7954f1a2c /sound | |
parent | 83d605fd63e704419ccb92d48b735c6890ce3d6a (diff) |
ALSA: hda - Replace the rest of jack-detections with snd_hda_jack_detect()
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/patch_analog.c | 47 | ||||
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 37 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 3 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 7 | ||||
-rw-r--r-- | sound/pci/hda/patch_via.c | 46 |
5 files changed, 45 insertions, 95 deletions
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 8a1064bdf4c6..455a0494f907 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -720,10 +720,10 @@ static struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = { | |||
720 | static void ad1986a_automic(struct hda_codec *codec) | 720 | static void ad1986a_automic(struct hda_codec *codec) |
721 | { | 721 | { |
722 | unsigned int present; | 722 | unsigned int present; |
723 | present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0); | 723 | present = snd_hda_jack_detect(codec, 0x1f); |
724 | /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */ | 724 | /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */ |
725 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL, | 725 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL, |
726 | (present & AC_PINSENSE_PRESENCE) ? 0 : 2); | 726 | present ? 0 : 2); |
727 | } | 727 | } |
728 | 728 | ||
729 | #define AD1986A_MIC_EVENT 0x36 | 729 | #define AD1986A_MIC_EVENT 0x36 |
@@ -762,10 +762,8 @@ static void ad1986a_update_hp(struct hda_codec *codec) | |||
762 | static void ad1986a_hp_automute(struct hda_codec *codec) | 762 | static void ad1986a_hp_automute(struct hda_codec *codec) |
763 | { | 763 | { |
764 | struct ad198x_spec *spec = codec->spec; | 764 | struct ad198x_spec *spec = codec->spec; |
765 | unsigned int present; | ||
766 | 765 | ||
767 | present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0); | 766 | spec->jack_present = snd_hda_jack_detect(codec, 0x1a); |
768 | spec->jack_present = !!(present & 0x80000000); | ||
769 | if (spec->inv_jack_detect) | 767 | if (spec->inv_jack_detect) |
770 | spec->jack_present = !spec->jack_present; | 768 | spec->jack_present = !spec->jack_present; |
771 | ad1986a_update_hp(codec); | 769 | ad1986a_update_hp(codec); |
@@ -1555,8 +1553,7 @@ static void ad1981_hp_automute(struct hda_codec *codec) | |||
1555 | { | 1553 | { |
1556 | unsigned int present; | 1554 | unsigned int present; |
1557 | 1555 | ||
1558 | present = snd_hda_codec_read(codec, 0x06, 0, | 1556 | present = snd_hda_jack_detect(codec, 0x06); |
1559 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1560 | snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0, | 1557 | snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0, |
1561 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 1558 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
1562 | } | 1559 | } |
@@ -1576,8 +1573,7 @@ static void ad1981_hp_automic(struct hda_codec *codec) | |||
1576 | }; | 1573 | }; |
1577 | unsigned int present; | 1574 | unsigned int present; |
1578 | 1575 | ||
1579 | present = snd_hda_codec_read(codec, 0x08, 0, | 1576 | present = snd_hda_jack_detect(codec, 0x08); |
1580 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1581 | if (present) | 1577 | if (present) |
1582 | snd_hda_sequence_write(codec, mic_jack_on); | 1578 | snd_hda_sequence_write(codec, mic_jack_on); |
1583 | else | 1579 | else |
@@ -2532,7 +2528,7 @@ static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) | |||
2532 | { | 2528 | { |
2533 | if ((res >> 26) != AD1988_HP_EVENT) | 2529 | if ((res >> 26) != AD1988_HP_EVENT) |
2534 | return; | 2530 | return; |
2535 | if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31)) | 2531 | if (snd_hda_jack_detect(codec, 0x11)) |
2536 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); | 2532 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); |
2537 | else | 2533 | else |
2538 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); | 2534 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); |
@@ -3778,8 +3774,7 @@ static void ad1884a_hp_automute(struct hda_codec *codec) | |||
3778 | { | 3774 | { |
3779 | unsigned int present; | 3775 | unsigned int present; |
3780 | 3776 | ||
3781 | present = snd_hda_codec_read(codec, 0x11, 0, | 3777 | present = snd_hda_jack_detect(codec, 0x11); |
3782 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
3783 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | 3778 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
3784 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 3779 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
3785 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, | 3780 | 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) | |||
3791 | { | 3786 | { |
3792 | unsigned int present; | 3787 | unsigned int present; |
3793 | 3788 | ||
3794 | present = snd_hda_codec_read(codec, 0x14, 0, | 3789 | present = snd_hda_jack_detect(codec, 0x14); |
3795 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
3796 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, | 3790 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, |
3797 | present ? 0 : 1); | 3791 | present ? 0 : 1); |
3798 | } | 3792 | } |
@@ -3827,13 +3821,9 @@ static void ad1884a_laptop_automute(struct hda_codec *codec) | |||
3827 | { | 3821 | { |
3828 | unsigned int present; | 3822 | unsigned int present; |
3829 | 3823 | ||
3830 | present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0); | 3824 | present = snd_hda_jack_detect(codec, 0x11); |
3831 | present &= AC_PINSENSE_PRESENCE; | 3825 | if (!present) |
3832 | if (!present) { | 3826 | present = snd_hda_jack_detect(codec, 0x12); |
3833 | present = snd_hda_codec_read(codec, 0x12, 0, | ||
3834 | AC_VERB_GET_PIN_SENSE, 0); | ||
3835 | present &= AC_PINSENSE_PRESENCE; | ||
3836 | } | ||
3837 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | 3827 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
3838 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 3828 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
3839 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, | 3829 | 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) | |||
3845 | { | 3835 | { |
3846 | unsigned int idx; | 3836 | unsigned int idx; |
3847 | 3837 | ||
3848 | if (snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) & | 3838 | if (snd_hda_jack_detect(codec, 0x14)) |
3849 | AC_PINSENSE_PRESENCE) | ||
3850 | idx = 0; | 3839 | idx = 0; |
3851 | else if (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) & | 3840 | else if (snd_hda_jack_detect(codec, 0x1c)) |
3852 | AC_PINSENSE_PRESENCE) | ||
3853 | idx = 4; | 3841 | idx = 4; |
3854 | else | 3842 | else |
3855 | idx = 1; | 3843 | idx = 1; |
@@ -4018,8 +4006,7 @@ static void ad1984a_thinkpad_automute(struct hda_codec *codec) | |||
4018 | { | 4006 | { |
4019 | unsigned int present; | 4007 | unsigned int present; |
4020 | 4008 | ||
4021 | present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) | 4009 | present = snd_hda_jack_detect(codec, 0x11); |
4022 | & AC_PINSENSE_PRESENCE; | ||
4023 | snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0, | 4010 | snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0, |
4024 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 4011 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
4025 | } | 4012 | } |
@@ -4127,14 +4114,12 @@ static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = { | |||
4127 | /* switch to external mic if plugged */ | 4114 | /* switch to external mic if plugged */ |
4128 | static void ad1984a_touchsmart_automic(struct hda_codec *codec) | 4115 | static void ad1984a_touchsmart_automic(struct hda_codec *codec) |
4129 | { | 4116 | { |
4130 | if (snd_hda_codec_read(codec, 0x1c, 0, | 4117 | if (snd_hda_jack_detect(codec, 0x1c)) |
4131 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000) { | ||
4132 | snd_hda_codec_write(codec, 0x0c, 0, | 4118 | snd_hda_codec_write(codec, 0x0c, 0, |
4133 | AC_VERB_SET_CONNECT_SEL, 0x4); | 4119 | AC_VERB_SET_CONNECT_SEL, 0x4); |
4134 | } else { | 4120 | else |
4135 | snd_hda_codec_write(codec, 0x0c, 0, | 4121 | snd_hda_codec_write(codec, 0x0c, 0, |
4136 | AC_VERB_SET_CONNECT_SEL, 0x5); | 4122 | AC_VERB_SET_CONNECT_SEL, 0x5); |
4137 | } | ||
4138 | } | 4123 | } |
4139 | 4124 | ||
4140 | 4125 | ||
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 905859d4f4df..0b097fa5421f 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -397,9 +397,7 @@ static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | |||
397 | for (i = 0; i < spec->jacks.used; i++) { | 397 | for (i = 0; i < spec->jacks.used; i++) { |
398 | if (jacks->nid == nid) { | 398 | if (jacks->nid == nid) { |
399 | unsigned int present; | 399 | unsigned int present; |
400 | present = snd_hda_codec_read(codec, nid, 0, | 400 | present = snd_hda_jack_detect(codec, nid); |
401 | AC_VERB_GET_PIN_SENSE, 0) & | ||
402 | AC_PINSENSE_PRESENCE; | ||
403 | 401 | ||
404 | present = (present) ? jacks->type : 0 ; | 402 | present = (present) ? jacks->type : 0 ; |
405 | 403 | ||
@@ -750,8 +748,7 @@ static void cxt5045_hp_automic(struct hda_codec *codec) | |||
750 | }; | 748 | }; |
751 | unsigned int present; | 749 | unsigned int present; |
752 | 750 | ||
753 | present = snd_hda_codec_read(codec, 0x12, 0, | 751 | present = snd_hda_jack_detect(codec, 0x12); |
754 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
755 | if (present) | 752 | if (present) |
756 | snd_hda_sequence_write(codec, mic_jack_on); | 753 | snd_hda_sequence_write(codec, mic_jack_on); |
757 | else | 754 | else |
@@ -765,8 +762,7 @@ static void cxt5045_hp_automute(struct hda_codec *codec) | |||
765 | struct conexant_spec *spec = codec->spec; | 762 | struct conexant_spec *spec = codec->spec; |
766 | unsigned int bits; | 763 | unsigned int bits; |
767 | 764 | ||
768 | spec->hp_present = snd_hda_codec_read(codec, 0x11, 0, | 765 | spec->hp_present = snd_hda_jack_detect(codec, 0x11); |
769 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
770 | 766 | ||
771 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; | 767 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
772 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, | 768 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, |
@@ -1243,8 +1239,7 @@ static void cxt5047_hp_automute(struct hda_codec *codec) | |||
1243 | struct conexant_spec *spec = codec->spec; | 1239 | struct conexant_spec *spec = codec->spec; |
1244 | unsigned int bits; | 1240 | unsigned int bits; |
1245 | 1241 | ||
1246 | spec->hp_present = snd_hda_codec_read(codec, 0x13, 0, | 1242 | spec->hp_present = snd_hda_jack_detect(codec, 0x13); |
1247 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1248 | 1243 | ||
1249 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; | 1244 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
1250 | /* See the note in cxt5047_hp_master_sw_put */ | 1245 | /* See the note in cxt5047_hp_master_sw_put */ |
@@ -1267,8 +1262,7 @@ static void cxt5047_hp_automic(struct hda_codec *codec) | |||
1267 | }; | 1262 | }; |
1268 | unsigned int present; | 1263 | unsigned int present; |
1269 | 1264 | ||
1270 | present = snd_hda_codec_read(codec, 0x15, 0, | 1265 | present = snd_hda_jack_detect(codec, 0x15); |
1271 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1272 | if (present) | 1266 | if (present) |
1273 | snd_hda_sequence_write(codec, mic_jack_on); | 1267 | snd_hda_sequence_write(codec, mic_jack_on); |
1274 | else | 1268 | else |
@@ -1621,9 +1615,7 @@ static void cxt5051_portb_automic(struct hda_codec *codec) | |||
1621 | 1615 | ||
1622 | if (spec->no_auto_mic) | 1616 | if (spec->no_auto_mic) |
1623 | return; | 1617 | return; |
1624 | present = snd_hda_codec_read(codec, 0x17, 0, | 1618 | present = snd_hda_jack_detect(codec, 0x17); |
1625 | AC_VERB_GET_PIN_SENSE, 0) & | ||
1626 | AC_PINSENSE_PRESENCE; | ||
1627 | snd_hda_codec_write(codec, 0x14, 0, | 1619 | snd_hda_codec_write(codec, 0x14, 0, |
1628 | AC_VERB_SET_CONNECT_SEL, | 1620 | AC_VERB_SET_CONNECT_SEL, |
1629 | present ? 0x01 : 0x00); | 1621 | present ? 0x01 : 0x00); |
@@ -1638,9 +1630,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec) | |||
1638 | 1630 | ||
1639 | if (spec->no_auto_mic) | 1631 | if (spec->no_auto_mic) |
1640 | return; | 1632 | return; |
1641 | present = snd_hda_codec_read(codec, 0x18, 0, | 1633 | present = snd_hda_jack_detect(codec, 0x18); |
1642 | AC_VERB_GET_PIN_SENSE, 0) & | ||
1643 | AC_PINSENSE_PRESENCE; | ||
1644 | if (present) | 1634 | if (present) |
1645 | spec->cur_adc_idx = 1; | 1635 | spec->cur_adc_idx = 1; |
1646 | else | 1636 | else |
@@ -1661,9 +1651,7 @@ static void cxt5051_hp_automute(struct hda_codec *codec) | |||
1661 | { | 1651 | { |
1662 | struct conexant_spec *spec = codec->spec; | 1652 | struct conexant_spec *spec = codec->spec; |
1663 | 1653 | ||
1664 | spec->hp_present = snd_hda_codec_read(codec, 0x16, 0, | 1654 | spec->hp_present = snd_hda_jack_detect(codec, 0x16); |
1665 | AC_VERB_GET_PIN_SENSE, 0) & | ||
1666 | AC_PINSENSE_PRESENCE; | ||
1667 | cxt5051_update_speaker(codec); | 1655 | cxt5051_update_speaker(codec); |
1668 | } | 1656 | } |
1669 | 1657 | ||
@@ -2011,8 +1999,7 @@ static void cxt5066_automic(struct hda_codec *codec) | |||
2011 | }; | 1999 | }; |
2012 | unsigned int present; | 2000 | unsigned int present; |
2013 | 2001 | ||
2014 | present = snd_hda_codec_read(codec, 0x1a, 0, | 2002 | present = snd_hda_jack_detect(codec, 0x1a); |
2015 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2016 | if (present) { | 2003 | if (present) { |
2017 | snd_printdd("CXT5066: external microphone detected\n"); | 2004 | snd_printdd("CXT5066: external microphone detected\n"); |
2018 | snd_hda_sequence_write(codec, ext_mic_present); | 2005 | snd_hda_sequence_write(codec, ext_mic_present); |
@@ -2029,12 +2016,10 @@ static void cxt5066_hp_automute(struct hda_codec *codec) | |||
2029 | unsigned int portA, portD; | 2016 | unsigned int portA, portD; |
2030 | 2017 | ||
2031 | /* Port A */ | 2018 | /* Port A */ |
2032 | portA = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0) | 2019 | portA = snd_hda_jack_detect(codec, 0x19); |
2033 | & AC_PINSENSE_PRESENCE; | ||
2034 | 2020 | ||
2035 | /* Port D */ | 2021 | /* Port D */ |
2036 | portD = (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) | 2022 | portD = snd_hda_jack_detect(codec, 0x1c); |
2037 | & AC_PINSENSE_PRESENCE) << 1; | ||
2038 | 2023 | ||
2039 | spec->hp_present = !!(portA | portD); | 2024 | spec->hp_present = !!(portA | portD); |
2040 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", | 2025 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cbb2d326e6ad..28acbe63dfc8 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -8446,8 +8446,7 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | |||
8446 | { | 8446 | { |
8447 | unsigned int present; | 8447 | unsigned int present; |
8448 | 8448 | ||
8449 | present = snd_hda_codec_read(codec, 0x18, 0, | 8449 | present = snd_hda_jack_detect(codec, 0x18); |
8450 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8451 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | 8450 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, |
8452 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8451 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8453 | } | 8452 | } |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 7f76a97954f9..d83649c25fb2 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -4413,14 +4413,11 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
4413 | pin_ctl & ~flag); | 4413 | pin_ctl & ~flag); |
4414 | } | 4414 | } |
4415 | 4415 | ||
4416 | static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) | 4416 | static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
4417 | { | 4417 | { |
4418 | if (!nid) | 4418 | if (!nid) |
4419 | return 0; | 4419 | return 0; |
4420 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) | 4420 | return snd_hda_jack_detect(codec, nid); |
4421 | & (1 << 31)) | ||
4422 | return 1; | ||
4423 | return 0; | ||
4424 | } | 4421 | } |
4425 | 4422 | ||
4426 | static void stac92xx_line_out_detect(struct hda_codec *codec, | 4423 | static void stac92xx_line_out_detect(struct hda_codec *codec, |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 0c621d74b165..b70e26ad263f 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -547,8 +547,7 @@ static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid, | |||
547 | unsigned no_presence = (def_conf & AC_DEFCFG_MISC) | 547 | unsigned no_presence = (def_conf & AC_DEFCFG_MISC) |
548 | >> AC_DEFCFG_MISC_SHIFT | 548 | >> AC_DEFCFG_MISC_SHIFT |
549 | & AC_DEFCFG_MISC_NO_PRESENCE; /* do not support pin sense */ | 549 | & AC_DEFCFG_MISC_NO_PRESENCE; /* do not support pin sense */ |
550 | unsigned present = snd_hda_codec_read(codec, nid, 0, | 550 | unsigned present = snd_hda_jack_detect(codec, nid); |
551 | AC_VERB_GET_PIN_SENSE, 0) >> 31; | ||
552 | struct via_spec *spec = codec->spec; | 551 | struct via_spec *spec = codec->spec; |
553 | if ((spec->smart51_enabled && is_smart51_pins(spec, nid)) | 552 | if ((spec->smart51_enabled && is_smart51_pins(spec, nid)) |
554 | || ((no_presence || present) | 553 | || ((no_presence || present) |
@@ -786,14 +785,11 @@ static void set_jack_power_state(struct hda_codec *codec) | |||
786 | 785 | ||
787 | /* Mono out */ | 786 | /* Mono out */ |
788 | /* SW4(28h)->MW1(29h)-> PW12 (2ah)*/ | 787 | /* SW4(28h)->MW1(29h)-> PW12 (2ah)*/ |
789 | present = snd_hda_codec_read( | 788 | present = snd_hda_jack_detect(codec, 0x1c); |
790 | codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
791 | if (present) | 789 | if (present) |
792 | mono_out = 0; | 790 | mono_out = 0; |
793 | else { | 791 | else { |
794 | present = snd_hda_codec_read( | 792 | present = snd_hda_jack_detect(codec, 0x1d); |
795 | codec, 0x1d, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
796 | & 0x80000000; | ||
797 | if (!spec->hp_independent_mode && present) | 793 | if (!spec->hp_independent_mode && present) |
798 | mono_out = 0; | 794 | mono_out = 0; |
799 | else | 795 | else |
@@ -872,8 +868,7 @@ static void set_jack_power_state(struct hda_codec *codec) | |||
872 | 868 | ||
873 | /* Class-D */ | 869 | /* Class-D */ |
874 | /* PW0 (24h), MW0(18h), MUX0(34h) */ | 870 | /* PW0 (24h), MW0(18h), MUX0(34h) */ |
875 | present = snd_hda_codec_read( | 871 | present = snd_hda_jack_detect(codec, 0x25); |
876 | codec, 0x25, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
877 | parm = AC_PWRST_D3; | 872 | parm = AC_PWRST_D3; |
878 | set_pin_power_state(codec, 0x24, &parm); | 873 | set_pin_power_state(codec, 0x24, &parm); |
879 | if (present) { | 874 | if (present) { |
@@ -894,8 +889,7 @@ static void set_jack_power_state(struct hda_codec *codec) | |||
894 | 889 | ||
895 | /* Mono Out */ | 890 | /* Mono Out */ |
896 | /* PW15 (31h), MW8(17h), MUX8(3bh) */ | 891 | /* PW15 (31h), MW8(17h), MUX8(3bh) */ |
897 | present = snd_hda_codec_read( | 892 | present = snd_hda_jack_detect(codec, 0x26); |
898 | codec, 0x26, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
899 | parm = AC_PWRST_D3; | 893 | parm = AC_PWRST_D3; |
900 | set_pin_power_state(codec, 0x31, &parm); | 894 | set_pin_power_state(codec, 0x31, &parm); |
901 | if (present) { | 895 | if (present) { |
@@ -973,8 +967,7 @@ static void set_jack_power_state(struct hda_codec *codec) | |||
973 | 967 | ||
974 | /* Internal Speaker */ | 968 | /* Internal Speaker */ |
975 | /* PW0 (24h), MW0(14h), MUX0(34h) */ | 969 | /* PW0 (24h), MW0(14h), MUX0(34h) */ |
976 | present = snd_hda_codec_read( | 970 | present = snd_hda_jack_detect(codec, 0x25); |
977 | codec, 0x25, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
978 | parm = AC_PWRST_D3; | 971 | parm = AC_PWRST_D3; |
979 | set_pin_power_state(codec, 0x24, &parm); | 972 | set_pin_power_state(codec, 0x24, &parm); |
980 | if (present) { | 973 | if (present) { |
@@ -994,8 +987,7 @@ static void set_jack_power_state(struct hda_codec *codec) | |||
994 | } | 987 | } |
995 | /* Mono Out */ | 988 | /* Mono Out */ |
996 | /* PW13 (31h), MW13(1ch), MUX13(3ch), MW14(3eh) */ | 989 | /* PW13 (31h), MW13(1ch), MUX13(3ch), MW14(3eh) */ |
997 | present = snd_hda_codec_read( | 990 | present = snd_hda_jack_detect(codec, 0x28); |
998 | codec, 0x28, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
999 | parm = AC_PWRST_D3; | 991 | parm = AC_PWRST_D3; |
1000 | set_pin_power_state(codec, 0x31, &parm); | 992 | set_pin_power_state(codec, 0x31, &parm); |
1001 | if (present) { | 993 | if (present) { |
@@ -1920,8 +1912,7 @@ static void via_hp_automute(struct hda_codec *codec) | |||
1920 | unsigned int present = 0; | 1912 | unsigned int present = 0; |
1921 | struct via_spec *spec = codec->spec; | 1913 | struct via_spec *spec = codec->spec; |
1922 | 1914 | ||
1923 | present = snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0, | 1915 | present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
1924 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1925 | 1916 | ||
1926 | if (!spec->hp_independent_mode) { | 1917 | if (!spec->hp_independent_mode) { |
1927 | struct snd_ctl_elem_id id; | 1918 | struct snd_ctl_elem_id id; |
@@ -1947,9 +1938,8 @@ static void via_mono_automute(struct hda_codec *codec) | |||
1947 | if (spec->codec_type != VT1716S) | 1938 | if (spec->codec_type != VT1716S) |
1948 | return; | 1939 | return; |
1949 | 1940 | ||
1950 | lineout_present = snd_hda_codec_read( | 1941 | lineout_present = snd_hda_jack_detect(codec, |
1951 | codec, spec->autocfg.line_out_pins[0], 0, | 1942 | spec->autocfg.line_out_pins[0]); |
1952 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1953 | 1943 | ||
1954 | /* Mute Mono Out if Line Out is plugged */ | 1944 | /* Mute Mono Out if Line Out is plugged */ |
1955 | if (lineout_present) { | 1945 | if (lineout_present) { |
@@ -1958,9 +1948,7 @@ static void via_mono_automute(struct hda_codec *codec) | |||
1958 | return; | 1948 | return; |
1959 | } | 1949 | } |
1960 | 1950 | ||
1961 | hp_present = snd_hda_codec_read( | 1951 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
1962 | codec, spec->autocfg.hp_pins[0], 0, | ||
1963 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1964 | 1952 | ||
1965 | if (!spec->hp_independent_mode) | 1953 | if (!spec->hp_independent_mode) |
1966 | snd_hda_codec_amp_stereo( | 1954 | snd_hda_codec_amp_stereo( |
@@ -2025,8 +2013,7 @@ static void via_speaker_automute(struct hda_codec *codec) | |||
2025 | if (spec->codec_type != VT2002P && spec->codec_type != VT1812) | 2013 | if (spec->codec_type != VT2002P && spec->codec_type != VT1812) |
2026 | return; | 2014 | return; |
2027 | 2015 | ||
2028 | hp_present = snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0, | 2016 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
2029 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2030 | 2017 | ||
2031 | if (!spec->hp_independent_mode) { | 2018 | if (!spec->hp_independent_mode) { |
2032 | struct snd_ctl_elem_id id; | 2019 | struct snd_ctl_elem_id id; |
@@ -2055,11 +2042,9 @@ static void via_hp_bind_automute(struct hda_codec *codec) | |||
2055 | if (!spec->autocfg.hp_pins[0] || !spec->autocfg.line_out_pins[0]) | 2042 | if (!spec->autocfg.hp_pins[0] || !spec->autocfg.line_out_pins[0]) |
2056 | return; | 2043 | return; |
2057 | 2044 | ||
2058 | hp_present = snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0, | 2045 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
2059 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2060 | 2046 | ||
2061 | present = snd_hda_codec_read(codec, spec->autocfg.line_out_pins[0], 0, | 2047 | present = snd_hda_jack_detect(codec, spec->autocfg.line_out_pins[0]); |
2062 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2063 | 2048 | ||
2064 | if (!spec->hp_independent_mode) { | 2049 | if (!spec->hp_independent_mode) { |
2065 | /* Mute Line-Outs */ | 2050 | /* Mute Line-Outs */ |
@@ -2529,8 +2514,7 @@ static void vt1708_update_hp_jack_state(struct work_struct *work) | |||
2529 | return; | 2514 | return; |
2530 | /* if jack state toggled */ | 2515 | /* if jack state toggled */ |
2531 | if (spec->vt1708_hp_present | 2516 | if (spec->vt1708_hp_present |
2532 | != (snd_hda_codec_read(spec->codec, spec->autocfg.hp_pins[0], 0, | 2517 | != snd_hda_jack_detect(spec->codec, spec->autocfg.hp_pins[0])) { |
2533 | AC_VERB_GET_PIN_SENSE, 0) >> 31)) { | ||
2534 | spec->vt1708_hp_present ^= 1; | 2518 | spec->vt1708_hp_present ^= 1; |
2535 | via_hp_automute(spec->codec); | 2519 | via_hp_automute(spec->codec); |
2536 | } | 2520 | } |