summaryrefslogtreecommitdiff
path: root/lib/igt_kms.c
diff options
context:
space:
mode:
authorAbhinav Kumar <abhinavk@codeaurora.org>2020-09-15 12:56:11 -0700
committerPetri Latvala <petri.latvala@intel.com>2020-09-16 11:17:16 +0300
commit2e212b8397975926dc94293e1543b00e4bb359e6 (patch)
tree187138beba2b51b5f1a287d24324c3a063c0aa1c /lib/igt_kms.c
parente1b1f185c9e8b9d41f7dc8fb835de57454894581 (diff)
lib/igt_kms: move some of the useful dump functions to igt_kms
Some of the functions inside the intel_dp_compliance are generic and can be used by other modules as well. Move these to the igt_kms lib. changes in v2: - add more documentation for the new APIs in the lib Signed-off-by: Abhinav Kumar <abhinavk@codeaurora.org> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'lib/igt_kms.c')
-rw-r--r--lib/igt_kms.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7cf2008e..4023811a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
* Copyright © 2013 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -4778,3 +4779,110 @@ uint32_t igt_reduce_format(uint32_t format)
return format;
}
}
+
+/**
+ * igt_dump_connectors_fd:
+ * @drmfd: handle to open drm device.
+ *
+ * Iterates through list of connectors and
+ * dumps their list of modes.
+ *
+ */
+void igt_dump_connectors_fd(int drmfd)
+{
+ int i, j;
+
+ drmModeRes *mode_resources = drmModeGetResources(drmfd);
+
+ if (!mode_resources) {
+ igt_warn("drmModeGetResources failed: %s\n", strerror(errno));
+ return;
+ }
+
+ igt_info("Connectors:\n");
+ igt_info("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\n");
+ for (i = 0; i < mode_resources->count_connectors; i++) {
+ drmModeConnector *connector;
+
+ connector = drmModeGetConnectorCurrent(drmfd,
+ mode_resources->connectors[i]);
+ if (!connector) {
+ igt_warn("Could not get connector %i: %s\n",
+ mode_resources->connectors[i],
+ strerror(errno));
+ continue;
+ }
+
+ igt_info("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n",
+ connector->connector_id,
+ connector->encoder_id,
+ kmstest_connector_status_str(connector->connection),
+ kmstest_connector_type_str(connector->connector_type),
+ connector->mmWidth,
+ connector->mmHeight,
+ connector->count_modes);
+
+ if (!connector->count_modes)
+ continue;
+
+ igt_info(" Modes:\n");
+ igt_info(" name refresh (Hz) hdisp hss hse htot vdisp ""vss vse vtot flags type clock\n");
+ for (j = 0; j < connector->count_modes; j++) {
+ igt_info("[%d]", j);
+ kmstest_dump_mode(&connector->modes[j]);
+ }
+
+ drmModeFreeConnector(connector);
+ }
+ igt_info("\n");
+
+ drmModeFreeResources(mode_resources);
+}
+
+/**
+ * igt_dump_crtcs_fd:
+ * @drmfd: handle to open drm device.
+ *
+ * Iterates through the list of crtcs and
+ * dumps out the mode and basic information
+ * for each of them.
+ */
+void igt_dump_crtcs_fd(int drmfd)
+{
+ int i;
+ drmModeRes *mode_resources;
+
+ mode_resources = drmModeGetResources(drmfd);
+ if (!mode_resources) {
+ igt_warn("drmModeGetResources failed: %s\n", strerror(errno));
+ return;
+ }
+
+ igt_info("CRTCs:\n");
+ igt_info("id\tfb\tpos\tsize\n");
+ for (i = 0; i < mode_resources->count_crtcs; i++) {
+ drmModeCrtc *crtc;
+
+ crtc = drmModeGetCrtc(drmfd, mode_resources->crtcs[i]);
+ if (!crtc) {
+ igt_warn("Could not get crtc %i: %s\n",
+ mode_resources->crtcs[i],
+ strerror(errno));
+ continue;
+ }
+ igt_info("%d\t%d\t(%d,%d)\t(%dx%d)\n",
+ crtc->crtc_id,
+ crtc->buffer_id,
+ crtc->x,
+ crtc->y,
+ crtc->width,
+ crtc->height);
+
+ kmstest_dump_mode(&crtc->mode);
+
+ drmModeFreeCrtc(crtc);
+ }
+ igt_info("\n");
+
+ drmModeFreeResources(mode_resources);
+}