-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UX8406 (Zenbook Duo 2024) support #25
Comments
Here's my keyboard work so far (from my post on a NixOS forum thread)
|
Excellent work! I applied this patch to my kernel though and didn't experience working hotkeys over bluetooth... in fact no keys were working. I checked the logs and it seems that when connecting the bluetooth keyboard, the hid data failed to parse...
This seems related to the tweak you've made to |
Strange. I just tried applying the patch directly myself, and the keyboard with hotkeys worked fine, but the touchpad wasn't showing up... Are you able to upload the contents of all files matching |
On the topic of power profiles, here's a patch that should get them working. The firmware API seems to match the Vivobook Pro 16X 2023 (K6604). I'm actually pretty happy with this, so I guess it's time to learn how to send a kernel patch upstream 😅 . Click to expandFrom 2f8f8e6bb2da47c677a07f76f141c527ddd5d51c Mon Sep 17 00:00:00 2001
From: hacker1024 <[email protected]>
Date: Fri, 12 Apr 2024 13:59:24 +1000
Subject: [PATCH] asus-wmi: Add additional DEVID_THROTTLE_THERMAL_POLICY
---
drivers/platform/x86/asus-wmi.c | 102 +++++++++++++++------
include/linux/platform_data/x86/asus-wmi.h | 1 +
2 files changed, 76 insertions(+), 27 deletions(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 18be35fdb381..c7958b31dae0 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -93,9 +93,13 @@ module_param(fnlock_default, bool, 0444);
#define ASUS_FAN_BOOST_MODE_SILENT_MASK 0x02
#define ASUS_FAN_BOOST_MODES_MASK 0x03
+#define ASUS_THROTTLE_THERMAL_POLICY_COUNT 3
#define ASUS_THROTTLE_THERMAL_POLICY_DEFAULT 0
#define ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST 1
#define ASUS_THROTTLE_THERMAL_POLICY_SILENT 2
+#define ASUS_THROTTLE_THERMAL_POLICY_LITE_DEFAULT 0
+#define ASUS_THROTTLE_THERMAL_POLICY_LITE_OVERBOOST 2
+#define ASUS_THROTTLE_THERMAL_POLICY_LITE_SILENT 1
#define USB_INTEL_XUSB2PR 0xD0
#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
@@ -282,6 +286,7 @@ struct asus_wmi {
bool kbd_rgb_state_available;
bool throttle_thermal_policy_available;
+ bool throttle_thermal_policy_lite;
u8 throttle_thermal_policy_mode;
bool cpu_fan_curve_available;
@@ -3404,6 +3409,14 @@ static int throttle_thermal_policy_check_present(struct asus_wmi *asus)
err = asus_wmi_get_devstate(asus,
ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY,
&result);
+ if (err == -ENODEV) {
+ err = asus_wmi_get_devstate(asus,
+ ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_LITE,
+ &result);
+ asus->throttle_thermal_policy_lite = true;
+ } else {
+ asus->throttle_thermal_policy_lite = false;
+ }
if (err) {
if (err == -ENODEV)
return 0;
@@ -3424,7 +3437,10 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
value = asus->throttle_thermal_policy_mode;
- err = asus_wmi_set_devstate(ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY,
+ err = asus_wmi_set_devstate(
+ asus->throttle_thermal_policy_lite
+ ? ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_LITE
+ : ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY,
value, &retval);
sysfs_notify(&asus->platform_device->dev.kobj, NULL,
@@ -3466,7 +3482,7 @@ static int throttle_thermal_policy_switch_next(struct asus_wmi *asus)
u8 new_mode = asus->throttle_thermal_policy_mode + 1;
int err;
- if (new_mode > ASUS_THROTTLE_THERMAL_POLICY_SILENT)
+ if (new_mode > ASUS_THROTTLE_THERMAL_POLICY_COUNT - 1)
new_mode = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT;
asus->throttle_thermal_policy_mode = new_mode;
@@ -3505,7 +3521,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev,
if (result < 0)
return result;
- if (new_mode > ASUS_THROTTLE_THERMAL_POLICY_SILENT)
+ if (new_mode > ASUS_THROTTLE_THERMAL_POLICY_COUNT - 1)
return -EINVAL;
asus->throttle_thermal_policy_mode = new_mode;
@@ -3536,18 +3552,34 @@ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof,
tp = asus->throttle_thermal_policy_mode;
- switch (tp) {
- case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT:
- *profile = PLATFORM_PROFILE_BALANCED;
- break;
- case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST:
- *profile = PLATFORM_PROFILE_PERFORMANCE;
- break;
- case ASUS_THROTTLE_THERMAL_POLICY_SILENT:
- *profile = PLATFORM_PROFILE_QUIET;
- break;
- default:
- return -EINVAL;
+ if (!asus->throttle_thermal_policy_lite) {
+ switch (tp) {
+ case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT:
+ *profile = PLATFORM_PROFILE_BALANCED;
+ break;
+ case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST:
+ *profile = PLATFORM_PROFILE_PERFORMANCE;
+ break;
+ case ASUS_THROTTLE_THERMAL_POLICY_SILENT:
+ *profile = PLATFORM_PROFILE_QUIET;
+ break;
+ default:
+ return -EINVAL;
+ }
+ } else {
+ switch (tp) {
+ case ASUS_THROTTLE_THERMAL_POLICY_LITE_DEFAULT:
+ *profile = PLATFORM_PROFILE_BALANCED;
+ break;
+ case ASUS_THROTTLE_THERMAL_POLICY_LITE_OVERBOOST:
+ *profile = PLATFORM_PROFILE_PERFORMANCE;
+ break;
+ case ASUS_THROTTLE_THERMAL_POLICY_LITE_SILENT:
+ *profile = PLATFORM_PROFILE_QUIET;
+ break;
+ default:
+ return -EINVAL;
+ }
}
return 0;
@@ -3561,18 +3593,34 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof,
asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
- switch (profile) {
- case PLATFORM_PROFILE_PERFORMANCE:
- tp = ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST;
- break;
- case PLATFORM_PROFILE_BALANCED:
- tp = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT;
- break;
- case PLATFORM_PROFILE_QUIET:
- tp = ASUS_THROTTLE_THERMAL_POLICY_SILENT;
- break;
- default:
- return -EOPNOTSUPP;
+ if (!asus->throttle_thermal_policy_lite) {
+ switch (profile) {
+ case PLATFORM_PROFILE_PERFORMANCE:
+ tp = ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST;
+ break;
+ case PLATFORM_PROFILE_BALANCED:
+ tp = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT;
+ break;
+ case PLATFORM_PROFILE_QUIET:
+ tp = ASUS_THROTTLE_THERMAL_POLICY_SILENT;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+ } else {
+ switch (profile) {
+ case PLATFORM_PROFILE_PERFORMANCE:
+ tp = ASUS_THROTTLE_THERMAL_POLICY_LITE_OVERBOOST;
+ break;
+ case PLATFORM_PROFILE_BALANCED:
+ tp = ASUS_THROTTLE_THERMAL_POLICY_LITE_DEFAULT;
+ break;
+ case PLATFORM_PROFILE_QUIET:
+ tp = ASUS_THROTTLE_THERMAL_POLICY_LITE_SILENT;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
}
asus->throttle_thermal_policy_mode = tp;
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index ab1c7deff118..ddf5b3766cd2 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -64,6 +64,7 @@
#define ASUS_WMI_DEVID_SCREENPAD_LIGHT 0x00050032
#define ASUS_WMI_DEVID_FAN_BOOST_MODE 0x00110018
#define ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY 0x00120075
+#define ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_LITE 0x00110019
/* Misc */
#define ASUS_WMI_DEVID_PANEL_OD 0x00050019
--
2.44.0 Of course, if you don't want to bother with a kernel patch, you can do it over the CLI - # echo 0x00110019 > /sys/kernel/debug/asus-nb-wmi/dev_id
# echo 0x0 > /sys/kernel/debug/asus-nb-wmi/ctrl_param
# cat /sys/kernel/debug/asus-nb-wmi/devs Interestingly, there's another ACPI endpoint that relates to the fan. It seems to set the Intel Dynamic Platform and Thermal Framework OEM variable 3 and call an EC function based on the given argument (0-3) and fan setting. Search for Has anyone more experienced with ACPI, DPTF or ECs seen anything like this before? |
Following this! Thanks a lot for your work so far, @hacker1024 |
For point 3 I have had to make a patch for the new G14 and G16 also. This might also work here: I was about to submit this. If you test with extra DMI match, please let me know. |
Sweet! I'll take a look at this tonight, thanks. |
Please don't quote an entire patch. It makes it hard to read the post train. |
Updated patch: From 441d0ade8b01cc39c13a8c29f15e588c19754d54 Mon Sep 17 00:00:00 2001
From: "Luke D. Jones" <[email protected]>
Date: Mon, 13 May 2024 19:20:04 +1200
Subject: [PATCH] hid-asus: use hid for brightness control on keyboard
Signed-off-by: Luke D. Jones <[email protected]>
---
drivers/hid/hid-asus.c | 18 +++++++++++++-
drivers/platform/x86/asus-wmi.c | 3 ++-
include/linux/platform_data/x86/asus-wmi.h | 28 ++++++++++++++++++++++
3 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 02de2bf4f790..7dca9fe156e9 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -101,6 +101,7 @@ struct asus_kbd_leds {
unsigned int brightness;
spinlock_t lock;
bool removed;
+ int report_id;
};
struct asus_touchpad_info {
@@ -473,7 +474,7 @@ static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev)
static void asus_kbd_backlight_work(struct work_struct *work)
{
struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
- u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
+ u8 buf[] = { led->report_id, 0xba, 0xc5, 0xc4, 0x00 };
int ret;
unsigned long flags;
@@ -492,12 +493,18 @@ static void asus_kbd_backlight_work(struct work_struct *work)
*/
static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
{
+ struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
u32 value;
int ret;
if (!IS_ENABLED(CONFIG_ASUS_WMI))
return false;
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_use_hidraw_led()) {
+ hid_info(hdev, "using hidraw for asus::kbd_backlight\n");
+ return false;
+ }
+
ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS,
ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);
@@ -507,6 +514,11 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT);
}
+static bool asus_kbd_is_input_led(void) {
+ return dmi_match(DMI_PRODUCT_NAME, "GU605")
+ || dmi_match(DMI_PRODUCT_NAME, "GA403");
+}
+
static int asus_kbd_register_leds(struct hid_device *hdev)
{
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -549,6 +561,10 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
if (!drvdata->kbd_backlight)
return -ENOMEM;
+ drvdata->kbd_backlight->report_id = FEATURE_KBD_REPORT_ID;
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_kbd_is_input_led())
+ drvdata->kbd_backlight->report_id = FEATURE_KBD_LED_REPORT_ID1;
+
drvdata->kbd_backlight->removed = false;
drvdata->kbd_backlight->brightness = 0;
drvdata->kbd_backlight->hdev = hdev;
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3f9b6285c9a6..a58df18a70ad 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1681,7 +1681,8 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
goto error;
}
- if (!kbd_led_read(asus, &led_val, NULL)) {
+ if (!kbd_led_read(asus, &led_val, NULL) && !asus_use_hidraw_led()) {
+ pr_info("using asus-wmi for asus::kbd_backlight\n");
asus->kbd_led_wk = led_val;
asus->kbd_led.name = "asus::kbd_backlight";
asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED;
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 3eb5cd6773ad..8c0ebb660299 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -160,4 +160,32 @@ static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1,
}
#endif
+/* To be used by both hid-asus and asus-wmi to determine which controls kbd_brightness */
+#if IS_REACHABLE(CONFIG_ASUS_WMI)
+static bool asus_use_hidraw_led(void) {
+ const char *product, *board;
+
+ product = dmi_get_system_info(DMI_PRODUCT_NAME);
+ if (!product)
+ return true;
+
+ if (strcmp(product, "ROG Zephyrus")
+ || strcmp(product, "ROG Strix")
+ || strcmp(product, "ROG Flow")
+ || strcmp(product, "GA403")
+ || strcmp(product, "GU605"))
+ return false;
+
+ board = dmi_get_system_info(DMI_PRODUCT_NAME);
+ if (!board)
+ return true;
+
+ return strcmp(board, "RC71L");
+}
+#else
+static inline bool asus_use_hidraw_led(void) {
+ return true;
+}
+#endif
+
#endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */
--
2.45.0 |
Hi @flukejones, |
As noted on the nix thread, the kernel 6.9.x series and beyond break the bottom screen on the Zenbook Duo. It also looks like this will not be fixed in the upcoming 6.10.x updates. |
The correct fix is to submit that patch upstream. |
Not so simple, I'm afraid: That patch is just a revert of a well-intentioned commit that happens to break the second screen. We'll have to wait for a true fix from Intel, and patch the kernel ourselves in the meantime. |
Well that is unfortunate. Has anyone actually filed a bug upstream for it, or notified the people who commited the work? |
For those like me who are not comfortable building/compiling their own kernel: |
Yes -- I have both filed a bug upstream (https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11488) and reached out to the author Haridhar. |
The patch doesn't apply for
Context
kernelPackages = pkgs.linuxPackages_6_9;
kernelPatches = [
# Fixes second display being permanently black.
# Ref: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11488
{
name = "zenbook-i915-revert-93cbc1ac";
patch = ./zenbook-i915-revert-93cbc1accbcec2740231755774420934658e2b18.patch;
}
# Fixes thermal policy and keyboard backlight.
# Ref: https://github.com/flukejones/asusctl/issues/25
{
name = "thermal-policy";
patch = ./thermal-policy-2f8f8e6bb2da47c677a07f76f141c527ddd5d51c.patch;
}
{
name = "keyboard-backlight";
patch = ./keyboard-backlight-441d0ade8b01cc39c13a8c29f15e588c19754d54.patch;
}
];
blacklistedKernelModules = [
"asus_nb_wmi" # Kills the Wi-Fi any time I connect the keyboard
]; |
You might want to check that the patch file you're trying to apply hasn't
had all the tab characters replaced with spaces. I had that issue when
copying this patch from this thread originally, but, save for that issue,
it applies to 6.9 cleanly in my experience.
Le jeu. 18 juil. 2024, 21:55, Tomas Sandven ***@***.***> a
écrit :
… On the topic of power profiles, here's a patch that should get them
working ...
The patch doesn't apply for linuxPackages_6_9:
applying patch /nix/store/qb9757a421isfvxii2isnv131g8b7sk0-thermal-policy-2f8f8e6bb2da47c677a07f76f141c527ddd5d51c.patch
patching file drivers/platform/x86/asus-wmi.c
Hunk #1 FAILED at 93.
Hunk #2 FAILED at 282.
Hunk #3 FAILED at 3404.
Hunk #4 FAILED at 3424.
Hunk #5 FAILED at 3466.
Hunk #6 FAILED at 3505.
Hunk #7 FAILED at 3536.
Hunk #8 FAILED at 3561.
8 out of 8 hunks FAILED -- saving rejects to file drivers/platform/x86/asus-wmi.c.rej
patching file include/linux/platform_data/x86/asus-wmi.h
Hunk #1 succeeded at 64 with fuzz 2.
------------------------------
Context
kernelPackages = pkgs.linuxPackages_6_9;
kernelPatches = [
# Fixes second display being permanently black.
# Ref: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11488
{
name = "zenbook-i915-revert-93cbc1ac";
patch = ./zenbook-i915-revert-93cbc1accbcec2740231755774420934658e2b18.patch;
}
# Fixes thermal policy and keyboard backlight.
# Ref: #25
{
name = "thermal-policy";
patch = ./thermal-policy-2f8f8e6bb2da47c677a07f76f141c527ddd5d51c.patch;
}
{
name = "keyboard-backlight";
patch = ./keyboard-backlight-441d0ade8b01cc39c13a8c29f15e588c19754d54.patch;
}
];
blacklistedKernelModules = [
"asus_nb_wmi" # Kills the Wi-Fi any time I connect the keyboard
];
—
Reply to this email directly, view it on GitHub
<#25 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAWHVKKNGRAPZYQD74AUXDZNAMQNAVCNFSM6AAAAABF4JD5F2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZXGQ2TINBWGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Patch for the second display seems to be merged upstream in 6.10. Currently on 6.10.10 (Arch) and the display works out of the box.
I just got my Zenbook back from warranty service for a broken motherboard (dead second display output, and unstable GPU), so I am unsure if this is due to some hardware change, or the new kernel, but I would rather guess the kernel. |
I updated my kernel yesterday, can confirm. Both screens work now, and there's a phantom screen "Unknown-1" that I needed to disable in my Hyprland config to stop my windows from disappearing 😄 |
I've also experienced the Unknown-1 display, but I believe it might have correlated with an upgrade to linux-firmware-20240909 release, rather than a kernel upgrade. Note that firmware 20240811 had another bug preventing the secondary display from functioning, though. |
a couple of points to add: I submitted a few patches to alesyas zenbook github that handles the screens and keyboard on/off really well, as well as some compatibility fixes for both duo and the brightness-sync service. Sound for me is quirkier. Whenever I boot from windows 11 into fedora 40 silverblue I get no sound output from the built-in speakers. Same for fedora silverblue 41 beta. BUT if I reboot to 41 then again to 40 sound works for me? and continues to work between reboots until I boot back into windows for a bit, then I need to boot into 41 once, then back to 40. weird. And of course bottom touch registers on top and no keyboard backlight yet. :-( |
For the sound, I have found that you can just mute and then unmute the sound again, and it should start working. Worked for me every time actually.
And yeah Keyboard backlight will probably have to be fixed in the kernel, no update on that yet... |
You are a genius! That works perfectly with fedora 41 with kernel 6.11.0-63. Thanks!
|
There seems to be an open PR for the keyboard backlight on the duo backlight utility: alesya-h/zenbook-duo-2024-ux8406ma-linux#12 The code might be helpful for patching it in the kernel/asusctl. It's using libusb to interact with the keyboard, but doesnt appear to work for Bluetooth. |
I'm creating this umbrella issue to discuss all features UX8406-related.
To start, here's a list of known issues:
Keyboard
Display
Power
The text was updated successfully, but these errors were encountered: