[igt-dev] [PATCH i-g-t 2/5] lib/igt_kms: move some of the useful dump functions to igt_kms

Abhinav Kumar abhinavk at codeaurora.org
Fri Sep 4 00:54:36 UTC 2020


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.

Signed-off-by: Abhinav Kumar <abhinavk at codeaurora.org>
---
 lib/igt_kms.c               | 92 +++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h               |  5 ++
 tools/intel_dp_compliance.c | 92 +------------------------------------
 3 files changed, 99 insertions(+), 90 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f57972f1..1399d0bf 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
@@ -4726,3 +4727,94 @@ uint32_t igt_reduce_format(uint32_t format)
 		return format;
 	}
 }
+
+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);
+}
+
+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);
+}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 26dc9f5f..0468314f 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -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
@@ -868,6 +869,7 @@ int igt_connector_sysfs_open(int drm_fd,
 			     drmModeConnector *connector);
 uint32_t igt_reduce_format(uint32_t format);
 
+
 /*
  * igt_require_pipe:
  * @display: pointer to igt_display_t
@@ -881,4 +883,7 @@ uint32_t igt_reduce_format(uint32_t format);
 void igt_require_pipe(igt_display_t *display,
 		enum pipe pipe);
 
+void igt_dump_connectors_fd(int drmfd);
+void igt_dump_crtcs_fd(int drmfd);
+
 #endif /* __IGT_KMS_H__ */
diff --git a/tools/intel_dp_compliance.c b/tools/intel_dp_compliance.c
index 5c423897..fc512711 100644
--- a/tools/intel_dp_compliance.c
+++ b/tools/intel_dp_compliance.c
@@ -347,98 +347,10 @@ static int process_test_request(int test_type)
 	return -1;
 }
 
-static void 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);
-}
-
-static void 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);
-}
-
 static void dump_info(void)
 {
-	dump_connectors_fd(drm_fd);
-	dump_crtcs_fd(drm_fd);
+	igt_dump_connectors_fd(drm_fd);
+	igt_dump_crtcs_fd(drm_fd);
 }
 
 static int setup_framebuffers(struct connector *dp_conn)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



More information about the igt-dev mailing list