From: "Luke D. Jones" <luke@ljones.dev>
To: jikos@kernel.org
Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com,
corentin.chary@gmail.com, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
bentiss@kernel.org, "Luke D. Jones" <luke@ljones.dev>
Subject: [PATCH v1 1/2] hid-asus: use hid for brightness control on keyboard
Date: Wed, 29 May 2024 13:28:26 +1200 [thread overview]
Message-ID: <20240529012827.146005-2-luke@ljones.dev> (raw)
In-Reply-To: <20240529012827.146005-1-luke@ljones.dev>
On almost all ASUS ROG series laptops the MCU used for the USB keyboard
also has a HID packet used for setting the brightness. This is usually
the same as the WMI method. But in some laptops the WMI method either
is missing or doesn't work, so we should default to the HID control.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
drivers/hid/hid-asus.c | 6 ++++
drivers/platform/x86/asus-wmi.c | 35 +++++++++++++++++++++-
include/linux/platform_data/x86/asus-wmi.h | 10 +++++++
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 02de2bf4f790..4cba8e143031 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -492,12 +492,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_hid_led()) {
+ hid_info(hdev, "using HID 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);
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3f9b6285c9a6..54cb07c79fcf 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -144,6 +144,15 @@ module_param(fnlock_default, bool, 0444);
static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL };
+static const char * const use_hid_led_matches[] = {
+ "ROG Zephyrus",
+ "ROG Strix",
+ "ROG Flow",
+ "GA403",
+ "GU605",
+ "RC71L",
+};
+
static int throttle_thermal_policy_write(struct asus_wmi *);
static bool ashs_present(void)
@@ -1642,6 +1651,29 @@ static int micmute_led_set(struct led_classdev *led_cdev,
return err < 0 ? err : 0;
}
+bool asus_use_hid_led(void)
+{
+ const char *product, *board;
+ int i;
+
+ product = dmi_get_system_info(DMI_PRODUCT_FAMILY);
+ if (!product)
+ return false;
+
+ board = dmi_get_system_info(DMI_BOARD_NAME);
+ if (!board)
+ return false;
+
+ for (i = 0; i < ARRAY_SIZE(use_hid_led_matches); i++) {
+ if (strstr(product, use_hid_led_matches[i]))
+ return true;
+ if (strstr(board, use_hid_led_matches[i]))
+ return true;
+ }
+ return false;
+}
+EXPORT_SYMBOL_GPL(asus_use_hid_led);
+
static void asus_wmi_led_exit(struct asus_wmi *asus)
{
led_classdev_unregister(&asus->kbd_led);
@@ -1681,7 +1713,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_hid_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..6833035f7006 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -160,4 +160,14 @@ 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_ENABLED(CONFIG_ASUS_WMI)
+bool asus_use_hid_led(void);
+#else
+static inline bool asus_use_hid_led(void)
+{
+ return true;
+}
+#endif
+
#endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */
--
2.45.1
next prev parent reply other threads:[~2024-05-29 1:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 1:28 [PATCH v1 0/2] asus wmi and hid: use HID LED for brightness Luke D. Jones
2024-05-29 1:28 ` Luke D. Jones [this message]
2024-05-29 8:21 ` [PATCH v1 1/2] hid-asus: use hid for brightness control on keyboard Hans de Goede
2024-05-29 1:28 ` [PATCH v1 2/2] hid-asus: change the report_id used for HID LED control Luke D. Jones
2024-05-29 8:25 ` Hans de Goede
2024-05-29 9:27 ` Luke Jones
2024-05-29 15:28 ` [PATCH v1 0/2] asus wmi and hid: use HID LED for brightness Hans de Goede
2024-06-06 8:49 ` Benjamin Tissoires
2024-06-06 9:53 ` Hans de Goede
2024-06-06 21:02 ` Luke Jones
-- strict thread matches above, loose matches on Subject: below --
2024-05-29 1:24 [PATCH v1 1/2] hid-asus: use hid for brightness control on keyboard Luke D. Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240529012827.146005-2-luke@ljones.dev \
--to=luke@ljones.dev \
--cc=bentiss@kernel.org \
--cc=corentin.chary@gmail.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).