[ar71xx] preliminary support for the Ubiquiti RouterStation Pro
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1305-suppress-onkey-events-on-resume-Was-Re-Where-ar.patch
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?]
5
6 Michael 'Mickey' Lauer wrote:
7 ...
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.
13 >
14 > Kernel-guys, can we change that?
15
16 suppress-resume-onkey-event.patch
17
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.
21
22 Signed-off-by: Mike Westerhof <mwester@dls.net>
23 ---
24 drivers/i2c/chips/pcf50606.c | 34 +++++++++++++++++++++++++++++-----
25 drivers/i2c/chips/pcf50633.c | 30 ++++++++++++++++++++++++++----
26 2 files changed, 55 insertions(+), 9 deletions(-)
27
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 {
33 int onkey_seconds;
34 int irq;
35 int coldplug_done;
36 + int suppress_onkey_events;
37 enum pcf50606_suspend_states suspend_state;
38 #ifdef CONFIG_PM
39 struct {
40 @@ -656,9 +657,21 @@ static void pcf50606_work(struct work_struct *work)
41 *
42 * pcf50606 resume is really really over now then.
43 */
44 - if (pcf->suspend_state != PCF50606_SS_RUNNING)
45 + if (pcf->suspend_state != PCF50606_SS_RUNNING) {
46 pcf->suspend_state = PCF50606_SS_RUNNING;
47
48 + /* peek at the IRQ reason, if power button then set a flag
49 + * so that we do not signal the event to userspace
50 + */
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");
55 + } else {
56 + pcf->suppress_onkey_events = 0;
57 + }
58 + }
59 +
60 if (!pcf->coldplug_done) {
61 DEBUGPC("PMU Coldplug init\n");
62
63 @@ -689,9 +702,13 @@ static void pcf50606_work(struct work_struct *work)
64
65 if (pcfirq[0] & PCF50606_INT1_ONKEYF) {
66 /* ONKEY falling edge (start of button press) */
67 - DEBUGPC("ONKEYF ");
68 pcf->flags |= PCF50606_F_PWR_PRESSED;
69 - input_report_key(pcf->input_dev, KEY_POWER, 1);
70 + if (!pcf->suppress_onkey_events) {
71 + DEBUGPC("ONKEYF ");
72 + input_report_key(pcf->input_dev, KEY_POWER, 1);
73 + } else {
74 + DEBUGPC("ONKEYF(unreported) ");
75 + }
76 }
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)
80 }
81 if (pcfirq[0] & PCF50606_INT1_ONKEYR) {
82 /* ONKEY rising edge (end of button press) */
83 - DEBUGPC("ONKEYR ");
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) {
88 + DEBUGPC("ONKEYR ");
89 + input_report_key(pcf->input_dev, KEY_POWER, 0);
90 + } else {
91 + DEBUGPC("ONKEYR(suppressed) ");
92 + /* don't suppress any more power button events */
93 + pcf->suppress_onkey_events = 0;
94 + }
95 /* disable SECOND interrupt in case RTC didn't
96 * request it */
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);
100 data->irq = irq;
101 data->working = 0;
102 + data->suppress_onkey_events = 0;
103 data->onkey_seconds = -1;
104 data->pdata = pcf50606_pdev->dev.platform_data;
105
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;
112 u8 pcfirq_resume[5];
113 int probe_completed;
114 + int suppress_onkey_events;
115
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)
119
120 /* pcf50633 resume is really really over now then */
121 pcf->suspend_state = PCF50633_SS_RUNNING;
122 +
123 + /* peek at the IRQ reason, if power button then set a flag
124 + * so that we do not signal the event to userspace
125 + */
126 + if (pcfirq[1] & (PCF50633_INT2_ONKEYF | PCF50633_INT2_ONKEYR)) {
127 + pcf->suppress_onkey_events = 1;
128 + DEBUGP("Wake by ONKEY, suppressing ONKEY event");
129 + } else {
130 + pcf->suppress_onkey_events = 0;
131 + }
132 }
133
134 if (!pcf->coldplug_done) {
135 @@ -988,16 +999,26 @@ static void pcf50633_work(struct work_struct *work)
136
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);
145 + } else {
146 + DEBUGPC("ONKEYF(unreported) ");
147 + }
148 }
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);
158 + } else {
159 + DEBUGPC("ONKEYR(unreported) ");
160 + /* don't suppress any more power button events */
161 + pcf->suppress_onkey_events = 0;
162 + }
163 /* disable SECOND interrupt in case RTC didn't
164 * request it */
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);
168 pcf->irq = irq;
169 pcf->working = 0;
170 + pcf->suppress_onkey_events = 0;
171 pcf->onkey_seconds = -1;
172 pcf->pdata = pcf50633_pdev->dev.platform_data;
173
174 --
175 1.5.6.5
176
This page took 0.05905 seconds and 5 git commands to generate.