* [PATCH v2 0/1] hid-asus: use hid for keyboard brightness control @ 2024-06-07 4:05 Luke D. Jones 2024-06-07 4:05 ` [PATCH v2 1/1] hid-asus: use hid for brightness control on keyboard Luke D. Jones 0 siblings, 1 reply; 6+ messages in thread From: Luke D. Jones @ 2024-06-07 4:05 UTC (permalink / raw) To: jikos; +Cc: bentiss, linux-input, linux-kernel, Luke D. Jones Refactored V1 of patch to remove the report_id changing as it isn't required. Changelog: - V2 - Split patch in two (use hid, and change report_id) - Drop the report_id changing as not required - Use dmi_check_system() for DMI matching History: - https://lore.kernel.org/linux-input/20240528013959.14661-1-luke@ljones.dev/T/#u Luke D. Jones (1): hid-asus: use hid for brightness control on keyboard drivers/hid/hid-asus.c | 7 ++++ drivers/platform/x86/asus-wmi.c | 3 +- include/linux/platform_data/x86/asus-wmi.h | 45 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) -- 2.45.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/1] hid-asus: use hid for brightness control on keyboard 2024-06-07 4:05 [PATCH v2 0/1] hid-asus: use hid for keyboard brightness control Luke D. Jones @ 2024-06-07 4:05 ` Luke D. Jones 2024-06-07 23:24 ` Luke Jones 0 siblings, 1 reply; 6+ messages in thread From: Luke D. Jones @ 2024-06-07 4:05 UTC (permalink / raw) To: jikos; +Cc: bentiss, linux-input, linux-kernel, Luke D. Jones 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 | 7 ++++ drivers/platform/x86/asus-wmi.c | 3 +- include/linux/platform_data/x86/asus-wmi.h | 45 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 02de2bf4f790..0ed3708ef7e2 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -492,12 +492,19 @@ 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 && + dmi_check_system(asus_use_hid_led_dmi_ids)) { + 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..799d928c7d3d 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) && !dmi_check_system(asus_use_hid_led_dmi_ids)) { + 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..6ba0015e4386 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -4,6 +4,7 @@ #include <linux/errno.h> #include <linux/types.h> +#include <linux/dmi.h> /* WMI Methods */ #define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */ @@ -160,4 +161,48 @@ 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 + +static const struct dmi_system_id asus_use_hid_led_dmi_ids[] = { + { + .matches = { + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Zephyrus"), + }, + }, + { + .matches = { + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Strix"), + }, + }, + { + .matches = { + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Flow"), + }, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GA403"), + }, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GU605"), + }, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "RC71L"), + }, + }, + NULL, +}; + #endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */ -- 2.45.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] hid-asus: use hid for brightness control on keyboard 2024-06-07 4:05 ` [PATCH v2 1/1] hid-asus: use hid for brightness control on keyboard Luke D. Jones @ 2024-06-07 23:24 ` Luke Jones 2024-06-16 5:25 ` Luke Jones 0 siblings, 1 reply; 6+ messages in thread From: Luke Jones @ 2024-06-07 23:24 UTC (permalink / raw) To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel I thought this was finalised but I'm still getting conflicting reports. Please don't merge until I confirm the fix. On Fri, 7 Jun 2024, at 4:05 PM, Luke D. Jones wrote: > 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 | 7 ++++ > drivers/platform/x86/asus-wmi.c | 3 +- > include/linux/platform_data/x86/asus-wmi.h | 45 ++++++++++++++++++++++ > 3 files changed, 54 insertions(+), 1 deletion(-) > > diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c > index 02de2bf4f790..0ed3708ef7e2 100644 > --- a/drivers/hid/hid-asus.c > +++ b/drivers/hid/hid-asus.c > @@ -492,12 +492,19 @@ 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 && > + dmi_check_system(asus_use_hid_led_dmi_ids)) { > + 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..799d928c7d3d 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) && !dmi_check_system(asus_use_hid_led_dmi_ids)) { > + 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..6ba0015e4386 100644 > --- a/include/linux/platform_data/x86/asus-wmi.h > +++ b/include/linux/platform_data/x86/asus-wmi.h > @@ -4,6 +4,7 @@ > > #include <linux/errno.h> > #include <linux/types.h> > +#include <linux/dmi.h> > > /* WMI Methods */ > #define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */ > @@ -160,4 +161,48 @@ 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 > + > +static const struct dmi_system_id asus_use_hid_led_dmi_ids[] = { > + { > + .matches = { > + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Zephyrus"), > + }, > + }, > + { > + .matches = { > + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Strix"), > + }, > + }, > + { > + .matches = { > + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Flow"), > + }, > + }, > + { > + .matches = { > + DMI_MATCH(DMI_BOARD_NAME, "GA403"), > + }, > + }, > + { > + .matches = { > + DMI_MATCH(DMI_BOARD_NAME, "GU605"), > + }, > + }, > + { > + .matches = { > + DMI_MATCH(DMI_BOARD_NAME, "RC71L"), > + }, > + }, > + NULL, > +}; > + > #endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */ > -- > 2.45.1 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] hid-asus: use hid for brightness control on keyboard 2024-06-07 23:24 ` Luke Jones @ 2024-06-16 5:25 ` Luke Jones 2024-06-19 14:39 ` Jiri Kosina 0 siblings, 1 reply; 6+ messages in thread From: Luke Jones @ 2024-06-16 5:25 UTC (permalink / raw) To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel On Sat, 8 Jun 2024, at 11:24 AM, Luke Jones wrote: > I thought this was finalised but I'm still getting conflicting reports. > Please don't merge until I confirm the fix. This is ready for merge now. I have more confirmation that the single patch with no adjustment to report_id works well. > On Fri, 7 Jun 2024, at 4:05 PM, Luke D. Jones wrote: > > 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 | 7 ++++ > > drivers/platform/x86/asus-wmi.c | 3 +- > > include/linux/platform_data/x86/asus-wmi.h | 45 ++++++++++++++++++++++ > > 3 files changed, 54 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c > > index 02de2bf4f790..0ed3708ef7e2 100644 > > --- a/drivers/hid/hid-asus.c > > +++ b/drivers/hid/hid-asus.c > > @@ -492,12 +492,19 @@ 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 && > > + dmi_check_system(asus_use_hid_led_dmi_ids)) { > > + 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..799d928c7d3d 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) && !dmi_check_system(asus_use_hid_led_dmi_ids)) { > > + 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..6ba0015e4386 100644 > > --- a/include/linux/platform_data/x86/asus-wmi.h > > +++ b/include/linux/platform_data/x86/asus-wmi.h > > @@ -4,6 +4,7 @@ > > > > #include <linux/errno.h> > > #include <linux/types.h> > > +#include <linux/dmi.h> > > > > /* WMI Methods */ > > #define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */ > > @@ -160,4 +161,48 @@ 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 > > + > > +static const struct dmi_system_id asus_use_hid_led_dmi_ids[] = { > > + { > > + .matches = { > > + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Zephyrus"), > > + }, > > + }, > > + { > > + .matches = { > > + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Strix"), > > + }, > > + }, > > + { > > + .matches = { > > + DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Flow"), > > + }, > > + }, > > + { > > + .matches = { > > + DMI_MATCH(DMI_BOARD_NAME, "GA403"), > > + }, > > + }, > > + { > > + .matches = { > > + DMI_MATCH(DMI_BOARD_NAME, "GU605"), > > + }, > > + }, > > + { > > + .matches = { > > + DMI_MATCH(DMI_BOARD_NAME, "RC71L"), > > + }, > > + }, > > + NULL, > > +}; > > + > > #endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */ > > -- > > 2.45.1 > > > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] hid-asus: use hid for brightness control on keyboard 2024-06-16 5:25 ` Luke Jones @ 2024-06-19 14:39 ` Jiri Kosina 2024-06-25 15:02 ` Benjamin Tissoires 0 siblings, 1 reply; 6+ messages in thread From: Jiri Kosina @ 2024-06-19 14:39 UTC (permalink / raw) To: Luke Jones; +Cc: Benjamin Tissoires, linux-input, linux-kernel On Sun, 16 Jun 2024, Luke Jones wrote: > > I thought this was finalised but I'm still getting conflicting > > reports. Please don't merge until I confirm the fix. > > This is ready for merge now. I have more confirmation that the single > patch with no adjustment to report_id works well. Applied, thanks. -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] hid-asus: use hid for brightness control on keyboard 2024-06-19 14:39 ` Jiri Kosina @ 2024-06-25 15:02 ` Benjamin Tissoires 0 siblings, 0 replies; 6+ messages in thread From: Benjamin Tissoires @ 2024-06-25 15:02 UTC (permalink / raw) To: Jiri Kosina; +Cc: Luke Jones, linux-input, linux-kernel On Jun 19 2024, Jiri Kosina wrote: > On Sun, 16 Jun 2024, Luke Jones wrote: > > > > I thought this was finalised but I'm still getting conflicting > > > reports. Please don't merge until I confirm the fix. > > > > This is ready for merge now. I have more confirmation that the single > > patch with no adjustment to report_id works well. > > Applied, thanks. This patch should have been taken through the platform x86 tree [0]. I have now reverted it (and it was buggy, it failed to compile on linux-next). Cheers, Benjamin [0] https://lore.kernel.org/all/b0d8eebc-5abb-4ec0-898c-af7eedc730d9@redhat.com/ > > -- > Jiri Kosina > SUSE Labs > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-06-25 15:02 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-06-07 4:05 [PATCH v2 0/1] hid-asus: use hid for keyboard brightness control Luke D. Jones 2024-06-07 4:05 ` [PATCH v2 1/1] hid-asus: use hid for brightness control on keyboard Luke D. Jones 2024-06-07 23:24 ` Luke Jones 2024-06-16 5:25 ` Luke Jones 2024-06-19 14:39 ` Jiri Kosina 2024-06-25 15:02 ` Benjamin Tissoires
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox