Add patches accepted for 2.6.29-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.29-rc2 / 0009-ACPI-thinkpad-acpi-clean-up-hotkey_notify.patch
blob43a8ad4e0231bd8c2f716f9fd931ef1fbac8603b
1 From 3827e7a3fd03718d4d204c66d9e3ab9b125ae552 Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sun, 11 Jan 2009 03:01:05 -0200
4 Subject: ACPI: thinkpad-acpi: clean up hotkey_notify()
6 Clean up the hotkey_notify() handler, which handles the HKEY notifications
7 from the ACPI firmware. It was getting too long and deep.
9 No functional changes.
11 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
12 Signed-off-by: Len Brown <len.brown@intel.com>
13 ---
14 drivers/platform/x86/thinkpad_acpi.c | 174 +++++++++++++++++++++-------------
15 1 files changed, 109 insertions(+), 65 deletions(-)
17 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
18 index 7670c8e..d833ee6 100644
19 --- a/drivers/platform/x86/thinkpad_acpi.c
20 +++ b/drivers/platform/x86/thinkpad_acpi.c
21 @@ -2571,13 +2571,100 @@ err_exit:
22 return (res < 0)? res : 1;
25 +static bool hotkey_notify_hotkey(const u32 hkey,
26 + bool *send_acpi_ev,
27 + bool *ignore_acpi_ev)
29 + /* 0x1000-0x1FFF: key presses */
30 + unsigned int scancode = hkey & 0xfff;
31 + *send_acpi_ev = true;
32 + *ignore_acpi_ev = false;
34 + if (scancode > 0 && scancode < 0x21) {
35 + scancode--;
36 + if (!(hotkey_source_mask & (1 << scancode))) {
37 + tpacpi_input_send_key(scancode);
38 + *send_acpi_ev = false;
39 + } else {
40 + *ignore_acpi_ev = true;
41 + }
42 + return true;
43 + }
44 + return false;
47 +static bool hotkey_notify_wakeup(const u32 hkey,
48 + bool *send_acpi_ev,
49 + bool *ignore_acpi_ev)
51 + /* 0x2000-0x2FFF: Wakeup reason */
52 + *send_acpi_ev = true;
53 + *ignore_acpi_ev = false;
55 + switch (hkey) {
56 + case 0x2304: /* suspend, undock */
57 + case 0x2404: /* hibernation, undock */
58 + hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK;
59 + *ignore_acpi_ev = true;
60 + break;
62 + case 0x2305: /* suspend, bay eject */
63 + case 0x2405: /* hibernation, bay eject */
64 + hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ;
65 + *ignore_acpi_ev = true;
66 + break;
68 + default:
69 + return false;
70 + }
72 + if (hotkey_wakeup_reason != TP_ACPI_WAKEUP_NONE) {
73 + printk(TPACPI_INFO
74 + "woke up due to a hot-unplug "
75 + "request...\n");
76 + hotkey_wakeup_reason_notify_change();
77 + }
78 + return true;
81 +static bool hotkey_notify_usrevent(const u32 hkey,
82 + bool *send_acpi_ev,
83 + bool *ignore_acpi_ev)
85 + /* 0x5000-0x5FFF: human interface helpers */
86 + *send_acpi_ev = true;
87 + *ignore_acpi_ev = false;
89 + switch (hkey) {
90 + case 0x5010: /* Lenovo new BIOS: brightness changed */
91 + case 0x500b: /* X61t: tablet pen inserted into bay */
92 + case 0x500c: /* X61t: tablet pen removed from bay */
93 + return true;
95 + case 0x5009: /* X41t-X61t: swivel up (tablet mode) */
96 + case 0x500a: /* X41t-X61t: swivel down (normal mode) */
97 + tpacpi_input_send_tabletsw();
98 + hotkey_tablet_mode_notify_change();
99 + *send_acpi_ev = false;
100 + return true;
102 + case 0x5001:
103 + case 0x5002:
104 + /* LID switch events. Do not propagate */
105 + *ignore_acpi_ev = true;
106 + return true;
108 + default:
109 + return false;
113 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
115 u32 hkey;
116 - unsigned int scancode;
117 - int send_acpi_ev;
118 - int ignore_acpi_ev;
119 - int unk_ev;
120 + bool send_acpi_ev;
121 + bool ignore_acpi_ev;
122 + bool known_ev;
124 if (event != 0x80) {
125 printk(TPACPI_ERR
126 @@ -2601,105 +2688,62 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
127 return;
130 - send_acpi_ev = 1;
131 - ignore_acpi_ev = 0;
132 - unk_ev = 0;
133 + send_acpi_ev = true;
134 + ignore_acpi_ev = false;
136 switch (hkey >> 12) {
137 case 1:
138 /* 0x1000-0x1FFF: key presses */
139 - scancode = hkey & 0xfff;
140 - if (scancode > 0 && scancode < 0x21) {
141 - scancode--;
142 - if (!(hotkey_source_mask & (1 << scancode))) {
143 - tpacpi_input_send_key(scancode);
144 - send_acpi_ev = 0;
145 - } else {
146 - ignore_acpi_ev = 1;
148 - } else {
149 - unk_ev = 1;
151 + known_ev = hotkey_notify_hotkey(hkey, &send_acpi_ev,
152 + &ignore_acpi_ev);
153 break;
154 case 2:
155 - /* Wakeup reason */
156 - switch (hkey) {
157 - case 0x2304: /* suspend, undock */
158 - case 0x2404: /* hibernation, undock */
159 - hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK;
160 - ignore_acpi_ev = 1;
161 - break;
162 - case 0x2305: /* suspend, bay eject */
163 - case 0x2405: /* hibernation, bay eject */
164 - hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ;
165 - ignore_acpi_ev = 1;
166 - break;
167 - default:
168 - unk_ev = 1;
170 - if (hotkey_wakeup_reason != TP_ACPI_WAKEUP_NONE) {
171 - printk(TPACPI_INFO
172 - "woke up due to a hot-unplug "
173 - "request...\n");
174 - hotkey_wakeup_reason_notify_change();
176 + /* 0x2000-0x2FFF: Wakeup reason */
177 + known_ev = hotkey_notify_wakeup(hkey, &send_acpi_ev,
178 + &ignore_acpi_ev);
179 break;
180 case 3:
181 - /* bay-related wakeups */
182 + /* 0x3000-0x3FFF: bay-related wakeups */
183 if (hkey == 0x3003) {
184 hotkey_autosleep_ack = 1;
185 printk(TPACPI_INFO
186 "bay ejected\n");
187 hotkey_wakeup_hotunplug_complete_notify_change();
188 + known_ev = true;
189 } else {
190 - unk_ev = 1;
191 + known_ev = false;
193 break;
194 case 4:
195 - /* dock-related wakeups */
196 + /* 0x4000-0x4FFF: dock-related wakeups */
197 if (hkey == 0x4003) {
198 hotkey_autosleep_ack = 1;
199 printk(TPACPI_INFO
200 "undocked\n");
201 hotkey_wakeup_hotunplug_complete_notify_change();
202 + known_ev = true;
203 } else {
204 - unk_ev = 1;
205 + known_ev = false;
207 break;
208 case 5:
209 /* 0x5000-0x5FFF: human interface helpers */
210 - switch (hkey) {
211 - case 0x5010: /* Lenovo new BIOS: brightness changed */
212 - case 0x500b: /* X61t: tablet pen inserted into bay */
213 - case 0x500c: /* X61t: tablet pen removed from bay */
214 - break;
215 - case 0x5009: /* X41t-X61t: swivel up (tablet mode) */
216 - case 0x500a: /* X41t-X61t: swivel down (normal mode) */
217 - tpacpi_input_send_tabletsw();
218 - hotkey_tablet_mode_notify_change();
219 - send_acpi_ev = 0;
220 - break;
221 - case 0x5001:
222 - case 0x5002:
223 - /* LID switch events. Do not propagate */
224 - ignore_acpi_ev = 1;
225 - break;
226 - default:
227 - unk_ev = 1;
229 + known_ev = hotkey_notify_usrevent(hkey, &send_acpi_ev,
230 + &ignore_acpi_ev);
231 break;
232 case 7:
233 /* 0x7000-0x7FFF: misc */
234 if (tp_features.hotkey_wlsw && hkey == 0x7000) {
235 tpacpi_send_radiosw_update();
236 send_acpi_ev = 0;
237 + known_ev = true;
238 break;
240 /* fallthrough to default */
241 default:
242 - unk_ev = 1;
243 + known_ev = false;
245 - if (unk_ev) {
246 + if (!known_ev) {
247 printk(TPACPI_NOTICE
248 "unhandled HKEY event 0x%04x\n", hkey);
251 1.5.6.5