aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hsu <KCHSU0@nuvoton.com>2017-11-24 05:08:26 -0500
committerMark Brown <broonie@kernel.org>2017-11-29 05:32:12 -0500
commit226d7449135ffc62866c06d73b28cac90b3f31e4 (patch)
treec562801418dd2e0bd869740daaf3b499dd78d5c0
parent4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323 (diff)
ASoC: nau8825: disable crosstalk by default
The driver makes the crosstalk funciton disabled by default which can simplify the codec function. The platform may not need this funciton and reduce the potential risk. Therefore, We change the property "nuvoton,crosstalk-bypass" to "nuvoton,crosstalk-enable". The crosstalk measurement is enabled if the property is set. Otherwise, it is disabled. Besides, add more condition in the entry point of the crosstalk sequence to disable the function completely. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/sound/nau8825.txt4
-rw-r--r--sound/soc/codecs/nau8825.c23
-rw-r--r--sound/soc/codecs/nau8825.h2
3 files changed, 16 insertions, 13 deletions
diff --git a/Documentation/devicetree/bindings/sound/nau8825.txt b/Documentation/devicetree/bindings/sound/nau8825.txt
index 2f5e973285a6..d16d96839bcb 100644
--- a/Documentation/devicetree/bindings/sound/nau8825.txt
+++ b/Documentation/devicetree/bindings/sound/nau8825.txt
@@ -69,7 +69,7 @@ Optional properties:
69 - nuvoton,jack-insert-debounce: number from 0 to 7 that sets debounce time to 2^(n+2) ms 69 - nuvoton,jack-insert-debounce: number from 0 to 7 that sets debounce time to 2^(n+2) ms
70 - nuvoton,jack-eject-debounce: number from 0 to 7 that sets debounce time to 2^(n+2) ms 70 - nuvoton,jack-eject-debounce: number from 0 to 7 that sets debounce time to 2^(n+2) ms
71 71
72 - nuvoton,crosstalk-bypass: make crosstalk function bypass if set. 72 - nuvoton,crosstalk-enable: make crosstalk function enable if set.
73 73
74 - clocks: list of phandle and clock specifier pairs according to common clock bindings for the 74 - clocks: list of phandle and clock specifier pairs according to common clock bindings for the
75 clocks described in clock-names 75 clocks described in clock-names
@@ -98,7 +98,7 @@ Example:
98 nuvoton,short-key-debounce = <2>; 98 nuvoton,short-key-debounce = <2>;
99 nuvoton,jack-insert-debounce = <7>; 99 nuvoton,jack-insert-debounce = <7>;
100 nuvoton,jack-eject-debounce = <7>; 100 nuvoton,jack-eject-debounce = <7>;
101 nuvoton,crosstalk-bypass; 101 nuvoton,crosstalk-enable;
102 102
103 clock-names = "mclk"; 103 clock-names = "mclk";
104 clocks = <&tegra_car TEGRA210_CLK_CLK_OUT_2>; 104 clocks = <&tegra_car TEGRA210_CLK_CLK_OUT_2>;
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 714ce17da717..d3c1a02f1e15 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -815,11 +815,12 @@ static void nau8825_xtalk_work(struct work_struct *work)
815 815
816static void nau8825_xtalk_cancel(struct nau8825 *nau8825) 816static void nau8825_xtalk_cancel(struct nau8825 *nau8825)
817{ 817{
818 /* If the xtalk_protect is true, that means the process is still 818 /* If the crosstalk is eanbled and the process is on going,
819 * on going. The driver forces to cancel the cross talk task and 819 * the driver forces to cancel the crosstalk task and
820 * restores the configuration to original status. 820 * restores the configuration to original status.
821 */ 821 */
822 if (nau8825->xtalk_protect) { 822 if (nau8825->xtalk_enable && nau8825->xtalk_state !=
823 NAU8825_XTALK_DONE) {
823 cancel_work_sync(&nau8825->xtalk_work); 824 cancel_work_sync(&nau8825->xtalk_work);
824 nau8825_xtalk_clean(nau8825); 825 nau8825_xtalk_clean(nau8825);
825 } 826 }
@@ -1686,7 +1687,7 @@ static irqreturn_t nau8825_interrupt(int irq, void *data)
1686 } else if (active_irq & NAU8825_HEADSET_COMPLETION_IRQ) { 1687 } else if (active_irq & NAU8825_HEADSET_COMPLETION_IRQ) {
1687 if (nau8825_is_jack_inserted(regmap)) { 1688 if (nau8825_is_jack_inserted(regmap)) {
1688 event |= nau8825_jack_insert(nau8825); 1689 event |= nau8825_jack_insert(nau8825);
1689 if (!nau8825->xtalk_bypass && !nau8825->high_imped) { 1690 if (nau8825->xtalk_enable && !nau8825->high_imped) {
1690 /* Apply the cross talk suppression in the 1691 /* Apply the cross talk suppression in the
1691 * headset without high impedance. 1692 * headset without high impedance.
1692 */ 1693 */
@@ -1732,8 +1733,10 @@ static irqreturn_t nau8825_interrupt(int irq, void *data)
1732 nau8825->xtalk_event_mask = event_mask; 1733 nau8825->xtalk_event_mask = event_mask;
1733 } 1734 }
1734 } else if (active_irq & NAU8825_IMPEDANCE_MEAS_IRQ) { 1735 } else if (active_irq & NAU8825_IMPEDANCE_MEAS_IRQ) {
1735 schedule_work(&nau8825->xtalk_work); 1736 if (nau8825->xtalk_enable) {
1736 clear_irq = NAU8825_IMPEDANCE_MEAS_IRQ; 1737 schedule_work(&nau8825->xtalk_work);
1738 clear_irq = NAU8825_IMPEDANCE_MEAS_IRQ;
1739 }
1737 } else if ((active_irq & NAU8825_JACK_INSERTION_IRQ_MASK) == 1740 } else if ((active_irq & NAU8825_JACK_INSERTION_IRQ_MASK) ==
1738 NAU8825_JACK_INSERTION_DETECTED) { 1741 NAU8825_JACK_INSERTION_DETECTED) {
1739 /* One more step to check GPIO status directly. Thus, the 1742 /* One more step to check GPIO status directly. Thus, the
@@ -2440,8 +2443,8 @@ static void nau8825_print_device_properties(struct nau8825 *nau8825)
2440 nau8825->jack_insert_debounce); 2443 nau8825->jack_insert_debounce);
2441 dev_dbg(dev, "jack-eject-debounce: %d\n", 2444 dev_dbg(dev, "jack-eject-debounce: %d\n",
2442 nau8825->jack_eject_debounce); 2445 nau8825->jack_eject_debounce);
2443 dev_dbg(dev, "crosstalk-bypass: %d\n", 2446 dev_dbg(dev, "crosstalk-enable: %d\n",
2444 nau8825->xtalk_bypass); 2447 nau8825->xtalk_enable);
2445} 2448}
2446 2449
2447static int nau8825_read_device_properties(struct device *dev, 2450static int nau8825_read_device_properties(struct device *dev,
@@ -2506,8 +2509,8 @@ static int nau8825_read_device_properties(struct device *dev,
2506 &nau8825->jack_eject_debounce); 2509 &nau8825->jack_eject_debounce);
2507 if (ret) 2510 if (ret)
2508 nau8825->jack_eject_debounce = 0; 2511 nau8825->jack_eject_debounce = 0;
2509 nau8825->xtalk_bypass = device_property_read_bool(dev, 2512 nau8825->xtalk_enable = device_property_read_bool(dev,
2510 "nuvoton,crosstalk-bypass"); 2513 "nuvoton,crosstalk-enable");
2511 2514
2512 nau8825->mclk = devm_clk_get(dev, "mclk"); 2515 nau8825->mclk = devm_clk_get(dev, "mclk");
2513 if (PTR_ERR(nau8825->mclk) == -EPROBE_DEFER) { 2516 if (PTR_ERR(nau8825->mclk) == -EPROBE_DEFER) {
diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h
index 8aee5c8647ae..199d6ea4dcdc 100644
--- a/sound/soc/codecs/nau8825.h
+++ b/sound/soc/codecs/nau8825.h
@@ -476,7 +476,7 @@ struct nau8825 {
476 int xtalk_event_mask; 476 int xtalk_event_mask;
477 bool xtalk_protect; 477 bool xtalk_protect;
478 int imp_rms[NAU8825_XTALK_IMM]; 478 int imp_rms[NAU8825_XTALK_IMM];
479 int xtalk_bypass; 479 int xtalk_enable;
480}; 480};
481 481
482int nau8825_enable_jack_detect(struct snd_soc_codec *codec, 482int nau8825_enable_jack_detect(struct snd_soc_codec *codec,