Re: [PATCH v3 2/2] platform/x86: acer-wmi: add fan speed monitoring for Predator PHN16-71

From: Ilpo Järvinen
Date: Thu Nov 23 2023 - 10:32:06 EST


On Fri, 24 Nov 2023, SungHwan Jung wrote:

> Support CPU and GPU fan speed monitoring through WMI for Predator
> PHN16-71.
>
> This patch depends on patch "platform/x86: acer-wmi: Add platform
> profile and mode key support for Predator PHN16-71"
>
> "select ACPI_VIDEO" cause recursive dependency and it is not recommended
> to use "select" for visible symbol, "select" has changed to "depends on".
>
> Signed-off-by: SungHwan Jung <onenowy@xxxxxxxxx>
> ---
> drivers/platform/x86/Kconfig | 3 +-
> drivers/platform/x86/acer-wmi.c | 98 ++++++++++++++++++++++++++++++++-
> 2 files changed, 99 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 7e69fdacc..33ddb644e 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -177,7 +177,8 @@ config ACER_WMI
> depends on INPUT
> depends on RFKILL || RFKILL = n
> depends on ACPI_WMI
> - select ACPI_VIDEO
> + depends on HWMON
> + depends on ACPI_VIDEO
> select INPUT_SPARSEKMAP
> select LEDS_CLASS
> select NEW_LEDS
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index e3650dce0..f2f3b1c45 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> static const struct key_entry acer_wmi_keymap[] __initconst = {
> @@ -241,6 +244,7 @@ struct hotkey_function_type_aa {
> #define ACER_CAP_TURBO_LED BIT(8)
> #define ACER_CAP_TURBO_FAN BIT(9)
> #define ACER_CAP_PLATFORM_PROFILE BIT(10)
> +#define ACER_CAP_FAN_SPEED_READ BIT(11)

It would be nice to align these with tabs.

> @@ -1722,6 +1727,25 @@ static int acer_gsensor_event(void)
> return 0;
> }
>
> +static int acer_get_fan_speed(int fan)
> +{
> + if (quirks->predator_v4) {
> + acpi_status status;
> + u64 fanspeed;
> +
> + status = WMI_gaming_execute_u64(
> + ACER_WMID_GET_GAMING_SYS_INFO_METHODID,
> + fan == 0 ? ACER_WMID_CMD_GET_PREDATOR_V4_CPU_FAN_SPEED :
> + ACER_WMID_CMD_GET_PREDATOR_V4_GPU_FAN_SPEED,
> + &fanspeed);
> +
> + if (ACPI_FAILURE(status))
> + return -EIO;
> + return fanspeed >> 8;

Define a named field using GENMASK() and use FIELD_GET() ?


--
i.