Browse Source

ASoC: Allow disabling of WM835x jack detection

If no report is specified then disable detection. Note that we don't
disable the slow clock, though the power consumption from it should
be negligable. That should be reference counted, ideally through DAPM.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Mark Brown 15 năm trước cách đây
mục cha
commit
f06bce9c8c
1 tập tin đã thay đổi với 18 bổ sung6 xóa
  1. 18 6
      sound/soc/codecs/wm8350.c

+ 18 - 6
sound/soc/codecs/wm8350.c

@@ -1393,7 +1393,8 @@ static irqreturn_t wm8350_hp_jack_handler(int irq, void *data)
  * @jack:   jack to report detection events on
  * @jack:   jack to report detection events on
  * @report: value to report
  * @report: value to report
  *
  *
- * Enables the headphone jack detection of the WM8350.
+ * Enables the headphone jack detection of the WM8350.  If no report
+ * is specified then detection is disabled.
  */
  */
 int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which,
 int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which,
 			  struct snd_soc_jack *jack, int report)
 			  struct snd_soc_jack *jack, int report)
@@ -1422,8 +1423,12 @@ int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which,
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
-	wm8350_set_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA);
-	wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena);
+	if (report) {
+		wm8350_set_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA);
+		wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena);
+	} else {
+		wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, ena);
+	}
 
 
 	/* Sync status */
 	/* Sync status */
 	wm8350_hp_jack_handler(irq + wm8350->irq_base, priv);
 	wm8350_hp_jack_handler(irq + wm8350->irq_base, priv);
@@ -1459,7 +1464,8 @@ static irqreturn_t wm8350_mic_handler(int irq, void *data)
  * @detect_report: value to report when presence detected
  * @detect_report: value to report when presence detected
  * @short_report:  value to report when microphone short detected
  * @short_report:  value to report when microphone short detected
  *
  *
- * Enables the microphone jack detection of the WM8350.
+ * Enables the microphone jack detection of the WM8350.  If both reports
+ * are specified as zero then detection is disabled.
  */
  */
 int wm8350_mic_jack_detect(struct snd_soc_codec *codec,
 int wm8350_mic_jack_detect(struct snd_soc_codec *codec,
 			   struct snd_soc_jack *jack,
 			   struct snd_soc_jack *jack,
@@ -1472,8 +1478,14 @@ int wm8350_mic_jack_detect(struct snd_soc_codec *codec,
 	priv->mic.report = detect_report;
 	priv->mic.report = detect_report;
 	priv->mic.short_report = short_report;
 	priv->mic.short_report = short_report;
 
 
-	wm8350_set_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA);
-	wm8350_set_bits(wm8350, WM8350_POWER_MGMT_1, WM8350_MIC_DET_ENA);
+	if (detect_report || short_report) {
+		wm8350_set_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA);
+		wm8350_set_bits(wm8350, WM8350_POWER_MGMT_1,
+				WM8350_MIC_DET_ENA);
+	} else {
+		wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_1,
+				  WM8350_MIC_DET_ENA);
+	}
 
 
 	return 0;
 	return 0;
 }
 }