From eaed5c8825a1d901ff29526b1463643bb7970d7d Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 5 Sep 2018 11:00:19 -0700 Subject: [PATCH] modeprint: use libutil to lookup strings Use libutil to lookup connector type names and state. This also makes sure that the latest connector type addition "DPI" gets printed correctly. Signed-off-by: Stefan Agner Reviewed-by: Emil Velikov --- tests/modeprint/Makefile.am | 1 + tests/modeprint/meson.build | 2 +- tests/modeprint/modeprint.c | 43 +++++++------------------------------------ 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/tests/modeprint/Makefile.am b/tests/modeprint/Makefile.am index 84d5990..568185f 100644 --- a/tests/modeprint/Makefile.am +++ b/tests/modeprint/Makefile.am @@ -16,4 +16,5 @@ endif modeprint_SOURCES = \ modeprint.c modeprint_LDADD = \ + $(top_builddir)/tests/util/libutil.la \ $(top_builddir)/libdrm.la diff --git a/tests/modeprint/meson.build b/tests/modeprint/meson.build index 898fd18..0801808 100644 --- a/tests/modeprint/meson.build +++ b/tests/modeprint/meson.build @@ -23,7 +23,7 @@ modeprint = executable( files('modeprint.c'), c_args : libdrm_c_args, include_directories : [inc_root, inc_tests, inc_drm], - link_with : libdrm, + link_with : [libdrm, libutil], dependencies : dep_threads, install : with_install_tests, ) diff --git a/tests/modeprint/modeprint.c b/tests/modeprint/modeprint.c index c81dd91..1d62270 100644 --- a/tests/modeprint/modeprint.c +++ b/tests/modeprint/modeprint.c @@ -42,6 +42,7 @@ #include "xf86drmMode.h" #include "util/common.h" +#include "util/kms.h" int current; int connectors; @@ -54,20 +55,6 @@ int crtcs; int fbs; char *module_name; -static const char* getConnectionText(drmModeConnection conn) -{ - switch (conn) { - case DRM_MODE_CONNECTED: - return "connected"; - case DRM_MODE_DISCONNECTED: - return "disconnected"; - case DRM_MODE_UNKNOWNCONNECTION: - default: - return "unknown"; - } - -} - static int printMode(struct drm_mode_modeinfo *mode) { if (full_modes) { @@ -141,40 +128,24 @@ static int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, ui return 0; } -static const char * const output_names[] = { "None", - "VGA", - "DVI-I", - "DVI-D", - "DVI-A", - "Composite", - "SVIDEO", - "LVDS", - "Component", - "DIN", - "DP", - "HDMI-A", - "HDMI-B", - "TV", - "eDP", - "Virtual", - "DSI", -}; - static int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uint32_t id) { int i = 0; struct drm_mode_modeinfo *mode = NULL; drmModePropertyPtr props; + const char *connector_type_name = NULL; + + connector_type_name = util_lookup_connector_type_name(connector->connector_type); - if (connector->connector_type < ARRAY_SIZE(output_names)) - printf("Connector: %s-%d\n", output_names[connector->connector_type], + if (connector_type_name) + printf("Connector: %s-%d\n", connector_type_name, connector->connector_type_id); else printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id); printf("\tid : %i\n", id); printf("\tencoder id : %i\n", connector->encoder_id); - printf("\tconn : %s\n", getConnectionText(connector->connection)); + printf("\tconn : %s\n", util_lookup_connector_status_name(connector->connection)); printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); printf("\tcount_modes : %i\n", connector->count_modes); printf("\tcount_props : %i\n", connector->count_props); -- 2.7.4