diff mbox

Add support for Acer Predator macro keys

Message ID 1457244539-23763-1-git-send-email-bero@lindev.ch (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Bernhard Rosenkränzer March 6, 2016, 6:08 a.m. UTC
This patch adds support for the macro keys found on
Acer Predator laptops.

Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
---
 drivers/platform/x86/acer-wmi.c | 44 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

joeyli March 7, 2016, 5:03 a.m. UTC | #1
On Sun, Mar 06, 2016 at 07:08:59AM +0100, Bernhard Rosenkränzer wrote:
> This patch adds support for the macro keys found on
> Acer Predator laptops.
> 
> Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>

Acked-by: Lee, Chun-Yi <jlee@suse.com>


Thanks a lot!

Joey Lee

> ---
>  drivers/platform/x86/acer-wmi.c | 44 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index 1062fa4..e2d333c 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> @@ -7,6 +7,9 @@
>   *    Copyright (C) 2005-2007	E.M. Smith
>   *    Copyright (C) 2007-2008	Carlos Corbacho <cathectic@gmail.com>
>   *
> + *  Added support for Acer Predator hotkeys:
> + *    Copyright (C) 2016	Bernhard Rosenkraenzer <bero@lindev.ch>
> + *
>   *  This program is free software; you can redistribute it and/or modify
>   *  it under the terms of the GNU General Public License as published by
>   *  the Free Software Foundation; either version 2 of the License, or
> @@ -94,6 +97,7 @@ MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
>  enum acer_wmi_event_ids {
>  	WMID_HOTKEY_EVENT = 0x1,
>  	WMID_ACCEL_EVENT = 0x5,
> +	WMID_MACROKEY_EVENT = 0x7,
>  };
>  
>  static const struct key_entry acer_wmi_keymap[] __initconst = {
> @@ -128,6 +132,26 @@ static const struct key_entry acer_wmi_keymap[] __initconst = {
>  	{KE_KEY, KEY_TOUCHPAD_OFF, {KEY_TOUCHPAD_OFF} },
>  	{KE_IGNORE, 0x83, {KEY_TOUCHPAD_TOGGLE} },
>  	{KE_KEY, 0x85, {KEY_TOUCHPAD_TOGGLE} },
> +	/* Acer Predator macro keys:
> +	 * 0xdaXY:
> +	 *   da   - magic value (preDAtor)
> +	 *     X  - macro key selector state (0: red, 1: blue, 2: green)
> +	 *      Y - key pressed (0: 1, 1: 2, ...) */
> +	{KE_KEY, 0xda00, {KEY_PROG1} },
> +	{KE_KEY, 0xda01, {KEY_PROG2} },
> +	{KE_KEY, 0xda02, {KEY_PROG3} },
> +	{KE_KEY, 0xda03, {KEY_PROG4} },
> +	{KE_KEY, 0xda04, {KEY_F13} },
> +	{KE_KEY, 0xda10, {KEY_F14} },
> +	{KE_KEY, 0xda11, {KEY_F15} },
> +	{KE_KEY, 0xda12, {KEY_F16} },
> +	{KE_KEY, 0xda13, {KEY_F17} },
> +	{KE_KEY, 0xda14, {KEY_F18} },
> +	{KE_KEY, 0xda20, {KEY_F19} },
> +	{KE_KEY, 0xda21, {KEY_F20} },
> +	{KE_KEY, 0xda22, {KEY_F21} },
> +	{KE_KEY, 0xda23, {KEY_F22} },
> +	{KE_KEY, 0xda24, {KEY_F23} },
>  	{KE_END, 0}
>  };
>  
> @@ -232,6 +256,7 @@ static bool ec_raw_mode;
>  static bool has_type_aa;
>  static u16 commun_func_bitmap;
>  static u8 commun_fn_key_number;
> +static u8 macro_key_state = 0;
>  
>  module_param(mailled, int, 0444);
>  module_param(brightness, int, 0444);
> @@ -1731,6 +1756,25 @@ static void acer_wmi_notify(u32 value, void *context)
>  	case WMID_ACCEL_EVENT:
>  		acer_gsensor_event();
>  		break;
> +	case WMID_MACROKEY_EVENT:
> +		switch(return_value.key_num) {
> +		case 1:
> +			if(return_value.device_state >= 1 && return_value.device_state <= 3)
> +				macro_key_state = return_value.device_state - 1;
> +			else
> +				pr_warn("acer_wmi: macro key state set to %d (only values 1 to 3 are known)", return_value.device_state);
> +			break;
> +		case 2:
> +			if(return_value.device_state >= 1 && return_value.device_state <= 5)
> +				sparse_keymap_report_event(acer_wmi_input_dev, 0xda00 + (macro_key_state<<4) + return_value.device_state-1, 1, true);
> +			else
> +				pr_warn("acer_wmi: macro key %d pressed (only 1 to 5 are known)", return_value.device_state);
> +			break;
> +		default:
> +			pr_warn("Unknown macro key event: %d %d %d", return_value.key_num, return_value.device_state, return_value.reserved);
> +			break;
> +		}
> +		break;
>  	default:
>  		pr_warn("Unknown function number - %d - %d\n",
>  			return_value.function, return_value.key_num);
> -- 
> 2.7.2
> 
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 1062fa4..e2d333c 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -7,6 +7,9 @@ 
  *    Copyright (C) 2005-2007	E.M. Smith
  *    Copyright (C) 2007-2008	Carlos Corbacho <cathectic@gmail.com>
  *
+ *  Added support for Acer Predator hotkeys:
+ *    Copyright (C) 2016	Bernhard Rosenkraenzer <bero@lindev.ch>
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
@@ -94,6 +97,7 @@  MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
 enum acer_wmi_event_ids {
 	WMID_HOTKEY_EVENT = 0x1,
 	WMID_ACCEL_EVENT = 0x5,
+	WMID_MACROKEY_EVENT = 0x7,
 };
 
 static const struct key_entry acer_wmi_keymap[] __initconst = {
@@ -128,6 +132,26 @@  static const struct key_entry acer_wmi_keymap[] __initconst = {
 	{KE_KEY, KEY_TOUCHPAD_OFF, {KEY_TOUCHPAD_OFF} },
 	{KE_IGNORE, 0x83, {KEY_TOUCHPAD_TOGGLE} },
 	{KE_KEY, 0x85, {KEY_TOUCHPAD_TOGGLE} },
+	/* Acer Predator macro keys:
+	 * 0xdaXY:
+	 *   da   - magic value (preDAtor)
+	 *     X  - macro key selector state (0: red, 1: blue, 2: green)
+	 *      Y - key pressed (0: 1, 1: 2, ...) */
+	{KE_KEY, 0xda00, {KEY_PROG1} },
+	{KE_KEY, 0xda01, {KEY_PROG2} },
+	{KE_KEY, 0xda02, {KEY_PROG3} },
+	{KE_KEY, 0xda03, {KEY_PROG4} },
+	{KE_KEY, 0xda04, {KEY_F13} },
+	{KE_KEY, 0xda10, {KEY_F14} },
+	{KE_KEY, 0xda11, {KEY_F15} },
+	{KE_KEY, 0xda12, {KEY_F16} },
+	{KE_KEY, 0xda13, {KEY_F17} },
+	{KE_KEY, 0xda14, {KEY_F18} },
+	{KE_KEY, 0xda20, {KEY_F19} },
+	{KE_KEY, 0xda21, {KEY_F20} },
+	{KE_KEY, 0xda22, {KEY_F21} },
+	{KE_KEY, 0xda23, {KEY_F22} },
+	{KE_KEY, 0xda24, {KEY_F23} },
 	{KE_END, 0}
 };
 
@@ -232,6 +256,7 @@  static bool ec_raw_mode;
 static bool has_type_aa;
 static u16 commun_func_bitmap;
 static u8 commun_fn_key_number;
+static u8 macro_key_state = 0;
 
 module_param(mailled, int, 0444);
 module_param(brightness, int, 0444);
@@ -1731,6 +1756,25 @@  static void acer_wmi_notify(u32 value, void *context)
 	case WMID_ACCEL_EVENT:
 		acer_gsensor_event();
 		break;
+	case WMID_MACROKEY_EVENT:
+		switch(return_value.key_num) {
+		case 1:
+			if(return_value.device_state >= 1 && return_value.device_state <= 3)
+				macro_key_state = return_value.device_state - 1;
+			else
+				pr_warn("acer_wmi: macro key state set to %d (only values 1 to 3 are known)", return_value.device_state);
+			break;
+		case 2:
+			if(return_value.device_state >= 1 && return_value.device_state <= 5)
+				sparse_keymap_report_event(acer_wmi_input_dev, 0xda00 + (macro_key_state<<4) + return_value.device_state-1, 1, true);
+			else
+				pr_warn("acer_wmi: macro key %d pressed (only 1 to 5 are known)", return_value.device_state);
+			break;
+		default:
+			pr_warn("Unknown macro key event: %d %d %d", return_value.key_num, return_value.device_state, return_value.reserved);
+			break;
+		}
+		break;
 	default:
 		pr_warn("Unknown function number - %d - %d\n",
 			return_value.function, return_value.key_num);