platform/x86: bitland-mifs-wmi: Xiaomi Book Pro 14 support
v3 cover platform/x86: bitland-mifs-wmi: Xiaomi Book Pro 14 support
Four patches on top of Mingyou Chen's v15 "Merge redmi-wmi into bitland-mifs-wmi" [1] for the Xiaomi Book Pro 14 (TM2424).
Kento was right about the mode map in v2 [2]. The firmware passes SystemPerMode to Intel DTT, and the DTT tables in its data vault name each mode and set its PL1 per power source. v2 was measured on AC only, where 0x03 looks like a 37 W mode, but on battery 0x03 is the firmware's Turbo mode, so v2's balanced was the fastest mode on battery: 54 W measured on BIOS 0A0A.
v3 maps low-power, balanced and performance to 0x02, 0x09 and 0x04, and patch 3 lets performance use 0x03 on battery, re-applied when the power source changes.
Kento, two differences from your map: low-power sets 0x02, which selects the same DTT tables as 0x0a without the dimming, and performance picks 0x03 by power source rather than reading back whether 0x04 stuck, so it does not depend on which BIOS refuses 0x04 on battery.
The Fn+K patch [3] is now patch 4, since it changes the quirks entry from patch 1.
Changes since v2:
- New mode map from the firmware's DTT tables (Kento)
- Drop Mingyou's Reviewed-by from patch 1, as the map changed
- New patch 3: separate performance value on battery
- Fold in the Fn+K patch [3] as patch 4
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
Chris Taraszka (4):
platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on
profile errors
platform/x86: bitland-mifs-wmi: Support a separate profile value on
battery
platform/x86: bitland-mifs-wmi: Cycle the platform profile on Fn+K
drivers/platform/x86/bitland-mifs-wmi.c | 183 +++++++++++++++++++++--- 1 file changed, 163 insertions(+), 20 deletions(-)
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
Signature · 1 line
2.56.0
PATCH v3 1/4 platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk
The Xiaomi Book Pro 14 (board TM2424) implements SystemPerMode with its own values. Its firmware ignores 0x00 and 0x01, and GET returns one of 0x02, 0x03, 0x04, 0x09 or 0x0a, so with the default table balanced and balanced-performance are no-ops and reading the profile fails with -EINVAL whenever the firmware is in 0x04, 0x09 or 0x0a. The failed read also aborts system suspend.
The firmware passes the mode to Intel DTT as an OEM design variable. The DTT tables in its data vault name the modes and set the sustained package power limit (PL1) for each, by power source. For the H484 CPU variant (H404 has the same layout with lower limits):
value AC battery 0x02 Silent 15-25 W Silent 15-25 W 0x0a Silent 15-25 W Silent 15-25 W 0x09 Balance 35-45 W Balance 32-40 W 0x03 Smart 36-37 W Turbo 50-58 W 0x04 Crazy 50-58 W no entry
Map low-power, balanced and performance to 0x02, 0x09 and 0x04. 0x0a selects the same tables as 0x02, and 0x03 gives on battery what 0x04 gives on AC, so report them as low-power and performance without offering them for SET. There is no balanced-performance mode.
The machine is USB-C only and WMI_FN_SYSTEM_AC_TYPE is not implemented, so skip the AC type check.
---
Notes:
Tested on the Xiaomi Book Pro 14 (TM2424, BIOS XMAPT4B0P0A0A, H484)
with this series on top of v15, loaded on v7.3. Firmware mode (EC 0x68),
DTT OEM variable 1 and PL1 a few seconds after each set:
AC low-power 0x02 ODV1 2 25 W
balanced 0x09 ODV1 0 45 W
performance 0x04 ODV1 4 58 W
battery low-power 0x02 ODV1 2 25 W
performance 0x03 ODV1 1 58 W (with patch 3)
With v2 on battery, balanced set 0x03 and PL1 went to 54 W.drivers/platform/x86/bitland-mifs-wmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/platform/x86/bitland-mifs-wmi.c +21 -0
@@ -113,7 +113,28 @@ static const struct bitland_mifs_quirks default_quirks = { .num_profile_entries = ARRAY_SIZE(default_profile_entries), }; +static const struct bitland_profile_entry tm2424_profile_entries[] = { + {PLATFORM_PROFILE_LOW_POWER ,0x02 }, + {PLATFORM_PROFILE_LOW_POWER ,0x0a , true }, + {PLATFORM_PROFILE_BALANCED ,0x09 }, + {PLATFORM_PROFILE_PERFORMANCE ,0x04 }, + {PLATFORM_PROFILE_PERFORMANCE ,0x03 , true }, +}; + +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, +}; +static const struct dmi_system_id bitland_mifs_dmi_table[] = { + { + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"XIAOMI" ), +DMI_EXACT_MATCH (DMI_BOARD_NAME ,"TM2424" ), + }, + .driver_data = (void *)&tm2424_quirks, + }, {} };
Signature · 1 line
2.56.0
Re: [PATCH v3 1/4] platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk
Quoted 69 lines · Chris Taraszka
The Xiaomi Book Pro 14 (board TM2424) implements SystemPerMode with its own values. Its firmware ignores
0x00and0x01, and GET returns one of0x02,0x03,0x04,0x09or0x0a, so with the default table balanced and balanced-performance are no-ops and reading the profile fails with-EINVALwhenever the firmware is in0x04,0x09or0x0a. The failed read also aborts system suspend.The firmware passes the mode to Intel DTT as an OEM design variable. The DTT tables in its data vault name the modes and set the sustained package power limit (PL1) for each, by power source. For the H484 CPU variant (H404 has the same layout with lower limits):
value AC battery 0x02 Silent 15-25 W Silent 15-25 W 0x0a Silent 15-25 W Silent 15-25 W 0x09 Balance 35-45 W Balance 32-40 W 0x03 Smart 36-37 W Turbo 50-58 W 0x04 Crazy 50-58 W no entryMap low-power, balanced and performance to
0x02,0x09and0x04.0x0aselects the same tables as0x02, and0x03gives on battery what0x04gives on AC, so report them as low-power and performance without offering them for SET. There is no balanced-performance mode.The machine is USB-C only and
WMI_FN_SYSTEM_AC_TYPEis not implemented, so skip the AC type check.Signed-off-by Chris Taraszka <[email protected]>---
Notes:
Tested on the Xiaomi Book Pro 14 (TM2424, BIOS XMAPT4B0P0A0A, H484) with this series on top of v15, loaded on v7.3. Firmware mode (EC 0x68), DTT OEM variable 1 and PL1 a few seconds after each set: AC low-power 0x02 ODV1 2 25 W balanced 0x09 ODV1 0 45 W performance 0x04 ODV1 4 58 W battery low-power 0x02 ODV1 2 25 W performance 0x03 ODV1 1 58 W (with patch 3) With v2 on battery, balanced set 0x03 and PL1 went to 54 W.drivers/platform/x86/bitland-mifs-wmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/platform/x86/bitland-mifs-wmi.c +14
-0@@ -113,7 +113,28 @@ static const struct bitland_mifs_quirks default_quirks = { .num_profile_entries = ARRAY_SIZE(default_profile_entries), }; +static const struct bitland_profile_entry tm2424_profile_entries[] = { + {PLATFORM_PROFILE_LOW_POWER ,0x02 }, + {PLATFORM_PROFILE_LOW_POWER ,0x0a , true }, + {PLATFORM_PROFILE_BALANCED ,0x09 }, + {PLATFORM_PROFILE_PERFORMANCE ,0x04 }, + {PLATFORM_PROFILE_PERFORMANCE ,0x03 , true }, +}; + +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, +}; +static const struct dmi_system_id bitland_mifs_dmi_table[] = {
drivers/platform/x86/bitland-mifs-wmi.c static const struct bitland_mifs_quirks default_quirks = { · line 140
Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +7
-0+ { + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "XIAOMI"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "TM2424"), + }, + .driver_data = (void *)&tm2424_quirks, + }, {} };
I'd prefer to have this applied on top of patch 3/4 instead, so the infrastructure is in place first.
Re: [PATCH v3 1/4] platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk
Quoted 2 lines · Mingyou Chen
I'd prefer to have this applied on top of patch 3/4 instead, so the infrastructure is in place first.
Sure, v4 will add the quirk after the battery support, with 0x03 as the battery entry from the start.
Thanks,
Chris
Quoted 83 lines · Mingyou Chen
Quoted 69 lines · Chris Taraszka
The Xiaomi Book Pro 14 (board TM2424) implements SystemPerMode with its own values. Its firmware ignores
0x00and0x01, and GET returns one of0x02,0x03,0x04,0x09or0x0a, so with the default table balanced and balanced-performance are no-ops and reading the profile fails with-EINVALwhenever the firmware is in0x04,0x09or0x0a. The failed read also aborts system suspend.The firmware passes the mode to Intel DTT as an OEM design variable. The DTT tables in its data vault name the modes and set the sustained package power limit (PL1) for each, by power source. For the H484 CPU variant (H404 has the same layout with lower limits):
value AC battery 0x02 Silent 15-25 W Silent 15-25 W 0x0a Silent 15-25 W Silent 15-25 W 0x09 Balance 35-45 W Balance 32-40 W 0x03 Smart 36-37 W Turbo 50-58 W 0x04 Crazy 50-58 W no entryMap low-power, balanced and performance to
0x02,0x09and0x04.0x0aselects the same tables as0x02, and0x03gives on battery what0x04gives on AC, so report them as low-power and performance without offering them for SET. There is no balanced-performance mode.The machine is USB-C only and
WMI_FN_SYSTEM_AC_TYPEis not implemented, so skip the AC type check.Signed-off-by Chris Taraszka <[email protected]>---
Notes:
Tested on the Xiaomi Book Pro 14 (TM2424, BIOS XMAPT4B0P0A0A, H484) with this series on top of v15, loaded on v7.3. Firmware mode (EC 0x68), DTT OEM variable 1 and PL1 a few seconds after each set: AC low-power 0x02 ODV1 2 25 W balanced 0x09 ODV1 0 45 W performance 0x04 ODV1 4 58 W battery low-power 0x02 ODV1 2 25 W performance 0x03 ODV1 1 58 W (with patch 3) With v2 on battery, balanced set 0x03 and PL1 went to 54 W.drivers/platform/x86/bitland-mifs-wmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/platform/x86/bitland-mifs-wmi.c +14
-0@@ -113,7 +113,28 @@ static const struct bitland_mifs_quirks default_quirks = { .num_profile_entries = ARRAY_SIZE(default_profile_entries), }; +static const struct bitland_profile_entry tm2424_profile_entries[] = { + {PLATFORM_PROFILE_LOW_POWER ,0x02 }, + {PLATFORM_PROFILE_LOW_POWER ,0x0a , true }, + {PLATFORM_PROFILE_BALANCED ,0x09 }, + {PLATFORM_PROFILE_PERFORMANCE ,0x04 }, + {PLATFORM_PROFILE_PERFORMANCE ,0x03 , true }, +}; + +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, +}; +static const struct dmi_system_id bitland_mifs_dmi_table[] = {drivers/platform/x86/bitland-mifs-wmi.c static const struct bitland_mifs_quirks default_quirks = { · line 140
Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +7
-0+ { + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "XIAOMI"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "TM2424"), + }, + .driver_data = (void *)&tm2424_quirks, + }, {} };I'd prefer to have this applied on top of patch 3/4 instead, so the infrastructure is in place first.
PATCH v3 2/4 platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on profile errors
In reply to Chris Taraszkabitland_mifs_wmi_suspend() returns the laptop_profile_get() error to the PM core, which aborts the whole system suspend. This happens on any machine whose firmware reports a SystemPerMode value that is missing from its profile table, and on such a laptop with the lid closed logind keeps retrying the suspend, so the machine stays awake and drains its battery.
bitland_mifs_wmi_resume() likewise returns any error other than -EOPNOTSUPP from restoring the profile, so the resume is reported as failed although the machine is fully usable.
Saving and restoring the platform profile is best effort. Warn and continue instead of failing the system transition, and skip the restore when nothing was saved, so resume does not write a stale or default profile.
---
Notes:
Unchanged since v2.
drivers/platform/x86/bitland-mifs-wmi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +15 -7
@@ -234,6 +234,7 @@ struct bitland_mifs_wmi_data {struct device *pp_dev;const struct bitland_mifs_quirks *quirks;enum platform_profile_option saved_profile; +bool profile_saved; }; static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
@@ -404,10 +405,15 @@ static int bitland_mifs_wmi_suspend(struct device *dev)return 0 ; ret =laptop_profile_get (data->pp_dev, &profile); -if (ret ==0 ) - data->saved_profile = profile; + data->profile_saved = !ret; +if (ret) { +dev_warn (dev,"Failed to save platform profile: %d\n" , ret); +return 0 ; + } -return ret; + data->saved_profile = profile; + +return 0 ; }static int bitland_mifs_wmi_resume (struct device *dev)
@@ -415,8 +421,8 @@ static int bitland_mifs_wmi_resume(struct device *dev)struct bitland_mifs_wmi_data *data =dev_get_drvdata (dev);int ret; -/* Skip event device */ -if (!data->pp_dev) +/* Skip event device, or nothing was saved on suspend */ +if (!data->pp_dev || !data->profile_saved)return 0 ; ret =laptop_profile_set (dev, data->saved_profile);
@@ -432,8 +438,10 @@ static int bitland_mifs_wmi_resume(struct device *dev) } } -dev_dbg (dev,"Resuming, restoring profile %d\n" , data->saved_profile); -return ret; +if (ret) +dev_warn (dev,"Failed to restore platform profile: %d\n" , ret); + +return 0 ; } static DEFINE_SIMPLE_DEV_PM_OPS(bitland_mifs_wmi_pm_ops,
Signature · 1 line
2.56.0
PATCH v3 3/4 platform/x86: bitland-mifs-wmi: Support a separate profile value on battery
In reply to Chris TaraszkaThe Xiaomi Book Pro 14 firmware uses different SystemPerMode values for performance depending on the power source: 0x04 on AC and 0x03 on battery, both with a 50-58 W sustained power limit. Its DTT tables have no battery entry for 0x04, and BIOS 0707 refuses 0x04 on battery, so the driver currently refuses performance on battery.
Let a profile entry be marked for battery use. It is set in place of the AC entry for the same profile while the system runs on battery, without the AC check. The firmware does not change the mode when the power source changes, so re-apply the current profile from an ACPI AC notifier, taking the AC state from the event. A mutex keeps this from racing with profile changes from userspace.
Mark 0x03 as the battery value for performance on the Xiaomi Book Pro 14.
---
Notes:
Tested with ftrace kprobes on the AC notifier and on the WMI calls:
AC, performance (0x04), unplug: the notifier sets 0x03 within 1 ms battery, performance: set 0x03, PL1 58 W
battery, performance (0x03), plug in: the notifier sets 0x04 s2idle from performance on AC: resume restores 0x04
Battery class events are ignored. Here Omarchy also switches to its saved per-source profile about a second later, which goes through laptop_profile_set() after the notifier.
drivers/platform/x86/bitland-mifs-wmi.c | 122 +++++++++++++++++++++--- 1 file changed, 108 insertions(+), 14 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +108 -14
@@ -91,6 +91,7 @@ struct bitland_profile_entry {enum platform_profile_option profile;u8 wmi_val;bool no_set; +bool battery;/* Set in place of the AC entry while on battery */ };struct bitland_mifs_quirks {
@@ -118,7 +119,7 @@ static const struct bitland_profile_entry tm2424_profile_entries[] = { { PLATFORM_PROFILE_LOW_POWER, 0x0a, true }, { PLATFORM_PROFILE_BALANCED, 0x09 }, { PLATFORM_PROFILE_PERFORMANCE, 0x04 }, - { PLATFORM_PROFILE_PERFORMANCE, 0x03, true }, + { PLATFORM_PROFILE_PERFORMANCE, 0x03, .battery = true }, }; static const struct bitland_mifs_quirks tm2424_quirks = {
@@ -227,8 +228,10 @@ struct bitland_fan_notify_data {struct bitland_mifs_wmi_data {struct wmi_device *wdev;struct mutex lock;/* Protects WMI calls */ +struct mutex profile_lock;/* Serializes profile changes */ struct led_classdev kbd_led;struct notifier_block notifier; +struct notifier_block ac_notifier;struct input_dev *input_dev;struct device *hwmon_dev;struct device *pp_dev;
@@ -350,34 +353,108 @@ static int bitland_pp_check_capability(struct bitland_mifs_wmi_data *data)return 0 ; } -static int laptop_profile_set (struct device *dev, -enum platform_profile_option profile) +static const struct bitland_profile_entry * +bitland_profile_set_entry (const struct bitland_mifs_quirks *quirks, +enum platform_profile_option profile,bool on_battery) +{ +const struct bitland_profile_entry *entry =NULL ; +size_t i; + +for (i =0 ; i < quirks->num_profile_entries; i++) { +const struct bitland_profile_entry *e = &quirks->profile_entries[i]; + +if (e->profile != profile || e->no_set) +continue ; + +if (e->battery && on_battery) +return e; + +if (!e->battery && !entry) + entry = e; + } + +return entry; +} + +static int bitland_profile_set (struct bitland_mifs_wmi_data *data, +enum platform_profile_option profile, +bool on_battery) { -struct bitland_mifs_wmi_data *data =dev_get_drvdata (dev); -const struct bitland_mifs_quirks *quirks = data->quirks;struct bitland_mifs_input input = { .operation =cpu_to_le16 (WMI_METHOD_SET ), .function =cpu_to_le16 (WMI_FN_SYSTEM_PER_MODE ), }; -size_t i; +const struct bitland_profile_entry *entry;int ret; -if (profile ==PLATFORM_PROFILE_PERFORMANCE || - profile ==PLATFORM_PROFILE_BALANCED_PERFORMANCE ) { + entry =bitland_profile_set_entry (data->quirks, profile, on_battery); +if (!entry) +return -EOPNOTSUPP ; + +if (!entry->battery && + (profile ==PLATFORM_PROFILE_PERFORMANCE || + profile ==PLATFORM_PROFILE_BALANCED_PERFORMANCE )) { ret =bitland_pp_check_capability (data);if (ret)return ret; } + input.payload[0 ] = entry->wmi_val; + +return bitland_mifs_wmi_call (data, &input,NULL ); +} + +static int laptop_profile_set (struct device *dev, +enum platform_profile_option profile) +{ +struct bitland_mifs_wmi_data *data =dev_get_drvdata (dev); + +guard (mutex)(&data->profile_lock); + +return bitland_profile_set (data, profile, + !power_supply_is_system_supplied ()); +} + +static int bitland_ac_notify (struct notifier_block *nb,unsigned long action, +void *data) +{ +struct bitland_mifs_wmi_data *drv_data = + container_of(nb, struct bitland_mifs_wmi_data, ac_notifier); +struct acpi_bus_event *event = data; +enum platform_profile_option profile; +int ret; + +if (strcmp (event->device_class,ACPI_AC_CLASS )) +return NOTIFY_DONE ; + +guard (mutex)(&drv_data->profile_lock); + +/* Switch to the AC or battery value of the current profile */ + ret =laptop_profile_get (drv_data->pp_dev, &profile); +if (!ret) + ret =bitland_profile_set (drv_data, profile, !event->data); +if (ret) +dev_warn (&drv_data->wdev->dev, +"Failed to update platform profile on AC change: %d\n" , ret); + +return NOTIFY_DONE ; +} + +static void bitland_ac_notifier_unregister (void *data) +{ +unregister_acpi_notifier (data); +} + +static bool bitland_has_battery_entries (const struct bitland_mifs_quirks *quirks) +{ +size_t i; +for (i =0 ; i < quirks->num_profile_entries; i++) { -if (quirks->profile_entries[i].profile == profile && - !quirks->profile_entries[i].no_set) { - input.payload[0 ] = quirks->profile_entries[i].wmi_val; -return bitland_mifs_wmi_call (data, &input,NULL ); - } +if (quirks->profile_entries[i].battery) +return true; } -return -EOPNOTSUPP ; +return false; }static int platform_profile_probe (void *drvdata,unsigned long *choices)
@@ -826,6 +903,10 @@ static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context)if (ret)return ret; + ret =devm_mutex_init (&wdev->dev, &drv_data->profile_lock); +if (ret) +return ret; +dev_set_drvdata (&wdev->dev, drv_data); drv_data->quirks = &default_quirks;
@@ -858,6 +939,19 @@ static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context)if (IS_ERR (drv_data->pp_dev))return PTR_ERR (drv_data->pp_dev); +if (bitland_has_battery_entries (drv_data->quirks)) { + drv_data->ac_notifier.notifier_call = bitland_ac_notify; + ret =register_acpi_notifier (&drv_data->ac_notifier); +if (ret) +return ret; + + ret =devm_add_action_or_reset (&wdev->dev, + bitland_ac_notifier_unregister, + &drv_data->ac_notifier); +if (ret) +return ret; + } +/* Register hwmon */ drv_data->hwmon_dev = devm_hwmon_device_register_with_info(&wdev->dev, "bitland_mifs",
Signature · 1 line
2.56.0
PATCH v3 4/4 platform/x86: bitland-mifs-wmi: Cycle the platform profile on Fn+K
In reply to Chris TaraszkaOn 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.
---
Notes:
Sent on its own earlier today [1]. It is now part of the series since
it changes the TM2424 quirks entry from patch 1. Retested with v3: three
Fn+K presses from balanced step performance (0x04) -> low-power (0x02)
-> balanced (0x09).
[1] https://lore.kernel.org/all/[email protected]/drivers/platform/x86/bitland-mifs-wmi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/platform/x86/bitland-mifs-wmi.c +20 -0
@@ -100,6 +100,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[] = {
@@ -126,6 +129,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[] = {
@@ -169,6 +173,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 {
@@ -217,6 +222,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 , };
@@ -869,6 +875,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;
@@ -1015,6 +1025,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;
@@ -1043,6 +1054,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
Signature · 1 line
2.56.0
Re: [PATCH v3 4/4] platform/x86: bitland-mifs-wmi: Cycle the platform profile on Fn+K
Quoted 86 lines · Chris Taraszka
On the Xiaomi Book Pro 14 (TM2424), Fn+K sends hotkey event
0x28and 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 <[email protected]>Signed-off-by Chris Taraszka <[email protected]>---
Notes:
Sent on its own earlier today [1]. It is now part of the series since it changes the TM2424 quirks entry from patch 1. Retested with v3: three Fn+K presses from balanced step performance (0x04) -> low-power (0x02) -> balanced (0x09). [1] https://lore.kernel.org/all/[email protected]/drivers/platform/x86/bitland-mifs-wmi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/platform/x86/bitland-mifs-wmi.c +11
-0@@ -100,6 +100,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[] = {@@ -126,6 +129,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[] = {@@ -169,6 +173,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 {@@ -217,6 +222,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 , };@@ -869,6 +875,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;@@ -1015,6 +1025,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;@@ -1043,6 +1054,15 @@ static void bitland_mifs_wmi_notify(struct wmi_device *wdev, NULL);return ;
drivers/platform/x86/bitland-mifs-wmi.c static void bitland_mifs_wmi_notify(struct wmi_device *wdev, · line 1065
Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +9
-0+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 ; +
How about 0x16 (WMI_EVENT_PERFORMANCE_PLAN_ALT)? Some devices report this instead of 0x28 (WMI_EVENT_PERFORMANCE_CYCLE).
Quoted 3 lines
drivers/platform/x86/bitland-mifs-wmi.c +0
-0/* * The device has 3 fans (CPU, GPU, SYS), * but there are only the CPU and GPU fan has events
Re: [PATCH v3 4/4] platform/x86: bitland-mifs-wmi: Cycle the platform profile on Fn+K
Quoted 2 lines · Mingyou Chen
How about
0x16(WMI_EVENT_PERFORMANCE_PLAN_ALT)? Some devices report this instead of0x28(WMI_EVENT_PERFORMANCE_CYCLE).
0x16 reports a mode change rather than asking for one. On TM2135 the firmware cycles the mode itself on Fn+K and then sends 0x16 with the new value [1]. TM2424 sends it after every SET as well, within 10 ms:
SET 0x09 -> 0x16 value 0x09
SET 0x03 -> 0x16 value 0x03
SET 0x02 -> 0x16 value 0x02
Cycling on 0x16 would step twice per Fn+K press on TM2135, and on any of these machines it would loop, since each step does a SET that sends another 0x16. v15 already handles it with platform_profile_notify(). 0x28 is different: TM2424 sends it on Fn+K and leaves the mode alone.
Thanks,
Chris
Quoted 107 lines · Mingyou Chen
Quoted 86 lines · Chris Taraszka
On the Xiaomi Book Pro 14 (TM2424), Fn+K sends hotkey event
0x28and 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 <[email protected]>Signed-off-by Chris Taraszka <[email protected]>---
Notes:
Sent on its own earlier today [1]. It is now part of the series since it changes the TM2424 quirks entry from patch 1. Retested with v3: three Fn+K presses from balanced step performance (0x04) -> low-power (0x02) -> balanced (0x09). [1] https://lore.kernel.org/all/[email protected]/drivers/platform/x86/bitland-mifs-wmi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/platform/x86/bitland-mifs-wmi.c +11
-0@@ -100,6 +100,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[] = {@@ -126,6 +129,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[] = {@@ -169,6 +173,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 {@@ -217,6 +222,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 , };@@ -869,6 +875,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;@@ -1015,6 +1025,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;@@ -1043,6 +1054,15 @@ static void bitland_mifs_wmi_notify(struct wmi_device *wdev, NULL);return ;drivers/platform/x86/bitland-mifs-wmi.c static void bitland_mifs_wmi_notify(struct wmi_device *wdev, · line 1065
Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +9
-0+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 ; +How about
0x16(WMI_EVENT_PERFORMANCE_PLAN_ALT)? Some devices report this instead of0x28(WMI_EVENT_PERFORMANCE_CYCLE).Quoted 3 lines
drivers/platform/x86/bitland-mifs-wmi.c +0
-0/* * The device has 3 fans (CPU, GPU, SYS), * but there are only the CPU and GPU fan has events