Am 01.10.24 um 00:37 schrieb Alexander:
Hi, I've recently been trying to add support for gaming features to my Nitro AN17-41 laptop. in particular, I was interested in the "mode/turbo" button, which changes the CPU/GPU overclocking and fan control from the HW. Looking through the ACPI tables and WMI methods, I realized that this support was already provided for Predator series in the `acer-wmi` driver. But it currently ignores AC adapter plug/unplug events. I have found relevant WMI events that are currently ignored: [352418.426647] acer-wmi: Unknown function number - 8 - 0 [352418.426647] acer-wmi: Unknown function number - 9 - 0 After fiddling a bit more, I now know how to trigger these events and what their values mean: * Event 8: triggered every time when AC adapter is plugged in or unplugged. It also triggered when charging via a USB PD adapter. Values: 0 - not charging 1 - standard AC charging 4 - charging via USB-PD * Event 9: triggered when HW detects that it is being powered via a reliable adapter. It also somehow coordinates with the result of the WMI method `GetGamingSysInfo(ACER_WMID_CMD_GET_PREDATOR_V4_BAT_STATUS)`. In most cases this event fires at the same time as the previous event, but in some cases (USB-PD charging, or AC charging when the battery is low) this event fires later, when the battery is charged to a certain level and the AC adapter is connected. I assume this event means "allow turbo mode". Values: 0 - turbo mode is not allowed 1 - turbo mode is allowed. This can be used to automatically switch to the appropriate mode. I can work on this and submit a patch, but I struggling to find what has to be done here. Questions: 1. Is it allowed to change supported platform profile modes at runtime? Suppose I set or clear bits in the `platform_profile_handler.choices` when these events fire, so that userspace can know what modes are currently available. Is it allowed, and if so, do I need to use additional locking mechanisms? 2. Do I even need to export this specific HW state ("reliable-AC-adapter-and-good-battery") via sysfs?
Hi, the documentation at https://docs.kernel.org/userspace-api/sysfs-platform_profile.html says: "It is explicitly NOT a goal of this API to let userspace know about any sub-optimal conditions which are impeding reaching the requested performance level." So i think the acer-wmi driver should automatically switch to turbo mode if: 1. Turbo mode is currently selected. 2. It receives event 9 indicating that it can switch to turbo mode. I think commit d23430233494 ("platform/x86: hp-wmi: Fix platform profile option switch bug on Omen and Victus laptops") might be a good example on what to do in such a situation. Exporting the availability of turbo mode via sysfs is optional. Please note that you cannot modify platform_profile_handler.choices at runtime, so you have to "hide" such things like "cannot reach turbo mode yet" from userspace. Thanks, Armin Wolf