[PATCH 2/2] tests/amdgpu/amd_abm: Add support for panel_power_saving property

Mario Limonciello mario.limonciello at amd.com
Sun May 19 13:07:17 UTC 2024


From: Mario Limonciello <superm1 at ubuntu.com>

When the "panel power saving" property is set to forbidden the
compositor has indicated that userspace prefers to have color
accuracy and fidelity instead of power saving.

Verify that the sysfs file behaves as expected in this situation.

Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
---
 tests/amdgpu/amd_abm.c | 65 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/tests/amdgpu/amd_abm.c b/tests/amdgpu/amd_abm.c
index f74c3012c..971cda153 100644
--- a/tests/amdgpu/amd_abm.c
+++ b/tests/amdgpu/amd_abm.c
@@ -104,6 +104,32 @@ static int backlight_write_brightness(int value)
 	return 0;
 }
 
+static int toggle_panel_power_saving_prop(data_t *data, igt_output_t *output, bool forbid)
+{
+	uint32_t type = DRM_MODE_OBJECT_CONNECTOR;
+	bool prop_exists;
+	uint32_t prop_id;
+
+	prop_exists = kmstest_get_property(
+		data->drm_fd, output->id, type, "panel power saving",
+		&prop_id, NULL, NULL);
+
+	if (!prop_exists)
+		return -ENODEV;
+
+	return drmModeObjectSetProperty(data->drm_fd, output->id, type, prop_id, forbid);
+}
+
+static int allow_panel_power_saving(data_t *data, igt_output_t *output)
+{
+	return toggle_panel_power_saving_prop(data, output, false);
+}
+
+static int forbid_panel_power_saving(data_t *data, igt_output_t *output)
+{
+	return toggle_panel_power_saving_prop(data, output, true);
+}
+
 static int set_abm_level(data_t *data, igt_output_t *output, int level)
 {
 	char buf[PATH_MAX];
@@ -365,6 +391,43 @@ static void abm_gradual(data_t *data)
 	}
 }
 
+
+static void abm_forbidden(data_t *data)
+{
+	igt_output_t *output;
+	enum pipe pipe;
+	int target, r;
+
+	for_each_pipe_with_valid_output(&data->display, pipe, output) {
+		if (output->config.connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+			continue;
+
+		r = allow_panel_power_saving(data, output);
+		if (r == -ENODEV) {
+			igt_skip("No panel power saving prop\n");
+			return;
+		}
+		igt_assert_eq(r, 0);
+
+		target = 3;
+		r = set_abm_level(data, output, target);
+		igt_assert_eq(r, 0);
+
+		r = forbid_panel_power_saving(data, output);
+		igt_assert_eq(r, 0);
+
+		target = 0;
+		r = set_abm_level(data, output, target);
+		igt_assert_eq(r, -1);
+
+		r = allow_panel_power_saving(data, output);
+		igt_assert_eq(r, 0);
+
+		r = set_abm_level(data, output, target);
+		igt_assert_eq(r, 0);
+	}
+}
+
 igt_main
 {
 	data_t data = {};
@@ -393,6 +456,8 @@ igt_main
 		abm_enabled(&data);
 	igt_subtest("abm_gradual")
 		abm_gradual(&data);
+	igt_subtest("abm_forbidden")
+		abm_forbidden(&data);
 
 	igt_fixture {
 		igt_display_fini(&data.display);
-- 
2.45.0



More information about the amd-gfx mailing list