aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/thinkpad_acpi.h
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2008-01-08 10:02:41 -0500
committerLen Brown <len.brown@intel.com>2008-02-01 22:26:06 -0500
commit01e88f25985d8ea5866c9a73d56b3a9a9145066f (patch)
treedb5869b85a28a0bf86e8427f54d4b2cd0a597126 /drivers/misc/thinkpad_acpi.h
parentb7c8c200bfbf523ea0a72fd8a5e39089c74da371 (diff)
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 <hmh@hmh.eng.br> Cc: Richard Hughes <hughsient@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/misc/thinkpad_acpi.h')
-rw-r--r--drivers/misc/thinkpad_acpi.h60
1 files changed, 56 insertions, 4 deletions
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 3b0313443138..582184dc4543 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -31,6 +31,9 @@
31#include <linux/string.h> 31#include <linux/string.h>
32#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/kthread.h>
35#include <linux/freezer.h>
36#include <linux/delay.h>
34 37
35#include <linux/nvram.h> 38#include <linux/nvram.h>
36#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
@@ -82,10 +85,31 @@
82#define TP_CMOS_BRIGHTNESS_UP 4 85#define TP_CMOS_BRIGHTNESS_UP 4
83#define TP_CMOS_BRIGHTNESS_DOWN 5 86#define TP_CMOS_BRIGHTNESS_DOWN 5
84 87
85/* ThinkPad CMOS NVRAM constants */ 88/* NVRAM Addresses */
86#define TP_NVRAM_ADDR_BRIGHTNESS 0x5e 89enum tp_nvram_addr {
87#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x0f 90 TP_NVRAM_ADDR_HK2 = 0x57,
88#define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0 91 TP_NVRAM_ADDR_THINKLIGHT = 0x58,
92 TP_NVRAM_ADDR_VIDEO = 0x59,
93 TP_NVRAM_ADDR_BRIGHTNESS = 0x5e,
94 TP_NVRAM_ADDR_MIXER = 0x60,
95};
96
97/* NVRAM bit masks */
98enum {
99 TP_NVRAM_MASK_HKT_THINKPAD = 0x08,
100 TP_NVRAM_MASK_HKT_ZOOM = 0x20,
101 TP_NVRAM_MASK_HKT_DISPLAY = 0x40,
102 TP_NVRAM_MASK_HKT_HIBERNATE = 0x80,
103 TP_NVRAM_MASK_THINKLIGHT = 0x10,
104 TP_NVRAM_MASK_HKT_DISPEXPND = 0x30,
105 TP_NVRAM_MASK_HKT_BRIGHTNESS = 0x20,
106 TP_NVRAM_MASK_LEVEL_BRIGHTNESS = 0x0f,
107 TP_NVRAM_POS_LEVEL_BRIGHTNESS = 0,
108 TP_NVRAM_MASK_MUTE = 0x40,
109 TP_NVRAM_MASK_HKT_VOLUME = 0x80,
110 TP_NVRAM_MASK_LEVEL_VOLUME = 0x0f,
111 TP_NVRAM_POS_LEVEL_VOLUME = 0,
112};
89 113
90#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") 114#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")
91#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled") 115#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -255,6 +279,7 @@ static struct {
255 u32 sensors_pdrv_registered:1; 279 u32 sensors_pdrv_registered:1;
256 u32 sensors_pdrv_attrs_registered:1; 280 u32 sensors_pdrv_attrs_registered:1;
257 u32 sensors_pdev_attrs_registered:1; 281 u32 sensors_pdev_attrs_registered:1;
282 u32 hotkey_poll_active:1;
258} tp_features; 283} tp_features;
259 284
260struct thinkpad_id_data { 285struct thinkpad_id_data {
@@ -454,6 +479,33 @@ static int fan_write_cmd_watchdog(const char *cmd, int *rc);
454 * Hotkey subdriver 479 * Hotkey subdriver
455 */ 480 */
456 481
482enum { /* hot key scan codes (derived from ACPI DSDT) */
483 TP_ACPI_HOTKEYSCAN_FNF1 = 0,
484 TP_ACPI_HOTKEYSCAN_FNF2,
485 TP_ACPI_HOTKEYSCAN_FNF3,
486 TP_ACPI_HOTKEYSCAN_FNF4,
487 TP_ACPI_HOTKEYSCAN_FNF5,
488 TP_ACPI_HOTKEYSCAN_FNF6,
489 TP_ACPI_HOTKEYSCAN_FNF7,
490 TP_ACPI_HOTKEYSCAN_FNF8,
491 TP_ACPI_HOTKEYSCAN_FNF9,
492 TP_ACPI_HOTKEYSCAN_FNF10,
493 TP_ACPI_HOTKEYSCAN_FNF11,
494 TP_ACPI_HOTKEYSCAN_FNF12,
495 TP_ACPI_HOTKEYSCAN_FNBACKSPACE,
496 TP_ACPI_HOTKEYSCAN_FNINSERT,
497 TP_ACPI_HOTKEYSCAN_FNDELETE,
498 TP_ACPI_HOTKEYSCAN_FNHOME,
499 TP_ACPI_HOTKEYSCAN_FNEND,
500 TP_ACPI_HOTKEYSCAN_FNPAGEUP,
501 TP_ACPI_HOTKEYSCAN_FNPAGEDOWN,
502 TP_ACPI_HOTKEYSCAN_FNSPACE,
503 TP_ACPI_HOTKEYSCAN_VOLUMEUP,
504 TP_ACPI_HOTKEYSCAN_VOLUMEDOWN,
505 TP_ACPI_HOTKEYSCAN_MUTE,
506 TP_ACPI_HOTKEYSCAN_THINKPAD,
507};
508
457static int hotkey_orig_status; 509static int hotkey_orig_status;
458static u32 hotkey_orig_mask; 510static u32 hotkey_orig_mask;
459 511