]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.15/asoc-nau8824-fix-the-issue-of-the-widget-with-prefix.patch
Linux 4.19.42
[thirdparty/kernel/stable-queue.git] / releases / 5.0.15 / asoc-nau8824-fix-the-issue-of-the-widget-with-prefix.patch
1 From 9273d4c1ea753488dc208dad8fd39a4e0c716525 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
5
6 [ Upstream commit 844a4a362dbec166b44d6b9b3dd45b08cb273703 ]
7
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.
11
12 The patch will fix these issues caused by prefixed name added.
13
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>
17 ---
18 sound/soc/codecs/nau8824.c | 46 +++++++++++++++++++++++++++++++-------
19 1 file changed, 38 insertions(+), 8 deletions(-)
20
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),
28
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),
33
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)
37 }
38 }
39
40 +static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin)
41 +{
42 + struct snd_soc_dapm_context *dapm = nau8824->dapm;
43 + const char *prefix = dapm->component->name_prefix;
44 + char prefixed_pin[80];
45 +
46 + if (prefix) {
47 + snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
48 + prefix, pin);
49 + snd_soc_dapm_disable_pin(dapm, prefixed_pin);
50 + } else {
51 + snd_soc_dapm_disable_pin(dapm, pin);
52 + }
53 +}
54 +
55 +static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin)
56 +{
57 + struct snd_soc_dapm_context *dapm = nau8824->dapm;
58 + const char *prefix = dapm->component->name_prefix;
59 + char prefixed_pin[80];
60 +
61 + if (prefix) {
62 + snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
63 + prefix, pin);
64 + snd_soc_dapm_force_enable_pin(dapm, prefixed_pin);
65 + } else {
66 + snd_soc_dapm_force_enable_pin(dapm, pin);
67 + }
68 +}
69 +
70 static void nau8824_eject_jack(struct nau8824 *nau8824)
71 {
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);
76
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);
82
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;
87
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);
93
94 msleep(100);
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;
98
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);
104 } else {
105 event |= SND_JACK_HEADSET;
106 --
107 2.20.1
108