[Intel-gfx] [PATCH IGT 05/11] lib: Add library functions for PSR source and sink support

Jim Bride jim.bride at linux.intel.com
Tue Jul 11 22:48:30 UTC 2017


Add functions to tell whether the source and sink support PSR as well
as a function to determine whether PSR is possible (both source and
sink support PSR.)  Also modify the PSR tests to use these functions.

Signed-off-by: Jim Bride <jim.bride at linux.intel.com>
---
 lib/Makefile.sources             |  1 +
 lib/igt_psr.c                    | 85 ++++++++++++++++++++++++++++++++++++++++
 lib/igt_psr.h                    |  4 ++
 tests/kms_fbcon_fbt.c            |  5 +--
 tests/kms_frontbuffer_tracking.c |  5 +--
 tests/kms_psr_sink_crc.c         |  6 +--
 6 files changed, 93 insertions(+), 13 deletions(-)
 create mode 100644 lib/igt_psr.c

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 7ec6711..6a73c8c 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -83,6 +83,7 @@ lib_source_list =	 	\
 	uwildmat/uwildmat.c	\
 	igt_kmod.c		\
 	igt_kmod.h		\
+	igt_psr.c		\
 	igt_psr.h		\
 	$(NULL)
 
diff --git a/lib/igt_psr.c b/lib/igt_psr.c
new file mode 100644
index 0000000..c5c9b4c
--- /dev/null
+++ b/lib/igt_psr.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include <stdio.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <string.h>
+#include <fcntl.h>
+
+/**
+ * SECTION:igt_psr
+ * @short_description: Panel Self Refresh helpers
+ * @title: Panel Self Refresh
+ * @include: igt.h
+ *
+ * This library provides various helpers to enable Panel Self Refresh,
+ * as well as to check the state of PSR on the system (enabled vs.
+ * disabled, active vs. inactive) or to wait for PSR to be active
+ * or inactive.
+ */
+
+#define BUFSIZE 512 /* Size of char buffer to read debugfs data into */
+
+/**
+ * igt_psr_source_support:
+ *
+ * Returns true if the source supports PSR.
+ */
+bool igt_psr_source_support(int fd)
+{
+	char buf[BUFSIZE];
+
+	igt_debugfs_read(fd, "i915_edp_psr_status", buf);
+
+	return !!strstr(buf, "Source_OK: yes\n");
+}
+
+
+/**
+ * igt_psr_sink_support:
+ *
+ * Returns true if the current eDP panel supports PSR.
+ */
+bool igt_psr_sink_support(int fd)
+{
+	char buf[BUFSIZE];
+
+	igt_debugfs_read(fd, "i915_edp_psr_status", buf);
+	return !!strstr(buf, "Sink_Support: yes\n");
+}
+
+/**
+ * igt_psr_possible:
+ *
+ * Returns true if both the source and sink support PSR.
+ */
+bool igt_psr_possible(int fd)
+{
+	char buf[BUFSIZE];
+
+	igt_debugfs_read(fd, "i915_edp_psr_status", buf);
+
+	return igt_psr_source_support(fd) && igt_psr_sink_support(fd);
+}
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
index 71b1233..98774c8 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -27,4 +27,8 @@
 #define igt_psr_enable() igt_set_module_param_int("enable_psr", 1)
 #define igt_psr_disable() igt_set_module_param_int("enable_psr", 0)
 
+bool igt_psr_source_support(int fd);
+bool igt_psr_sink_support(int fd);
+bool igt_psr_possible(int fd);
+
 #endif /* IGT_PSR_H */
diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c
index 4b9cb43..d0ed9f5 100644
--- a/tests/kms_fbcon_fbt.c
+++ b/tests/kms_fbcon_fbt.c
@@ -149,10 +149,7 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb,
 
 static bool psr_supported_on_chipset(int fd)
 {
-	char buf[256];
-
-	igt_debugfs_read(fd, "i915_edp_psr_status", buf);
-	return strstr(buf, "Sink_Support: yes\n");
+	return igt_psr_sink_support(fd);
 }
 
 static bool connector_can_psr(drmModeConnectorPtr connector)
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 3c30745..347dcc1 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -1543,10 +1543,7 @@ static void teardown_fbc(void)
 
 static bool psr_sink_has_support(void)
 {
-	char buf[256];
-
-	debugfs_read("i915_edp_psr_status", buf);
-	return strstr(buf, "Sink_Support: yes\n");
+	return igt_psr_sink_support(drm.fd);
 }
 
 static void setup_psr(void)
diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
index c0404b2..952a109 100644
--- a/tests/kms_psr_sink_crc.c
+++ b/tests/kms_psr_sink_crc.c
@@ -194,12 +194,8 @@ static void fill_render(data_t *data, uint32_t handle, unsigned char color)
 
 static bool psr_possible(data_t *data)
 {
-	char buf[512];
-
-	igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf);
-
 	return running_with_psr_disabled ||
-		strstr(buf, "Sink_Support: yes\n");
+		igt_psr_possible(data->drm_fd);
 }
 
 static bool psr_active(data_t *data)
-- 
2.7.4



More information about the Intel-gfx mailing list