[igt-dev] [PATCH i-g-t] lib/igt_kms: Add helper to turn on and off the displays

Mohammed Thasleem mohammed.thasleem at intel.com
Tue Sep 12 08:11:29 UTC 2023


From: Bhanuprakash Modem <bhanuprakash.modem at intel.com>

This helper will turn on and off the displays with the help of
IGT_CRTC_ACTIVE properties set to ON and OFF.

v2: Use IGT_CRTC_ACTIVE for displays On/Off.
v3: -Update commit message and helper names.
    -Update display on and off helpers.
v4: Remove redundant code. (Bhanu)

Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta at intel.com>
Signed-off-by: Mohammed Thasleem <mohammed.thasleem at intel.com>
---
 lib/igt_kms.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  3 +++
 2 files changed, 57 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index c2f3728a6..b9cb6aa85 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -6083,3 +6083,57 @@ int igt_get_dp_mst_connector_id(igt_output_t *output)
 
 	return connector_id;
 }
+
+/*
+ * igt_turn_on_display:
+ * @fd: A drm file descriptor
+ *
+ * It will Enable the all connected display.
+ */
+void igt_turn_on_display(int drm_fd)
+{
+	igt_display_t display;
+	igt_output_t *output;
+	enum pipe pipe;
+
+	if (!drmModeGetResources(drm_fd))
+		return;
+
+	igt_display_require(&display, drm_fd);
+	igt_display_reset(&display);
+
+	for_each_pipe(&display, pipe) {
+		for_each_valid_output_on_pipe(&display, pipe, output) {
+			if (output->pending_pipe != PIPE_NONE)
+				continue;
+
+			igt_output_set_pipe(output, pipe);
+			break;
+		}
+	}
+
+	igt_display_commit2(&display, COMMIT_ATOMIC);
+
+	igt_display_fini(&display);
+}
+
+/*
+ * igt_turn_off_display:
+ * @fd: A drm file descriptor
+ *
+ * It will disable  the all connected display.
+ */
+void igt_turn_off_display(int drm_fd)
+{
+	igt_display_t display;
+
+	if (!drmModeGetResources(drm_fd))
+		return;
+
+	igt_display_require(&display, drm_fd);
+	igt_display_reset(&display);
+
+	igt_display_commit2(&display, COMMIT_ATOMIC);
+
+	igt_display_fini(&display);
+}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index f2c3741fc..526477e4d 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -1016,4 +1016,7 @@ bool i915_pipe_output_combo_valid(igt_display_t *display);
 bool igt_check_output_is_dp_mst(igt_output_t *output);
 int igt_get_dp_mst_connector_id(igt_output_t *output);
 
+void igt_turn_on_display(int drm_fd);
+void igt_turn_off_display(int drm_fd);
+
 #endif /* __IGT_KMS_H__ */
-- 
2.25.1



More information about the igt-dev mailing list