aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amdfalconx86/recipes-graphics/drm/files/0013-kmstest-Use-util_open.patch
blob: 88c7144227e49b63dc47fc1a3cbddae92996efd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
From 0caf58a6cb82327a3f6a53f05dea8e02f1412a05 Mon Sep 17 00:00:00 2001
From: Stefan Agner <stefan@agner.ch>
Date: Sat, 19 Dec 2015 21:52:58 -0800
Subject: [PATCH 013/117] kmstest: Use util_open()

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 <stefan@agner.ch>
v2: correctly use util_open() - swap device, module
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
 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..a0e4ebb 100644
--- a/tests/kmstest/main.c
+++ b/tests/kmstest/main.c
@@ -25,12 +25,14 @@
  *
  **************************************************************************/
 
-
+#include <getopt.h>
 #include <stdio.h>
 #include <string.h>
 #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(device, module);
 	CHECK_RET_RETURN(fd, "Could not open device");
 
 	ret = kms_create(fd, &kms);
-- 
2.7.4