From 6942c103fb4b0ce91be910a716044ac181a9c2dd Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 20 Apr 2012 13:08:40 +0200
Subject: [PATCH] ALSA: hda - Skip pin capability sanity check for bogus values
Git-commit: 6942c103fb4b0ce91be910a716044ac181a9c2dd
Patch-mainline: 3.5-rc1
References: FATE#313695

Some old codecs like ALC880 seem to give a bogus pin capability value 0
occasionally.  This breaks the new sanity check in snd_hda_set_pin_ctl().
Skip the sanity checks in such a case.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/pci/hda/hda_codec.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4826,14 +4826,14 @@ int _snd_hda_set_pin_ctl(struct hda_code
 {
 	if (val) {
 		unsigned int cap = snd_hda_query_pin_caps(codec, pin);
-		if (val & AC_PINCTL_OUT_EN) {
+		if (cap && (val & AC_PINCTL_OUT_EN)) {
 			if (!(cap & AC_PINCAP_OUT))
 				val &= ~(AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
 			else if ((val & AC_PINCTL_HP_EN) &&
 				 !(cap & AC_PINCAP_HP_DRV))
 				val &= ~AC_PINCTL_HP_EN;
 		}
-		if (val & AC_PINCTL_IN_EN) {
+		if (cap && (val & AC_PINCTL_IN_EN)) {
 			if (!(cap & AC_PINCAP_IN))
 				val &= ~(AC_PINCTL_IN_EN | AC_PINCTL_VREFEN);
 		}
