From patchwork Wed Sep 5 18:00:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 10589241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFECF1669 for ; Wed, 5 Sep 2018 18:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1F202A8BF for ; Wed, 5 Sep 2018 18:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DD152A84C; Wed, 5 Sep 2018 18:00:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 120392A8B5 for ; Wed, 5 Sep 2018 18:00:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 411366E523; Wed, 5 Sep 2018 18:00:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kmu-office.ch (mail.kmu-office.ch [IPv6:2a02:418:6a02::a2]) by gabe.freedesktop.org (Postfix) with ESMTPS id F37256E0ED for ; Wed, 5 Sep 2018 18:00:34 +0000 (UTC) Received: from trochilidae.toradex.int (75-146-58-181-Washington.hfc.comcastbusiness.net [75.146.58.181]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 152445C0169; Wed, 5 Sep 2018 20:00:32 +0200 (CEST) From: Stefan Agner To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 1/2] modeprint: use libutil to lookup strings Date: Wed, 5 Sep 2018 11:00:19 -0700 Message-Id: <20180905180025.13282-2-stefan@agner.ch> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180905180025.13282-1-stefan@agner.ch> References: <20180905180025.13282-1-stefan@agner.ch> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 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);