[PATCH i-g-t 2/2] kms_psr2_sf: Add dynamic subtests which use DSC feature

Jouni Högander jouni.hogander at intel.com
Tue Dec 20 10:55:18 UTC 2022


Add mechanism to add coexisting features with selective fetch
and add subtest for DSC as coexisting feature.

Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
---
 tests/i915/kms_psr2_sf.c | 383 ++++++++++++++++++++++++++++-----------
 1 file changed, 276 insertions(+), 107 deletions(-)

diff --git a/tests/i915/kms_psr2_sf.c b/tests/i915/kms_psr2_sf.c
index 078884ac0d..d7b6bb39e2 100644
--- a/tests/i915/kms_psr2_sf.c
+++ b/tests/i915/kms_psr2_sf.c
@@ -86,6 +86,13 @@ typedef struct {
 	uint32_t screen_changes;
 	int cur_x, cur_y;
 	enum pipe pipe;
+	bool force_dsc_en_orig;
+	int force_dsc_restore_fd;
+	enum {
+		FEATURE_NONE  = 0,
+		FEATURE_DSC   = 1,
+		FEATURE_COUNT = 2,
+	} coexist_feature;
 } data_t;
 
 static const char *op_str(enum operations op)
@@ -104,6 +111,71 @@ static const char *op_str(enum operations op)
 	return name[op];
 }
 
+static const char *coexist_feature_str(int coexist_feature)
+{
+	switch (coexist_feature) {
+	case FEATURE_NONE:
+		return "";
+	case FEATURE_DSC:
+		return "-dsc";
+	default:
+		igt_assert(false);
+	}
+}
+
+static void force_dsc_enable(data_t *data)
+{
+	int ret;
+
+	igt_debug("Forcing DSC enable on %s\n", data->output->name);
+	ret = igt_force_dsc_enable(data->drm_fd,
+				   data->output->name);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+static void save_force_dsc_en(data_t *data)
+{
+	data->force_dsc_en_orig =
+		igt_is_force_dsc_enabled(data->drm_fd,
+					 data->output->name);
+	data->force_dsc_restore_fd =
+		igt_get_dsc_debugfs_fd(data->drm_fd,
+				       data->output->name);
+	igt_assert(data->force_dsc_restore_fd >= 0);
+}
+
+static void restore_force_dsc_en(data_t *data)
+{
+	if (data->force_dsc_restore_fd < 0)
+		return;
+
+	igt_debug("Restoring DSC enable\n");
+	igt_assert(write(data->force_dsc_restore_fd, data->force_dsc_en_orig ? "1" : "0", 1) == 1);
+
+	close(data->force_dsc_restore_fd);
+	data->force_dsc_restore_fd = -1;
+}
+
+static bool check_dsc_on_connector(data_t *data)
+{
+	igt_output_t *output = data->output;
+
+	if (!igt_is_dsc_supported(data->drm_fd, output->name)) {
+		igt_debug("DSC not supported on connector %s\n",
+			  output->name);
+		return false;
+	}
+
+	if (!output_is_internal_panel(output) &&
+	    !igt_is_fec_supported(data->drm_fd, output->name)) {
+		igt_debug("DSC cannot be enabled without FEC on %s\n",
+			  output->name);
+		return false;
+	}
+
+	return true;
+}
+
 static void display_init(data_t *data)
 {
 	igt_display_require(&data->display, data->drm_fd);
@@ -224,9 +296,17 @@ static void prepare(data_t *data)
 	igt_plane_t *primary, *sprite = NULL, *cursor = NULL;
 	int fb_w, fb_h, x, y, view_w, view_h;
 
-	igt_output_set_pipe(output, data->pipe);
 	data->mode = igt_output_get_mode(output);
 
+	if (data->coexist_feature & FEATURE_DSC) {
+		save_force_dsc_en(data);
+		force_dsc_enable(data);
+		igt_output_set_pipe(output, PIPE_NONE);
+		igt_display_commit2(&data->display, COMMIT_ATOMIC);
+	}
+
+	igt_output_set_pipe(output, data->pipe);
+
 	if (data->big_fb_test) {
 		fb_w = data->big_fb_width;
 		fb_h = data->big_fb_height;
@@ -816,6 +896,11 @@ static void cleanup(data_t *data)
 		igt_plane_set_fb(sprite, NULL);
 	}
 
+	if (data->coexist_feature & FEATURE_DSC) {
+		restore_force_dsc_en(data);
+		igt_output_set_pipe(output, PIPE_NONE);
+	}
+
 	igt_display_commit2(&data->display, COMMIT_ATOMIC);
 
 	igt_remove_fb(data->drm_fd, &data->fb_primary);
@@ -839,9 +924,10 @@ igt_main
 {
 	data_t data = {};
 	igt_output_t *outputs[IGT_MAX_PIPES * IGT_MAX_PIPES];
-	int i, j;
+	int i, j, k;
 	int pipes[IGT_MAX_PIPES * IGT_MAX_PIPES];
 	int n_pipes = 0;
+	int coexist_features[IGT_MAX_PIPES * IGT_MAX_PIPES];
 
 	igt_fixture {
 		drmModeResPtr res;
@@ -877,9 +963,14 @@ igt_main
 			      "PSR2 selective fetch not enabled\n");
 
 		for_each_pipe_with_valid_output(&data.display, data.pipe, data.output) {
+			coexist_features[n_pipes] = 0;
 			if (check_psr2_support(&data)) {
 				pipes[n_pipes] = data.pipe;
 				outputs[n_pipes] = data.output;
+
+				if (check_dsc_on_connector(&data))
+					coexist_features[n_pipes] |= FEATURE_DSC;
+
 				n_pipes++;
 			}
 		}
@@ -889,16 +980,22 @@ igt_main
 	igt_describe("Test that selective fetch works on primary plane");
 	igt_subtest_with_dynamic_f("primary-%s-sf-dmg-area", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				for (j = 1; j <= MAX_DAMAGE_AREAS; j++) {
-					data.damage_area_count = j;
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
 					data.test_plane_id = DRM_PLANE_TYPE_PRIMARY;
-					prepare(&data);
-					run(&data);
-					cleanup(&data);
+					data.coexist_feature = j;
+					for (k = 1; k <= MAX_DAMAGE_AREAS; k++) {
+						data.damage_area_count = k;
+						prepare(&data);
+						run(&data);
+						cleanup(&data);
+					}
 				}
 			}
 		}
@@ -909,16 +1006,22 @@ igt_main
 	igt_describe("Test that selective fetch works on primary plane with big fb");
 	igt_subtest_with_dynamic_f("primary-%s-sf-dmg-area-big-fb", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				for (j = 1; j <= MAX_DAMAGE_AREAS; j++) {
-					data.damage_area_count = j;
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
 					data.test_plane_id = DRM_PLANE_TYPE_PRIMARY;
-					prepare(&data);
-					run(&data);
-					cleanup(&data);
+					data.coexist_feature = j;
+					for (k = 1; k <= MAX_DAMAGE_AREAS; k++) {
+						data.damage_area_count = k;
+						prepare(&data);
+						run(&data);
+						cleanup(&data);
+					}
 				}
 			}
 		}
@@ -929,16 +1032,22 @@ igt_main
 	igt_describe("Test that selective fetch works on overlay plane");
 	igt_subtest_with_dynamic_f("overlay-%s-sf-dmg-area", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				for (j = 1; j <= MAX_DAMAGE_AREAS; j++) {
-					data.damage_area_count = j;
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
 					data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
-					prepare(&data);
-					run(&data);
-					cleanup(&data);
+					data.coexist_feature = j;
+					for (k = 1; k <= MAX_DAMAGE_AREAS; k++) {
+						data.damage_area_count = k;
+						prepare(&data);
+						run(&data);
+						cleanup(&data);
+					}
 				}
 			}
 		}
@@ -949,14 +1058,20 @@ igt_main
 	igt_describe("Test that selective fetch works on cursor plane");
 	igt_subtest_with_dynamic_f("cursor-%s-sf", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				data.test_plane_id = DRM_PLANE_TYPE_CURSOR;
-				prepare(&data);
-				run(&data);
-				cleanup(&data);
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
+					data.test_plane_id = DRM_PLANE_TYPE_CURSOR;
+					data.coexist_feature = j;
+					prepare(&data);
+					run(&data);
+					cleanup(&data);
+				}
 			}
 		}
 	}
@@ -965,14 +1080,20 @@ igt_main
 	igt_describe("Test that selective fetch works on moving cursor plane (no update)");
 	igt_subtest_with_dynamic_f("cursor-%s-sf", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				data.test_plane_id = DRM_PLANE_TYPE_CURSOR;
-				prepare(&data);
-				run(&data);
-				cleanup(&data);
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
+					data.test_plane_id = DRM_PLANE_TYPE_CURSOR;
+					data.coexist_feature = j;
+					prepare(&data);
+					run(&data);
+					cleanup(&data);
+				}
 			}
 		}
 	}
@@ -981,14 +1102,20 @@ igt_main
 	igt_describe("Test that selective fetch works on moving cursor plane exceeding partially visible area (no update)");
 	igt_subtest_with_dynamic_f("cursor-%s-sf", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				data.test_plane_id = DRM_PLANE_TYPE_CURSOR;
-				prepare(&data);
-				run(&data);
-				cleanup(&data);
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
+					data.test_plane_id = DRM_PLANE_TYPE_CURSOR;
+					data.coexist_feature = j;
+					prepare(&data);
+					run(&data);
+					cleanup(&data);
+				}
 			}
 		}
 	}
@@ -997,14 +1124,20 @@ igt_main
 	igt_describe("Test that selective fetch works on moving cursor plane exceeding fully visible area (no update)");
 	igt_subtest_with_dynamic_f("cursor-%s-sf", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				data.test_plane_id = DRM_PLANE_TYPE_CURSOR;
-				prepare(&data);
-				run(&data);
-				cleanup(&data);
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
+					data.test_plane_id = DRM_PLANE_TYPE_CURSOR;
+					data.coexist_feature = j;
+					prepare(&data);
+					run(&data);
+					cleanup(&data);
+				}
 			}
 		}
 	}
@@ -1015,16 +1148,22 @@ igt_main
 	igt_describe("Test that selective fetch works on moving overlay plane");
 	igt_subtest_with_dynamic_f("%s-sf-dmg-area", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				for (j = POS_TOP_LEFT; j <= POS_BOTTOM_RIGHT ; j++) {
-					data.pos = j;
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
 					data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
-					prepare(&data);
-					run(&data);
-					cleanup(&data);
+					data.coexist_feature = j;
+					for (k = POS_TOP_LEFT; k <= POS_BOTTOM_RIGHT ; k++) {
+						data.pos = k;
+						prepare(&data);
+						run(&data);
+						cleanup(&data);
+					}
 				}
 			}
 		}
@@ -1034,14 +1173,20 @@ igt_main
 	igt_describe("Test that selective fetch works on moving overlay plane (no update)");
 	igt_subtest_with_dynamic_f("overlay-%s-sf", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
 				data.pipe = pipes[i];
 				data.output = outputs[i];
 				data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
+				data.coexist_feature = j;
 				prepare(&data);
 				run(&data);
 				cleanup(&data);
+				}
 			}
 		}
 	}
@@ -1050,14 +1195,20 @@ igt_main
 	igt_describe("Test that selective fetch works on moving overlay plane partially exceeding visible area (no update)");
 	igt_subtest_with_dynamic_f("overlay-%s-sf", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
-				prepare(&data);
-				run(&data);
-				cleanup(&data);
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
+					data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
+					data.coexist_feature = j;
+					prepare(&data);
+					run(&data);
+					cleanup(&data);
+				}
 			}
 		}
 	}
@@ -1066,14 +1217,20 @@ igt_main
 	igt_describe("Test that selective fetch works on moving overlay plane fully exceeding visible area (no update)");
 	igt_subtest_with_dynamic_f("overlay-%s-sf", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
-				prepare(&data);
-				run(&data);
-				cleanup(&data);
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
+					data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
+					data.coexist_feature = j;
+					prepare(&data);
+					run(&data);
+					cleanup(&data);
+				}
 			}
 		}
 	}
@@ -1084,16 +1241,22 @@ igt_main
 		     "with blended overlay plane");
 	igt_subtest_with_dynamic_f("%s-sf-dmg-area", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-					igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				for (j = 1; j <= MAX_DAMAGE_AREAS; j++) {
-					data.damage_area_count = j;
-					data.test_plane_id = DRM_PLANE_TYPE_PRIMARY;
-					prepare(&data);
-					run(&data);
-					cleanup(&data);
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
+					for (k = 1; k <= MAX_DAMAGE_AREAS; k++) {
+						data.damage_area_count = k;
+						data.test_plane_id = DRM_PLANE_TYPE_PRIMARY;
+						data.coexist_feature = j;
+						prepare(&data);
+						run(&data);
+						cleanup(&data);
+					}
 				}
 			}
 		}
@@ -1108,15 +1271,21 @@ igt_main
 	igt_describe("Test that selective fetch works on overlay plane");
 	igt_subtest_with_dynamic_f("overlay-%s-sf", op_str(data.op)) {
 		for (i = 0; i < n_pipes; i++) {
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipes[i]),
-				      igt_output_name(outputs[i])) {
-				data.pipe = pipes[i];
-				data.output = outputs[i];
-				data.damage_area_count = 1;
-				data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
-				prepare(&data);
-				run(&data);
-				cleanup(&data);
+			for (j = FEATURE_NONE; j < FEATURE_COUNT; j++) {
+				if (j != FEATURE_NONE && !(coexist_features[i] & j))
+					continue;
+				igt_dynamic_f("pipe-%s-%s%s", kmstest_pipe_name(pipes[i]),
+					      igt_output_name(outputs[i]),
+					      coexist_feature_str(j)) {
+					data.pipe = pipes[i];
+					data.output = outputs[i];
+					data.damage_area_count = 1;
+					data.test_plane_id = DRM_PLANE_TYPE_OVERLAY;
+					data.coexist_feature = j;
+					prepare(&data);
+					run(&data);
+					cleanup(&data);
+				}
 			}
 		}
 	}
-- 
2.34.1



More information about the Intel-gfx-trybot mailing list