From patchwork Mon Dec 12 12:42:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 9470701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 72E4A60573 for ; Mon, 12 Dec 2016 12:43:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B91328480 for ; Mon, 12 Dec 2016 12:43:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 502D828487; Mon, 12 Dec 2016 12:43:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9267128480 for ; Mon, 12 Dec 2016 12:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752436AbcLLMnK (ORCPT ); Mon, 12 Dec 2016 07:43:10 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34480 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751584AbcLLMnJ (ORCPT ); Mon, 12 Dec 2016 07:43:09 -0500 Received: by mail-pf0-f171.google.com with SMTP id c4so12860203pfb.1 for ; Mon, 12 Dec 2016 04:43:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=jyTMzWZMYnZywyHo155+iDPizgSNr1b8vwKnsP3GBKA=; b=h9N9LaHDSL1qymZ473iAckLmFRV5iULS0BXGg4Nsdl1sMOaoEbJPLfDL5Kv758UWHp qKULUx+Cmo9/Vd/G8gjBX8MmB7lmJ0gNRtvrvl/oUulo6dh7KpnyHyjdrCH1KKCUPLL5 u8X80RqLrAAlEK8ZVH8Ce4Wz/wStmlmhUluOikbkx6G5ElJc7blLBXBZI40JqmdRhBTs bfRuU+r+jDM77BjX4p0LofbJXXJV7Mufa1wwHffXKWI8P6cqUTcS/MX8wfZKYlVLEyaZ z1QJVfzcYxro2lmPZw7ttQwp7SMVDuOP38m4uO3KMnN0FrMtLt8yL2STEJC9bGnyCkbS XnnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jyTMzWZMYnZywyHo155+iDPizgSNr1b8vwKnsP3GBKA=; b=j5b8zNPZ6WK++DH2kmFEnXoN7dr4BT+Q6AJbbD5Np9I+Tcv6cIE/sikTXcyIdnlNSr sADPTUopcb9ffXxWzkjOtnt1rjLK9XwPGcreZwlAnehs6sMcvtwHTwqdxfOBwbl5nOuh LNtWLfddgYn62td3W7NvoeWYdp4KqX9L3F2EAIBFLCpIgm8Gcdl0D5edtx4nVUVM2Rmt rv2sIYXZYk6XwjVLtHpcJRFUIN5UMs6enc3emuug7rOvKTLHHqiVwFri3xEHnv+IJXr+ CH0wuKlIJ5iF6Y7JVeYkvP+vmbxOt4oGjNH2syF/EGGKBsCUlAD4pxOH/BqCzW9bgp3x VpIQ== X-Gm-Message-State: AKaTC03knOVGfeJBk8FOI0rBgY6TnILRkolE1gy3clyFt5+hz7HW4cr+CpS+VghHVdRC7EIM X-Received: by 10.98.35.5 with SMTP id j5mr95549260pfj.91.1481546588630; Mon, 12 Dec 2016 04:43:08 -0800 (PST) Received: from localhost.localdomain (61-224-120-165.dynamic.hinet.net. [61.224.120.165]) by smtp.gmail.com with ESMTPSA id z28sm76407441pgc.40.2016.12.12.04.43.06 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Dec 2016 04:43:07 -0800 (PST) From: Chris Chiu To: Jiri Kosina , Benjamin Tissoires , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Cc: linux@endlessm.com, Chris Chiu Subject: [PATCH] HID: add Asus macrokey support for Asus "Republic of Gamers" laptop Date: Mon, 12 Dec 2016 20:42:58 +0800 Message-Id: <1481546578-40703-1-git-send-email-chiu@endlessm.com> X-Mailer: git-send-email 2.5.4 (Apple Git-61) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ROG means ASUS "Republic of Gamers" laptops. The input device info also represents itself as "ASASTeK COMPUTER INC. ROG MacroKey". It uses special HID_USAGE code for function keys. This commit remap the special code to standard keycode for function keys handling. It's verified on GL553VD/VE, GL753VD/VE. Signed-off-by: Chris Chiu Reported-by: Yukai Li --- drivers/hid/Kconfig | 11 +++++++ drivers/hid/Makefile | 1 + drivers/hid/hid-asus-rog.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/hid/hid-ids.h | 2 ++ include/linux/hid.h | 1 + 5 files changed, 95 insertions(+) create mode 100644 drivers/hid/hid-asus-rog.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 78ac481..925aa7b 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -144,6 +144,17 @@ config HID_ASUS - EeeBook X205TA - VivoBook E200HA +config HID_ASUS_GAMING_NB_KBD + tristate "ASUS special macrokey device for Republic of Gamers laptop" + depends on HID + ---help--- + Support for ASUS special macrokey devices on Republic of Gamers latops + that are not fully compliant with HID standard + + Say Y if you want support for the non-compliant features of the Asus + Republic of Gamers laptop keyboards, e.g: + - Asus Notebook GL553VD/GL553VE/GL753VD/GL753VE + config HID_AUREAL tristate "Aureal" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index fc4b2aa..f15479a 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_HID_ACRUX) += hid-axff.o obj-$(CONFIG_HID_APPLE) += hid-apple.o obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o obj-$(CONFIG_HID_ASUS) += hid-asus.o +obj-$(CONFIG_HID_ASUS_GAMING_NB_KBD) += hid-asus-rog.o obj-$(CONFIG_HID_AUREAL) += hid-aureal.o obj-$(CONFIG_HID_BELKIN) += hid-belkin.o obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o diff --git a/drivers/hid/hid-asus-rog.c b/drivers/hid/hid-asus-rog.c new file mode 100644 index 0000000..a33a693 --- /dev/null +++ b/drivers/hid/hid-asus-rog.c @@ -0,0 +1,80 @@ +/* + * HID driver for some Asus Gaming model equipped with "special" macrokey + * devices for hotkey handling + * + * Currently supported devices are: + * ASUS laptops for "Republic of Gamers" + * GL553VD/GL553VE + * GL753VD/GL753VE + * + * Copyright (c) 2016 Chris Chiu + * + * This module based on hid-gyration + * + */ + +/* + * 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 (at your option) + * any later version. + */ + +#include +#include +#include +#include + +#include "hid-ids.h" + +#define asus_rog_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \ + max, EV_KEY, (c)) +static int asus_rog_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_ASUS_ROG_HOTKEY) + return 0; + + set_bit(EV_REP, hi->input->evbit); + switch (usage->hid & HID_USAGE) { + /* Reported on ASUS Gaming model (Republic of Gamers) keyboards */ + case 0x6c: asus_rog_map_key_clear(KEY_SLEEP); break; + case 0x88: asus_rog_map_key_clear(KEY_WLAN); break; + case 0xc5: asus_rog_map_key_clear(KEY_KBDILLUMDOWN); break; + case 0xc4: asus_rog_map_key_clear(KEY_KBDILLUMUP); break; + case 0x10: asus_rog_map_key_clear(KEY_BRIGHTNESSDOWN); break; + case 0x20: asus_rog_map_key_clear(KEY_BRIGHTNESSUP); break; + case 0x35: asus_rog_map_key_clear(KEY_DISPLAY_OFF); break; + // KEY_F21 is for ASUS touchpad toggle + case 0x6b: asus_rog_map_key_clear(KEY_F21); break; + case 0x82: asus_rog_map_key_clear(KEY_CAMERA); break; + case 0xb5: asus_rog_map_key_clear(KEY_CALC); break; + // KEY_PROG1 for ROG key + case 0x38: asus_rog_map_key_clear(KEY_PROG1); break; + // KEY_PROG2 for Fn+C ASUS Splendid + case 0xba: asus_rog_map_key_clear(KEY_PROG2); break; + // KEY_PROG3 for Fn+Space Power4Gear Hybrid, may not be present + case 0x5c: asus_rog_map_key_clear(KEY_PROG3); break; + + default: + return 0; + } + return 1; +} + +static const struct hid_device_id asus_rog_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_MACROKEY1) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_MACROKEY2) }, + { } +}; +MODULE_DEVICE_TABLE(hid, asus_rog_devices); + +static struct hid_driver asus_rog_driver = { + .name = "asus-rog", + .id_table = asus_rog_devices, + .input_mapping = asus_rog_input_mapping, +}; +module_hid_driver(asus_rog_driver); + +MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 4ed9a4f..5c60aee 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -168,6 +168,8 @@ #define USB_DEVICE_ID_ASUSTEK_LCM 0x1726 #define USB_DEVICE_ID_ASUSTEK_LCM2 0x175b #define USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD 0x8585 +#define USB_DEVICE_ID_ASUSTEK_ROG_MACROKEY1 0x1854 +#define USB_DEVICE_ID_ASUSTEK_ROG_MACROKEY2 0x1837 #define USB_VENDOR_ID_ATEN 0x0557 #define USB_DEVICE_ID_ATEN_UC100KM 0x2004 diff --git a/include/linux/hid.h b/include/linux/hid.h index 75b66ec..a6ccadb 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -170,6 +170,7 @@ struct hid_item { #define HID_UP_LOGIVENDOR 0xffbc0000 #define HID_UP_LOGIVENDOR2 0xff090000 #define HID_UP_LOGIVENDOR3 0xff430000 +#define HID_UP_ASUS_ROG_HOTKEY 0xff310000 #define HID_UP_LNVENDOR 0xffa00000 #define HID_UP_SENSOR 0x00200000