From 01e88f25985d8ea5866c9a73d56b3a9a9145066f Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 8 Jan 2008 13:02:41 -0200 Subject: ACPI: thinkpad-acpi: add CMOS NVRAM polling for hot keys (v9) Older ThinkPad models do not export some of the hot keys over the event-based ACPI hot key interface. For these models, one has to poll the CMOS NVRAM to check the key state at a rate faster than the expected rate at which the user might repeatedly press the same hot key. This patch implements this functionality for many of the hotkeys in a transparent way: hot keys will now Just Work, and the driver knows the best approach (events or NVRAM polling) to employ, based on the HKEY.MHKA ACPI method. Also, the driver can turn off the polling when there are no users for the hot keys that need such polling. The NVRAM-based hot keys of the A3x series that have never been implemented by later models are not supported, to avoid changes in the keymap of the input devices that could cause headaches in the future. There is a Kconfig option to avoid compiling the NVRAM polling code, as it is not very small, and unlikely to be useful on any ThinkPad newer than a T40, X31 or R52. This feature is based on a previous effort by Richard Hughes. Signed-off-by: Henrique de Moraes Holschuh Cc: Richard Hughes Signed-off-by: Len Brown --- Documentation/thinkpad-acpi.txt | 71 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 6 deletions(-) (limited to 'Documentation') diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt index 10c041ca13c..70d91a52e0f 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/thinkpad-acpi.txt @@ -215,6 +215,11 @@ The following commands can be written to the /proc/acpi/ibm/hotkey file: ... any other 8-hex-digit mask ... echo reset > /proc/acpi/ibm/hotkey -- restore the original mask +The procfs interface does not support NVRAM polling control. So as to +maintain maximum bug-to-bug compatibility, it does not report any masks, +nor does it allow one to manipulate the hot key mask when the firmware +does not support masks at all, even if NVRAM polling is in use. + sysfs notes: hotkey_bios_enabled: @@ -231,17 +236,26 @@ sysfs notes: to this value. hotkey_enable: - Enables/disables the hot keys feature, and reports - current status of the hot keys feature. + Enables/disables the hot keys feature in the ACPI + firmware, and reports current status of the hot keys + feature. Has no effect on the NVRAM hot key polling + functionality. 0: disables the hot keys feature / feature disabled 1: enables the hot keys feature / feature enabled hotkey_mask: - bit mask to enable driver-handling and ACPI event - generation for each hot key (see above). Returns the - current status of the hot keys mask, and allows one to - modify it. + bit mask to enable driver-handling (and depending on + the firmware, ACPI event generation) for each hot key + (see above). Returns the current status of the hot keys + mask, and allows one to modify it. + + Note: when NVRAM polling is active, the firmware mask + will be different from the value returned by + hotkey_mask. The driver will retain enabled bits for + hotkeys that are under NVRAM polling even if the + firmware refuses them, and will not set these bits on + the firmware hot key mask. hotkey_all_mask: bit mask that should enable event reporting for all @@ -257,6 +271,40 @@ sysfs notes: handled by the firmware anyway. Echo it to hotkey_mask above, to use. + hotkey_source_mask: + bit mask that selects which hot keys will the driver + poll the NVRAM for. This is auto-detected by the driver + based on the capabilities reported by the ACPI firmware, + but it can be overridden at runtime. + + Hot keys whose bits are set in both hotkey_source_mask + and also on hotkey_mask are polled for in NVRAM. Only a + few hot keys are available through CMOS NVRAM polling. + + Warning: when in NVRAM mode, the volume up/down/mute + keys are synthesized according to changes in the mixer, + so you have to use volume up or volume down to unmute, + as per the ThinkPad volume mixer user interface. When + in ACPI event mode, volume up/down/mute are reported as + separate events, but this behaviour may be corrected in + future releases of this driver, in which case the + ThinkPad volume mixer user interface semanthics will be + enforced. + + hotkey_poll_freq: + frequency in Hz for hot key polling. It must be between + 0 and 25 Hz. Polling is only carried out when strictly + needed. + + Setting hotkey_poll_freq to zero disables polling, and + will cause hot key presses that require NVRAM polling + to never be reported. + + Setting hotkey_poll_freq too low will cause repeated + pressings of the same hot key to be misreported as a + single key press, or to not even be detected at all. + The recommended polling frequency is 10Hz. + hotkey_radio_sw: if the ThinkPad has a hardware radio switch, this attribute will read 0 if the switch is in the "radios @@ -1263,3 +1311,14 @@ Sysfs interface changelog: and the hwmon class for libsensors4 (lm-sensors 3) compatibility. Moved all hwmon attributes to this new platform device. + +0x020100: Marker for thinkpad-acpi with hot key NVRAM polling + support. If you must, use it to know you should not + start an userspace NVRAM poller (allows to detect when + NVRAM is compiled out by the user because it is + unneeded/undesired in the first place). +0x020101: Marker for thinkpad-acpi with hot key NVRAM polling + and proper hotkey_mask semanthics (version 8 of the + NVRAM polling patch). Some development snapshots of + 0.18 had an earlier version that did strange things + to hotkey_mask. -- cgit v1.2.3 From 50efd8310f4f532231b15c6bcb9007c99ac05466 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 8 Jan 2008 13:02:42 -0200 Subject: ACPI: thinkpad-acpi: bump up version to 0.18 The NVRAM polling support for hot keys is reason enough to bump up the version string. Do it. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- Documentation/thinkpad-acpi.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Documentation') diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt index 70d91a52e0f..7c7bd4720cf 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/thinkpad-acpi.txt @@ -1,7 +1,7 @@ ThinkPad ACPI Extras Driver - Version 0.17 - October 04th, 2007 + Version 0.18 + October 08th, 2007 Borislav Deianov Henrique de Moraes Holschuh -- cgit v1.2.3 From 3b64b51d20d9b633bb2efe63af785a49f8092898 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 8 Jan 2008 13:02:51 -0200 Subject: ACPI: thinkpad-acpi: cleanup hotkey_notify and HKEY log messages Use a generic message on hotkey_notify to log unknown and unhandled events, and cleanup hotkey_notify a little. Also, document event 0x5010 (brightness changed notification) and do not log it as an unknown event (even if we do not use it for anything right now). Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- Documentation/thinkpad-acpi.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Documentation') diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt index 7c7bd4720cf..3fb864733ca 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/thinkpad-acpi.txt @@ -475,6 +475,10 @@ Non hot-key ACPI HKEY event map: The above events are not propagated by the driver, except for legacy compatibility purposes when hotkey_report_mode is set to 1. +0x5010 Brightness level changed (newer Lenovo BIOSes) + +The above events are propagated by the driver. + Compatibility notes: ibm-acpi and thinkpad-acpi 0.15 (mainline kernels before 2.6.23) never -- cgit v1.2.3 From a713b4d7bca51e56cdb5357507f46674111d032c Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 8 Jan 2008 13:02:52 -0200 Subject: ACPI: thinkpad-acpi: wakeup on hotunplug reporting Handle some HKEY events that the firmware uses to report the reason for a wake up, and to also notify that the system could go back to sleep (if it woke up just to eject something from the bay, or to undock). The driver will report the reason of the last wake up in the sysfs attribute "wakeup_reason": 0 for "none, unknown, or standard ACPI wake up event", 1 for "bay ejection request" and 2 for "undock request". The firmware will also report if the operation that triggered the wake up has been completed, by issuing an HKEY 0x3003 or 0x4003 event. If the operation fails, no event is sent. When such a hotunplug sucessfull notification is issued, the driver sets the attribute "wakeup_hotunplug_complete" to 1. While the firmware does tell us whether we are waking from a suspend or hibernation scenario, the Linux way of hibernating makes this information not reliable, and therefore it is not reported. The idea is that if any of these attributes are non-zero, userspace might want to do something at the end of the "wake up from sleep" procedures, such as offering to send the machine back into sleep as soon as it is safe to do so. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- Documentation/thinkpad-acpi.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Documentation') diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt index 3fb864733ca..9d08e472ef7 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/thinkpad-acpi.txt @@ -325,6 +325,21 @@ sysfs notes: May return -EPERM (write access locked out by module parameter) or -EACCES (read-only). + wakeup_reason: + Set to 1 if the system is waking up because the user + requested a bay ejection. Set to 2 if the system is + waking up because the user requested the system to + undock. Set to zero for normal wake-ups or wake-ups + due to unknown reasons. + + wakeup_hotunplug_complete: + Set to 1 if the system was waken up because of an + undock or bay ejection request, and that request + was sucessfully completed. At this point, it might + be useful to send the system back to sleep, at the + user's choice. Refer to HKEY events 0x4003 and + 0x3003, below. + input layer notes: A Hot key is mapped to a single input layer EV_KEY event, possibly @@ -475,6 +490,15 @@ Non hot-key ACPI HKEY event map: The above events are not propagated by the driver, except for legacy compatibility purposes when hotkey_report_mode is set to 1. +0x2304 System is waking up from suspend to undock +0x2305 System is waking up from suspend to eject bay +0x2404 System is waking up from hibernation to undock +0x2405 System is waking up from hibernation to eject bay + +The above events are never propagated by the driver. + +0x3003 Bay ejection (see 0x2x05) complete, can sleep again +0x4003 Undocked (see 0x2x04), can sleep again 0x5010 Brightness level changed (newer Lenovo BIOSes) The above events are propagated by the driver. -- cgit v1.2.3 From d1edb2b5f1d016d679600cccf2716e0134fff917 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 8 Jan 2008 13:02:53 -0200 Subject: ACPI: thinkpad-acpi: add X61t HKEY events Tomas Carnecky reports that events 0x5009 and 0x500a are swivel events, and that 0x500b/0x500c are tablet pen storage bay events. Document these events, and avoid nasty messages when they happen. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- Documentation/thinkpad-acpi.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Documentation') diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt index 9d08e472ef7..e1c4550dac9 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/thinkpad-acpi.txt @@ -499,6 +499,10 @@ The above events are never propagated by the driver. 0x3003 Bay ejection (see 0x2x05) complete, can sleep again 0x4003 Undocked (see 0x2x04), can sleep again +0x5009 Tablet swivel: switched to tablet mode +0x500A Tablet swivel: switched to normal mode +0x500B Tablet pen insterted into its storage bay +0x500C Tablet pen removed from its storage bay 0x5010 Brightness level changed (newer Lenovo BIOSes) The above events are propagated by the driver. -- cgit v1.2.3 From 50ebec09f1a79df27afeceb14a3059944f327e1d Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 8 Jan 2008 13:02:55 -0200 Subject: ACPI: thinkpad-acpi: add poll() support to some sysfs attributes Implement poll()/select() support through sysfs_notify() for some key attributes which userspace might want to poll() or select() on. In order to let userspace know poll()/select() support is available for an attribute, the thinkpad-acpi sysfs interface version is also bumped up. Further changes that add poll()/select() capabilities to any pre-existing attributes will also increment the sysfs interface version. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- Documentation/thinkpad-acpi.txt | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Documentation') diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt index e1c4550dac9..9bbd0f54143 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/thinkpad-acpi.txt @@ -311,6 +311,8 @@ sysfs notes: disabled" postition, and 1 if the switch is in the "radios enabled" position. + This attribute has poll()/select() support. + hotkey_report_mode: Returns the state of the procfs ACPI event report mode filter for hot keys. If it is set to 1 (the default), @@ -332,6 +334,8 @@ sysfs notes: undock. Set to zero for normal wake-ups or wake-ups due to unknown reasons. + This attribute has poll()/select() support. + wakeup_hotunplug_complete: Set to 1 if the system was waken up because of an undock or bay ejection request, and that request @@ -340,6 +344,8 @@ sysfs notes: user's choice. Refer to HKEY events 0x4003 and 0x3003, below. + This attribute has poll()/select() support. + input layer notes: A Hot key is mapped to a single input layer EV_KEY event, possibly @@ -1354,3 +1360,6 @@ Sysfs interface changelog: NVRAM polling patch). Some development snapshots of 0.18 had an earlier version that did strange things to hotkey_mask. + +0x020200: Add poll()/select() support to the following attributes: + hotkey_radio_sw, wakeup_hotunplug_complete, wakeup_reason -- cgit v1.2.3 From 1cee5cce9776d88778b6c00e3f72fffbcbec40d4 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 8 Jan 2008 13:02:57 -0200 Subject: ACPI: thinkpad-acpi: bump up version to 0.19 The major code reorganization and cleanups, and new HKEY events, plus poll()/select() support are good reasons to checkpoint a new version... Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- Documentation/thinkpad-acpi.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Documentation') diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt index 9bbd0f54143..6c2477754a2 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/thinkpad-acpi.txt @@ -1,7 +1,7 @@ ThinkPad ACPI Extras Driver - Version 0.18 - October 08th, 2007 + Version 0.19 + January 06th, 2008 Borislav Deianov Henrique de Moraes Holschuh -- cgit v1.2.3