09b0646
From e1e62b98ebddc3234f3259019d3236f66fc667f8 Mon Sep 17 00:00:00 2001
09b0646
From: Kailang Yang <kailang@realtek.com>
09b0646
Date: Wed, 8 Apr 2015 16:01:22 +0800
09b0646
Subject: [PATCH] ALSA: hda/realtek - Support Dell headset mode for ALC288
09b0646
09b0646
Dell create new platform with ALC288 codec.
09b0646
This patch will enable headset mode for Dino platform.
09b0646
09b0646
[slight code refactoring and compile fix by tiwai]
09b0646
09b0646
Signed-off-by: Kailang Yang <kailang@realtek.com>
09b0646
Signed-off-by: Takashi Iwai <tiwai@suse.de>
09b0646
---
09b0646
 sound/pci/hda/patch_realtek.c | 67 +++++++++++++++++++++++++++++++++++++++++++
09b0646
 1 file changed, 67 insertions(+)
09b0646
09b0646
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
09b0646
index ceb599a..7b5c93e 100644
09b0646
--- a/sound/pci/hda/patch_realtek.c
09b0646
+++ b/sound/pci/hda/patch_realtek.c
09b0646
@@ -4121,6 +4121,29 @@ static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
09b0646
 		alc_fixup_headset_mode(codec, fix, action);
09b0646
 }
09b0646
 
09b0646
+static void alc288_update_headset_jack_cb(struct hda_codec *codec,
09b0646
+				       struct hda_jack_callback *jack)
09b0646
+{
09b0646
+	struct alc_spec *spec = codec->spec;
09b0646
+	int present;
09b0646
+
09b0646
+	alc_update_headset_jack_cb(codec, jack);
09b0646
+	/* Headset Mic enable or disable, only for Dell Dino */
09b0646
+	present = spec->gen.hp_jack_present ? 0x40 : 0;
09b0646
+	snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
09b0646
+				present);
09b0646
+}
09b0646
+
09b0646
+static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
09b0646
+				const struct hda_fixup *fix, int action)
09b0646
+{
09b0646
+	alc_fixup_headset_mode(codec, fix, action);
09b0646
+	if (action == HDA_FIXUP_ACT_PROBE) {
09b0646
+		struct alc_spec *spec = codec->spec;
09b0646
+		spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
09b0646
+	}
09b0646
+}
09b0646
+
09b0646
 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
09b0646
 					const struct hda_fixup *fix, int action)
09b0646
 {
09b0646
@@ -4460,6 +4483,9 @@ enum {
09b0646
 	ALC286_FIXUP_HP_GPIO_LED,
09b0646
 	ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
09b0646
 	ALC280_FIXUP_HP_DOCK_PINS,
09b0646
+	ALC288_FIXUP_DELL_HEADSET_MODE,
09b0646
+	ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
09b0646
+	ALC288_FIXUP_DELL_XPS_13_GPIO6,
09b0646
 };
09b0646
 
09b0646
 static const struct hda_fixup alc269_fixups[] = {
09b0646
@@ -4948,6 +4974,33 @@ static const struct hda_fixup alc269_fixups[] = {
09b0646
 		.chained = true,
09b0646
 		.chain_id = ALC280_FIXUP_HP_GPIO4
09b0646
 	},
09b0646
+	[ALC288_FIXUP_DELL_HEADSET_MODE] = {
09b0646
+		.type = HDA_FIXUP_FUNC,
09b0646
+		.v.func = alc_fixup_headset_mode_dell_alc288,
09b0646
+		.chained = true,
09b0646
+		.chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
09b0646
+	},
09b0646
+	[ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
09b0646
+		.type = HDA_FIXUP_PINS,
09b0646
+		.v.pins = (const struct hda_pintbl[]) {
09b0646
+			{ 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
09b0646
+			{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
09b0646
+			{ }
09b0646
+		},
09b0646
+		.chained = true,
09b0646
+		.chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
09b0646
+	},
09b0646
+	[ALC288_FIXUP_DELL_XPS_13_GPIO6] = {
09b0646
+		.type = HDA_FIXUP_VERBS,
09b0646
+		.v.verbs = (const struct hda_verb[]) {
09b0646
+			{0x01, AC_VERB_SET_GPIO_MASK, 0x40},
09b0646
+			{0x01, AC_VERB_SET_GPIO_DIRECTION, 0x40},
09b0646
+			{0x01, AC_VERB_SET_GPIO_DATA, 0x00},
09b0646
+			{ }
09b0646
+		},
09b0646
+		.chained = true,
09b0646
+		.chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
09b0646
+	},
09b0646
 };
09b0646
 
09b0646
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
09b0646
@@ -5174,6 +5227,13 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
09b0646
 	{0x1b, 0x411111f0}, \
09b0646
 	{0x1e, 0x411111f0}
09b0646
 
09b0646
+#define ALC288_STANDARD_PINS \
09b0646
+	{0x17, 0x411111f0}, \
09b0646
+	{0x18, 0x411111f0}, \
09b0646
+	{0x19, 0x411111f0}, \
09b0646
+	{0x1a, 0x411111f0}, \
09b0646
+	{0x1e, 0x411111f0}
09b0646
+
09b0646
 #define ALC290_STANDARD_PINS \
09b0646
 	{0x12, 0x99a30130}, \
09b0646
 	{0x13, 0x40000000}, \
09b0646
@@ -5369,6 +5429,13 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
09b0646
 		{0x19, 0x03a11020},
09b0646
 		{0x1d, 0x40e00001},
09b0646
 		{0x21, 0x0321101f}),
09b0646
+	SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL_XPS_13_GPIO6,
09b0646
+		ALC288_STANDARD_PINS,
09b0646
+		{0x12, 0x90a60120},
09b0646
+		{0x13, 0x40000000},
09b0646
+		{0x14, 0x90170110},
09b0646
+		{0x1d, 0x4076832d},
09b0646
+		{0x21, 0x0321101f}),
09b0646
 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
09b0646
 		ALC290_STANDARD_PINS,
09b0646
 		{0x14, 0x411111f0},
09b0646
-- 
09b0646
2.1.0
09b0646