aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-07-18 22:45:36 -0400
committerLen Brown <len.brown@intel.com>2007-07-21 23:45:56 -0400
commit1a343760b516ca5466d201bec32b1794858b18a5 (patch)
treea3ba178b79e5f17365fac6bbd9aa475e42e102b0
parent6a38abbf2b68e37493f2d5e8702b895a6c23ba0f (diff)
ACPI: thinkpad-acpi: make the input event mode the default
Make the input layer the default way to deal with thinkpad-acpi hot keys, but add a kernel config option to retain the old way of doing things. This means we map a lot more keys to useful stuff by default, and also that we enable hot key handling by default on driver load (like Windows does). The documentation for proper use of this resource is also updated. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Cc: Richard Hughes <hughsient@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--Documentation/thinkpad-acpi.txt89
-rw-r--r--drivers/misc/Kconfig13
-rw-r--r--drivers/misc/thinkpad_acpi.c19
3 files changed, 70 insertions, 51 deletions
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index 91d08921a4ca..5b59cf50b2e9 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -155,52 +155,47 @@ Hot keys
155procfs: /proc/acpi/ibm/hotkey 155procfs: /proc/acpi/ibm/hotkey
156sysfs device attribute: hotkey_* 156sysfs device attribute: hotkey_*
157 157
158Without this driver, only the Fn-F4 key (sleep button) generates an 158In a ThinkPad, the ACPI HKEY handler is responsible for comunicating
159ACPI event. With the driver loaded, the hotkey feature enabled and the 159some important events and also keyboard hot key presses to the operating
160mask set (see below), the various hot keys generate ACPI events in the 160system. Enabling the hotkey functionality of thinkpad-acpi signals the
161firmware that such a driver is present, and modifies how the ThinkPad
162firmware will behave in many situations.
163
164When the hotkey feature is enabled and the hot key mask is set (see
165below), the various hot keys either generate ACPI events in the
161following format: 166following format:
162 167
163 ibm/hotkey HKEY 00000080 0000xxxx 168 ibm/hotkey HKEY 00000080 0000xxxx
164 169
165The last four digits vary depending on the key combination pressed. 170or events over the input layer. The input layer support accepts the
166All labeled Fn-Fx key combinations generate distinct events. In 171standard IOCTLs to remap the keycodes assigned to each hotkey.
167addition, the lid microswitch and some docking station buttons may
168also generate such events.
169
170Hot keys also generate regular keyboard key press/release events through
171the input layer in addition to the ibm/hotkey ACPI events. The input
172layer support accepts the standard IOCTLs to remap the keycodes assigned
173to each hotkey.
174 172
175When the input device is open, the driver will suppress any ACPI hot key 173When the input device is open, the driver will suppress any ACPI hot key
176events that get translated into a meaningful input layer event, in order 174events that get translated into a meaningful input layer event, in order
177to avoid sending duplicate events to userspace. Hot keys that are 175to avoid sending duplicate events to userspace. Hot keys that are
178mapped to KEY_RESERVED are not translated, and will always generate only 176mapped to KEY_RESERVED in the keymap are not translated, and will always
179ACPI hot key event, and no input layer events. 177generate an ACPI ibm/hotkey HKEY event, and no input layer events.
180 178
181The bit mask allows some control over which hot keys generate ACPI 179The hot key bit mask allows some control over which hot keys generate
182events. Not all bits in the mask can be modified. Not all bits that can 180events. If a key is "masked" (bit set to 0 in the mask), the firmware
183be modified do anything. Not all hot keys can be individually controlled 181will handle it. If it is "unmasked", it signals the firmware that
184by the mask. Some models do not support the mask at all. On those 182thinkpad-acpi would prefer to handle it, if the firmware would be so
185models, hot keys cannot be controlled individually. 183kind to allow it (and it often doesn't!).
186 184
187Note that enabling ACPI events for some keys prevents their default 185Not all bits in the mask can be modified. Not all bits that can be
188behavior. For example, if events for Fn-F5 are enabled, that key will no 186modified do anything. Not all hot keys can be individually controlled
189longer enable/disable Bluetooth by itself. This can still be done from 187by the mask. Some models do not support the mask at all, and in those
190an acpid handler for the ibm/hotkey event. 188models, hot keys cannot be controlled individually. The behaviour of
191 189the mask is, therefore, higly dependent on the ThinkPad model.
192On some models, even enabling/disabling the entire hot key feature may 190
193change the way some keys behave (e.g. in a T43, Fn+F4 will generate an 191Note that unmasking some keys prevents their default behavior. For
194button/sleep ACPI event if hot keys are disabled, and it will ignore its 192example, if Fn+F5 is unmasked, that key will no longer enable/disable
195mask when hot keys are enabled, so the key always does something. On a 193Bluetooth by itself.
196X40, Fn+F4 respects its mask status, but generates the button/sleep ACPI 194
197event if masked off). 195Note also that not all Fn key combinations are supported through ACPI.
198 196For example, on the X40, the brightness, volume and "Access IBM" buttons
199Note also that not all Fn key combinations are supported through 197do not generate ACPI events even with this driver. They *can* be used
200ACPI. For example, on the X40, the brightness, volume and "Access IBM" 198through the "ThinkPad Buttons" utility, see http://www.nongnu.org/tpb/
201buttons do not generate ACPI events even with this driver. They *can*
202be used through the "ThinkPad Buttons" utility, see
203http://www.nongnu.org/tpb/
204 199
205procfs notes: 200procfs notes:
206 201
@@ -221,7 +216,7 @@ sysfs notes:
221 key feature status will be restored to this value. 216 key feature status will be restored to this value.
222 217
223 0: hot keys were disabled 218 0: hot keys were disabled
224 1: hot keys were enabled 219 1: hot keys were enabled (unusual)
225 220
226 hotkey_bios_mask: 221 hotkey_bios_mask:
227 Returns the hot keys mask when thinkpad-acpi was loaded. 222 Returns the hot keys mask when thinkpad-acpi was loaded.
@@ -236,9 +231,10 @@ sysfs notes:
236 1: enables the hot keys feature / feature enabled 231 1: enables the hot keys feature / feature enabled
237 232
238 hotkey_mask: 233 hotkey_mask:
239 bit mask to enable ACPI event generation for each hot 234 bit mask to enable driver-handling and ACPI event
240 key (see above). Returns the current status of the hot 235 generation for each hot key (see above). Returns the
241 keys mask, and allows one to modify it. 236 current status of the hot keys mask, and allows one to
237 modify it.
242 238
243 hotkey_all_mask: 239 hotkey_all_mask:
244 bit mask that should enable event reporting for all 240 bit mask that should enable event reporting for all
@@ -250,8 +246,9 @@ sysfs notes:
250 246
251 hotkey_recommended_mask: 247 hotkey_recommended_mask:
252 bit mask that should enable event reporting for all 248 bit mask that should enable event reporting for all
253 supported hot keys, except those which are handled by 249 supported hot keys, except those which are always
254 the firmware. Echo it to hotkey_mask above, to use. 250 handled by the firmware anyway. Echo it to
251 hotkey_mask above, to use.
255 252
256 hotkey_radio_sw: 253 hotkey_radio_sw:
257 if the ThinkPad has a hardware radio switch, this 254 if the ThinkPad has a hardware radio switch, this
@@ -390,10 +387,6 @@ ACPI hotkey event.
390If a key is mapped to anything else, it will only generate legacy 387If a key is mapped to anything else, it will only generate legacy
391thinkpad-acpi ACPI hotkey events if nobody has opened the input device. 388thinkpad-acpi ACPI hotkey events if nobody has opened the input device.
392 389
393For userspace backwards-compatibility purposes, the keycode map is
394initially filled with KEY_RESERVED and KEY_UNKNOWN mappings for scan codes
3950x00 to 0x10 (and maybe others).
396
397Non hot-key ACPI HKEY event map: 390Non hot-key ACPI HKEY event map:
3980x5001 Lid closed 3910x5001 Lid closed
3990x5002 Lid opened 3920x5002 Lid opened
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 1d516f24ba53..5197f9b9b65d 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -196,4 +196,17 @@ config THINKPAD_ACPI_BAY
196 196
197 If you are not sure, say Y here. 197 If you are not sure, say Y here.
198 198
199config THINKPAD_ACPI_INPUT_ENABLED
200 bool "Enable input layer support by default"
201 depends on THINKPAD_ACPI
202 default y
203 ---help---
204 Enables hot key handling over the input layer by default. If unset,
205 the driver does not enable any hot key handling by default, and also
206 starts up with a mostly empty keymap.
207
208 If you are not sure, say Y here. Say N to retain the deprecated
209 behavior of ibm-acpi, and thinkpad-acpi for kernels up to 2.6.21.
210
211
199endif # MISC_DEVICES 212endif # MISC_DEVICES
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 5c1bea1a6c37..c86b228375cc 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -734,9 +734,9 @@ static u32 hotkey_reserved_mask;
734 734
735static u16 hotkey_keycode_map[] = { 735static u16 hotkey_keycode_map[] = {
736 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */ 736 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */
737 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, 737 KEY_FN_F1, KEY_FN_F2, KEY_FN_F3, KEY_SLEEP,
738 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, 738 KEY_FN_F5, KEY_FN_F6, KEY_FN_F7, KEY_FN_F8,
739 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, 739 KEY_FN_F9, KEY_FN_F10, KEY_FN_F11, KEY_SUSPEND,
740 /* Scan codes 0x0C to 0x0F: Other ACPI HKEY hot keys */ 740 /* Scan codes 0x0C to 0x0F: Other ACPI HKEY hot keys */
741 KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ 741 KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */
742 KEY_UNKNOWN, /* 0x0D: FN+INSERT */ 742 KEY_UNKNOWN, /* 0x0D: FN+INSERT */
@@ -977,6 +977,11 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
977 if (res) 977 if (res)
978 return res; 978 return res;
979 979
980#ifndef CONFIG_THINKPAD_ACPI_INPUT_ENABLED
981 for (i = 0; i < 12; i++)
982 hotkey_keycode_map[i] = KEY_UNKNOWN;
983#endif /* ! CONFIG_THINKPAD_ACPI_INPUT_ENABLED */
984
980 set_bit(EV_KEY, tpacpi_inputdev->evbit); 985 set_bit(EV_KEY, tpacpi_inputdev->evbit);
981 set_bit(EV_MSC, tpacpi_inputdev->evbit); 986 set_bit(EV_MSC, tpacpi_inputdev->evbit);
982 set_bit(MSC_SCAN, tpacpi_inputdev->mscbit); 987 set_bit(MSC_SCAN, tpacpi_inputdev->mscbit);
@@ -993,6 +998,14 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
993 } 998 }
994 } 999 }
995 1000
1001#ifdef CONFIG_THINKPAD_ACPI_INPUT_ENABLED
1002 dbg_printk(TPACPI_DBG_INIT,
1003 "enabling hot key handling\n");
1004 res = hotkey_set(1, (hotkey_all_mask & ~hotkey_reserved_mask)
1005 | hotkey_orig_mask);
1006 if (res)
1007 return res;
1008#endif /* CONFIG_THINKPAD_ACPI_INPUT_ENABLED */
996 } 1009 }
997 1010
998 return (tp_features.hotkey)? 0 : 1; 1011 return (tp_features.hotkey)? 0 : 1;