[PATCH i-g-t 1/3] tests/i915/kms_frontbuffer_tracking: Split fbc into separate helper

Jouni Högander jouni.hogander at intel.com
Mon Apr 3 08:22:47 UTC 2023


Split fbc handling into separate helper to be used by other tests
as well.

Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
---
 tests/i915/kms_fbc_helper.c           | 25 +++++++++++++++++++++++++
 tests/i915/kms_fbc_helper.h           | 17 +++++++++++++++++
 tests/i915/kms_frontbuffer_tracking.c | 25 +++++++------------------
 tests/meson.build                     |  9 ++++++++-
 4 files changed, 57 insertions(+), 19 deletions(-)
 create mode 100644 tests/i915/kms_fbc_helper.c
 create mode 100644 tests/i915/kms_fbc_helper.h

diff --git a/tests/i915/kms_fbc_helper.c b/tests/i915/kms_fbc_helper.c
new file mode 100644
index 00000000..5f2e1408
--- /dev/null
+++ b/tests/i915/kms_fbc_helper.c
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <fcntl.h>
+
+#include "igt.h"
+
+#include "kms_fbc_helper.h"
+
+bool fbc_supported_on_chipset(int device, enum pipe pipe)
+{
+	char buf[128];
+	int dir;
+
+	dir = igt_debugfs_pipe_dir(device, pipe, O_DIRECTORY);
+	igt_require_fd(dir);
+	igt_debugfs_simple_read(dir, "i915_fbc_status", buf, sizeof(buf));
+	close(dir);
+	if (*buf == '\0')
+		return false;
+
+	return !strstr(buf, "FBC unsupported on this chipset\n");
+}
diff --git a/tests/i915/kms_fbc_helper.h b/tests/i915/kms_fbc_helper.h
new file mode 100644
index 00000000..9d9b6f58
--- /dev/null
+++ b/tests/i915/kms_fbc_helper.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2022 Intel Corporation
+ */
+
+#ifndef IGT_KMS_FBC_HELPER_H
+#define IGT_KMS_FBC_HELPER_H
+
+#include "igt.h"
+
+#define fbc_enable(device) igt_set_module_param_int(device, "enable_fbc", 1)
+#define fbc_disable(device) igt_set_module_param_int(device, "enable_fbc", 0)
+
+bool fbc_supported_on_chipset(int device, enum pipe pipe);
+
+#endif
+
diff --git a/tests/i915/kms_frontbuffer_tracking.c b/tests/i915/kms_frontbuffer_tracking.c
index 650e14a7..e78073e5 100644
--- a/tests/i915/kms_frontbuffer_tracking.c
+++ b/tests/i915/kms_frontbuffer_tracking.c
@@ -36,6 +36,8 @@
 #include "igt_sysfs.h"
 #include "igt_psr.h"
 
+#include "kms_fbc_helper.h"
+
 #define TIME SLOW_QUICK(1000, 10000)
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
@@ -982,10 +984,8 @@ static bool drrs_wait_until_rr_switch_to_low(void)
 	return igt_wait(is_drrs_low(), 5000, 1);
 }
 
-#define fbc_enable() igt_set_module_param_int(drm.fd, "enable_fbc", 1)
-#define fbc_disable() igt_set_module_param_int(drm.fd, "enable_fbc", 0)
-#define drrs_enable()	drrs_set(1)
-#define drrs_disable()	drrs_set(0)
+#define drrs_enable()  drrs_set(1)
+#define drrs_disable() drrs_set(0)
 
 static struct rect pat1_get_rect(struct fb_region *fb, int r)
 {
@@ -1188,8 +1188,8 @@ static bool disable_features(const struct test_mode *t)
 	if (t->feature == FEATURE_DEFAULT)
 		return false;
 
-	fbc_disable();
 	drrs_disable();
+	fbc_disable(drm.fd);
 	return psr.can_test ? psr_disable(drm.fd, drm.debugfs) : false;
 }
 
@@ -1429,20 +1429,9 @@ static void teardown_crcs(void)
 	igt_pipe_crc_free(pipe_crc);
 }
 
-static bool fbc_supported_on_chipset(void)
-{
-	char buf[128];
-
-	debugfs_read_crtc("i915_fbc_status", buf);
-	if (*buf == '\0')
-		return false;
-
-	return !strstr(buf, "FBC unsupported on this chipset\n");
-}
-
 static void setup_fbc(void)
 {
-	if (!fbc_supported_on_chipset()) {
+	if (!fbc_supported_on_chipset(drm.fd, prim_mode_params.pipe)) {
 		igt_info("Can't test FBC: not supported on this chipset\n");
 		return;
 	}
@@ -1797,7 +1786,7 @@ static bool enable_features_for_test(const struct test_mode *t)
 		return false;
 
 	if (t->feature & FEATURE_FBC)
-		fbc_enable();
+		fbc_enable(drm.fd);
 	if (t->feature & FEATURE_PSR)
 		ret = psr_enable(drm.fd, drm.debugfs, PSR_MODE_1);
 	if (t->feature & FEATURE_DRRS)
diff --git a/tests/meson.build b/tests/meson.build
index 7d2168be..3c1151f5 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -227,7 +227,6 @@ i915_progs = [
 	'kms_fence_pin_leak',
 	'kms_flip_scaled_crc',
 	'kms_flip_tiling',
-	'kms_frontbuffer_tracking',
 	'kms_legacy_colorkey',
 	'kms_mmap_write_crc',
 	'kms_pipe_b_c_ivb',
@@ -486,6 +485,14 @@ test_executables += executable('kms_psr2_sf',
 	   install : true)
 test_list += 'kms_psr2_sf'
 
+test_executables += executable('kms_frontbuffer_tracking',
+	   [ join_paths('i915', 'kms_frontbuffer_tracking.c'), join_paths ('i915', 'kms_fbc_helper.c')],
+	   dependencies : test_deps,
+	   install_dir : libexecdir,
+	   install_rpath : libexecdir_rpathdir,
+	   install : true)
+test_list += 'kms_frontbuffer_tracking'
+
 if chamelium.found()
        test_executables += executable('kms_chamelium_color',
                              [ 'chamelium/kms_chamelium_color.c', 'kms_color_helper.c' ],
-- 
2.34.1



More information about the Intel-gfx-trybot mailing list