Skip to content

Commit 286e937

Browse files
Enverbalalicjwrdegoede
authored andcommitted
platform/x86: hp-wmi: support omen thermal profile policy v1
As it turns out, these laptops have 2 thermal profile versions. A previous patch added support for v0, this patch adds support for v1 thermal policies that are in use on some devices. We obtain the thermal policy version by querying the get system design data WMI call and looking at the fourth byte it returns, except if the system board DMI Board ID is in a specific array that the windows command center app overrides to thermal policy v0 for some reason. Signed-off-by: Enver Balalic <balalic.enver@gmail.com> Link: https://lore.kernel.org/r/20220314121453.kjszdciymtg6ctbq@omen Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 4b4967c commit 286e937

1 file changed

Lines changed: 67 additions & 14 deletions

File tree

drivers/platform/x86/hp-wmi.c

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ static const char * const omen_thermal_profile_boards[] = {
5757
"8917", "8918", "8949", "894A", "89EB"
5858
};
5959

60+
/* DMI Board names of Omen laptops that are specifically set to be thermal
61+
* profile version 0 by the Omen Command Center app, regardless of what
62+
* the get system design information WMI call returns
63+
*/
64+
static const char *const omen_thermal_profile_force_v0_boards[] = {
65+
"8607", "8746", "8747", "8749", "874A", "8748"
66+
};
67+
6068
enum hp_wmi_radio {
6169
HPWMI_WIFI = 0x0,
6270
HPWMI_BLUETOOTH = 0x1,
@@ -117,6 +125,7 @@ enum hp_wmi_gm_commandtype {
117125
HPWMI_SET_PERFORMANCE_MODE = 0x1A,
118126
HPWMI_FAN_SPEED_MAX_GET_QUERY = 0x26,
119127
HPWMI_FAN_SPEED_MAX_SET_QUERY = 0x27,
128+
HPWMI_GET_SYSTEM_DESIGN_DATA = 0x28,
120129
};
121130

122131
enum hp_wmi_command {
@@ -151,10 +160,16 @@ enum hp_wireless2_bits {
151160
HPWMI_POWER_FW_OR_HW = HPWMI_POWER_BIOS | HPWMI_POWER_HARD,
152161
};
153162

154-
enum hp_thermal_profile_omen {
155-
HP_OMEN_THERMAL_PROFILE_DEFAULT = 0x00,
156-
HP_OMEN_THERMAL_PROFILE_PERFORMANCE = 0x01,
157-
HP_OMEN_THERMAL_PROFILE_COOL = 0x02,
163+
enum hp_thermal_profile_omen_v0 {
164+
HP_OMEN_V0_THERMAL_PROFILE_DEFAULT = 0x00,
165+
HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE = 0x01,
166+
HP_OMEN_V0_THERMAL_PROFILE_COOL = 0x02,
167+
};
168+
169+
enum hp_thermal_profile_omen_v1 {
170+
HP_OMEN_V1_THERMAL_PROFILE_DEFAULT = 0x30,
171+
HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE = 0x31,
172+
HP_OMEN_V1_THERMAL_PROFILE_COOL = 0x50,
158173
};
159174

160175
enum hp_thermal_profile {
@@ -407,9 +422,6 @@ static int omen_thermal_profile_set(int mode)
407422
char buffer[2] = {0, mode};
408423
int ret;
409424

410-
if (mode < 0 || mode > 2)
411-
return -EINVAL;
412-
413425
ret = hp_wmi_perform_query(HPWMI_SET_PERFORMANCE_MODE, HPWMI_GM,
414426
&buffer, sizeof(buffer), 0);
415427

@@ -431,6 +443,30 @@ static bool is_omen_thermal_profile(void)
431443
board_name) >= 0;
432444
}
433445

446+
static int omen_get_thermal_policy_version(void)
447+
{
448+
unsigned char buffer[8] = { 0 };
449+
int ret;
450+
451+
const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
452+
453+
if (board_name) {
454+
int matches = match_string(omen_thermal_profile_force_v0_boards,
455+
ARRAY_SIZE(omen_thermal_profile_force_v0_boards),
456+
board_name);
457+
if (matches >= 0)
458+
return 0;
459+
}
460+
461+
ret = hp_wmi_perform_query(HPWMI_GET_SYSTEM_DESIGN_DATA, HPWMI_GM,
462+
&buffer, sizeof(buffer), sizeof(buffer));
463+
464+
if (ret)
465+
return ret < 0 ? ret : -EINVAL;
466+
467+
return buffer[3];
468+
}
469+
434470
static int omen_thermal_profile_get(void)
435471
{
436472
u8 data;
@@ -1053,13 +1089,16 @@ static int platform_profile_omen_get(struct platform_profile_handler *pprof,
10531089
return tp;
10541090

10551091
switch (tp) {
1056-
case HP_OMEN_THERMAL_PROFILE_PERFORMANCE:
1092+
case HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE:
1093+
case HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE:
10571094
*profile = PLATFORM_PROFILE_PERFORMANCE;
10581095
break;
1059-
case HP_OMEN_THERMAL_PROFILE_DEFAULT:
1096+
case HP_OMEN_V0_THERMAL_PROFILE_DEFAULT:
1097+
case HP_OMEN_V1_THERMAL_PROFILE_DEFAULT:
10601098
*profile = PLATFORM_PROFILE_BALANCED;
10611099
break;
1062-
case HP_OMEN_THERMAL_PROFILE_COOL:
1100+
case HP_OMEN_V0_THERMAL_PROFILE_COOL:
1101+
case HP_OMEN_V1_THERMAL_PROFILE_COOL:
10631102
*profile = PLATFORM_PROFILE_COOL;
10641103
break;
10651104
default:
@@ -1072,17 +1111,31 @@ static int platform_profile_omen_get(struct platform_profile_handler *pprof,
10721111
static int platform_profile_omen_set(struct platform_profile_handler *pprof,
10731112
enum platform_profile_option profile)
10741113
{
1075-
int err, tp;
1114+
int err, tp, tp_version;
1115+
1116+
tp_version = omen_get_thermal_policy_version();
1117+
1118+
if (tp_version < 0 || tp_version > 1)
1119+
return -EOPNOTSUPP;
10761120

10771121
switch (profile) {
10781122
case PLATFORM_PROFILE_PERFORMANCE:
1079-
tp = HP_OMEN_THERMAL_PROFILE_PERFORMANCE;
1123+
if (tp_version == 0)
1124+
tp = HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE;
1125+
else
1126+
tp = HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE;
10801127
break;
10811128
case PLATFORM_PROFILE_BALANCED:
1082-
tp = HP_OMEN_THERMAL_PROFILE_DEFAULT;
1129+
if (tp_version == 0)
1130+
tp = HP_OMEN_V0_THERMAL_PROFILE_DEFAULT;
1131+
else
1132+
tp = HP_OMEN_V1_THERMAL_PROFILE_DEFAULT;
10831133
break;
10841134
case PLATFORM_PROFILE_COOL:
1085-
tp = HP_OMEN_THERMAL_PROFILE_COOL;
1135+
if (tp_version == 0)
1136+
tp = HP_OMEN_V0_THERMAL_PROFILE_COOL;
1137+
else
1138+
tp = HP_OMEN_V1_THERMAL_PROFILE_COOL;
10861139
break;
10871140
default:
10881141
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)