diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-05-17 05:28:16 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-05-17 06:33:27 -0400 |
commit | e35d9d6a153493055fc888add70786154f00edd4 (patch) | |
tree | 19a6339a5b782ecbac23a7983d84b6fe15a2624b /sound | |
parent | 43c1b2e9209cc824177a5a13e34fb21dfab3455a (diff) |
ALSA: hda - Check unsol-cap in is_jack_detectalbe()
Also replace more open-codes with this function.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_local.h | 3 | ||||
-rw-r--r-- | sound/pci/hda/patch_cirrus.c | 2 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 2 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 11 |
4 files changed, 8 insertions, 10 deletions
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 01a7cf6b5fb1..08ec073444e2 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -495,7 +495,8 @@ int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid); | |||
495 | 495 | ||
496 | static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid) | 496 | static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid) |
497 | { | 497 | { |
498 | return !!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT); | 498 | return (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT) && |
499 | (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP); | ||
499 | } | 500 | } |
500 | 501 | ||
501 | /* flags for hda_nid_item */ | 502 | /* flags for hda_nid_item */ |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 4ff70c130dab..26a1521045bb 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -922,7 +922,7 @@ static void init_output(struct hda_codec *codec) | |||
922 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | 922 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); |
923 | if (!cfg->speaker_outs) | 923 | if (!cfg->speaker_outs) |
924 | continue; | 924 | continue; |
925 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { | 925 | if (is_jack_detectable(codec, nid)) { |
926 | snd_hda_codec_write(codec, nid, 0, | 926 | snd_hda_codec_write(codec, nid, 0, |
927 | AC_VERB_SET_UNSOLICITED_ENABLE, | 927 | AC_VERB_SET_UNSOLICITED_ENABLE, |
928 | AC_USRSP_EN | HP_EVENT); | 928 | AC_USRSP_EN | HP_EVENT); |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 1f00cdbf2341..24bc8a67a39d 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -1628,7 +1628,7 @@ static void alc_init_auto_mic(struct hda_codec *codec) | |||
1628 | } | 1628 | } |
1629 | if (!ext || !fixed) | 1629 | if (!ext || !fixed) |
1630 | return; | 1630 | return; |
1631 | if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) | 1631 | if (!is_jack_detectable(codec, ext)) |
1632 | return; /* no unsol support */ | 1632 | return; /* no unsol support */ |
1633 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n", | 1633 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n", |
1634 | ext, fixed); | 1634 | ext, fixed); |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 38f43175168d..8d26a5102b09 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -3114,8 +3114,7 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, | |||
3114 | 3114 | ||
3115 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { | 3115 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
3116 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { | 3116 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
3117 | wid_caps = get_wcaps(codec, pins[i]); | 3117 | if (is_jack_detectable(codec, pins[i])) |
3118 | if (wid_caps & AC_WCAP_UNSOL_CAP) | ||
3119 | spec->hp_detect = 1; | 3118 | spec->hp_detect = 1; |
3120 | } | 3119 | } |
3121 | nid = dac_nids[i]; | 3120 | nid = dac_nids[i]; |
@@ -3611,7 +3610,7 @@ static int stac_check_auto_mic(struct hda_codec *codec) | |||
3611 | return 0; | 3610 | return 0; |
3612 | if (!fixed || (!ext && !dock)) | 3611 | if (!fixed || (!ext && !dock)) |
3613 | return 0; /* no input to switch */ | 3612 | return 0; /* no input to switch */ |
3614 | if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) | 3613 | if (!is_jack_detectable(codec, ext)) |
3615 | return 0; /* no unsol support */ | 3614 | return 0; /* no unsol support */ |
3616 | if (set_mic_route(codec, &spec->ext_mic, ext) || | 3615 | if (set_mic_route(codec, &spec->ext_mic, ext) || |
3617 | set_mic_route(codec, &spec->int_mic, fixed) || | 3616 | set_mic_route(codec, &spec->int_mic, fixed) || |
@@ -3926,13 +3925,11 @@ static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, | |||
3926 | { | 3925 | { |
3927 | struct sigmatel_spec *spec = codec->spec; | 3926 | struct sigmatel_spec *spec = codec->spec; |
3928 | hda_nid_t pin = cfg->hp_pins[0]; | 3927 | hda_nid_t pin = cfg->hp_pins[0]; |
3929 | unsigned int wid_caps; | ||
3930 | 3928 | ||
3931 | if (! pin) | 3929 | if (! pin) |
3932 | return 0; | 3930 | return 0; |
3933 | 3931 | ||
3934 | wid_caps = get_wcaps(codec, pin); | 3932 | if (is_jack_detectable(codec, pin)) |
3935 | if (wid_caps & AC_WCAP_UNSOL_CAP) | ||
3936 | spec->hp_detect = 1; | 3933 | spec->hp_detect = 1; |
3937 | 3934 | ||
3938 | return 0; | 3935 | return 0; |
@@ -4143,7 +4140,7 @@ static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, | |||
4143 | struct sigmatel_event *event; | 4140 | struct sigmatel_event *event; |
4144 | int tag; | 4141 | int tag; |
4145 | 4142 | ||
4146 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) | 4143 | if (!is_jack_detectable(codec, nid)) |
4147 | return 0; | 4144 | return 0; |
4148 | event = stac_get_event(codec, nid); | 4145 | event = stac_get_event(codec, nid); |
4149 | if (event) { | 4146 | if (event) { |