CHROMIUM: ASoC: max98090 - Expose HP out enable.

Expose the headphone output enables to user space.  This will allow
userspace to ensure that there is stable output before the headphones
are turned on, avoiding a pop on insertion.

BUG=chromium:702468
TEST=Use 'HP Left Out Switch' and 'HP Right Out Switch' in UCM for
headphone enable/disable sequence. Verify that hotplug headphone
won't trigger loud pop noise.

Change-Id: I8e1a86b13e4c954ee2ba2176ae5d72545ccf2e8f
Reviewed-on: https://chromium-review.googlesource.com/456718
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
(cherry picked from commit 2292d6a6c40cd8332a3da6ae9cb1d4f0a31a5bf1)
Reviewed-on: https://chromium-review.googlesource.com/456879
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 89c3967..4349b7d 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -1133,6 +1133,15 @@
 static const struct snd_kcontrol_new max98090_mixhprsel_mux =
 	SOC_DAPM_ENUM("MIXHPRSEL Mux", mixhprsel_mux_enum);
 
+/* HP output enables. */
+static const struct snd_kcontrol_new max98090_hpl_enable =
+	SOC_DAPM_SINGLE("Switch", M98090_REG_OUTPUT_ENABLE,
+			M98090_HPLEN_SHIFT, 1, 0);
+
+static const struct snd_kcontrol_new max98090_hpr_enable =
+	SOC_DAPM_SINGLE("Switch", M98090_REG_OUTPUT_ENABLE,
+			M98090_HPREN_SHIFT, 1, 0);
+
 static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = {
 	SND_SOC_DAPM_INPUT("MIC1"),
 	SND_SOC_DAPM_INPUT("MIC2"),
@@ -1275,10 +1284,10 @@
 	SND_SOC_DAPM_MUX("MIXHPRSEL Mux", M98090_REG_HP_CONTROL,
 		M98090_MIXHPRSEL_SHIFT, 0, &max98090_mixhprsel_mux),
 
-	SND_SOC_DAPM_PGA("HP Left Out", M98090_REG_OUTPUT_ENABLE,
-		M98090_HPLEN_SHIFT, 0, NULL, 0),
-	SND_SOC_DAPM_PGA("HP Right Out", M98090_REG_OUTPUT_ENABLE,
-		M98090_HPREN_SHIFT, 0, NULL, 0),
+	SND_SOC_DAPM_SWITCH("HP Left Out", SND_SOC_NOPM, 0, 0,
+			    &max98090_hpl_enable),
+	SND_SOC_DAPM_SWITCH("HP Right Out", SND_SOC_NOPM, 0, 0,
+			    &max98090_hpr_enable),
 
 	SND_SOC_DAPM_PGA("SPK Left Out", M98090_REG_OUTPUT_ENABLE,
 		M98090_SPLEN_SHIFT, 0, NULL, 0),
@@ -1462,8 +1471,8 @@
 	 * Disable this for lowest power if bypassing
 	 * the DAC with an analog signal
 	 */
-	{"HP Left Out", NULL, "DACL"},
-	{"HP Left Out", NULL, "MIXHPLSEL Mux"},
+	{"HP Left Out", "Switch", "DACL"},
+	{"HP Left Out", "Switch", "MIXHPLSEL Mux"},
 
 	{"MIXHPRSEL Mux", "HP Mixer", "Right Headphone Mixer"},
 
@@ -1471,8 +1480,8 @@
 	 * Disable this for lowest power if bypassing
 	 * the DAC with an analog signal
 	 */
-	{"HP Right Out", NULL, "DACR"},
-	{"HP Right Out", NULL, "MIXHPRSEL Mux"},
+	{"HP Right Out", "Switch", "DACR"},
+	{"HP Right Out", "Switch", "MIXHPRSEL Mux"},
 
 	{"SPK Left Out", NULL, "Left Speaker Mixer"},
 	{"SPK Right Out", NULL, "Right Speaker Mixer"},