1 From 1dd6a1914216dd76535b49ee0196bd20d0d862be Mon Sep 17 00:00:00 2001
2 From: John Hsu <KCHSU0@nuvoton.com>
3 Date: Mon, 11 Mar 2019 09:36:45 +0800
4 Subject: ASoC: nau8824: fix the issue of the widget with prefix name
6 [ Upstream commit 844a4a362dbec166b44d6b9b3dd45b08cb273703 ]
8 The driver has two issues when machine add prefix name for codec.
9 (1)The stream name of DAI can't find the AIF widgets.
10 (2)The drivr can enable/disalbe the MICBIAS and SAR widgets.
12 The patch will fix these issues caused by prefixed name added.
14 Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
15 Signed-off-by: Mark Brown <broonie@kernel.org>
16 Signed-off-by: Sasha Levin <sashal@kernel.org>
18 sound/soc/codecs/nau8824.c | 46 +++++++++++++++++++++++++++++++-------
19 1 file changed, 38 insertions(+), 8 deletions(-)
21 diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
22 index 468d5143e2c4f..663a208c2f784 100644
23 --- a/sound/soc/codecs/nau8824.c
24 +++ b/sound/soc/codecs/nau8824.c
25 @@ -681,8 +681,8 @@ static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = {
26 SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2,
27 NAU8824_ADCR_EN_SFT, 0),
29 - SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
30 - SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
31 + SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, SND_SOC_NOPM, 0, 0),
32 + SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0),
34 SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC,
35 NAU8824_DACL_EN_SFT, 0),
36 @@ -831,6 +831,36 @@ static void nau8824_int_status_clear_all(struct regmap *regmap)
40 +static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin)
42 + struct snd_soc_dapm_context *dapm = nau8824->dapm;
43 + const char *prefix = dapm->component->name_prefix;
44 + char prefixed_pin[80];
47 + snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
49 + snd_soc_dapm_disable_pin(dapm, prefixed_pin);
51 + snd_soc_dapm_disable_pin(dapm, pin);
55 +static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin)
57 + struct snd_soc_dapm_context *dapm = nau8824->dapm;
58 + const char *prefix = dapm->component->name_prefix;
59 + char prefixed_pin[80];
62 + snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
64 + snd_soc_dapm_force_enable_pin(dapm, prefixed_pin);
66 + snd_soc_dapm_force_enable_pin(dapm, pin);
70 static void nau8824_eject_jack(struct nau8824 *nau8824)
72 struct snd_soc_dapm_context *dapm = nau8824->dapm;
73 @@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824)
74 /* Clear all interruption status */
75 nau8824_int_status_clear_all(regmap);
77 - snd_soc_dapm_disable_pin(dapm, "SAR");
78 - snd_soc_dapm_disable_pin(dapm, "MICBIAS");
79 + nau8824_dapm_disable_pin(nau8824, "SAR");
80 + nau8824_dapm_disable_pin(nau8824, "MICBIAS");
81 snd_soc_dapm_sync(dapm);
83 /* Enable the insertion interruption, disable the ejection
84 @@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work)
85 struct regmap *regmap = nau8824->regmap;
86 int adc_value, event = 0, event_mask = 0;
88 - snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
89 - snd_soc_dapm_force_enable_pin(dapm, "SAR");
90 + nau8824_dapm_enable_pin(nau8824, "MICBIAS");
91 + nau8824_dapm_enable_pin(nau8824, "SAR");
92 snd_soc_dapm_sync(dapm);
95 @@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work)
96 if (adc_value < HEADSET_SARADC_THD) {
97 event |= SND_JACK_HEADPHONE;
99 - snd_soc_dapm_disable_pin(dapm, "SAR");
100 - snd_soc_dapm_disable_pin(dapm, "MICBIAS");
101 + nau8824_dapm_disable_pin(nau8824, "SAR");
102 + nau8824_dapm_disable_pin(nau8824, "MICBIAS");
103 snd_soc_dapm_sync(dapm);
105 event |= SND_JACK_HEADSET;