summaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-05-17 11:28:16 +0200
committerTakashi Iwai <tiwai@suse.de>2011-05-17 12:33:27 +0200
commite35d9d6a153493055fc888add70786154f00edd4 (patch)
tree19a6339a5b782ecbac23a7983d84b6fe15a2624b /sound/pci
parent43c1b2e9209cc824177a5a13e34fb21dfab3455a (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/pci')
-rw-r--r--sound/pci/hda/hda_local.h3
-rw-r--r--sound/pci/hda/patch_cirrus.c2
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/pci/hda/patch_sigmatel.c11
4 files changed, 8 insertions, 10 deletions
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 01a7cf6b5fb..08ec073444e 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);
static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
{
- return !!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT);
+ return (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT) &&
+ (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP);
}
/* flags for hda_nid_item */
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 4ff70c130da..26a1521045b 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)
AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
if (!cfg->speaker_outs)
continue;
- if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
+ if (is_jack_detectable(codec, nid)) {
snd_hda_codec_write(codec, nid, 0,
AC_VERB_SET_UNSOLICITED_ENABLE,
AC_USRSP_EN | HP_EVENT);
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 1f00cdbf234..24bc8a67a39 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)
}
if (!ext || !fixed)
return;
- if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
+ if (!is_jack_detectable(codec, ext))
return; /* no unsol support */
snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
ext, fixed);
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 38f43175168..8d26a5102b0 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,
for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
- wid_caps = get_wcaps(codec, pins[i]);
- if (wid_caps & AC_WCAP_UNSOL_CAP)
+ if (is_jack_detectable(codec, pins[i]))
spec->hp_detect = 1;
}
nid = dac_nids[i];
@@ -3611,7 +3610,7 @@ static int stac_check_auto_mic(struct hda_codec *codec)
return 0;
if (!fixed || (!ext && !dock))
return 0; /* no input to switch */
- if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
+ if (!is_jack_detectable(codec, ext))
return 0; /* no unsol support */
if (set_mic_route(codec, &spec->ext_mic, ext) ||
set_mic_route(codec, &spec->int_mic, fixed) ||
@@ -3926,13 +3925,11 @@ static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
{
struct sigmatel_spec *spec = codec->spec;
hda_nid_t pin = cfg->hp_pins[0];
- unsigned int wid_caps;
if (! pin)
return 0;
- wid_caps = get_wcaps(codec, pin);
- if (wid_caps & AC_WCAP_UNSOL_CAP)
+ if (is_jack_detectable(codec, pin))
spec->hp_detect = 1;
return 0;
@@ -4143,7 +4140,7 @@ static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
struct sigmatel_event *event;
int tag;
- if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
+ if (!is_jack_detectable(codec, nid))
return 0;
event = stac_get_event(codec, nid);
if (event) {