[i-g-t 3/4] tests/kms_vrr: Add a test for VRR range capability

Bhanuprakash Modem bhanuprakash.modem at intel.com
Tue Feb 22 16:04:11 UTC 2022


VRR range capability is parsed from EDID and reported to debugfs.
The new tests check if the parsing is correct by reading it from
EDID.

Cc: Manasi Navare <manasi.d.navare at intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 tests/kms_vrr.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/tests/kms_vrr.c b/tests/kms_vrr.c
index 7deab77311..1aac9e3bff 100644
--- a/tests/kms_vrr.c
+++ b/tests/kms_vrr.c
@@ -24,6 +24,7 @@
 #include "sw_sync.h"
 #include <fcntl.h>
 #include <signal.h>
+#include "igt_edid.h"
 
 #define NSECS_PER_SEC (1000000000ull)
 
@@ -485,6 +486,71 @@ test_negative_basic(data_t *data, enum pipe pipe,
 	igt_remove_fb(data->drm_fd, &data->fb0);
 }
 
+static range_t
+get_monitor_range_from_edid(const struct edid *edid)
+{
+	range_t range = {0, 0};
+	uint8_t i;
+
+	for (i = 0; i < DETAILED_TIMINGS_LEN; i++) {
+		struct detailed_non_pixel *other_data;
+		struct detailed_data_monitor_range *range_edid;
+		struct detailed_timing timings = edid->detailed_timings[i];
+
+		if (timings.pixel_clock[0] != 0 &&
+		    timings.pixel_clock[1] != 0)
+			continue;
+
+		other_data = &timings.data.other_data;
+		if (other_data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+
+		range_edid = &other_data->data.range;
+		range.min = range_edid->min_vfreq;
+		range.max = range_edid->max_vfreq;
+
+		break;
+	}
+
+	return range;
+}
+
+static void
+test_vrr_range(data_t *data, enum pipe pipe,
+		igt_output_t *output, uint32_t flags)
+{
+	range_t expected_range;
+	uint64_t edid_blob_id;
+	const struct edid *edid;
+	drmModePropertyBlobPtr edid_blob = NULL;
+	drmModeConnector *connector = output->config.connector;
+
+	igt_assert(kmstest_get_property(data->drm_fd, connector->connector_id,
+					DRM_MODE_OBJECT_CONNECTOR, "EDID", NULL,
+					&edid_blob_id, NULL));
+	edid_blob = drmModeGetPropertyBlob(data->drm_fd, edid_blob_id);
+	igt_require_f(edid_blob, "EDID blob is NULL\n");
+
+	edid = (const struct edid *) edid_blob->data;
+
+	prepare_negative_test(data, output, pipe);
+	expected_range = get_monitor_range_from_edid(edid);
+
+	igt_assert_f(data->range.min == expected_range.min &&
+		     data->range.max == expected_range.max,
+		     "Expecting VRR range %d-%d, got %d-%d\n",
+		     expected_range.min, expected_range.max,
+		     data->range.min, data->range.max);
+	igt_info("VRR range: %d-%d\n", data->range.min, data->range.max);
+
+	/* Clean-up */
+	igt_plane_set_fb(data->primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	set_vrr_on_pipe(data, pipe, false);
+
+	igt_remove_fb(data->drm_fd, &data->fb0);
+}
+
 /* Runs tests on outputs that are VRR capable. */
 static void
 run_vrr_test(data_t *data, test_t test, uint32_t flags)
@@ -514,6 +580,25 @@ run_vrr_test(data_t *data, test_t test, uint32_t flags)
 	}
 }
 
+static void
+run_parse_test(data_t *data, test_t test, uint32_t flags)
+{
+	igt_output_t *output;
+
+	for_each_connected_output(&data->display, output) {
+		enum pipe pipe;
+
+		for_each_pipe(&data->display, pipe) {
+			if (igt_pipe_connector_valid(pipe, output)) {
+				igt_dynamic_f("pipe-%s-%s",
+					      kmstest_pipe_name(pipe), output->name)
+					test(data, pipe, output, flags);
+				break;
+			}
+		}
+	}
+}
+
 igt_main
 {
 	data_t data = {};
@@ -551,6 +636,11 @@ igt_main
 	igt_subtest_with_dynamic("negative-basic")
 		run_vrr_test(&data, test_negative_basic, TEST_NEGATIVE);
 
+	igt_describe("Read the monitor RR range from monitor and make sure that "
+		     "Kernel is parsing it properly.");
+	igt_subtest_with_dynamic("vrr-parse")
+		run_parse_test(&data, test_vrr_range, TEST_NONE);
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 	}
-- 
2.35.0



More information about the Intel-gfx-trybot mailing list