linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: twl4030 power button: don't lose presses on resume
@ 2012-04-25  2:21 NeilBrown
  2012-04-25  5:09 ` Dmitry Torokhov
  0 siblings, 1 reply; 7+ messages in thread
From: NeilBrown @ 2012-04-25  2:21 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1784 bytes --]


If we press and release the power button before the press interrupt is
handled - as can happen on resume - we lose the press event so the
release event is ignored and we don't know what happened to cause the
wakeup.

So make sure that each interrupt handled does generate an event.
Because twl4030 queues interrupt events we will see two interrupts
for a press-release even if we handle the first one later.  This means
that such a sequence will be reported as two button presses.  This
is unfortunate but is better than no button presses.
Possibly we could set the PENDDIS_MASK to disable queuing of
interrupts, but that might adversely affect other interrupt sources.

Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index 38e4b50..7ea0ea8 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -42,7 +42,19 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
 	err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value,
 				STS_HW_CONDITIONS);
 	if (!err)  {
-		input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ);
+		int val = !!(value & PWR_PWRON_IRQ);
+
+		/* We got an interrupt, so we must see a change.
+		 * Because the TWL4030 queues pending interrupts to a depth
+		 * of 2, we end up seeing two key presses as there can
+		 * be two interrupts processed while the key appears to
+		 * be up.  This could be fixed by setting PNEDDIS_MASK
+		 * in PWR_SIH_CTRL in twl4030-irq.c.
+		 */
+		input_report_key(pwr, KEY_POWER, !val);
+		input_sync(pwr);
+
+		input_report_key(pwr, KEY_POWER, val);
 		input_sync(pwr);
 	} else {
 		dev_err(pwr->dev.parent, "twl4030: i2c error %d while reading"

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-04-26  7:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-25  2:21 [PATCH] Input: twl4030 power button: don't lose presses on resume NeilBrown
2012-04-25  5:09 ` Dmitry Torokhov
2012-04-25  5:26   ` NeilBrown
2012-04-25 16:56     ` anish kumar
2012-04-25 20:58       ` NeilBrown
2012-04-26  3:06         ` anish singh
2012-04-26  7:14     ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).