aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-10-06 18:54:28 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-10-07 15:58:56 -0400
commit4c14d78e8ad3bacfe1f70cb49ae17afcd658e368 (patch)
treeca487b5abebf8ce0b587434b682070c242e718ea
parentde535a5be53a06738409538c471a10a9de357bdd (diff)
ASoC: Use delayed work for debounce of GPIO based jacks
Rather than block the workqueue by sleeping to do the debounce use delayed work to implement the debounce time. This should also means that we extend the debounce time on each new bounce, potentially allowing shorter debounce times for clean insertions. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-rw-r--r--include/sound/soc.h2
-rw-r--r--sound/soc/soc-jack.c11
2 files changed, 6 insertions, 7 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 493b3a4c193a..4fb079e14e16 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -385,7 +385,7 @@ struct snd_soc_jack_gpio {
385 int invert; 385 int invert;
386 int debounce_time; 386 int debounce_time;
387 struct snd_soc_jack *jack; 387 struct snd_soc_jack *jack;
388 struct work_struct work; 388 struct delayed_work work;
389 389
390 int (*jack_status_check)(void); 390 int (*jack_status_check)(void);
391}; 391};
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 8862770aa221..8a0a9205b1e7 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -188,9 +188,6 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
188 int enable; 188 int enable;
189 int report; 189 int report;
190 190
191 if (gpio->debounce_time > 0)
192 mdelay(gpio->debounce_time);
193
194 enable = gpio_get_value(gpio->gpio); 191 enable = gpio_get_value(gpio->gpio);
195 if (gpio->invert) 192 if (gpio->invert)
196 enable = !enable; 193 enable = !enable;
@@ -211,7 +208,8 @@ static irqreturn_t gpio_handler(int irq, void *data)
211{ 208{
212 struct snd_soc_jack_gpio *gpio = data; 209 struct snd_soc_jack_gpio *gpio = data;
213 210
214 schedule_work(&gpio->work); 211 schedule_delayed_work(&gpio->work,
212 msecs_to_jiffies(gpio->debounce_time));
215 213
216 return IRQ_HANDLED; 214 return IRQ_HANDLED;
217} 215}
@@ -221,7 +219,7 @@ static void gpio_work(struct work_struct *work)
221{ 219{
222 struct snd_soc_jack_gpio *gpio; 220 struct snd_soc_jack_gpio *gpio;
223 221
224 gpio = container_of(work, struct snd_soc_jack_gpio, work); 222 gpio = container_of(work, struct snd_soc_jack_gpio, work.work);
225 snd_soc_jack_gpio_detect(gpio); 223 snd_soc_jack_gpio_detect(gpio);
226} 224}
227 225
@@ -262,7 +260,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
262 if (ret) 260 if (ret)
263 goto err; 261 goto err;
264 262
265 INIT_WORK(&gpios[i].work, gpio_work); 263 INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
266 gpios[i].jack = jack; 264 gpios[i].jack = jack;
267 265
268 ret = request_irq(gpio_to_irq(gpios[i].gpio), 266 ret = request_irq(gpio_to_irq(gpios[i].gpio),
@@ -312,6 +310,7 @@ void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
312 gpio_unexport(gpios[i].gpio); 310 gpio_unexport(gpios[i].gpio);
313#endif 311#endif
314 free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]); 312 free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]);
313 cancel_delayed_work_sync(&gpios[i].work);
315 gpio_free(gpios[i].gpio); 314 gpio_free(gpios[i].gpio);
316 gpios[i].jack = NULL; 315 gpios[i].jack = NULL;
317 } 316 }