From fb87fa3a79823c15e70d4fc7653bde59f8556ca1 Mon Sep 17 00:00:00 2001
From: Mengdong Lin <mengdong.lin@intel.com>
Date: Wed, 4 Sep 2013 16:36:57 -0400
Subject: [PATCH] ALSA: hda - define is_haswell() to check if a display audio codec is Haswell
Git-commit: fb87fa3a79823c15e70d4fc7653bde59f8556ca1
Patch-mainline: 3.12-rc1
References: FATE#317933

To apply Haswell specific fixings, this patch defines is_haswell() to check
whether a display audio codec is Haswell, to avoid explicitly checking Haswell
vendor ID everywhere.

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

---
 sound/pci/hda/patch_hdmi.c |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -54,6 +54,8 @@ MODULE_PARM_DESC(static_hdmi_pcm, "Don't
 #define MAX_HDMI_CVTS	8
 #define MAX_HDMI_PINS	8
 
+#define is_haswell(codec)  ((codec)->vendor_id == 0x80862807)
+
 struct hdmi_spec_per_cvt {
 	hda_nid_t cvt_nid;
 	int assigned;
@@ -916,7 +918,7 @@ static int hdmi_setup_stream(struct hda_
 	int pinctl;
 	int new_pinctl = 0;
 
-	if (codec->vendor_id == 0x80862807)
+	if (is_haswell(codec))
 		haswell_verify_pin_D0(codec, cvt_nid, pin_nid);
 
 	if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) {
@@ -1056,7 +1058,7 @@ static int hdmi_pcm_open(struct hda_pcm_
 			    mux_idx);
 
 	/* configure unused pins to choose other converters */
-	if (codec->vendor_id == 0x80862807)
+	if (is_haswell(codec))
 		haswell_config_cvts(codec, pin_idx, mux_idx);
 
 	snd_hda_spdif_ctls_assign(codec, pin_idx, per_cvt->cvt_nid);
@@ -1159,7 +1161,7 @@ static void hdmi_present_sense(struct hd
 		/* Haswell-specific workaround: re-setup when the
 		 * transcoder is changed during the stream playback
 		 */
-		if (codec->vendor_id == 0x80862807 &&
+		if (is_haswell(codec) &&
 		    eld->eld_valid && !old_eld_valid && per_pin->setup) {
 			snd_hda_codec_write(codec, pin_nid, 0,
 					    AC_VERB_SET_AMP_GAIN_MUTE,
@@ -1204,7 +1206,7 @@ static int hdmi_add_pin(struct hda_codec
 	if (snd_BUG_ON(spec->num_pins >= MAX_HDMI_PINS))
 		return -E2BIG;
 
-	if (codec->vendor_id == 0x80862807)
+	if (is_haswell(codec))
 		intel_haswell_fixup_connect_list(codec, pin_nid);
 
 	pin_idx = spec->num_pins;
@@ -1613,7 +1615,7 @@ static int patch_generic_hdmi(struct hda
 
 	codec->spec = spec;
 
-	if (codec->vendor_id == 0x80862807) {
+	if (is_haswell(codec)) {
 		intel_haswell_enable_all_pins(codec, true);
 		intel_haswell_fixup_enable_dp12(codec);
 	}
@@ -1624,8 +1626,9 @@ static int patch_generic_hdmi(struct hda
 		return -EINVAL;
 	}
 	codec->patch_ops = generic_hdmi_patch_ops;
-	if (codec->vendor_id == 0x80862807)
+	if (is_haswell(codec)) {
 		codec->patch_ops.set_power_state = haswell_set_power_state;
+	}
 
 	generic_hdmi_init_per_pins(codec);
 
