mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Prepare for next work
This commit is contained in:
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Support for G531
|
||||
- Support for G731
|
||||
|
||||
## [0.15.3] - 2020-07-21
|
||||
## Changed
|
||||
- GX531 reverted to zone profile, G531 moved to per-key profile
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -710,7 +710,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rog-daemon"
|
||||
version = "0.15.2"
|
||||
version = "0.15.3"
|
||||
dependencies = [
|
||||
"dbus",
|
||||
"dbus-tokio",
|
||||
|
||||
24
README.md
24
README.md
@@ -1,5 +1,25 @@
|
||||
# ROG-Core
|
||||
|
||||
**NOTICE:**
|
||||
I have completed kernel patches to move a large chunk of rog-core functionality
|
||||
in to the Linux kernel. The patch is not in mainline yet, but can be found in the
|
||||
`./kernel-patch/` directory. The patch enables the following in kernel:
|
||||
|
||||
- All hotkeys (FN+Key combos)
|
||||
- Control of keyboard brightness using FN+Key combos (not RGB)
|
||||
- FN+F5 (fan) to toggle fan modes. You can watch the path `/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy`
|
||||
to see which mode you are in
|
||||
|
||||
You will not get RGB control in kernel (yet), and rog-core is still required to
|
||||
change modes and RGB settings. The current version in master and last release
|
||||
still take full control of the interfaces
|
||||
|
||||
**work on a version of rog-core for use with the kernel patch is in another branch**
|
||||
|
||||
The last version of rog-core will work with any kernel with or without this patch
|
||||
and provide full functions.
|
||||
|
||||
---
|
||||
rog-core is a utility for Linux to control many aspects (eventually) of the ASUS
|
||||
ROG laptops like the Zephyrus GX502GW.
|
||||
|
||||
@@ -42,6 +62,7 @@ LED brightness and mode change keys, Calc, fan-mode toggles etc.
|
||||
| G512 | X | X | | | X | X |
|
||||
| G712 | X | X | | | X | X |
|
||||
| G531 | X | X | | | X | X |
|
||||
| G731 | X | X | | | X | X |
|
||||
| G532 | X | X | | | X | X |
|
||||
| GA401 | X | X | X | | X | X |
|
||||
| GA502 | X | X | X | | X | X |
|
||||
@@ -63,7 +84,8 @@ Models GA401, GA502, GU502 support LED brightness change only (no RGB).
|
||||
| G712 | X | X | X | X | | | | | | | | | X | |
|
||||
| GX502 | X | X | X | X | X | X | X | X | X | X | X | X | | X |
|
||||
| GX701 | X | X | X | X | X | X | X | X | X | X | X | X | | X |
|
||||
| G531 | X | X | X | X | X | X | X | X | X | X | X | X | | X |
|
||||
| G531 | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
|
||||
| G731 | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
|
||||
| G532 | X | X | X | X | X | X | X | X | X | X | X | X | | X |
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
From 61e7ffe80b12db8ebb6033cfe2b70cccaefc07e1 Mon Sep 17 00:00:00 2001
|
||||
From: Luke D Jones <luke@ljones.dev>
|
||||
Date: Sat, 1 Aug 2020 20:33:28 +1200
|
||||
Subject: [PATCH] HID: asus: add support for ASUS N-Key keyboard
|
||||
|
||||
Enable missing functionality of the keyboard found in many ASUS
|
||||
Zephyrus laptops: Fn key combos and hotkeys, keyboard backlight
|
||||
brightness control, and notify asus-wmi to toggle "fan-mode".
|
||||
Two input event codes are added for keyboard LED mode switching
|
||||
prev/next.
|
||||
|
||||
The keyboard has many of the same key outputs as the existing G752
|
||||
keyboard including a few extras, and varies a little between laptop
|
||||
models.
|
||||
|
||||
Additionally the keyboard requires the LED interface to be
|
||||
intitialised before such things as keyboard backlight control work.
|
||||
|
||||
Misc changes in scope: update some hardcoded comparisons to use an
|
||||
available define, change "Mic Toggle" to use a keycode that works.
|
||||
|
||||
Signed-off-by: Luke D Jones <luke@ljones.dev>
|
||||
---
|
||||
drivers/hid/hid-asus.c | 164 ++++++++++++++++++---
|
||||
drivers/hid/hid-ids.h | 1 +
|
||||
include/linux/platform_data/x86/asus-wmi.h | 2 +
|
||||
include/uapi/linux/input-event-codes.h | 7 +
|
||||
4 files changed, 152 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
|
||||
index e6e4c841fb06..fa9928672110 100644
|
||||
--- a/drivers/hid/hid-asus.c
|
||||
+++ b/drivers/hid/hid-asus.c
|
||||
@@ -26,10 +26,12 @@
|
||||
#include <linux/dmi.h>
|
||||
#include <linux/hid.h>
|
||||
#include <linux/module.h>
|
||||
+#include <linux/acpi.h>
|
||||
#include <linux/platform_data/x86/asus-wmi.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/usb.h> /* For to_usb_interface for T100 touchpad intf check */
|
||||
#include <linux/power_supply.h>
|
||||
+#include <../drivers/platform/x86/asus-wmi.h>
|
||||
|
||||
#include "hid-ids.h"
|
||||
|
||||
@@ -46,6 +48,8 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
|
||||
#define INPUT_REPORT_ID 0x5d
|
||||
#define FEATURE_KBD_REPORT_ID 0x5a
|
||||
#define FEATURE_KBD_REPORT_SIZE 16
|
||||
+#define FEATURE_KBD_LED_REPORT_ID1 0x5d
|
||||
+#define FEATURE_KBD_LED_REPORT_ID2 0x5e
|
||||
|
||||
#define SUPPORT_KBD_BACKLIGHT BIT(0)
|
||||
|
||||
@@ -77,6 +81,7 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
|
||||
#define QUIRK_G752_KEYBOARD BIT(8)
|
||||
#define QUIRK_T101HA_DOCK BIT(9)
|
||||
#define QUIRK_T90CHI BIT(10)
|
||||
+#define QUIRK_ROG_NKEY_KEYBOARD BIT(12)
|
||||
|
||||
#define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
|
||||
QUIRK_NO_INIT_REPORTS | \
|
||||
@@ -257,10 +262,33 @@ static int asus_report_input(struct asus_drvdata *drvdat, u8 *data, int size)
|
||||
return 1;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * This enables triggering events in asus-wmi
|
||||
+*/
|
||||
+static int asus_wmi_send_event(struct asus_drvdata *drvdat, u8 code)
|
||||
+{
|
||||
+ int err;
|
||||
+ u32 retval;
|
||||
+
|
||||
+ err = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS,
|
||||
+ ASUS_WMI_METHODID_NOTIF, code, &retval);
|
||||
+ if (err) {
|
||||
+ pr_warn("Failed to notify asus-wmi: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ if (retval != 0) {
|
||||
+ pr_warn("Failed to notify asus-wmi (retval): 0x%x\n", retval);
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int asus_event(struct hid_device *hdev, struct hid_field *field,
|
||||
struct hid_usage *usage, __s32 value)
|
||||
{
|
||||
- if ((usage->hid & HID_USAGE_PAGE) == 0xff310000 &&
|
||||
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR &&
|
||||
(usage->hid & HID_USAGE) != 0x00 &&
|
||||
(usage->hid & HID_USAGE) != 0xff && !usage->type) {
|
||||
hid_warn(hdev, "Unmapped Asus vendor usagepage code 0x%02x\n",
|
||||
@@ -281,6 +309,20 @@ static int asus_raw_event(struct hid_device *hdev,
|
||||
if (drvdata->tp && data[0] == INPUT_REPORT_ID)
|
||||
return asus_report_input(drvdata, data, size);
|
||||
|
||||
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
|
||||
+ /*
|
||||
+ * Skip these report ID, the device emits a continuous stream associated
|
||||
+ * with the AURA mode it is in
|
||||
+ */
|
||||
+ if (report->id == FEATURE_KBD_LED_REPORT_ID1 ||
|
||||
+ report->id == FEATURE_KBD_LED_REPORT_ID2) {
|
||||
+ return -1;
|
||||
+ /* Fn+F5 "fan" symbol, trigger WMI event to toggle next mode */
|
||||
+ } else if (report->id == FEATURE_KBD_REPORT_ID && data[1] == 0xae) {
|
||||
+ return asus_wmi_send_event(drvdata, 0xae);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -293,7 +335,9 @@ static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size
|
||||
if (!dmabuf)
|
||||
return -ENOMEM;
|
||||
|
||||
- ret = hid_hw_raw_request(hdev, FEATURE_KBD_REPORT_ID, dmabuf,
|
||||
+ // The report ID should be set from the incoming buffer due to LED and key
|
||||
+ // interfaces having different pages
|
||||
+ ret = hid_hw_raw_request(hdev, buf[0], dmabuf,
|
||||
buf_size, HID_FEATURE_REPORT,
|
||||
HID_REQ_SET_REPORT);
|
||||
kfree(dmabuf);
|
||||
@@ -346,6 +390,44 @@ static int asus_kbd_get_functions(struct hid_device *hdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static int asus_kbd_led_init(struct hid_device *hdev)
|
||||
+{
|
||||
+ u8 buf_init_start[] = { FEATURE_KBD_LED_REPORT_ID1, 0xB9 };
|
||||
+ u8 buf_init2[] = { FEATURE_KBD_LED_REPORT_ID1, 0x41, 0x53, 0x55, 0x53, 0x20,
|
||||
+ 0x54, 0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
|
||||
+ u8 buf_init3[] = { FEATURE_KBD_LED_REPORT_ID1,
|
||||
+ 0x05, 0x20, 0x31, 0x00, 0x08 };
|
||||
+ int ret;
|
||||
+
|
||||
+ hid_warn(hdev, "Asus initialise N-KEY Device");
|
||||
+ /* The first message is an init start */
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init_start, sizeof(buf_init_start));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init start command: %d\n", ret);
|
||||
+ /* Followed by a string */
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init2, sizeof(buf_init2));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init command 1.0: %d\n", ret);
|
||||
+ /* Followed by a string */
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init3, sizeof(buf_init3));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init command 1.1: %d\n", ret);
|
||||
+
|
||||
+ /* begin second report ID with same data */
|
||||
+ buf_init2[0] = FEATURE_KBD_LED_REPORT_ID2;
|
||||
+ buf_init3[0] = FEATURE_KBD_LED_REPORT_ID2;
|
||||
+
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init2, sizeof(buf_init2));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init command 2.0: %d\n", ret);
|
||||
+
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init3, sizeof(buf_init3));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init command 2.1: %d\n", ret);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
static void asus_kbd_backlight_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness brightness)
|
||||
{
|
||||
@@ -409,19 +491,28 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
|
||||
unsigned char kbd_func;
|
||||
int ret;
|
||||
|
||||
- /* Initialize keyboard */
|
||||
- ret = asus_kbd_init(hdev);
|
||||
- if (ret < 0)
|
||||
- return ret;
|
||||
+ if (drvdata->quirks & QUIRK_G752_KEYBOARD) {
|
||||
+ /* Initialize keyboard */
|
||||
+ ret = asus_kbd_init(hdev);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
|
||||
- /* Get keyboard functions */
|
||||
- ret = asus_kbd_get_functions(hdev, &kbd_func);
|
||||
- if (ret < 0)
|
||||
- return ret;
|
||||
+ /* Get keyboard functions */
|
||||
+ ret = asus_kbd_get_functions(hdev, &kbd_func);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
|
||||
- /* Check for backlight support */
|
||||
- if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
|
||||
- return -ENODEV;
|
||||
+ /* Check for backlight support */
|
||||
+ if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
|
||||
+ /* Initialize keyboard LED interface and Vendor keys on 0x1866 */
|
||||
+ ret = asus_kbd_led_init(hdev);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
drvdata->kbd_backlight = devm_kzalloc(&hdev->dev,
|
||||
sizeof(struct asus_kbd_leds),
|
||||
@@ -693,14 +784,14 @@ static int asus_input_mapping(struct hid_device *hdev,
|
||||
}
|
||||
|
||||
/* ASUS-specific keyboard hotkeys */
|
||||
- if ((usage->hid & HID_USAGE_PAGE) == 0xff310000) {
|
||||
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR) {
|
||||
set_bit(EV_REP, hi->input->evbit);
|
||||
switch (usage->hid & HID_USAGE) {
|
||||
case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN); break;
|
||||
case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP); break;
|
||||
case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF); break;
|
||||
case 0x6c: asus_map_key_clear(KEY_SLEEP); break;
|
||||
- case 0x7c: asus_map_key_clear(KEY_MICMUTE); break;
|
||||
+ case 0x7c: asus_map_key_clear(KEY_F20); break;
|
||||
case 0x82: asus_map_key_clear(KEY_CAMERA); break;
|
||||
case 0x88: asus_map_key_clear(KEY_RFKILL); break;
|
||||
case 0xb5: asus_map_key_clear(KEY_CALC); break;
|
||||
@@ -713,16 +804,42 @@ static int asus_input_mapping(struct hid_device *hdev,
|
||||
/* ROG key */
|
||||
case 0x38: asus_map_key_clear(KEY_PROG1); break;
|
||||
|
||||
- /* Fn+C ASUS Splendid */
|
||||
- case 0xba: asus_map_key_clear(KEY_PROG2); break;
|
||||
+ default:
|
||||
+ if (drvdata->quirks & QUIRK_G752_KEYBOARD) {
|
||||
+ switch (usage->hid & HID_USAGE) {
|
||||
+ /* Fn+C ASUS Splendid */
|
||||
+ case 0xba: asus_map_key_clear(KEY_PROG2); break;
|
||||
|
||||
- /* Fn+Space Power4Gear Hybrid */
|
||||
- case 0x5c: asus_map_key_clear(KEY_PROG3); break;
|
||||
+ /* Fn+Space Power4Gear Hybrid */
|
||||
+ case 0x5c: asus_map_key_clear(KEY_PROG3); break;
|
||||
|
||||
- /* Fn+F5 "fan" symbol on FX503VD */
|
||||
- case 0x99: asus_map_key_clear(KEY_PROG4); break;
|
||||
+ /* Fn+F5 "fan" symbol on FX503VD */
|
||||
+ case 0x99: asus_map_key_clear(KEY_PROG4); break;
|
||||
+
|
||||
+ default:
|
||||
+ return -1;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ /* device 0x1866, N-KEY Device specific */
|
||||
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
|
||||
+ switch (usage->hid & HID_USAGE) {
|
||||
+ /* Fn+Ret "Calc" symbol on device 0x1866, N-KEY Device */
|
||||
+ case 0x92: asus_map_key_clear(KEY_CALC); break;
|
||||
+
|
||||
+ /* Fn+Left Aura mode previous */
|
||||
+ case 0xb2: asus_map_key_clear(KEY_KBDILLUM_MODE_PREV); break;
|
||||
+
|
||||
+ /* Fn+Right Aura mode next */
|
||||
+ case 0xb3: asus_map_key_clear(KEY_KBDILLUM_MODE_NEXT); break;
|
||||
+
|
||||
+ default:
|
||||
+ return -1;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
- default:
|
||||
/* ASUS lazily declares 256 usages, ignore the rest,
|
||||
* as some make the keyboard appear as a pointer device. */
|
||||
return -1;
|
||||
@@ -1043,6 +1160,9 @@ static const struct hid_device_id asus_devices[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD),
|
||||
QUIRK_USE_KBD_BACKLIGHT },
|
||||
+ { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
+ USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD),
|
||||
+ QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
USB_DEVICE_ID_ASUSTEK_T100TA_KEYBOARD),
|
||||
QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
|
||||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||
index 1c71a1aa76b2..42c2ca3832e0 100644
|
||||
--- a/drivers/hid/hid-ids.h
|
||||
+++ b/drivers/hid/hid-ids.h
|
||||
@@ -193,6 +193,7 @@
|
||||
#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854
|
||||
#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2 0x1837
|
||||
#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3 0x1822
|
||||
+#define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD 0x1866
|
||||
#define USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD 0x1869
|
||||
|
||||
#define USB_VENDOR_ID_ATEN 0x0557
|
||||
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
|
||||
index d39fc658c320..10fca778ff9c 100644
|
||||
--- a/include/linux/platform_data/x86/asus-wmi.h
|
||||
+++ b/include/linux/platform_data/x86/asus-wmi.h
|
||||
@@ -27,6 +27,8 @@
|
||||
#define ASUS_WMI_METHODID_INIT 0x54494E49 /* INITialize */
|
||||
#define ASUS_WMI_METHODID_HKEY 0x59454B48 /* Hot KEY ?? */
|
||||
|
||||
+#define ASUS_WMI_METHODID_NOTIF 0x00100021 /* Notify method ?? */
|
||||
+
|
||||
#define ASUS_WMI_UNSUPPORTED_METHOD 0xFFFFFFFE
|
||||
|
||||
/* Wireless */
|
||||
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
|
||||
index b6a835d37826..928abcf020d5 100644
|
||||
--- a/include/uapi/linux/input-event-codes.h
|
||||
+++ b/include/uapi/linux/input-event-codes.h
|
||||
@@ -772,6 +772,13 @@
|
||||
#define BTN_TRIGGER_HAPPY39 0x2e6
|
||||
#define BTN_TRIGGER_HAPPY40 0x2e7
|
||||
|
||||
+/*
|
||||
+ * Some keyboards have function keys associated with
|
||||
+ * changing the keyboard backlight modes, e.g, RGB patterns
|
||||
+ */
|
||||
+#define KEY_KBDILLUM_MODE_PREV 0x2ea
|
||||
+#define KEY_KBDILLUM_MODE_NEXT 0x2eb
|
||||
+
|
||||
/* We avoid low common keys in module aliases so they don't get huge. */
|
||||
#define KEY_MIN_INTERESTING KEY_MUTE
|
||||
#define KEY_MAX 0x2ff
|
||||
--
|
||||
2.26.2
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
From 2b70c3daf1bd92f9163efb726e37fb3e0bcc8989 Mon Sep 17 00:00:00 2001
|
||||
From: Luke D Jones <luke@ljones.dev>
|
||||
Date: Thu, 30 Jul 2020 16:51:06 +1200
|
||||
Subject: [PATCH] HID: asus: add support for ASUS N-Key keyboard
|
||||
|
||||
Enable missing functionality of the keyboard found in many ASUS
|
||||
Zephyrus laptops: Fn key combos and hotkeys, keyboard backlight
|
||||
brightness control, and notify asus-wmi to toggle "fan-mode".
|
||||
Two input event codes are added for keyboard LED mode switching
|
||||
prev/next.
|
||||
|
||||
The keyboard has many of the same key outputs as the existing G752
|
||||
keyboard including a few extras, and varies a little between laptop
|
||||
models.
|
||||
|
||||
Additionally the keyboard requires the LED interface to be
|
||||
intitialised before such things as keyboard backlight control work.
|
||||
|
||||
Misc changes in scope: update some hardcoded comparisons to use an
|
||||
available define, change "Mic Toggle" to use a keycode that works.
|
||||
|
||||
Signed-off-by: Luke D Jones <luke@ljones.dev>
|
||||
---
|
||||
drivers/hid/hid-asus.c | 166 ++++++++++++++++++---
|
||||
drivers/hid/hid-ids.h | 1 +
|
||||
include/linux/platform_data/x86/asus-wmi.h | 2 +
|
||||
include/uapi/linux/input-event-codes.h | 7 +
|
||||
4 files changed, 153 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
|
||||
index c183caf89d49..5dfca90cd616 100644
|
||||
--- a/drivers/hid/hid-asus.c
|
||||
+++ b/drivers/hid/hid-asus.c
|
||||
@@ -26,10 +26,12 @@
|
||||
#include <linux/dmi.h>
|
||||
#include <linux/hid.h>
|
||||
#include <linux/module.h>
|
||||
+#include <linux/acpi.h>
|
||||
#include <linux/platform_data/x86/asus-wmi.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/usb.h> /* For to_usb_interface for T100 touchpad intf check */
|
||||
#include <linux/power_supply.h>
|
||||
+#include <../drivers/platform/x86/asus-wmi.h>
|
||||
|
||||
#include "hid-ids.h"
|
||||
|
||||
@@ -48,6 +50,8 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
|
||||
#define INPUT_REPORT_ID 0x5d
|
||||
#define FEATURE_KBD_REPORT_ID 0x5a
|
||||
#define FEATURE_KBD_REPORT_SIZE 16
|
||||
+#define FEATURE_KBD_LED_REPORT_ID1 0x5d
|
||||
+#define FEATURE_KBD_LED_REPORT_ID2 0x5e
|
||||
|
||||
#define SUPPORT_KBD_BACKLIGHT BIT(0)
|
||||
|
||||
@@ -80,6 +84,7 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
|
||||
#define QUIRK_T101HA_DOCK BIT(9)
|
||||
#define QUIRK_T90CHI BIT(10)
|
||||
#define QUIRK_MEDION_E1239T BIT(11)
|
||||
+#define QUIRK_ROG_NKEY_KEYBOARD BIT(12)
|
||||
|
||||
#define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
|
||||
QUIRK_NO_INIT_REPORTS | \
|
||||
@@ -305,10 +310,33 @@ static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * This enables triggering events in asus-wmi
|
||||
+ */
|
||||
+static int asus_wmi_send_event(struct asus_drvdata *drvdat, u8 code)
|
||||
+{
|
||||
+ int err;
|
||||
+ u32 retval;
|
||||
+
|
||||
+ err = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS,
|
||||
+ ASUS_WMI_METHODID_NOTIF, code, &retval);
|
||||
+ if (err) {
|
||||
+ pr_warn("Failed to notify asus-wmi: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ if (retval != 0) {
|
||||
+ pr_warn("Failed to notify asus-wmi (retval): 0x%x\n", retval);
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int asus_event(struct hid_device *hdev, struct hid_field *field,
|
||||
struct hid_usage *usage, __s32 value)
|
||||
{
|
||||
- if ((usage->hid & HID_USAGE_PAGE) == 0xff310000 &&
|
||||
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR &&
|
||||
(usage->hid & HID_USAGE) != 0x00 &&
|
||||
(usage->hid & HID_USAGE) != 0xff && !usage->type) {
|
||||
hid_warn(hdev, "Unmapped Asus vendor usagepage code 0x%02x\n",
|
||||
@@ -332,6 +360,20 @@ static int asus_raw_event(struct hid_device *hdev,
|
||||
if (drvdata->quirks & QUIRK_MEDION_E1239T)
|
||||
return asus_e1239t_event(drvdata, data, size);
|
||||
|
||||
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
|
||||
+ /*
|
||||
+ * Skip these report ID, the device emits a continuous stream associated
|
||||
+ * with the AURA mode it is in
|
||||
+ */
|
||||
+ if (report->id == FEATURE_KBD_LED_REPORT_ID1 ||
|
||||
+ report->id == FEATURE_KBD_LED_REPORT_ID2) {
|
||||
+ return -1;
|
||||
+ /* Fn+F5 "fan" symbol, trigger WMI event to toggle next mode */
|
||||
+ } else if (report->id == FEATURE_KBD_REPORT_ID && data[1] == 0xae) {
|
||||
+ return asus_wmi_send_event(drvdata, 0xae);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -344,7 +386,9 @@ static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size
|
||||
if (!dmabuf)
|
||||
return -ENOMEM;
|
||||
|
||||
- ret = hid_hw_raw_request(hdev, FEATURE_KBD_REPORT_ID, dmabuf,
|
||||
+ // The report ID should be set from the incoming buffer due to LED and key
|
||||
+ // interfaces having different pages
|
||||
+ ret = hid_hw_raw_request(hdev, buf[0], dmabuf,
|
||||
buf_size, HID_FEATURE_REPORT,
|
||||
HID_REQ_SET_REPORT);
|
||||
kfree(dmabuf);
|
||||
@@ -397,6 +441,44 @@ static int asus_kbd_get_functions(struct hid_device *hdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static int asus_kbd_led_init(struct hid_device *hdev)
|
||||
+{
|
||||
+ u8 buf_init_start[] = { FEATURE_KBD_LED_REPORT_ID1, 0xB9 };
|
||||
+ u8 buf_init2[] = { FEATURE_KBD_LED_REPORT_ID1, 0x41, 0x53, 0x55, 0x53, 0x20,
|
||||
+ 0x54, 0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
|
||||
+ u8 buf_init3[] = { FEATURE_KBD_LED_REPORT_ID1,
|
||||
+ 0x05, 0x20, 0x31, 0x00, 0x08 };
|
||||
+ int ret;
|
||||
+
|
||||
+ hid_warn(hdev, "Asus initialise N-KEY Device");
|
||||
+ /* The first message is an init start */
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init_start, sizeof(buf_init_start));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init start command: %d\n", ret);
|
||||
+ /* Followed by a string */
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init2, sizeof(buf_init2));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init command 1.0: %d\n", ret);
|
||||
+ /* Followed by a string */
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init3, sizeof(buf_init3));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init command 1.1: %d\n", ret);
|
||||
+
|
||||
+ /* begin second report ID with same data */
|
||||
+ buf_init2[0] = FEATURE_KBD_LED_REPORT_ID2;
|
||||
+ buf_init3[0] = FEATURE_KBD_LED_REPORT_ID2;
|
||||
+
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init2, sizeof(buf_init2));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init command 2.0: %d\n", ret);
|
||||
+
|
||||
+ ret = asus_kbd_set_report(hdev, buf_init3, sizeof(buf_init3));
|
||||
+ if (ret < 0)
|
||||
+ hid_err(hdev, "Asus failed to send init command 2.1: %d\n", ret);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
static void asus_kbd_backlight_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness brightness)
|
||||
{
|
||||
@@ -460,19 +542,28 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
|
||||
unsigned char kbd_func;
|
||||
int ret;
|
||||
|
||||
- /* Initialize keyboard */
|
||||
- ret = asus_kbd_init(hdev);
|
||||
- if (ret < 0)
|
||||
- return ret;
|
||||
+ if (drvdata->quirks & QUIRK_G752_KEYBOARD) {
|
||||
+ /* Initialize keyboard */
|
||||
+ ret = asus_kbd_init(hdev);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
|
||||
- /* Get keyboard functions */
|
||||
- ret = asus_kbd_get_functions(hdev, &kbd_func);
|
||||
- if (ret < 0)
|
||||
- return ret;
|
||||
+ /* Get keyboard functions */
|
||||
+ ret = asus_kbd_get_functions(hdev, &kbd_func);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
|
||||
- /* Check for backlight support */
|
||||
- if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
|
||||
- return -ENODEV;
|
||||
+ /* Check for backlight support */
|
||||
+ if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
|
||||
+ /* Initialize keyboard LED interface and Vendor keys on 0x1866 */
|
||||
+ ret = asus_kbd_led_init(hdev);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
drvdata->kbd_backlight = devm_kzalloc(&hdev->dev,
|
||||
sizeof(struct asus_kbd_leds),
|
||||
@@ -751,14 +842,14 @@ static int asus_input_mapping(struct hid_device *hdev,
|
||||
usage->hid == (HID_UP_GENDEVCTRLS | 0x0026)))
|
||||
return -1;
|
||||
|
||||
- /* ASUS-specific keyboard hotkeys */
|
||||
- if ((usage->hid & HID_USAGE_PAGE) == 0xff310000) {
|
||||
+ /* ASUS-specific keyboard hotkeys and led backlight */
|
||||
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR) {
|
||||
switch (usage->hid & HID_USAGE) {
|
||||
case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN); break;
|
||||
case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP); break;
|
||||
case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF); break;
|
||||
case 0x6c: asus_map_key_clear(KEY_SLEEP); break;
|
||||
- case 0x7c: asus_map_key_clear(KEY_MICMUTE); break;
|
||||
+ case 0x7c: asus_map_key_clear(KEY_F20); break;
|
||||
case 0x82: asus_map_key_clear(KEY_CAMERA); break;
|
||||
case 0x88: asus_map_key_clear(KEY_RFKILL); break;
|
||||
case 0xb5: asus_map_key_clear(KEY_CALC); break;
|
||||
@@ -771,16 +862,42 @@ static int asus_input_mapping(struct hid_device *hdev,
|
||||
/* ROG key */
|
||||
case 0x38: asus_map_key_clear(KEY_PROG1); break;
|
||||
|
||||
- /* Fn+C ASUS Splendid */
|
||||
- case 0xba: asus_map_key_clear(KEY_PROG2); break;
|
||||
+ default:
|
||||
+ if (drvdata->quirks & QUIRK_G752_KEYBOARD) {
|
||||
+ switch (usage->hid & HID_USAGE) {
|
||||
+ /* Fn+C ASUS Splendid */
|
||||
+ case 0xba: asus_map_key_clear(KEY_PROG2); break;
|
||||
|
||||
- /* Fn+Space Power4Gear Hybrid */
|
||||
- case 0x5c: asus_map_key_clear(KEY_PROG3); break;
|
||||
+ /* Fn+Space Power4Gear Hybrid */
|
||||
+ case 0x5c: asus_map_key_clear(KEY_PROG3); break;
|
||||
|
||||
- /* Fn+F5 "fan" symbol on FX503VD */
|
||||
- case 0x99: asus_map_key_clear(KEY_PROG4); break;
|
||||
+ /* Fn+F5 "fan" symbol on FX503VD */
|
||||
+ case 0x99: asus_map_key_clear(KEY_PROG4); break;
|
||||
+
|
||||
+ default:
|
||||
+ return -1;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ /* device 0x1866, N-KEY Device specific */
|
||||
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
|
||||
+ switch (usage->hid & HID_USAGE) {
|
||||
+ /* Fn+Ret "Calc" symbol on device 0x1866, N-KEY Device */
|
||||
+ case 0x92: asus_map_key_clear(KEY_CALC); break;
|
||||
+
|
||||
+ /* Fn+Left Aura mode previous */
|
||||
+ case 0xb2: asus_map_key_clear(KEY_KBDILLUM_MODE_PREV); break;
|
||||
+
|
||||
+ /* Fn+Right Aura mode next */
|
||||
+ case 0xb3: asus_map_key_clear(KEY_KBDILLUM_MODE_NEXT); break;
|
||||
+
|
||||
+ default:
|
||||
+ return -1;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
- default:
|
||||
/* ASUS lazily declares 256 usages, ignore the rest,
|
||||
* as some make the keyboard appear as a pointer device. */
|
||||
return -1;
|
||||
@@ -1126,6 +1243,9 @@ static const struct hid_device_id asus_devices[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD),
|
||||
QUIRK_USE_KBD_BACKLIGHT },
|
||||
+ { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
+ USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD),
|
||||
+ QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
USB_DEVICE_ID_ASUSTEK_T100TA_KEYBOARD),
|
||||
QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
|
||||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||
index 6f370e020feb..c9f930ddcfd7 100644
|
||||
--- a/drivers/hid/hid-ids.h
|
||||
+++ b/drivers/hid/hid-ids.h
|
||||
@@ -190,6 +190,7 @@
|
||||
#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854
|
||||
#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2 0x1837
|
||||
#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3 0x1822
|
||||
+#define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD 0x1866
|
||||
#define USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD 0x1869
|
||||
|
||||
#define USB_VENDOR_ID_ATEN 0x0557
|
||||
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
|
||||
index 897b8332a39f..05253cfe786c 100644
|
||||
--- a/include/linux/platform_data/x86/asus-wmi.h
|
||||
+++ b/include/linux/platform_data/x86/asus-wmi.h
|
||||
@@ -27,6 +27,8 @@
|
||||
#define ASUS_WMI_METHODID_INIT 0x54494E49 /* INITialize */
|
||||
#define ASUS_WMI_METHODID_HKEY 0x59454B48 /* Hot KEY ?? */
|
||||
|
||||
+#define ASUS_WMI_METHODID_NOTIF 0x00100021 /* Notify method ?? */
|
||||
+
|
||||
#define ASUS_WMI_UNSUPPORTED_METHOD 0xFFFFFFFE
|
||||
|
||||
/* Wireless */
|
||||
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
|
||||
index 0c2e27d28e0a..ca59f7d7a25e 100644
|
||||
--- a/include/uapi/linux/input-event-codes.h
|
||||
+++ b/include/uapi/linux/input-event-codes.h
|
||||
@@ -772,6 +772,13 @@
|
||||
#define BTN_TRIGGER_HAPPY39 0x2e6
|
||||
#define BTN_TRIGGER_HAPPY40 0x2e7
|
||||
|
||||
+/*
|
||||
+ * Some keyboards have function keys associated with
|
||||
+ * changing the keyboard backlight modes, e.g, RGB patterns
|
||||
+ */
|
||||
+#define KEY_KBDILLUM_MODE_PREV 0x2ea
|
||||
+#define KEY_KBDILLUM_MODE_NEXT 0x2eb
|
||||
+
|
||||
/* We avoid low common keys in module aliases so they don't get huge. */
|
||||
#define KEY_MIN_INTERESTING KEY_MUTE
|
||||
#define KEY_MAX 0x2ff
|
||||
--
|
||||
2.26.2
|
||||
|
||||
11218
reverse_eng/dsl/FA506IV.dsl
Normal file
11218
reverse_eng/dsl/FA506IV.dsl
Normal file
File diff suppressed because it is too large
Load Diff
59177
reverse_eng/dsl/G531GW.dsl
Normal file
59177
reverse_eng/dsl/G531GW.dsl
Normal file
File diff suppressed because it is too large
Load Diff
59166
reverse_eng/dsl/G731GV.dsl
Normal file
59166
reverse_eng/dsl/G731GV.dsl
Normal file
File diff suppressed because it is too large
Load Diff
11827
reverse_eng/dsl/GA401IU.dsl
Normal file
11827
reverse_eng/dsl/GA401IU.dsl
Normal file
File diff suppressed because it is too large
Load Diff
11809
reverse_eng/dsl/GA502IU.dsl
Normal file
11809
reverse_eng/dsl/GA502IU.dsl
Normal file
File diff suppressed because it is too large
Load Diff
11854
reverse_eng/dsl/GA502IV.dsl
Normal file
11854
reverse_eng/dsl/GA502IV.dsl
Normal file
File diff suppressed because it is too large
Load Diff
59581
reverse_eng/dsl/GX502GW.dsl
Normal file
59581
reverse_eng/dsl/GX502GW.dsl
Normal file
File diff suppressed because it is too large
Load Diff
@@ -110,20 +110,26 @@ fn select_1866_device(prod: u16) -> LaptopBase {
|
||||
// TODO: actual check for the AniMe device here
|
||||
laptop.support_animatrix = true;
|
||||
// No AniMe, no RGB
|
||||
} else if board_name.starts_with("GA502")
|
||||
|| board_name.starts_with("GU502")
|
||||
{
|
||||
} else if board_name.starts_with("GA502") || board_name.starts_with("GU502") {
|
||||
info!("No RGB control available");
|
||||
// RGB, per-key settings, no zones
|
||||
} else if board_name.starts_with("GX502")
|
||||
|| board_name.starts_with("GX701")
|
||||
|| board_name.starts_with("G531")
|
||||
|| board_name.starts_with("GL531")
|
||||
|| board_name.starts_with("G532")
|
||||
{
|
||||
laptop.supported_modes = vec![
|
||||
SINGLE, BREATHING, STROBE, RAINBOW, STAR, RAIN, HIGHLIGHT, LASER, RIPPLE, PULSE, COMET,
|
||||
FLASH, RGB,
|
||||
];
|
||||
} else if board_name.starts_with("G531")
|
||||
|| board_name.starts_with("G731")
|
||||
{
|
||||
laptop.supported_modes = vec![
|
||||
SINGLE, BREATHING, STROBE, RAINBOW, STAR, RAIN, HIGHLIGHT, LASER, RIPPLE, PULSE, COMET,
|
||||
FLASH, MULTISTATIC, RGB,
|
||||
];
|
||||
// RGB, limited effects, no zones
|
||||
} else if board_name.starts_with("G512LI") || board_name.starts_with("G712LI") {
|
||||
laptop.supported_modes = vec![SINGLE, BREATHING, STROBE, RAINBOW, PULSE];
|
||||
|
||||
@@ -83,12 +83,28 @@ where
|
||||
/// Should only be used if the bytes you are writing are verified correct
|
||||
#[inline]
|
||||
async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> {
|
||||
println!("1 Wrote: {:X?}", message);
|
||||
match unsafe { self.handle.as_ref() }.write_interrupt(
|
||||
self.led_endpoint,
|
||||
message,
|
||||
Duration::from_millis(5),
|
||||
) {
|
||||
Ok(_) => {}
|
||||
Ok(_) => {
|
||||
let mut buf = [0; 32];
|
||||
match unsafe { self.handle.as_ref() }.read_interrupt(
|
||||
0x83,
|
||||
&mut buf,
|
||||
Duration::from_millis(5),
|
||||
) {
|
||||
Ok(_) => {
|
||||
println!("2 Read: {:X?}", buf);
|
||||
}
|
||||
Err(err) => match err {
|
||||
rusb::Error::Timeout => {}
|
||||
_ => error!("Failed to read to led interrupt: {:?}", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
Err(err) => match err {
|
||||
rusb::Error::Timeout => {}
|
||||
_ => error!("Failed to write to led interrupt: {:?}", err),
|
||||
|
||||
Reference in New Issue
Block a user