how to make KEY_POWER work in terminal system
wijnen at debian.org
Mon Nov 16 01:43:48 EST 2009
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
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.
Note that this is a corner-case, because most of the time that this
problem would arise, the keyboard is polled anyway. But it can also
happen when there's no need to poll, when no keys are pressed. (I'm not
sure if Linux polls in that case, but it shouldn't.)
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: Digital signature
More information about the discussion