[PATCH i-g-t v3 06/29] lib/igt_kms: Add helper to get a pipe from a connector
Louis Chauvet
louis.chauvet at bootlin.com
Sat Aug 23 02:11:26 UTC 2025
Currently there is no way to get a pipe from the connector. Add this tiny
helper that will try to get the currently used pipe for a specific
connector.
Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
lib/igt_kms.c | 34 ++++++++++++++++++++++++++++++++++
lib/igt_kms.h | 8 ++++++++
2 files changed, 42 insertions(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 843924e79eae1e21542b0dd916bd92627f7a8473..6929b7ea87ab04e945499ea73f014ef68c60d3aa 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -7878,3 +7878,37 @@ int kms_wait_for_new_connectors(uint32_t **newly_connected,
return newly_connected_count;
}
+
+enum pipe igt_get_pipe_from_connector(int drm_fd, int connector_id)
+{
+ drmModeObjectPropertiesPtr proplist;
+ drmModePropertyPtr crtc_id_prop;
+ drmModePropertyPtr prop;
+ uint32_t crtc_id;
+ enum pipe pipe_id;
+ int i;
+
+ proplist = drmModeObjectGetProperties(drm_fd, connector_id, DRM_MODE_OBJECT_CONNECTOR);
+ crtc_id_prop = NULL;
+
+ for (i = 0; i < proplist->count_props; i++) {
+ prop = drmModeGetProperty(drm_fd, proplist->props[i]);
+
+ if (strcmp(prop->name, "CRTC_ID") == 0) {
+ crtc_id_prop = prop;
+ break;
+ }
+ drmModeFreeProperty(prop);
+ }
+
+ igt_assert(crtc_id_prop);
+ igt_assert((crtc_id_prop->flags & DRM_MODE_PROP_EXTENDED_TYPE) == DRM_MODE_PROP_OBJECT);
+ crtc_id = proplist->prop_values[i];
+ drmModeFreeProperty(crtc_id_prop);
+ drmModeFreeObjectProperties(proplist);
+ if (crtc_id != 0) {
+ pipe_id = kmstest_get_pipe_from_crtc_id(drm_fd, crtc_id);
+ return pipe_id;
+ }
+ return PIPE_NONE;
+}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 94e9b4dec45603b26568c82cfa253c30e403b90c..97e91455faf0d08527c254123d3013393d981fb7 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -1312,4 +1312,12 @@ int kms_wait_for_new_connectors(uint32_t **newly_connected,
int
get_list_diff(const uint32_t *list_a, int list_a_len, const uint32_t *list_b, int list_b_len,
uint32_t **diff);
+/**
+ * igt_get_pipe_from_connector() - Get a pipe from the connector id
+ * @drm_fd: drm file descriptor to which the connector belongs
+ * @connector_id: connector to inspect
+ *
+ * Returns PIPE_NONE if the connector is not connected to any pipe
+ */
+enum pipe igt_get_pipe_from_connector(int drm_fd, int connector_id);
#endif /* __IGT_KMS_H__ */
--
2.50.1
More information about the igt-dev
mailing list