diff options
Diffstat (limited to 'sound/soc/soc-jack.c')
-rw-r--r-- | sound/soc/soc-jack.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 8a0a9205b1e7..ac5a5bc7375a 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c | |||
@@ -13,11 +13,11 @@ | |||
13 | 13 | ||
14 | #include <sound/jack.h> | 14 | #include <sound/jack.h> |
15 | #include <sound/soc.h> | 15 | #include <sound/soc.h> |
16 | #include <sound/soc-dapm.h> | ||
17 | #include <linux/gpio.h> | 16 | #include <linux/gpio.h> |
18 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
19 | #include <linux/workqueue.h> | 18 | #include <linux/workqueue.h> |
20 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <trace/events/asoc.h> | ||
21 | 21 | ||
22 | /** | 22 | /** |
23 | * snd_soc_jack_new - Create a new jack | 23 | * snd_soc_jack_new - Create a new jack |
@@ -60,14 +60,18 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_new); | |||
60 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | 60 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) |
61 | { | 61 | { |
62 | struct snd_soc_codec *codec; | 62 | struct snd_soc_codec *codec; |
63 | struct snd_soc_dapm_context *dapm; | ||
63 | struct snd_soc_jack_pin *pin; | 64 | struct snd_soc_jack_pin *pin; |
64 | int enable; | 65 | int enable; |
65 | int oldstatus; | 66 | int oldstatus; |
66 | 67 | ||
68 | trace_snd_soc_jack_report(jack, mask, status); | ||
69 | |||
67 | if (!jack) | 70 | if (!jack) |
68 | return; | 71 | return; |
69 | 72 | ||
70 | codec = jack->codec; | 73 | codec = jack->codec; |
74 | dapm = &codec->dapm; | ||
71 | 75 | ||
72 | mutex_lock(&codec->mutex); | 76 | mutex_lock(&codec->mutex); |
73 | 77 | ||
@@ -81,6 +85,8 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | |||
81 | if (mask && (jack->status == oldstatus)) | 85 | if (mask && (jack->status == oldstatus)) |
82 | goto out; | 86 | goto out; |
83 | 87 | ||
88 | trace_snd_soc_jack_notify(jack, status); | ||
89 | |||
84 | list_for_each_entry(pin, &jack->pins, list) { | 90 | list_for_each_entry(pin, &jack->pins, list) { |
85 | enable = pin->mask & jack->status; | 91 | enable = pin->mask & jack->status; |
86 | 92 | ||
@@ -88,15 +94,15 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | |||
88 | enable = !enable; | 94 | enable = !enable; |
89 | 95 | ||
90 | if (enable) | 96 | if (enable) |
91 | snd_soc_dapm_enable_pin(codec, pin->pin); | 97 | snd_soc_dapm_enable_pin(dapm, pin->pin); |
92 | else | 98 | else |
93 | snd_soc_dapm_disable_pin(codec, pin->pin); | 99 | snd_soc_dapm_disable_pin(dapm, pin->pin); |
94 | } | 100 | } |
95 | 101 | ||
96 | /* Report before the DAPM sync to help users updating micbias status */ | 102 | /* Report before the DAPM sync to help users updating micbias status */ |
97 | blocking_notifier_call_chain(&jack->notifier, status, NULL); | 103 | blocking_notifier_call_chain(&jack->notifier, status, NULL); |
98 | 104 | ||
99 | snd_soc_dapm_sync(codec); | 105 | snd_soc_dapm_sync(dapm); |
100 | 106 | ||
101 | snd_jack_report(jack->jack, status); | 107 | snd_jack_report(jack->jack, status); |
102 | 108 | ||
@@ -207,6 +213,12 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) | |||
207 | static irqreturn_t gpio_handler(int irq, void *data) | 213 | static irqreturn_t gpio_handler(int irq, void *data) |
208 | { | 214 | { |
209 | struct snd_soc_jack_gpio *gpio = data; | 215 | struct snd_soc_jack_gpio *gpio = data; |
216 | struct device *dev = gpio->jack->codec->card->dev; | ||
217 | |||
218 | trace_snd_soc_jack_irq(gpio->name); | ||
219 | |||
220 | if (device_may_wakeup(dev)) | ||
221 | pm_wakeup_event(dev, gpio->debounce_time + 50); | ||
210 | 222 | ||
211 | schedule_delayed_work(&gpio->work, | 223 | schedule_delayed_work(&gpio->work, |
212 | msecs_to_jiffies(gpio->debounce_time)); | 224 | msecs_to_jiffies(gpio->debounce_time)); |
@@ -263,11 +275,12 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
263 | INIT_DELAYED_WORK(&gpios[i].work, gpio_work); | 275 | INIT_DELAYED_WORK(&gpios[i].work, gpio_work); |
264 | gpios[i].jack = jack; | 276 | gpios[i].jack = jack; |
265 | 277 | ||
266 | ret = request_irq(gpio_to_irq(gpios[i].gpio), | 278 | ret = request_any_context_irq(gpio_to_irq(gpios[i].gpio), |
267 | gpio_handler, | 279 | gpio_handler, |
268 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 280 | IRQF_TRIGGER_RISING | |
269 | jack->codec->dev->driver->name, | 281 | IRQF_TRIGGER_FALLING, |
270 | &gpios[i]); | 282 | jack->codec->dev->driver->name, |
283 | &gpios[i]); | ||
271 | if (ret) | 284 | if (ret) |
272 | goto err; | 285 | goto err; |
273 | 286 | ||