aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-jack.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-jack.c')
-rw-r--r--sound/soc/soc-jack.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 3c07a94c2e30..29159e1781d0 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -37,6 +37,7 @@ int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type,
37{ 37{
38 jack->card = card; 38 jack->card = card;
39 INIT_LIST_HEAD(&jack->pins); 39 INIT_LIST_HEAD(&jack->pins);
40 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
40 41
41 return snd_jack_new(card->codec->card, id, type, &jack->jack); 42 return snd_jack_new(card->codec->card, id, type, &jack->jack);
42} 43}
@@ -63,10 +64,9 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
63 int enable; 64 int enable;
64 int oldstatus; 65 int oldstatus;
65 66
66 if (!jack) { 67 if (!jack)
67 WARN_ON_ONCE(!jack);
68 return; 68 return;
69 } 69
70 codec = jack->card->codec; 70 codec = jack->card->codec;
71 71
72 mutex_lock(&codec->mutex); 72 mutex_lock(&codec->mutex);
@@ -93,6 +93,9 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
93 snd_soc_dapm_disable_pin(codec, pin->pin); 93 snd_soc_dapm_disable_pin(codec, pin->pin);
94 } 94 }
95 95
96 /* Report before the DAPM sync to help users updating micbias status */
97 blocking_notifier_call_chain(&jack->notifier, status, NULL);
98
96 snd_soc_dapm_sync(codec); 99 snd_soc_dapm_sync(codec);
97 100
98 snd_jack_report(jack->jack, status); 101 snd_jack_report(jack->jack, status);
@@ -143,6 +146,40 @@ int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
143} 146}
144EXPORT_SYMBOL_GPL(snd_soc_jack_add_pins); 147EXPORT_SYMBOL_GPL(snd_soc_jack_add_pins);
145 148
149/**
150 * snd_soc_jack_notifier_register - Register a notifier for jack status
151 *
152 * @jack: ASoC jack
153 * @nb: Notifier block to register
154 *
155 * Register for notification of the current status of the jack. Note
156 * that it is not possible to report additional jack events in the
157 * callback from the notifier, this is intended to support
158 * applications such as enabling electrical detection only when a
159 * mechanical detection event has occurred.
160 */
161void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
162 struct notifier_block *nb)
163{
164 blocking_notifier_chain_register(&jack->notifier, nb);
165}
166EXPORT_SYMBOL_GPL(snd_soc_jack_notifier_register);
167
168/**
169 * snd_soc_jack_notifier_unregister - Unregister a notifier for jack status
170 *
171 * @jack: ASoC jack
172 * @nb: Notifier block to unregister
173 *
174 * Stop notifying for status changes.
175 */
176void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
177 struct notifier_block *nb)
178{
179 blocking_notifier_chain_unregister(&jack->notifier, nb);
180}
181EXPORT_SYMBOL_GPL(snd_soc_jack_notifier_unregister);
182
146#ifdef CONFIG_GPIOLIB 183#ifdef CONFIG_GPIOLIB
147/* gpio detect */ 184/* gpio detect */
148static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) 185static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)