1 From 71f219082f5c04a80f9b143fc92a51a3de5c6683 Mon Sep 17 00:00:00 2001
2 From: \\\\\\\"Mike (mwester)\\\\\\ <mwester@dls.net>
3 Date: Tue, 14 Oct 2008 05:46:34 +0100
4 Subject: [PATCH] suppress "onkey" events on resume [Was: Re: Where are actions configured for buttons in FSO?]
6 Michael 'Mickey' Lauer wrote:
8 > The problem is (and this is the reason why I'm crossposting this to the
9 > kernel mailing list), the kernel is not swallowing the power button
10 > presses that triggers the resume, so you need some "real" programming
11 > (as opposed to the expressional complexity of our rules) in order to
12 > prevent falling asleep right after resume.
14 > Kernel-guys, can we change that?
16 suppress-resume-onkey-event.patch
18 This suppresses the key press and key release events from the
19 power button, in the case where the power button is the wake
20 event for the GTA01 or GTA02 device.
22 Signed-off-by: Mike Westerhof <mwester@dls.net>
24 drivers/i2c/chips/pcf50606.c | 34 +++++++++++++++++++++++++++++-----
25 drivers/i2c/chips/pcf50633.c | 30 ++++++++++++++++++++++++++----
26 2 files changed, 55 insertions(+), 9 deletions(-)
28 diff --git a/drivers/i2c/chips/pcf50606.c b/drivers/i2c/chips/pcf50606.c
29 index 18263fb..706ce6d 100644
30 --- a/drivers/i2c/chips/pcf50606.c
31 +++ b/drivers/i2c/chips/pcf50606.c
32 @@ -120,6 +120,7 @@ struct pcf50606_data {
36 + int suppress_onkey_events;
37 enum pcf50606_suspend_states suspend_state;
40 @@ -656,9 +657,21 @@ static void pcf50606_work(struct work_struct *work)
42 * pcf50606 resume is really really over now then.
44 - if (pcf->suspend_state != PCF50606_SS_RUNNING)
45 + if (pcf->suspend_state != PCF50606_SS_RUNNING) {
46 pcf->suspend_state = PCF50606_SS_RUNNING;
48 + /* peek at the IRQ reason, if power button then set a flag
49 + * so that we do not signal the event to userspace
51 + if (pcfirq[0] & (PCF50606_INT1_ONKEYF | PCF50606_INT1_ONKEYR)) {
52 + pcf->suppress_onkey_events = 1;
53 + dev_dbg(&pcf->client.dev,
54 + "Wake by ONKEY, suppressing ONKEY events");
56 + pcf->suppress_onkey_events = 0;
60 if (!pcf->coldplug_done) {
61 DEBUGPC("PMU Coldplug init\n");
63 @@ -689,9 +702,13 @@ static void pcf50606_work(struct work_struct *work)
65 if (pcfirq[0] & PCF50606_INT1_ONKEYF) {
66 /* ONKEY falling edge (start of button press) */
68 pcf->flags |= PCF50606_F_PWR_PRESSED;
69 - input_report_key(pcf->input_dev, KEY_POWER, 1);
70 + if (!pcf->suppress_onkey_events) {
72 + input_report_key(pcf->input_dev, KEY_POWER, 1);
74 + DEBUGPC("ONKEYF(unreported) ");
77 if (pcfirq[0] & PCF50606_INT1_ONKEY1S) {
78 /* ONKEY pressed for more than 1 second */
79 @@ -706,10 +723,16 @@ static void pcf50606_work(struct work_struct *work)
81 if (pcfirq[0] & PCF50606_INT1_ONKEYR) {
82 /* ONKEY rising edge (end of button press) */
84 pcf->flags &= ~PCF50606_F_PWR_PRESSED;
85 pcf->onkey_seconds = -1;
86 - input_report_key(pcf->input_dev, KEY_POWER, 0);
87 + if (!pcf->suppress_onkey_events) {
89 + input_report_key(pcf->input_dev, KEY_POWER, 0);
91 + DEBUGPC("ONKEYR(suppressed) ");
92 + /* don't suppress any more power button events */
93 + pcf->suppress_onkey_events = 0;
95 /* disable SECOND interrupt in case RTC didn't
97 if (!(pcf->flags & PCF50606_F_RTC_SECOND))
98 @@ -1766,6 +1789,7 @@ static int pcf50606_detect(struct i2c_adapter *adapter, int address, int kind)
99 INIT_WORK(&data->work, pcf50606_work);
102 + data->suppress_onkey_events = 0;
103 data->onkey_seconds = -1;
104 data->pdata = pcf50606_pdev->dev.platform_data;
106 diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
107 index c186fdb..490e34d 100644
108 --- a/drivers/i2c/chips/pcf50633.c
109 +++ b/drivers/i2c/chips/pcf50633.c
110 @@ -135,6 +135,7 @@ struct pcf50633_data {
111 int usb_removal_count;
114 + int suppress_onkey_events;
116 /* if he pulls battery while charging, we notice that and correctly
117 * report that the charger is idle. But there is no interrupt that
118 @@ -848,6 +849,16 @@ static void pcf50633_work(struct work_struct *work)
120 /* pcf50633 resume is really really over now then */
121 pcf->suspend_state = PCF50633_SS_RUNNING;
123 + /* peek at the IRQ reason, if power button then set a flag
124 + * so that we do not signal the event to userspace
126 + if (pcfirq[1] & (PCF50633_INT2_ONKEYF | PCF50633_INT2_ONKEYR)) {
127 + pcf->suppress_onkey_events = 1;
128 + DEBUGP("Wake by ONKEY, suppressing ONKEY event");
130 + pcf->suppress_onkey_events = 0;
134 if (!pcf->coldplug_done) {
135 @@ -988,16 +999,26 @@ static void pcf50633_work(struct work_struct *work)
137 if (pcfirq[1] & PCF50633_INT2_ONKEYF) {
138 /* ONKEY falling edge (start of button press) */
139 - DEBUGPC("ONKEYF ");
140 pcf->flags |= PCF50633_F_PWR_PRESSED;
141 - input_report_key(pcf->input_dev, KEY_POWER, 1);
142 + if (!pcf->suppress_onkey_events) {
143 + DEBUGPC("ONKEYF ");
144 + input_report_key(pcf->input_dev, KEY_POWER, 1);
146 + DEBUGPC("ONKEYF(unreported) ");
149 if (pcfirq[1] & PCF50633_INT2_ONKEYR) {
150 /* ONKEY rising edge (end of button press) */
151 - DEBUGPC("ONKEYR ");
152 pcf->flags &= ~PCF50633_F_PWR_PRESSED;
153 pcf->onkey_seconds = -1;
154 - input_report_key(pcf->input_dev, KEY_POWER, 0);
155 + if (!pcf->suppress_onkey_events) {
156 + DEBUGPC("ONKEYR ");
157 + input_report_key(pcf->input_dev, KEY_POWER, 0);
159 + DEBUGPC("ONKEYR(unreported) ");
160 + /* don't suppress any more power button events */
161 + pcf->suppress_onkey_events = 0;
163 /* disable SECOND interrupt in case RTC didn't
165 if (!(pcf->flags & PCF50633_F_RTC_SECOND))
166 @@ -2135,6 +2156,7 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
167 INIT_WORK(&pcf->work_usb_curlimit, pcf50633_work_usbcurlim);
170 + pcf->suppress_onkey_events = 0;
171 pcf->onkey_seconds = -1;
172 pcf->pdata = pcf50633_pdev->dev.platform_data;