summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/asus-wmi.c
AgeCommit message (Collapse)AuthorFilesLines
2024-03-12platform/x86: asus-wmi: Consider device is absent when the read is ~0Kai-Heng Feng1-1/+11
AAEON PICO-TGU4 board doesn't have any LED but there are bogus LED controls under /sys/class/leds: $ ls /sys/class/leds asus::kbd_backlight asus::lightbar platform::micmute The reason is that the ~0 read from asus_wmi_get_devstate() is treated as a valid state, in truth it means the device is absent. So filter out ~0 read to prevent bogus LED controls being created. Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240308053255.224496-1-kai.heng.feng@canonical.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-02-27Revert "platform/x86: asus-wmi: Support WMI event queue"Armin Wolf1-66/+5
This reverts commit 1a373d15e283937b51eaf5debf4fc31474c31436. The WMI core now takes care of draining the event queue if asus-wmi is not loaded, so the hacky event queue handling code is not needed anymore. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20240219115919.16526-6-W_Armin@gmx.de Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-24platform/x86: remove obsolete calls to ledtrig_audio_getHeiner Kallweit1-1/+0
Since 64f67b5240db ("leds: trigger: audio: Add an activate callback to ensure the initial brightness is set") the audio triggers have an activate callback which sets the LED brightness as soon as the (default) trigger is bound to the LED device. So we can remove the call to ledtrig_audio_get. Positive side effect: There's no code dependency to ledtrig-audio any longer, what allows to remove some Kconfig dependencies. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/daef7331-dcb4-4b3a-802e-656629486b4c@gmail.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-12-11Merge tag 'platform-drivers-x86-v6.7-3' into pdx86/for-nextHans de Goede1-0/+58
Back merge pdx86 fixes into pdx86/for-next for further WMI work depending on some of the fixes. platform-drivers-x86 for v6.7-3 Highlights: - asus-wmi: Solve i8042 filter resource handling, input, and suspend issues - wmi: Skip zero instance WMI blocks to avoid issues with some laptops - mlxbf-bootctl: Differentiate dev/production keys - platform/surface: Correct serdev related return value to avoid leaking errno into userspace - Error checking fixes The following is an automated shortlog grouped by driver: asus-wmi: - Change q500a_i8042_filter() into a generic i8042-filter - disable USB0 hub on ROG Ally before suspend - Filter Volume key presses if also reported via atkbd - Move i8042 filter install to shared asus-wmi code mellanox: - Add null pointer checks for devm_kasprintf() - Check devm_hwmon_device_register_with_groups() return value mlxbf-bootctl: - correctly identify secure boot with development keys surface: aggregator: - fix recv_buf() return value wmi: - Skip blocks with zero instances
2023-12-11platform/x86: asus-wmi: Convert to platform remove callback returning voidUwe Kleine-König1-3/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/639b9ffc18422fe59125893bd7909e8a73cffb72.1701726190.git.u.kleine-koenig@pengutronix.de Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-11-28platform/x86: asus-wmi: disable USB0 hub on ROG Ally before suspendLuke D. Jones1-0/+50
ASUS have worked around an issue in XInput where it doesn't support USB selective suspend, which causes suspend issues in Windows. They worked around this by adjusting the MCU firmware to disable the USB0 hub when the screen is switched off during the Microsoft DSM suspend path in ACPI. The issue we have with this however is one of timing - the call the tells the MCU to this isn't able to complete before suspend is done so we call this in a prepare() and add a small msleep() to ensure it is done. This must be done before the screen is switched off to prevent a variety of possible races. Further to this the MCU powersave option must also be disabled as it can cause a number of issues such as: - unreliable resume connection of N-Key - complete loss of N-Key if the power is plugged in while suspended Disabling the powersave option prevents this. Without this the MCU is unable to initialise itself correctly on resume. Signed-off-by: "Luke D. Jones" <luke@ljones.dev> Tested-by: Philip Mueller <philm@manjaro.org> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20231126230521.125708-2-luke@ljones.dev Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-11-23platform/x86: asus-wmi: Change q500a_i8042_filter() into a generic i8042-filterHans de Goede1-4/+4
Change asus_q500a_i8042_filter() into a generic i8042-filter, using a new filter_i8042_e1_extended_codes flag in the quirks struct to decide if e1 extended codes should be filtered out or not. This is a preparation patch for adding support for filtering volume key events being reported twice through both the PS/2 keyboard and asus-wmi. Note while modifying the code also drop the unnecessary unlikely() annotations, this is not in a hot path so those are not necessary. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20231120154235.610808-3-hdegoede@redhat.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-11-23platform/x86: asus-wmi: Move i8042 filter install to shared asus-wmi codeHans de Goede1-0/+8
asus-nb-wmi calls i8042_install_filter() in some cases, but it never calls i8042_remove_filter(). This means that a dangling pointer to the filter function is left after rmmod leading to crashes. Fix this by moving the i8042-filter installation to the shared asus-wmi code and also remove it from the shared code on driver unbind. Fixes: b5643539b825 ("platform/x86: asus-wmi: Filter buggy scan codes on ASUS Q500A") Cc: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20231120154235.610808-2-hdegoede@redhat.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-11-01Merge tag 'platform-drivers-x86-v6.7-1' of ↵Linus Torvalds1-0/+133
git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 Pull x86 platform driver updates from Ilpo Järvinen: - asus-wmi: Support for screenpad and solve brightness key press duplication - int3472: Eliminate the last use of deprecated GPIO functions - mlxbf-pmc: New HW support - msi-ec: Support new EC configurations - thinkpad_acpi: Support reading aux MAC address during passthrough - wmi: Fixes & improvements - x86-android-tablets: Detection fix and avoid use of GPIO private APIs - Debug & metrics interface improvements - Miscellaneous cleanups / fixes / improvements * tag 'platform-drivers-x86-v6.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (80 commits) platform/x86: inspur-platform-profile: Add platform profile support platform/x86: thinkpad_acpi: Add battery quirk for Thinkpad X120e platform/x86: wmi: Decouple WMI device removal from wmi_block_list platform/x86: wmi: Fix opening of char device platform/x86: wmi: Fix probe failure when failing to register WMI devices platform/x86: wmi: Fix refcounting of WMI devices in legacy functions platform/x86: wmi: Decouple probe deferring from wmi_block_list platform/x86/amd/hsmp: Fix iomem handling platform/x86: asus-wmi: Do not report brightness up/down keys when also reported by acpi_video platform/x86: thinkpad_acpi: replace deprecated strncpy with memcpy tools/power/x86/intel-speed-select: v1.18 release tools/power/x86/intel-speed-select: Use cgroup isolate for CPU 0 tools/power/x86/intel-speed-select: Increase max CPUs in one request tools/power/x86/intel-speed-select: Display error for core-power support tools/power/x86/intel-speed-select: No TRL for non compute domains tools/power/x86/intel-speed-select: turbo-mode enable disable swapped tools/power/x86/intel-speed-select: Update help for TRL tools/power/x86/intel-speed-select: Sanitize integer arguments platform/x86: acer-wmi: Remove void function return platform/x86/amd/pmc: Add dump_custom_stb module parameter ...
2023-10-18platform/x86: asus-wmi: Only map brightness codes when using asus-wmi ↵Hans de Goede1-11/+4
backlight control Older Asus laptops change the backlight level themselves and then send WMI events with different codes for different backlight levels. The asus-wmi.c code maps the entire range of codes reported on brightness down keypresses to an internal ASUS_WMI_BRN_DOWN code: define NOTIFY_BRNUP_MIN 0x11 define NOTIFY_BRNUP_MAX 0x1f define NOTIFY_BRNDOWN_MIN 0x20 define NOTIFY_BRNDOWN_MAX 0x2e if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX) code = ASUS_WMI_BRN_UP; else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX) code = ASUS_WMI_BRN_DOWN; This mapping is causing issues on new laptop models which actually send 0x2b events for printscreen presses and 0x2c events for capslock presses, which get translated into spurious brightness-down presses. This mapping is really only necessary when asus-wmi has registered a backlight-device for backlight control. In this case the mapping was used to decide to filter out the keypresss since in this case the firmware has already modified the brightness itself and instead of reporting a keypress asus-wmi will just report the new brightness value to userspace. OTOH when the firmware does not adjust the brightness itself then it seems to always report 0x2e for brightness-down presses and 0x2f for brightness up presses independent of the actual brightness level. So in this case the mapping of the code is not necessary and this translation actually leads to spurious brightness-down presses being send to userspace when pressing printscreen or capslock. Modify asus_wmi_handle_event_code() to only do the mapping when using asus-wmi backlight control to fix the spurious brightness-down presses. Reported-by: James John <me@donjajo.com> Closes: https://lore.kernel.org/platform-driver-x86/a2c441fe-457e-44cf-a146-0ecd86b037cf@donjajo.com/ Closes: https://bbs.archlinux.org/viewtopic.php?pid=2123716 Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20231017090725.38163-3-hdegoede@redhat.com
2023-09-12platform/x86: asus-wmi: add support for ASUS screenpadLuke D. Jones1-0/+133
Add support for the WMI methods used to turn off and adjust the brightness of the secondary "screenpad" device found on some high-end ASUS laptops like the GX650P series and others. There are some small quirks with this device when considering only the raw WMI methods: 1. The Off method can only switch the device off 2. Changing the brightness turns the device back on 3. To turn the device back on the brightness must be > 1 4. When the device is off the brightness can't be changed (so it is stored by the driver if device is off). 5. Booting with a value of 0 brightness (retained by bios) means the bios will set a value of >0 <15 6. When the device is off it is "unplugged" asus_wmi sets the minimum brightness as 20 in general use, and 60 for booting with values <= min. The ACPI methods are used in a new backlight device named asus_screenpad. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20230830032237.42987-2-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-08-30platform/x86: asus-wmi: corrections to egpu safety checkLuke D. Jones1-8/+7
An incorrect if statement was preventing the enablement of the egpu. Fixes: d49f4d1a30ac ("platform/x86: asus-wmi: don't allow eGPU switching if eGPU not connected") Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20230830022908.36264-2-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-08-23Merge remote-tracking branch 'pdx86/fixes' into pdx86/for-nextHans de Goede1-2/+12
Merge pdx86/fixes into pdx86/for-next because there are some pdx86 patches pending for the next release which build on top of some of the fixes.
2023-08-21platform/x86: asus-wmi: Fix support for showing middle fan RPMLuke D. Jones1-40/+38
After the addition of the mid fan custom curve functionality various incorrect behaviour was uncovered. This commit fixes these areas. - Ensure mid fan attributes actually use the correct fan ID - Correction to a bit mask for selecting the correct fan data - Refactor the curve show/store functions to be cleaner and match each others layout Fixes: 536fce82d729 ("platform/x86: asus-wmi: add support for showing middle fan RPM") Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20230815014209.44903-1-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2023-07-25platform/x86: asus-wmi: Fix setting RGB mode on some TUF laptopsKristian Angelov1-2/+12
This patch fixes setting the cmd values to 0xb3 and 0xb4. This is necessary on some TUF laptops in order to set the RGB mode. Closes: https://lore.kernel.org/platform-driver-x86/443078148.491022.1677576298133@nm83.abv.bg Signed-off-by: Kristian Angelov <kristiana2000@abv.bg> Reviewed-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/ZLlS7o6UdTUBkyqa@wyvern.localdomain Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-12platform/x86: asus-wmi: expose dGPU and CPU tunables for ROGLuke D. Jones1-0/+285
Expose various CPU and dGPU tunables that are available on many ASUS ROG laptops. The tunables shown in sysfs will vary depending on the CPU and dGPU vendor. All of these variables are write only and there is no easy way to find what the defaults are. In general they seem to default to the max value the vendor sets for the CPU and dGPU package - this is not the same as the min/max writable value. Values written to these variables that are beyond the capabilities of the CPU are ignored by the laptop. Signed-off-by: Luke D. Jones <luke@ljones.dev> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230630053552.976579-9-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-12platform/x86: asus-wmi: support setting mini-LED modeLuke D. Jones1-0/+53
Support changing the mini-LED mode on some of the newer ASUS laptops. Signed-off-by: Luke D. Jones <luke@ljones.dev> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230630053552.976579-8-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-12platform/x86: asus-wmi: add safety checks to gpu switchingLuke D. Jones1-0/+48
Add safety checking to dgpu_disable, egpu_enable, gpu_mux_mode. These checks prevent users from doing such things as: - disabling the dGPU while is muxed to drive the internal screen - enabling the eGPU which also disables the dGPU, while muxed to the internal screen - switching the MUX to dGPU while the dGPU is disabled Signed-off-by: Luke D. Jones <luke@ljones.dev> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230630053552.976579-7-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-12platform/x86: asus-wmi: don't allow eGPU switching if eGPU not connectedLuke D. Jones1-0/+9
Check the ASUS_WMI_DEVID_EGPU_CONNECTED method for eGPU connection before allowing the ASUS_WMI_DEVID_EGPU method to run. Signed-off-by: Luke D. Jones <luke@ljones.dev> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230630053552.976579-6-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-12platform/x86: asus-wmi: add WMI method to show if egpu connectedLuke D. Jones1-0/+21
Exposes the WMI method which tells if the eGPU is properly connected on the devices that support it. Signed-off-by: Luke D. Jones <luke@ljones.dev> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230630053552.976579-5-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-12platform/x86: asus-wmi: support middle fan custom curvesLuke D. Jones1-2/+75
Adds support for fan curves defined for the middle fan which is available on some ASUS ROG laptops. Signed-off-by: Luke D. Jones <luke@ljones.dev> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230630053552.976579-4-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-12platform/x86: asus-wmi: add support for showing middle fan RPMLuke D. Jones1-0/+91
Some newer ASUS ROG laptops now have a middle/center fan in addition to the CPU and GPU fans. This new fan typically blows across the heatpipes and VRMs betweent eh CPU and GPU. This commit exposes that fan to PWM control plus showing RPM. Signed-off-by: Luke D. Jones <luke@ljones.dev> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230630053552.976579-3-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-12platform/x86: asus-wmi: add support for showing charger modeLuke D. Jones1-0/+21
Expose a WMI method in sysfs platform for showing which connected charger the laptop is currently using. Signed-off-by: Luke D. Jones <luke@ljones.dev> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230630053552.976579-2-luke@ljones.dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-01-24platform/x86: asus-wmi: Fix kbd_dock_devid tablet-switch reportingHans de Goede1-5/+12
Commit 1ea0d3b46798 ("platform/x86: asus-wmi: Simplify tablet-mode-switch handling") unified the asus-wmi tablet-switch handling, but it did not take into account that the value returned for the kbd_dock_devid WMI method is inverted where as the other ones are not inverted. This causes asus-wmi to report an inverted tablet-switch state for devices which use the kbd_dock_devid, which causes libinput to ignore touchpad events while the affected T10x model 2-in-1s are docked. Add inverting of the return value in the kbd_dock_devid case to fix this. Fixes: 1ea0d3b46798 ("platform/x86: asus-wmi: Simplify tablet-mode-switch handling") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230120143441.527334-1-hdegoede@redhat.com
2023-01-12platform/x86: asus-wmi: Don't load fan curves without fanThomas Weißschuh1-0/+3
If we do not have a fan it does not make sense to load curves for it. This removes the following warnings from the kernel log: asus_wmi: fan_curve_get_factory_default (0x00110024) failed: -19 asus_wmi: fan_curve_get_factory_default (0x00110025) failed: -19 Fixes: a2bdf10ce96e ("platform/x86: asus-wmi: Increase FAN_CURVE_BUF_LEN to 32") Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20221221-asus-fan-v1-3-e07f3949725b@weissschuh.net Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-01-12platform/x86: asus-wmi: Add quirk wmi_ignore_fanThomas Weißschuh1-1/+3
Some laptops have a fan device listed in their ACPI tables but do not actually contain a fan. Introduce a quirk that can be used to override the fan detection logic. This was observed with a ASUS VivoBook E410MA running firmware E410MAB.304. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20221221-asus-fan-v1-1-e07f3949725b@weissschuh.net Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-11-16ACPI: battery: Pass battery hook pointer to hook callbacksArmin Wolf1-2/+2
Right now, is impossible for battery hook callbacks to access instance-specific data, forcing most drivers to provide some sort of global state. This however is difficult for drivers which can be instantiated multiple times and/or are hotplug-capable. Pass a pointer to the battery hook to those callbacks for usage with container_of(). Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://lore.kernel.org/r/20220927204521.601887-2-W_Armin@gmx.de Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-11-15platform/x86: asus-wmi: add missing pci_dev_put() in asus_wmi_set_xusb2pr()Xiongfeng Wang1-0/+2
pci_get_device() will increase the reference count for the returned pci_dev. We need to use pci_dev_put() to decrease the reference count before asus_wmi_set_xusb2pr() returns. Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Link: https://lore.kernel.org/r/20221111100752.134311-1-wangxiongfeng2@huawei.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-09-19platform/x86: asus-wmi: Expand support of GPU fan to read RPM and labelLuke D. Jones1-2/+34
The previously added patch to add support for pwm change for TUF laptops also is usuable for more than TUF. The same method `0x00110014` is used to read the fan RPM. Add two extra attributes for reading fan2 plus fan2 label. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220916004623.10992-1-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-09-10platform/x86: asus-wmi: Make kbd_rgb_mode_groups staticHans de Goede1-1/+1
kbd_rgb_mode_groups is only used inside asus-wmi.c, make it static. Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20220909210950.385398-1-hdegoede@redhat.com
2022-09-05Merge tag 'backlight-detect-refactor-1' into review-hansHans de Goede1-13/+0
Immutable backlight-detect-refactor branch between acpi, drm-* and pdx86 Tag (immutable branch) with v6.0-rc1 + the (acpi/x86) backlight detect refactor work. For merging into the acpi, drm-* and pdx86 subsystems.
2022-09-03platform/x86: asus-wmi: Move acpi_backlight=native quirks to ACPI video_detect.cHans de Goede1-3/+0
Remove the asus-wmi quirk_entry.wmi_backlight_native quirk-flag, which called acpi_video_set_dmi_backlight_type(acpi_backlight_native) and replace it with acpi/video_detect.c video_detect_dmi_table[] entries using the video_detect_force_native callback. acpi_video_set_dmi_backlight_type() is troublesome because it may end up getting called after other backlight drivers have already called acpi_video_get_backlight_type() resulting in the other drivers already being registered even though they should not. Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-09-03platform/x86: asus-wmi: Move acpi_backlight=vendor quirks to ACPI video_detect.cHans de Goede1-3/+0
Remove the asus-wmi quirk_entry.wmi_backlight_power quirk-flag, which called acpi_video_set_dmi_backlight_type(acpi_backlight_vendor) and replace it with acpi/video_detect.c video_detect_dmi_table[] entries using the video_detect_force_vendor callback. acpi_video_set_dmi_backlight_type() is troublesome because it may end up getting called after other backlight drivers have already called acpi_video_get_backlight_type() resulting in the other drivers already being registered even though they should not. Note no entries are dropped from the dmi_system_id table in asus-nb-wmi.c. This is because the entries using the removed wmi_backlight_power flag also use other model specific quirks from the asus-wmi quirk_entry struct. So the quirk_asus_x55u struct and the entries pointing to it cannot be dropped. Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-09-03platform/x86: asus-wmi: Drop DMI chassis-type check from backlight handlingHans de Goede1-7/+0
Remove this check from the asus-wmi backlight handling: /* Some Asus desktop boards export an acpi-video backlight interface, stop this from showing up */ chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE); if (chassis_type && !strcmp(chassis_type, "3")) acpi_video_set_dmi_backlight_type(acpi_backlight_vendor); This acpi_video_set_dmi_backlight_type(acpi_backlight_vendor) call must be removed because other changes in this series change the native backlight drivers to no longer unconditionally register their backlight. Instead these drivers now do this check: if (acpi_video_get_backlight_type(false) != acpi_backlight_native) return 0; /* bail */ So leaving this in place can break things on laptops with a broken DMI chassis-type, which would have GPU native brightness control before the addition of the acpi_video_get_backlight_type() != native check. Removing this should be ok now, since the ACPI video code has improved heuristics for this itself now (which includes a chassis-type check). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-09-01platform/x86: asus-wmi: Increase FAN_CURVE_BUF_LEN to 32Luke D. Jones1-5/+4
Fix for TUF laptops returning with an -ENOSPC on calling asus_wmi_evaluate_method_buf() when fetching default curves. The TUF method requires at least 32 bytes space. This also moves and changes the pr_debug() in fan_curve_check_present() to pr_warn() in fan_curve_get_factory_default() so that there is at least some indication in logs of why it fails. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220828074638.5473-1-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-26platform/x86: asus-wmi: Fix the name of the mic-mute LED classdevPaddyKP_Yao1-1/+1
According to well-known-leds.txt, we should use "platform::micmute" instead of "asus::micmute" for the name of the mic-mute LED classdev. Signed-off-by: PaddyKP_Yao <PaddyKP_Yao@asus.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20220825004305.709539-1-PaddyKP_Yao@asus.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-26platform/x86: asus-wmi: Implement TUF laptop keyboard power statesLuke D. Jones1-0/+57
Adds support for setting various power states of TUF keyboards. These states are combinations of: - boot, set if a boot animation is shown on keyboard - awake, set if the keyboard LEDs are visible while laptop is on - sleep, set if an animation is displayed while the laptop is suspended - keyboard (unknown effect) Adds two sysfs attributes to asus::kbd_backlight: - kbd_rgb_state - kbd_rgb_state_index Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220825232251.345893-3-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-26platform/x86: asus-wmi: Implement TUF laptop keyboard LED modesLuke D. Jones1-1/+73
Adds support for changing the laptop keyboard LED mode and colour. The modes are visible effects such as static, rainbow, pulsing, colour cycles. These sysfs attributes are added to asus::kbd_backlight: - kbd_rgb_mode - kbd_rgb_mode_index Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220825232251.345893-2-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-26platform/x86: asus-wmi: Support the GPU fan on TUF laptopsLuke D. Jones1-0/+71
Add support for TUF laptops which have the ability to control the GPU fan. This will show as a second fan in hwmon, and has the ability to run as boost (fullspeed), or auto. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220826004210.356534-3-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-26platform/x86: asus-wmi: Modify behaviour of Fn+F5 fan keyLuke D. Jones1-6/+5
Some more recent TUF laptops have both fan_boost and thermal_throttle. The key code for Fn+F5 is also different and unmapped. This patch adjusts the asus_wmi_handle_event_code() match to match for both 0x99 and 0xAE, and run both mode switch functions for fan_boost and/or thermal_throttle if either are available. It is required that both are tried, as in some instances the ACPI set-method for one may not have any code body within it even though it was returned as supported by the get method. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220826004210.356534-2-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-25platform/x86: asus-wmi: Simplify tablet-mode-switch handlingHans de Goede1-62/+14
Simplify tablet-mode-switch handling: 1. The code is the same for all variants, the only difference is the dev_id and notify event code. Store the dev_id + code in struct asus_wmi and unify the handling 2. Make the new unified asus_wmi_tablet_mode_get_state() check dev_id has been set and make it a no-op when not set. This allows calling it unconditionally at resume/restore time 3. Simplify the tablet_mode_sw module-param handling, this also allows selecting the new lid-flip-rog type through the module-param. Cc: Luke D. Jones <luke@ljones.dev> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20220824151145.1448010-2-hdegoede@redhat.com
2022-08-25platform/x86: asus-wmi: Simplify tablet-mode-switch probingHans de Goede1-33/+22
The 3 different tablet-mode-switch initialization paths repeat a lot of the same code. Add a helper function for this. This also makes the error-handling for the kbd_dock_devid case consistent with the other 2 cases. Cc: Luke D. Jones <luke@ljones.dev> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20220824151145.1448010-1-hdegoede@redhat.com
2022-08-25platform/x86: asus-wmi: Add support for ROG X13 tablet modeLuke D. Jones1-0/+37
Add quirk for ASUS ROG X13 Flow 2-in-1 to enable tablet mode with lid flip (all screen rotations). Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220813092753.6635-2-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-25platform/x86: asus-wmi: Adjust tablet/lidflip handling to use enumLuke D. Jones1-14/+35
Due to multiple types of tablet/lidflip, the existing code for handling these events is refactored to use an enum for each type. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220813092753.6635-1-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-25platform/x86: asus-wmi: Support the hardware GPU MUX on some laptopsLuke D. Jones1-0/+51
Support the hardware GPU MUX switch available on some models. This switch can toggle the MUX between: - 0, Dedicated mode - 1, Optimus mode Optimus mode is the regular iGPU + dGPU available, while dedicated mode switches the system to have only the dGPU available. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220813092624.6228-1-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-25platform/x86: asus-wmi: Simplify some of the *_check_present() helpersHans de Goede1-44/+3
After the recent cleanup patches, some of the *_check_present() helpers just propagate the result of asus_wmi_dev_is_present(). Replace these with direct asus_wmi_dev_is_present() calls as a further cleanup. Cc: Luke D. Jones <luke@ljones.dev> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20220815150538.474306-1-hdegoede@redhat.com
2022-08-25platform/x86: asus-wmi: Refactor panel_od attributeLuke D. Jones1-49/+25
The settings for these attributes can be read from the device, this is now done instead of reading a stored value from module. The stored value is also removed. This means the simpler asus_wmi_dev_is_present() can be used in *_check_present() - it is not an error for these methods to be missing. The _write() functions have their bodies shifted in to *_store() which simplifies things further. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220812222509.292692-7-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-25platform/x86: asus-wmi: Refactor egpu_enable attributeLuke D. Jones1-58/+26
The settings for these attributes can be read from the device, this is now done instead of reading a stored value from module. The stored value is also removed. This means the simpler asus_wmi_dev_is_present() can be used in *_check_present() - it is not an error for these methods to be missing. The _write() functions have their bodies shifted in to *_store() which simplifies things further. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220812222509.292692-6-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-25platform/x86: asus-wmi: Refactor disable_gpu attributeLuke D. Jones1-49/+24
The settings for these attributes can be read from the device, this is now done instead of reading a stored value from module. The stored value is also removed. This means the simpler asus_wmi_dev_is_present() can be used in *_check_present() - it is not an error for these methods to be missing. The _write() functions have their bodies shifted in to *_store() which simplifies things further. Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220812222509.292692-5-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-08-25platform/x86: asus-wmi: Use kobj_to_dev()ye xingchen1-2/+2
Use kobj_to_dev() instead of open-coding it. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> Link: https://lore.kernel.org/r/20220811013203.16010-1-ye.xingchen@zte.com.cn Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>