how to make KEY_POWER work in terminal system

Lars-Peter Clausen lars at metafoo.de
Mon Nov 16 05:07:36 EST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bas Wijnen wrote:
> On Mon, Nov 16, 2009 at 01:46:57AM +0100, Lars-Peter Clausen wrote:
>
>> The gpio-keys driver needs support for irqs which are triggered
>> on falling and rising edges.
>
> I am surprised by that.  While the keyboard handler does work with
> edge-triggered events, it would AFAICS be hard to avoid a race
> condition.  If you use level-triggered interrupts, it is
> automatically avoided.  If you do this: - check state - set up
> interrupt edges (rising or falling) depending on state - wait for
> interrupts
Usually hardware supports triggering on both edges. In that case you
don't have to change the direction of the trigger and so there is no
chance for an race.
>
> You can miss a key press if the edge happens between step 1 and 2.
> For example, the signal is high in step 1, then there's a falling
> edge, then the falling edge interrupt is set up.  It has already
> happened and will not trigger until there's another one.  So you
> need to check the state again and handle restart the handler if
> there are new keys already. There's no need for this when using
> level-triggered interrupts, because the interrupt will be asserted
> immediately after the interrupt level has been set up.
Sure. But if you are able to press and release your button so fast
that you hit this race it would have been ignored anyway because of
debouncing. (And I highly doubt anyone will be able to press and
release a button faster then it takes the irq handler to run)

>
> Also, I don't understand why the power button would not work with
> edge-triggered interrupts.  It would have the race condition I
> mentioned (so level interrupts are certainly better), but that
> should hardly ever happen.  I can't imagine that this can result in
> a "the power button doesn't work properly"-report.
Well if you only get falling edge irqs were you expect both edges
you'll only see button down events. So the gpio-keys driver will only
report button down events to the core and the core will see that the
button is already down and filter the event.

- - Lars
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksBJGgACgkQBX4mSR26RiMT+QCeMjXymgg/FraQiIaGNYPrttcv
sl0AniQtGieV3QkUyM0HQU00pG9JYuxh
=sdMY
-----END PGP SIGNATURE-----





More information about the discussion mailing list


interactive