From patchwork Sun Mar 6 06:17:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bernhard_Rosenkr=C3=A4nzer?= X-Patchwork-Id: 8512321 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3FB2E9FC57 for ; Sun, 6 Mar 2016 06:18:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D83A20154 for ; Sun, 6 Mar 2016 06:18:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 533C62014A for ; Sun, 6 Mar 2016 06:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751136AbcCFGSP (ORCPT ); Sun, 6 Mar 2016 01:18:15 -0500 Received: from bero.eu ([88.198.22.18]:46179 "EHLO mail.lindev.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbcCFGSP (ORCPT ); Sun, 6 Mar 2016 01:18:15 -0500 Received: from localhost.localdomain (110-170-137-3.static.asianet.co.th [110.170.137.3]) by mail.lindev.ch (Postfix) with ESMTPA id 194A02B5502; Sun, 6 Mar 2016 07:17:14 +0100 (CET) From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= To: platform-driver-x86@vger.kernel.org Cc: jlee@suse.com, carlos@strangeworlds.co.uk, =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= Subject: [PATCH] Add support for Acer Predator macro keys Date: Sun, 6 Mar 2016 07:17:29 +0100 Message-Id: <1457245049-4326-1-git-send-email-bero@lindev.ch> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1457244539-23763-1-git-send-email-bero@lindev.ch> References: <1457244539-23763-1-git-send-email-bero@lindev.ch> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for the macro keys found on Acer Predator laptops. Signed-off-by: Bernhard Rosenkränzer --- 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..4cf0e2b 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 * + * Added support for Acer Predator hotkeys: + * Copyright (C) 2016 Bernhard Rosenkraenzer + * * 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 %d requested (only values 1 to 3 are known)\n", 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)\n", return_value.device_state); + break; + default: + pr_warn("Unknown macro key event: %d %d %d\n", 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);