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/pci/hda/patch_analog.c | |
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/pci/hda/patch_analog.c')
-rw-r--r-- | sound/pci/hda/patch_analog.c | 47 |
1 files changed, 16 insertions, 31 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 | ||