diff options
| -rw-r--r-- | Documentation/thinkpad-acpi.txt | 89 | ||||
| -rw-r--r-- | drivers/misc/Kconfig | 13 | ||||
| -rw-r--r-- | drivers/misc/thinkpad_acpi.c | 19 |
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 | |||
| 155 | procfs: /proc/acpi/ibm/hotkey | 155 | procfs: /proc/acpi/ibm/hotkey |
| 156 | sysfs device attribute: hotkey_* | 156 | sysfs device attribute: hotkey_* |
| 157 | 157 | ||
| 158 | Without this driver, only the Fn-F4 key (sleep button) generates an | 158 | In a ThinkPad, the ACPI HKEY handler is responsible for comunicating |
| 159 | ACPI event. With the driver loaded, the hotkey feature enabled and the | 159 | some important events and also keyboard hot key presses to the operating |
| 160 | mask set (see below), the various hot keys generate ACPI events in the | 160 | system. Enabling the hotkey functionality of thinkpad-acpi signals the |
| 161 | firmware that such a driver is present, and modifies how the ThinkPad | ||
| 162 | firmware will behave in many situations. | ||
| 163 | |||
| 164 | When the hotkey feature is enabled and the hot key mask is set (see | ||
| 165 | below), the various hot keys either generate ACPI events in the | ||
| 161 | following format: | 166 | following format: |
| 162 | 167 | ||
| 163 | ibm/hotkey HKEY 00000080 0000xxxx | 168 | ibm/hotkey HKEY 00000080 0000xxxx |
| 164 | 169 | ||
| 165 | The last four digits vary depending on the key combination pressed. | 170 | or events over the input layer. The input layer support accepts the |
| 166 | All labeled Fn-Fx key combinations generate distinct events. In | 171 | standard IOCTLs to remap the keycodes assigned to each hotkey. |
| 167 | addition, the lid microswitch and some docking station buttons may | ||
| 168 | also generate such events. | ||
| 169 | |||
| 170 | Hot keys also generate regular keyboard key press/release events through | ||
| 171 | the input layer in addition to the ibm/hotkey ACPI events. The input | ||
| 172 | layer support accepts the standard IOCTLs to remap the keycodes assigned | ||
| 173 | to each hotkey. | ||
| 174 | 172 | ||
| 175 | When the input device is open, the driver will suppress any ACPI hot key | 173 | When the input device is open, the driver will suppress any ACPI hot key |
| 176 | events that get translated into a meaningful input layer event, in order | 174 | events that get translated into a meaningful input layer event, in order |
| 177 | to avoid sending duplicate events to userspace. Hot keys that are | 175 | to avoid sending duplicate events to userspace. Hot keys that are |
| 178 | mapped to KEY_RESERVED are not translated, and will always generate only | 176 | mapped to KEY_RESERVED in the keymap are not translated, and will always |
| 179 | ACPI hot key event, and no input layer events. | 177 | generate an ACPI ibm/hotkey HKEY event, and no input layer events. |
| 180 | 178 | ||
| 181 | The bit mask allows some control over which hot keys generate ACPI | 179 | The hot key bit mask allows some control over which hot keys generate |
| 182 | events. Not all bits in the mask can be modified. Not all bits that can | 180 | events. If a key is "masked" (bit set to 0 in the mask), the firmware |
| 183 | be modified do anything. Not all hot keys can be individually controlled | 181 | will handle it. If it is "unmasked", it signals the firmware that |
| 184 | by the mask. Some models do not support the mask at all. On those | 182 | thinkpad-acpi would prefer to handle it, if the firmware would be so |
| 185 | models, hot keys cannot be controlled individually. | 183 | kind to allow it (and it often doesn't!). |
| 186 | 184 | ||
| 187 | Note that enabling ACPI events for some keys prevents their default | 185 | Not all bits in the mask can be modified. Not all bits that can be |
| 188 | behavior. For example, if events for Fn-F5 are enabled, that key will no | 186 | modified do anything. Not all hot keys can be individually controlled |
| 189 | longer enable/disable Bluetooth by itself. This can still be done from | 187 | by the mask. Some models do not support the mask at all, and in those |
| 190 | an acpid handler for the ibm/hotkey event. | 188 | models, hot keys cannot be controlled individually. The behaviour of |
| 191 | 189 | the mask is, therefore, higly dependent on the ThinkPad model. | |
| 192 | On some models, even enabling/disabling the entire hot key feature may | 190 | |
| 193 | change the way some keys behave (e.g. in a T43, Fn+F4 will generate an | 191 | Note that unmasking some keys prevents their default behavior. For |
| 194 | button/sleep ACPI event if hot keys are disabled, and it will ignore its | 192 | example, if Fn+F5 is unmasked, that key will no longer enable/disable |
| 195 | mask when hot keys are enabled, so the key always does something. On a | 193 | Bluetooth by itself. |
| 196 | X40, Fn+F4 respects its mask status, but generates the button/sleep ACPI | 194 | |
| 197 | event if masked off). | 195 | Note also that not all Fn key combinations are supported through ACPI. |
| 198 | 196 | For example, on the X40, the brightness, volume and "Access IBM" buttons | |
| 199 | Note also that not all Fn key combinations are supported through | 197 | do not generate ACPI events even with this driver. They *can* be used |
| 200 | ACPI. For example, on the X40, the brightness, volume and "Access IBM" | 198 | through the "ThinkPad Buttons" utility, see http://www.nongnu.org/tpb/ |
| 201 | buttons do not generate ACPI events even with this driver. They *can* | ||
| 202 | be used through the "ThinkPad Buttons" utility, see | ||
| 203 | http://www.nongnu.org/tpb/ | ||
| 204 | 199 | ||
| 205 | procfs notes: | 200 | procfs 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. | |||
| 390 | If a key is mapped to anything else, it will only generate legacy | 387 | If a key is mapped to anything else, it will only generate legacy |
| 391 | thinkpad-acpi ACPI hotkey events if nobody has opened the input device. | 388 | thinkpad-acpi ACPI hotkey events if nobody has opened the input device. |
| 392 | 389 | ||
| 393 | For userspace backwards-compatibility purposes, the keycode map is | ||
| 394 | initially filled with KEY_RESERVED and KEY_UNKNOWN mappings for scan codes | ||
| 395 | 0x00 to 0x10 (and maybe others). | ||
| 396 | |||
| 397 | Non hot-key ACPI HKEY event map: | 390 | Non hot-key ACPI HKEY event map: |
| 398 | 0x5001 Lid closed | 391 | 0x5001 Lid closed |
| 399 | 0x5002 Lid opened | 392 | 0x5002 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 | ||
| 199 | config 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 | |||
| 199 | endif # MISC_DEVICES | 212 | endif # 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 | ||
| 735 | static u16 hotkey_keycode_map[] = { | 735 | static 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; |
