* [PATCH] ASoC: Use delayed work for debounce of GPIO based jacks
@ 2010-10-06 23:05 Mark Brown
2010-10-07 5:54 ` Jarkko Nikula
2010-10-07 18:13 ` Liam Girdwood
0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2010-10-06 23:05 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, Mark Brown, Peter Ujfalusi
Rather than block the workqueue by sleeping to do the debounce use delayed
work to implement the debounce time. This should also mean 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>
---
This is completely untested as I do not have any systems to hand which
can make use of this functionality but I believe it should work - I've
CCed a couple of the OMAP people since they seem to be the main users.
include/sound/soc.h | 2 +-
sound/soc/soc-jack.c | 11 +++++------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 493b3a4..4fb079e 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -385,7 +385,7 @@ struct snd_soc_jack_gpio {
int invert;
int debounce_time;
struct snd_soc_jack *jack;
- struct work_struct work;
+ struct delayed_work work;
int (*jack_status_check)(void);
};
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 8862770..8a0a920 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)
int enable;
int report;
- if (gpio->debounce_time > 0)
- mdelay(gpio->debounce_time);
-
enable = gpio_get_value(gpio->gpio);
if (gpio->invert)
enable = !enable;
@@ -211,7 +208,8 @@ static irqreturn_t gpio_handler(int irq, void *data)
{
struct snd_soc_jack_gpio *gpio = data;
- schedule_work(&gpio->work);
+ schedule_delayed_work(&gpio->work,
+ msecs_to_jiffies(gpio->debounce_time));
return IRQ_HANDLED;
}
@@ -221,7 +219,7 @@ static void gpio_work(struct work_struct *work)
{
struct snd_soc_jack_gpio *gpio;
- gpio = container_of(work, struct snd_soc_jack_gpio, work);
+ gpio = container_of(work, struct snd_soc_jack_gpio, work.work);
snd_soc_jack_gpio_detect(gpio);
}
@@ -262,7 +260,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
if (ret)
goto err;
- INIT_WORK(&gpios[i].work, gpio_work);
+ INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
gpios[i].jack = jack;
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,
gpio_unexport(gpios[i].gpio);
#endif
free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]);
+ cancel_delayed_work_sync(&gpios[i].work);
gpio_free(gpios[i].gpio);
gpios[i].jack = NULL;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: Use delayed work for debounce of GPIO based jacks
2010-10-06 23:05 [PATCH] ASoC: Use delayed work for debounce of GPIO based jacks Mark Brown
@ 2010-10-07 5:54 ` Jarkko Nikula
2010-10-10 10:38 ` Liam Girdwood
2010-10-07 18:13 ` Liam Girdwood
1 sibling, 1 reply; 4+ messages in thread
From: Jarkko Nikula @ 2010-10-07 5:54 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Peter, Ujfalusi, Liam Girdwood
On Wed, 6 Oct 2010 16:05:01 -0700
Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> Rather than block the workqueue by sleeping to do the debounce use delayed
> work to implement the debounce time. This should also mean 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>
> ---
>
> This is completely untested as I do not have any systems to hand which
> can make use of this functionality but I believe it should work - I've
> CCed a couple of the OMAP people since they seem to be the main users.
>
> include/sound/soc.h | 2 +-
> sound/soc/soc-jack.c | 11 +++++------
> 2 files changed, 6 insertions(+), 7 deletions(-)
>
Works fine on N900 when testing with
hexdump /dev/input/by-path/platform-soc-audio-event
I have a vague memory that user space and actual state can get soon out
of sync if using delay based debouncing only and doing some insane plug
in/out cycle. So this is a step to right direction for implementing
more advanced debouncing.
Acked-by: Jarkko Nikula <jhnikula@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: Use delayed work for debounce of GPIO based jacks
2010-10-06 23:05 [PATCH] ASoC: Use delayed work for debounce of GPIO based jacks Mark Brown
2010-10-07 5:54 ` Jarkko Nikula
@ 2010-10-07 18:13 ` Liam Girdwood
1 sibling, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2010-10-07 18:13 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Peter Ujfalusi
On Wed, 2010-10-06 at 16:05 -0700, Mark Brown wrote:
> Rather than block the workqueue by sleeping to do the debounce use delayed
> work to implement the debounce time. This should also mean 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: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: Use delayed work for debounce of GPIO based jacks
2010-10-07 5:54 ` Jarkko Nikula
@ 2010-10-10 10:38 ` Liam Girdwood
0 siblings, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2010-10-10 10:38 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: alsa-devel, Mark Brown, Ujfalusi, Peter
On Thu, 2010-10-07 at 08:54 +0300, Jarkko Nikula wrote:
> On Wed, 6 Oct 2010 16:05:01 -0700
> Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
>
> > Rather than block the workqueue by sleeping to do the debounce use delayed
> > work to implement the debounce time. This should also mean 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>
> > ---
> >
> > This is completely untested as I do not have any systems to hand which
> > can make use of this functionality but I believe it should work - I've
> > CCed a couple of the OMAP people since they seem to be the main users.
> >
> > include/sound/soc.h | 2 +-
> > sound/soc/soc-jack.c | 11 +++++------
> > 2 files changed, 6 insertions(+), 7 deletions(-)
> >
> Works fine on N900 when testing with
> hexdump /dev/input/by-path/platform-soc-audio-event
>
> I have a vague memory that user space and actual state can get soon out
> of sync if using delay based debouncing only and doing some insane plug
> in/out cycle. So this is a step to right direction for implementing
> more advanced debouncing.
>
> Acked-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-10 10:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-06 23:05 [PATCH] ASoC: Use delayed work for debounce of GPIO based jacks Mark Brown
2010-10-07 5:54 ` Jarkko Nikula
2010-10-10 10:38 ` Liam Girdwood
2010-10-07 18:13 ` Liam Girdwood
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.