mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86: bitland-mifs-wmi: Cycle the platform profile on Fn+K
@ 2026-11-01 14:41 Chris Taraszka
  2026-11-01 16:23 ` Chris Taraszka
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Taraszka @ 2026-11-01 14:41 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, Mingyou Chen, Ilya Gladyshev,
	Armin Wolf, KentoNion, Chris Taraszka

On the Xiaomi Book Pro 14 (TM2424), Fn+K sends hotkey event 0x28 and
the firmware does not change SystemPerMode itself. The event is a
request that the vendor software acts on; without that software Fn+K
does nothing on Windows either, and on Linux it is currently logged as
an unknown event.

Add a quirk for this and call platform_profile_cycle() from the control
device when the event arrives, so Fn+K cycles through the profiles that
all platform profile handlers support. Models without the quirk keep
ignoring the event.

Suggested-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Chris Taraszka <chris@miget.com>
---

Notes:
    Tested on the Xiaomi Book Pro 14 (TM2424, BIOS XMAPT4B0P0A0A) on AC,
    with Mingyou's v15 and my two TM2424 patches, loaded on v7.3: four Fn+K
    presses step performance -> low-power -> balanced -> performance ->
    low-power. The bitland and SoC Power Slider handlers and SystemPerMode
    (EC 0x68) follow each press within a second, and power-profiles-daemon
    picks up the change.
    
    Depends on Mingyou Chen's v15 "Merge redmi-wmi into bitland-mifs-wmi" [1]
    and on my "platform/x86: bitland-mifs-wmi: Xiaomi Book Pro 14 support"
    v2 [2].
    
    [1] https://lore.kernel.org/all/20261028112742.674847-1-qby140326@gmail.com/
    [2] https://lore.kernel.org/all/20261025195456.43414-1-chris@miget.com/

 drivers/platform/x86/bitland-mifs-wmi.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
index a72569d810e3..8a994f5b089e 100644
--- a/drivers/platform/x86/bitland-mifs-wmi.c
+++ b/drivers/platform/x86/bitland-mifs-wmi.c
@@ -99,6 +99,9 @@ struct bitland_mifs_quirks {
 
 	bool return_code_at_end;
 	bool skip_ac_type_check;
+
+	/* Fn+K sends WMI_EVENT_PERFORMANCE_CYCLE and leaves the mode to the OS */
+	bool cycle_profile_on_key;
 };
 
 static const struct bitland_profile_entry default_profile_entries[] = {
@@ -125,6 +128,7 @@ static const struct bitland_mifs_quirks tm2424_quirks = {
 	.profile_entries = tm2424_profile_entries,
 	.num_profile_entries = ARRAY_SIZE(tm2424_profile_entries),
 	.skip_ac_type_check = true,
+	.cycle_profile_on_key = true,
 };
 
 static const struct dmi_system_id bitland_mifs_dmi_table[] = {
@@ -168,6 +172,7 @@ enum bitland_mifs_event_id {
 	WMI_EVENT_MIC_MUTE		= 33,
 	WMI_EVENT_RESERVED_23		= 34,
 	WMI_EVENT_OPEN_APP		= 35,
+	WMI_EVENT_PERFORMANCE_CYCLE	= 40,
 };
 
 enum bitland_mifs_event_type {
@@ -216,6 +221,7 @@ static BLOCKING_NOTIFIER_HEAD(bitland_notifier_list);
 enum bitland_notifier_actions {
 	BITLAND_NOTIFY_KBD_BRIGHTNESS,
 	BITLAND_NOTIFY_PLATFORM_PROFILE,
+	BITLAND_NOTIFY_PLATFORM_PROFILE_CYCLE,
 	BITLAND_NOTIFY_HWMON,
 };
 
@@ -792,6 +798,10 @@ static int bitland_notifier_callback(struct notifier_block *nb,
 	case BITLAND_NOTIFY_PLATFORM_PROFILE:
 		platform_profile_notify(data_ctx->pp_dev);
 		break;
+	case BITLAND_NOTIFY_PLATFORM_PROFILE_CYCLE:
+		if (data_ctx->pp_dev)
+			platform_profile_cycle();
+		break;
 	case BITLAND_NOTIFY_HWMON:
 		fan_info = data;
 
@@ -921,6 +931,7 @@ static void bitland_mifs_wmi_report_key(struct wmi_device *wdev, u32 payload)
 static void bitland_mifs_wmi_notify(struct wmi_device *wdev,
 				    const struct wmi_buffer *buffer)
 {
+	struct bitland_mifs_wmi_data *data = dev_get_drvdata(&wdev->dev);
 	const struct bitland_mifs_event *event = buffer->data;
 	struct bitland_fan_notify_data fan_data;
 	u8 brightness;
@@ -949,6 +960,15 @@ static void bitland_mifs_wmi_notify(struct wmi_device *wdev,
 					     NULL);
 		return;
 
+	case WMI_EVENT_PERFORMANCE_CYCLE:
+		if (!data->quirks->cycle_profile_on_key)
+			break;
+
+		blocking_notifier_call_chain(&bitland_notifier_list,
+					     BITLAND_NOTIFY_PLATFORM_PROFILE_CYCLE,
+					     NULL);
+		return;
+
 	/*
 	 * The device has 3 fans (CPU, GPU, SYS),
 	 * but there are only the CPU and GPU fan has events

base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8
prerequisite-patch-id: 99b10cd2b70d630ab65d8a8bb02c1d4bf89b1a63
prerequisite-patch-id: 27db041f827872b8be142c310a14c79962154bd5
prerequisite-patch-id: 74fc3298fa3dceb2224dfc3d2ae4cc6d4be61c01
prerequisite-patch-id: 254b8455d8a7f56b730e842207d91bd6904a50ce
prerequisite-patch-id: 9708c81da6b4ed6c2d47eb927efcd64ce4ed2ecf
prerequisite-patch-id: 2fe8c043993034f1a2cde98b1b2e299987d5ac7f
prerequisite-patch-id: 36137eee73ea8cee3db81af887f1f0859ef02b3a
prerequisite-patch-id: f0ba644539dc52241b96a74d6e32a6f06241e577
-- 
2.56.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform/x86: bitland-mifs-wmi: Cycle the platform profile on Fn+K
  2026-11-01 14:41 [PATCH] platform/x86: bitland-mifs-wmi: Cycle the platform profile on Fn+K Chris Taraszka
@ 2026-11-01 16:23 ` Chris Taraszka
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Taraszka @ 2026-11-01 16:23 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, Mingyou Chen, Ilya Gladyshev,
	Armin Wolf, KentoNion

This is now patch 4 of v3, please drop this one:
https://lore.kernel.org/all/20261101161814.1325847-1-chris@miget.com/

Thanks,
Chris


On Sun, Nov 1, 2026 at 3:41 PM Chris Taraszka <chris@miget.com> wrote:
>
> On the Xiaomi Book Pro 14 (TM2424), Fn+K sends hotkey event 0x28 and
> the firmware does not change SystemPerMode itself. The event is a
> request that the vendor software acts on; without that software Fn+K
> does nothing on Windows either, and on Linux it is currently logged as
> an unknown event.
>
> Add a quirk for this and call platform_profile_cycle() from the control
> device when the event arrives, so Fn+K cycles through the profiles that
> all platform profile handlers support. Models without the quirk keep
> ignoring the event.
>
> Suggested-by: Hans de Goede <hansg@kernel.org>
> Signed-off-by: Chris Taraszka <chris@miget.com>
> ---
>
> Notes:
>     Tested on the Xiaomi Book Pro 14 (TM2424, BIOS XMAPT4B0P0A0A) on AC,
>     with Mingyou's v15 and my two TM2424 patches, loaded on v7.3: four Fn+K
>     presses step performance -> low-power -> balanced -> performance ->
>     low-power. The bitland and SoC Power Slider handlers and SystemPerMode
>     (EC 0x68) follow each press within a second, and power-profiles-daemon
>     picks up the change.
>
>     Depends on Mingyou Chen's v15 "Merge redmi-wmi into bitland-mifs-wmi" [1]
>     and on my "platform/x86: bitland-mifs-wmi: Xiaomi Book Pro 14 support"
>     v2 [2].
>
>     [1] https://lore.kernel.org/all/20261028112742.674847-1-qby140326@gmail.com/
>     [2] https://lore.kernel.org/all/20261025195456.43414-1-chris@miget.com/
>
>  drivers/platform/x86/bitland-mifs-wmi.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
> index a72569d810e3..8a994f5b089e 100644
> --- a/drivers/platform/x86/bitland-mifs-wmi.c
> +++ b/drivers/platform/x86/bitland-mifs-wmi.c
> @@ -99,6 +99,9 @@ struct bitland_mifs_quirks {
>
>         bool return_code_at_end;
>         bool skip_ac_type_check;
> +
> +       /* Fn+K sends WMI_EVENT_PERFORMANCE_CYCLE and leaves the mode to the OS */
> +       bool cycle_profile_on_key;
>  };
>
>  static const struct bitland_profile_entry default_profile_entries[] = {
> @@ -125,6 +128,7 @@ static const struct bitland_mifs_quirks tm2424_quirks = {
>         .profile_entries = tm2424_profile_entries,
>         .num_profile_entries = ARRAY_SIZE(tm2424_profile_entries),
>         .skip_ac_type_check = true,
> +       .cycle_profile_on_key = true,
>  };
>
>  static const struct dmi_system_id bitland_mifs_dmi_table[] = {
> @@ -168,6 +172,7 @@ enum bitland_mifs_event_id {
>         WMI_EVENT_MIC_MUTE              = 33,
>         WMI_EVENT_RESERVED_23           = 34,
>         WMI_EVENT_OPEN_APP              = 35,
> +       WMI_EVENT_PERFORMANCE_CYCLE     = 40,
>  };
>
>  enum bitland_mifs_event_type {
> @@ -216,6 +221,7 @@ static BLOCKING_NOTIFIER_HEAD(bitland_notifier_list);
>  enum bitland_notifier_actions {
>         BITLAND_NOTIFY_KBD_BRIGHTNESS,
>         BITLAND_NOTIFY_PLATFORM_PROFILE,
> +       BITLAND_NOTIFY_PLATFORM_PROFILE_CYCLE,
>         BITLAND_NOTIFY_HWMON,
>  };
>
> @@ -792,6 +798,10 @@ static int bitland_notifier_callback(struct notifier_block *nb,
>         case BITLAND_NOTIFY_PLATFORM_PROFILE:
>                 platform_profile_notify(data_ctx->pp_dev);
>                 break;
> +       case BITLAND_NOTIFY_PLATFORM_PROFILE_CYCLE:
> +               if (data_ctx->pp_dev)
> +                       platform_profile_cycle();
> +               break;
>         case BITLAND_NOTIFY_HWMON:
>                 fan_info = data;
>
> @@ -921,6 +931,7 @@ static void bitland_mifs_wmi_report_key(struct wmi_device *wdev, u32 payload)
>  static void bitland_mifs_wmi_notify(struct wmi_device *wdev,
>                                     const struct wmi_buffer *buffer)
>  {
> +       struct bitland_mifs_wmi_data *data = dev_get_drvdata(&wdev->dev);
>         const struct bitland_mifs_event *event = buffer->data;
>         struct bitland_fan_notify_data fan_data;
>         u8 brightness;
> @@ -949,6 +960,15 @@ static void bitland_mifs_wmi_notify(struct wmi_device *wdev,
>                                              NULL);
>                 return;
>
> +       case WMI_EVENT_PERFORMANCE_CYCLE:
> +               if (!data->quirks->cycle_profile_on_key)
> +                       break;
> +
> +               blocking_notifier_call_chain(&bitland_notifier_list,
> +                                            BITLAND_NOTIFY_PLATFORM_PROFILE_CYCLE,
> +                                            NULL);
> +               return;
> +
>         /*
>          * The device has 3 fans (CPU, GPU, SYS),
>          * but there are only the CPU and GPU fan has events
>
> base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8
> prerequisite-patch-id: 99b10cd2b70d630ab65d8a8bb02c1d4bf89b1a63
> prerequisite-patch-id: 27db041f827872b8be142c310a14c79962154bd5
> prerequisite-patch-id: 74fc3298fa3dceb2224dfc3d2ae4cc6d4be61c01
> prerequisite-patch-id: 254b8455d8a7f56b730e842207d91bd6904a50ce
> prerequisite-patch-id: 9708c81da6b4ed6c2d47eb927efcd64ce4ed2ecf
> prerequisite-patch-id: 2fe8c043993034f1a2cde98b1b2e299987d5ac7f
> prerequisite-patch-id: 36137eee73ea8cee3db81af887f1f0859ef02b3a
> prerequisite-patch-id: f0ba644539dc52241b96a74d6e32a6f06241e577
> --
> 2.56.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-01 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-01 14:41 [PATCH] platform/x86: bitland-mifs-wmi: Cycle the platform profile on Fn+K Chris Taraszka
2026-11-01 16:23 ` Chris Taraszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®