From 9ab18c16acf9f46f078a3544b7d2df107898f02a Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Fri, 13 May 2011 09:22:14 -0300 Subject: [PATCH] thinkpad-acpi: add internal hotkey event API Add an internal API to the driver, to allow subdrivers to request and receive HKEY 0x1000 events. This API will be used by the backlight (brightness up/down) and upcoming ALSA mixer (volume up/down/mute) subdrivers. Signed-off-by: Henrique de Moraes Holschuh --- drivers/platform/x86/thinkpad_acpi.c | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index e717127dbac..ee8d0506572 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -1750,6 +1750,9 @@ static u16 *hotkey_keycode_map; static struct attribute_set *hotkey_dev_attributes; +static void tpacpi_driver_event(const unsigned int hkey_event); +static void hotkey_driver_event(const unsigned int scancode); + /* HKEY.MHKG() return bits */ #define TP_HOTKEY_TABLET_MASK (1 << 3) @@ -1898,6 +1901,35 @@ static int hotkey_user_mask_set(const u32 mask) return rc; } +/* + * Sets the driver hotkey mask. + * + * Can be called even if the hotkey subdriver is inactive + */ +static int tpacpi_hotkey_driver_mask_set(const u32 mask) +{ + int rc; + + /* Do the right thing if hotkey_init has not been called yet */ + if (!tp_features.hotkey) { + hotkey_driver_mask = mask; + return 0; + } + + mutex_lock(&hotkey_mutex); + + HOTKEY_CONFIG_CRITICAL_START + hotkey_driver_mask = mask; + hotkey_source_mask |= (mask & ~hotkey_all_mask); + HOTKEY_CONFIG_CRITICAL_END + + rc = hotkey_mask_set((hotkey_acpi_mask | hotkey_driver_mask) & + ~hotkey_source_mask); + mutex_unlock(&hotkey_mutex); + + return rc; +} + static int hotkey_status_get(int *status) { if (!acpi_evalf(hkey_handle, status, "DHKC", "d")) @@ -1957,6 +1989,7 @@ static void tpacpi_input_send_key(const unsigned int scancode) /* Do NOT call without validating scancode first */ static void tpacpi_input_send_key_masked(const unsigned int scancode) { + hotkey_driver_event(scancode); if (hotkey_user_mask & (1 << scancode)) tpacpi_input_send_key(scancode); } @@ -7587,6 +7620,21 @@ static struct ibm_struct fan_driver_data = { **************************************************************************** ****************************************************************************/ +/* + * HKEY event callout for other subdrivers go here + * (yes, it is ugly, but it is quick, safe, and gets the job done + */ +static void tpacpi_driver_event(const unsigned int hkey_event) +{ +} + + + +static void hotkey_driver_event(const unsigned int scancode) +{ + tpacpi_driver_event(0x1001 + scancode); +} + /* sysfs name ---------------------------------------------------------- */ static ssize_t thinkpad_acpi_pdev_name_show(struct device *dev, struct device_attribute *attr, -- 2.11.4.GIT