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 <stefan@xxxxxxxx> --- 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 601dbc96..c8c5e797 100644 --- a/tests/modeprint/Makefile.am +++ b/tests/modeprint/Makefile.am @@ -15,4 +15,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 5f0eb24b..5e752798 100644 --- a/tests/modeprint/meson.build +++ b/tests/modeprint/meson.build @@ -23,7 +23,7 @@ modeprint = executable( files('modeprint.c'), c_args : warn_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 c81dd91d..1d62270f 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.18.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel