Skip to content

Commit 2515e54

Browse files
onenowyjwrdegoede
authored andcommitted
platform/x86: hp-wmi: Add thermal profile for Victus 16-d1xxx
This patch includes Platform Profile support (performance, balanced, quiet) for Victus 16-d1xxx (8A25). Signed-off-by: SungHwan Jung <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]>
1 parent 7def1d3 commit 2515e54

File tree

1 file changed

+95
-1
lines changed

1 file changed

+95
-1
lines changed

drivers/platform/x86/hp/hp-wmi.c

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ static const char *const omen_thermal_profile_force_v0_boards[] = {
6666
"8607", "8746", "8747", "8749", "874A", "8748"
6767
};
6868

69+
/* DMI Board names of Victus laptops */
70+
static const char * const victus_thermal_profile_boards[] = {
71+
"8A25"
72+
};
73+
6974
enum hp_wmi_radio {
7075
HPWMI_WIFI = 0x0,
7176
HPWMI_BLUETOOTH = 0x1,
@@ -177,6 +182,12 @@ enum hp_thermal_profile_omen_v1 {
177182
HP_OMEN_V1_THERMAL_PROFILE_COOL = 0x50,
178183
};
179184

185+
enum hp_thermal_profile_victus {
186+
HP_VICTUS_THERMAL_PROFILE_DEFAULT = 0x00,
187+
HP_VICTUS_THERMAL_PROFILE_PERFORMANCE = 0x01,
188+
HP_VICTUS_THERMAL_PROFILE_QUIET = 0x03,
189+
};
190+
180191
enum hp_thermal_profile {
181192
HP_THERMAL_PROFILE_PERFORMANCE = 0x00,
182193
HP_THERMAL_PROFILE_DEFAULT = 0x01,
@@ -1299,6 +1310,70 @@ static int hp_wmi_platform_profile_set(struct platform_profile_handler *pprof,
12991310
return 0;
13001311
}
13011312

1313+
static bool is_victus_thermal_profile(void)
1314+
{
1315+
const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
1316+
1317+
if (!board_name)
1318+
return false;
1319+
1320+
return match_string(victus_thermal_profile_boards,
1321+
ARRAY_SIZE(victus_thermal_profile_boards),
1322+
board_name) >= 0;
1323+
}
1324+
1325+
static int platform_profile_victus_get(struct platform_profile_handler *pprof,
1326+
enum platform_profile_option *profile)
1327+
{
1328+
int tp;
1329+
1330+
tp = omen_thermal_profile_get();
1331+
if (tp < 0)
1332+
return tp;
1333+
1334+
switch (tp) {
1335+
case HP_VICTUS_THERMAL_PROFILE_PERFORMANCE:
1336+
*profile = PLATFORM_PROFILE_PERFORMANCE;
1337+
break;
1338+
case HP_VICTUS_THERMAL_PROFILE_DEFAULT:
1339+
*profile = PLATFORM_PROFILE_BALANCED;
1340+
break;
1341+
case HP_VICTUS_THERMAL_PROFILE_QUIET:
1342+
*profile = PLATFORM_PROFILE_QUIET;
1343+
break;
1344+
default:
1345+
return -EOPNOTSUPP;
1346+
}
1347+
1348+
return 0;
1349+
}
1350+
1351+
static int platform_profile_victus_set(struct platform_profile_handler *pprof,
1352+
enum platform_profile_option profile)
1353+
{
1354+
int err, tp;
1355+
1356+
switch (profile) {
1357+
case PLATFORM_PROFILE_PERFORMANCE:
1358+
tp = HP_VICTUS_THERMAL_PROFILE_PERFORMANCE;
1359+
break;
1360+
case PLATFORM_PROFILE_BALANCED:
1361+
tp = HP_VICTUS_THERMAL_PROFILE_DEFAULT;
1362+
break;
1363+
case PLATFORM_PROFILE_QUIET:
1364+
tp = HP_VICTUS_THERMAL_PROFILE_QUIET;
1365+
break;
1366+
default:
1367+
return -EOPNOTSUPP;
1368+
}
1369+
1370+
err = omen_thermal_profile_set(tp);
1371+
if (err < 0)
1372+
return err;
1373+
1374+
return 0;
1375+
}
1376+
13021377
static int thermal_profile_setup(void)
13031378
{
13041379
int err, tp;
@@ -1319,6 +1394,25 @@ static int thermal_profile_setup(void)
13191394

13201395
platform_profile_handler.profile_get = platform_profile_omen_get;
13211396
platform_profile_handler.profile_set = platform_profile_omen_set;
1397+
1398+
set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices);
1399+
} else if (is_victus_thermal_profile()) {
1400+
tp = omen_thermal_profile_get();
1401+
if (tp < 0)
1402+
return tp;
1403+
1404+
/*
1405+
* call thermal profile write command to ensure that the
1406+
* firmware correctly sets the OEM variables
1407+
*/
1408+
err = omen_thermal_profile_set(tp);
1409+
if (err < 0)
1410+
return err;
1411+
1412+
platform_profile_handler.profile_get = platform_profile_victus_get;
1413+
platform_profile_handler.profile_set = platform_profile_victus_set;
1414+
1415+
set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices);
13221416
} else {
13231417
tp = thermal_profile_get();
13241418

@@ -1337,9 +1431,9 @@ static int thermal_profile_setup(void)
13371431
platform_profile_handler.profile_set = hp_wmi_platform_profile_set;
13381432

13391433
set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices);
1434+
set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices);
13401435
}
13411436

1342-
set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices);
13431437
set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices);
13441438
set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices);
13451439

0 commit comments

Comments
 (0)