Skip to content

Commit 0959afb

Browse files
mrhpearsonij-intel
authored andcommitted
platform/x86: Support for mode FN key
New Thinkpads have added a 'Mode' Function key that on Windows allows you to choose the active profile (low-power, balanced, performance) Added suppoort for this hotkey (F8), and have it cycle through the options available. Tested on X1 Carbon G12. Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20240120232949.317337-1-mpearson-lenovo@squebb.ca Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 2cee4d0 commit 0959afb

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Documentation/admin-guide/laptops/thinkpad-acpi.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ event code Key Notes
444444

445445
0x1008 0x07 FN+F8 IBM: toggle screen expand
446446
Lenovo: configure UltraNav,
447-
or toggle screen expand
447+
or toggle screen expand.
448+
On newer platforms (2024+)
449+
replaced by 0x131f (see below)
448450

449451
0x1009 0x08 FN+F9 -
450452

@@ -504,6 +506,9 @@ event code Key Notes
504506

505507
0x1019 0x18 unknown
506508

509+
0x131f ... FN+F8 Platform Mode change.
510+
Implemented in driver.
511+
507512
... ... ...
508513

509514
0x1020 0x1F unknown

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ enum tpacpi_hkey_event_t {
166166
TP_HKEY_EV_VOL_MUTE = 0x1017, /* Mixer output mute */
167167
TP_HKEY_EV_PRIVACYGUARD_TOGGLE = 0x130f, /* Toggle priv.guard on/off */
168168
TP_HKEY_EV_AMT_TOGGLE = 0x131a, /* Toggle AMT on/off */
169+
TP_HKEY_EV_PROFILE_TOGGLE = 0x131f, /* Toggle platform profile */
169170

170171
/* Reasons for waking up from S3/S4 */
171172
TP_HKEY_EV_WKUP_S3_UNDOCK = 0x2304, /* undock requested, S3 */
@@ -3731,6 +3732,7 @@ static bool hotkey_notify_extended_hotkey(const u32 hkey)
37313732
switch (hkey) {
37323733
case TP_HKEY_EV_PRIVACYGUARD_TOGGLE:
37333734
case TP_HKEY_EV_AMT_TOGGLE:
3735+
case TP_HKEY_EV_PROFILE_TOGGLE:
37343736
tpacpi_driver_event(hkey);
37353737
return true;
37363738
}
@@ -11115,7 +11117,23 @@ static void tpacpi_driver_event(const unsigned int hkey_event)
1111511117
else
1111611118
dytc_control_amt(!dytc_amt_active);
1111711119
}
11118-
11120+
if (hkey_event == TP_HKEY_EV_PROFILE_TOGGLE) {
11121+
switch (dytc_current_profile) {
11122+
case PLATFORM_PROFILE_LOW_POWER:
11123+
dytc_profile_set(NULL, PLATFORM_PROFILE_BALANCED);
11124+
break;
11125+
case PLATFORM_PROFILE_BALANCED:
11126+
dytc_profile_set(NULL, PLATFORM_PROFILE_PERFORMANCE);
11127+
break;
11128+
case PLATFORM_PROFILE_PERFORMANCE:
11129+
dytc_profile_set(NULL, PLATFORM_PROFILE_LOW_POWER);
11130+
break;
11131+
default:
11132+
pr_warn("Profile HKEY unexpected profile %d", dytc_current_profile);
11133+
}
11134+
/* Notify user space the profile changed */
11135+
platform_profile_notify();
11136+
}
1111911137
}
1112011138

1112111139
static void hotkey_driver_event(const unsigned int scancode)

0 commit comments

Comments
 (0)