[PATCH i-g-t 1/6] tests/intel/kms_mst_helper: add helper for MST-related functions

Kunal Joshi kunal1.joshi at intel.com
Mon Feb 10 18:56:01 UTC 2025


Add helper to centralize commonly used MST-related logic.
igt_find_all_mst_output_in_topology() enumerates MST outputs
that share the same root connector id.

v2: fix docs (Ankit)
    change return type to int (Ankit)
    split patch (Ankit)

Cc: Ankit Nautiyal <ankit.k.nautiyal at intel.com>
Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>
---
 tests/intel/kms_mst_helper.c | 49 ++++++++++++++++++++++++++++++++++++
 tests/intel/kms_mst_helper.h | 15 +++++++++++
 2 files changed, 64 insertions(+)
 create mode 100644 tests/intel/kms_mst_helper.c
 create mode 100644 tests/intel/kms_mst_helper.h

diff --git a/tests/intel/kms_mst_helper.c b/tests/intel/kms_mst_helper.c
new file mode 100644
index 000000000..fb5aaab77
--- /dev/null
+++ b/tests/intel/kms_mst_helper.c
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include "kms_mst_helper.h"
+
+/*
+ * @drm_fd: DRM file descriptor
+ * @display: pointer to #igt_display_t structure
+ * @output: target output
+ * @mst_outputs: filled with mst output of same toplogy as @output
+ * @num_mst_outputs: filled with count of mst outputs found in topology
+ *
+ * Iterates over all connected outputs and adds each DP MST
+ * output that shares the same MST connector ID as @output
+ * into @mst_outputs.
+ *
+ * Returns: 0 on success, -1 on failure
+ */
+int igt_find_all_mst_output_in_topology(int drm_fd, igt_display_t *display,
+					 igt_output_t *output,
+					 igt_output_t *mst_outputs[],
+					 int *num_mst_outputs)
+{
+	int output_root_id, root_id;
+	igt_output_t *connector_output;
+
+	if (!igt_check_output_is_dp_mst(output))
+		return -1;
+
+	output_root_id = igt_get_dp_mst_connector_id(output);
+	if (output_root_id == -EINVAL)
+		return -1;
+
+	/*
+	 * If output is MST, check all other connected output which shares
+	 * same path and fill mst_outputs and num_mst_outputs
+	 */
+	for_each_connected_output(display, connector_output) {
+		if (!igt_check_output_is_dp_mst(connector_output))
+			continue;
+
+		root_id = igt_get_dp_mst_connector_id(connector_output);
+		if (((*num_mst_outputs) < IGT_MAX_PIPES) && root_id == output_root_id)
+			mst_outputs[(*num_mst_outputs)++] = connector_output;
+	}
+	return 0;
+}
diff --git a/tests/intel/kms_mst_helper.h b/tests/intel/kms_mst_helper.h
new file mode 100644
index 000000000..637ca696e
--- /dev/null
+++ b/tests/intel/kms_mst_helper.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#ifndef KMS_MST_HELPER_H
+#define KMS_MST_HELPER_H
+
+#include "igt.h"
+
+int igt_find_all_mst_output_in_topology(int drm_fd, igt_display_t *display,
+					 igt_output_t *output,
+					 igt_output_t *mst_outputs[],
+					 int *num_mst_outputs);
+#endif
-- 
2.25.1



More information about the igt-dev mailing list