From patchwork Sun Dec 20 05:52:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 7891291 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C6D60BEEED for ; Sun, 20 Dec 2015 05:52:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E50A9204AD for ; Sun, 20 Dec 2015 05:52:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BADAF20497 for ; Sun, 20 Dec 2015 05:52:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64E796E2C8; Sat, 19 Dec 2015 21:52:14 -0800 (PST) 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 [178.209.48.109]) by gabe.freedesktop.org (Postfix) with ESMTPS id 155746E2C8 for ; Sat, 19 Dec 2015 21:52:13 -0800 (PST) Received: from localhost.localdomain (unknown [IPv6:2601:602:8b00:ffde:3e97:eff:fe92:db3b]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 954255C022F; Sun, 20 Dec 2015 06:51:42 +0100 (CET) From: Stefan Agner To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 1/2] kmstest: Use util_open() Date: Sat, 19 Dec 2015 21:52:58 -0800 Message-Id: <1450590779-30832-1-git-send-email-stefan@agner.ch> X-Mailer: git-send-email 2.6.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1450590703; bh=uo0iWGAmidEXMQAPdS1xNfrmz9EDzIvsgaYInPshI78=; h=From:To:Cc:Subject:Date:Message-Id; b=BbGLqmKqJ3+5H1a3UqzhEZL8HFe6AMLmzHH4MMKIB1AztW90Qf7T0b7iVu2Ol10KqzAVxT+LV+fkQEB13FT+MX1KLWhapSS7/WiCYxe6U43sw5dqWJHXXq1yboeCsaeZP0i0wkfMS/mAHDqjmWum44xqW10pbuitt/6t8W/QWbQ= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the new util_open() helper instead of open-coding the method for finding a usable device. While at it, make the command-line interface more consistent with that of modetest by adding the -D and -M options. Signed-off-by: Stefan Agner --- tests/kmstest/Makefile.am | 4 +++- tests/kmstest/main.c | 45 +++++++++++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/tests/kmstest/Makefile.am b/tests/kmstest/Makefile.am index fd21e61..100662e 100644 --- a/tests/kmstest/Makefile.am +++ b/tests/kmstest/Makefile.am @@ -2,6 +2,7 @@ AM_CFLAGS = \ $(WARN_CFLAGS)\ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/libkms/ \ + -I$(top_srcdir)/tests/ \ -I$(top_srcdir) if HAVE_INSTALL_TESTS @@ -17,7 +18,8 @@ kmstest_SOURCES = \ kmstest_LDADD = \ $(top_builddir)/libdrm.la \ - $(top_builddir)/libkms/libkms.la + $(top_builddir)/libkms/libkms.la \ + $(top_builddir)/tests/util/libutil.la run: kmstest ./kmstest diff --git a/tests/kmstest/main.c b/tests/kmstest/main.c index 120bc0f..fe8f42e 100644 --- a/tests/kmstest/main.c +++ b/tests/kmstest/main.c @@ -25,12 +25,14 @@ * **************************************************************************/ - +#include #include #include #include "xf86drm.h" #include "libkms.h" +#include "util/kms.h" + #define CHECK_RET_RETURN(ret, str) \ if (ret < 0) { \ printf("%s: %s (%s)\n", __func__, str, strerror(-ret)); \ @@ -56,26 +58,37 @@ static int test_bo(struct kms_driver *kms) return 0; } -static const char *drivers[] = { - "i915", - "radeon", - "nouveau", - "vmwgfx", - "exynos", - "amdgpu", - "imx-drm", - "rockchip", - "atmel-hlcdc", - NULL -}; +static void usage(const char *program) +{ + fprintf(stderr, "Usage: %s [options]\n", program); + fprintf(stderr, "\n"); + fprintf(stderr, " -D DEVICE open the given device\n"); + fprintf(stderr, " -M MODULE open the given module\n"); +} int main(int argc, char** argv) { + static const char optstr[] = "D:M:"; struct kms_driver *kms; - int ret, fd, i; + int c, fd, ret; + char *device = NULL; + char *module = NULL; + + while ((c = getopt(argc, argv, optstr)) != -1) { + switch (c) { + case 'D': + device = optarg; + break; + case 'M': + module = optarg; + break; + default: + usage(argv[0]); + return 0; + } + } - for (i = 0, fd = -1; fd < 0 && drivers[i]; i++) - fd = drmOpen(drivers[i], NULL); + fd = util_open(module, device); CHECK_RET_RETURN(fd, "Could not open device"); ret = kms_create(fd, &kms);