From 1611a9c931e95fab871a33beba49cc9ea39bbba8 Mon Sep 17 00:00:00 2001
From: Mengdong Lin <mengdong.lin@intel.com>
Date: Fri, 8 Feb 2013 17:09:52 -0500
Subject: [PATCH] ALSA: hda - Add fixup for Haswell to enable all pin and convertor widgets
Git-commit: 1611a9c931e95fab871a33beba49cc9ea39bbba8
Patch-mainline: v3.9-rc1
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
References: bnc#801713

Some Haswell machines support more than one display outputs (HDMI or DP),
but its BIOS may not enable the codec's 2nd and 3rd pin and output cvt widgets.

This patch implements a board-specific fixup for Intel Haswell Machines:
If the hidden pins are not enabled by BIOS, the driver will enable them
and call common code to update the codec tree.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 sound/pci/hda/patch_hdmi.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -29,6 +29,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/moduleparam.h>
@@ -1411,6 +1412,31 @@ static void intel_haswell_fixup_connect_
 	snd_hda_override_conn_list(codec, 0x07, 3, list);
 }
 
+#define INTEL_VENDOR_NID 0x08
+#define INTEL_GET_VENDOR_VERB 0xf81
+#define INTEL_SET_VENDOR_VERB 0x781
+#define INTEL_EN_DP12			0x02 /* enable DP 1.2 features */
+#define INTEL_EN_ALL_PIN_CVTS	0x01 /* enable 2nd & 3rd pins and convertors */
+
+static void intel_haswell_enable_all_pins(struct hda_codec *codec)
+{
+	unsigned int vendor_param;
+
+	vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0,
+				INTEL_GET_VENDOR_VERB, 0);
+	if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS)
+		return;
+
+	vendor_param |= INTEL_EN_ALL_PIN_CVTS;
+	vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0,
+				INTEL_SET_VENDOR_VERB, vendor_param);
+	if (vendor_param == -1)
+		return;
+
+	snd_hda_codec_update_widgets(codec);
+	return;
+}
+
 
 static int patch_generic_hdmi(struct hda_codec *codec)
 {
@@ -1422,6 +1448,10 @@ static int patch_generic_hdmi(struct hda
 
 	codec->spec = spec;
 
+	if (codec->bus->pci->subsystem_vendor == 0x8086 &&
+	    codec->bus->pci->subsystem_device == 0x2010)
+		intel_haswell_enable_all_pins(codec);
+
 	if (codec->vendor_id == 0x80862807)
 		intel_haswell_fixup_connect_list(codec);
 
