Recognize the custom ACPI platform profile

This is new to 6.14. Currently PPD recognizes this as "cool"
This commit is contained in:
Mario Limonciello 2025-02-11 15:27:13 -06:00 committed by Marco Trevisan (Treviño)
parent c30bcb634a
commit 6b565b0b05
2 changed files with 38 additions and 13 deletions

View file

@ -81,19 +81,23 @@ acpi_platform_profile_value_to_profile (const char *str)
if (str == NULL)
return PPD_PROFILE_UNSET;
switch (str[0]) {
case 'l': /* low-power */
case 'q': /* quiet */
if (g_str_equal (str, "custom"))
return PPD_PROFILE_UNSET;
if (g_str_equal (str, "low-power") ||
g_str_equal (str, "quiet"))
return PPD_PROFILE_POWER_SAVER;
case 'c': /* cool */
case 'b':
if (g_str_equal (str, "balanced") ||
g_str_equal (str, "balanced_performance") ||
g_str_equal (str, "cool"))
return PPD_PROFILE_BALANCED;
case 'p':
if (g_str_equal (str, "performance"))
return PPD_PROFILE_PERFORMANCE;
default:
g_debug ("Unhandled ACPI platform profile '%c'", str[0]);
g_return_val_if_reached (PPD_PROFILE_UNSET);
}
g_debug ("Unhandled ACPI platform profile '%s'", str);
g_return_val_if_reached (PPD_PROFILE_UNSET);
}
static PpdProfile
@ -113,9 +117,9 @@ read_platform_profile (void)
return PPD_PROFILE_UNSET;
}
new_profile = acpi_platform_profile_value_to_profile (new_profile_str);
g_debug ("ACPI performance_profile is now %c, so profile is detected as %s",
new_profile_str[0],
new_profile = acpi_platform_profile_value_to_profile (g_strchomp (new_profile_str));
g_debug ("ACPI performance_profile is now '%s', so profile is detected as %s",
g_strchomp (new_profile_str),
ppd_profile_to_str (new_profile));
return new_profile;
}

View file

@ -377,6 +377,15 @@ class Tests(dbusmock.DBusTestCase):
"low-power balanced performance\n",
)
def create_custom_platform_profile(self):
acpi_dir = os.path.join(self.testbed.get_root_dir(), "sys/firmware/acpi/")
os.makedirs(acpi_dir, exist_ok=True)
self.write_file_contents(os.path.join(acpi_dir, "platform_profile"), "custom\n")
self.write_file_contents(
os.path.join(acpi_dir, "platform_profile_choices"),
"low-power balanced performance custom\n",
)
def remove_platform_profile(self):
acpi_dir = os.path.join(self.testbed.get_root_dir(), "sys/firmware/acpi/")
os.remove(os.path.join(acpi_dir, "platform_profile_choices"))
@ -1984,6 +1993,18 @@ class Tests(dbusmock.DBusTestCase):
self.read_sysfs_file("sys/firmware/acpi/platform_profile"), b"quiet"
)
def test_custom_acpi_platform_profile(self):
self.create_custom_platform_profile()
self.start_daemon()
profiles = self.get_dbus_property("Profiles")
self.assertEqual(len(profiles), 3)
self.assertEqual(profiles[0]["PlatformDriver"], "platform_profile")
# make sure PPD overrides it
self.assertEqual(
self.read_sysfs_file("sys/firmware/acpi/platform_profile"), b"balanced"
)
def test_hold_release_profile(self):
self.create_platform_profile()
self.start_daemon()