diff options
author | Thierry Reding | 2015-12-09 11:37:48 -0600 |
---|---|---|
committer | Emil Velikov | 2015-12-18 11:44:22 -0600 |
commit | b020b02f841af6c04d97d484db0ecf1149b93abf (patch) | |
tree | 5fbaf520ac2e243c8c4ac6dbf3e116d4b16f5274 | |
parent | 6223481b8de901b5356afdef538726f1fb77bfd1 (diff) | |
download | external-libdrm-b020b02f841af6c04d97d484db0ecf1149b93abf.tar.gz external-libdrm-b020b02f841af6c04d97d484db0ecf1149b93abf.tar.xz external-libdrm-b020b02f841af6c04d97d484db0ecf1149b93abf.zip |
vbltest: Use util_open()
Use the new util_open() helper instead of open-coding the method for
finding a usable device. While at it, this adds -D and -M command-line
options to vbltest to make its usage more consistent with its siblings
modetest and proptest.
Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r-- | tests/vbltest/Makefile.am | 3 | ||||
-rw-r--r-- | tests/vbltest/vbltest.c | 38 |
2 files changed, 20 insertions, 21 deletions
diff --git a/tests/vbltest/Makefile.am b/tests/vbltest/Makefile.am index 182e3b6d..276afad5 100644 --- a/tests/vbltest/Makefile.am +++ b/tests/vbltest/Makefile.am | |||
@@ -15,4 +15,5 @@ endif | |||
15 | vbltest_SOURCES = \ | 15 | vbltest_SOURCES = \ |
16 | vbltest.c | 16 | vbltest.c |
17 | vbltest_LDADD = \ | 17 | vbltest_LDADD = \ |
18 | $(top_builddir)/libdrm.la | 18 | $(top_builddir)/libdrm.la \ |
19 | $(top_builddir)/tests/util/libutil.la | ||
diff --git a/tests/vbltest/vbltest.c b/tests/vbltest/vbltest.c index de93e770..60badf11 100644 --- a/tests/vbltest/vbltest.c +++ b/tests/vbltest/vbltest.c | |||
@@ -55,10 +55,11 @@ | |||
55 | #include "xf86drmMode.h" | 55 | #include "xf86drmMode.h" |
56 | 56 | ||
57 | #include "util/common.h" | 57 | #include "util/common.h" |
58 | #include "util/kms.h" | ||
58 | 59 | ||
59 | extern char *optarg; | 60 | extern char *optarg; |
60 | extern int optind, opterr, optopt; | 61 | extern int optind, opterr, optopt; |
61 | static char optstr[] = "s"; | 62 | static char optstr[] = "D:M:s"; |
62 | 63 | ||
63 | int secondary = 0; | 64 | int secondary = 0; |
64 | 65 | ||
@@ -97,16 +98,19 @@ static void vblank_handler(int fd, unsigned int frame, unsigned int sec, | |||
97 | 98 | ||
98 | static void usage(char *name) | 99 | static void usage(char *name) |
99 | { | 100 | { |
100 | fprintf(stderr, "usage: %s [-s]\n", name); | 101 | fprintf(stderr, "usage: %s [-DMs]\n", name); |
101 | fprintf(stderr, "\t-s\tuse secondary pipe\n"); | 102 | fprintf(stderr, "\n"); |
103 | fprintf(stderr, "options:\n"); | ||
104 | fprintf(stderr, " -D DEVICE open the given device\n"); | ||
105 | fprintf(stderr, " -M MODULE open the given module\n"); | ||
106 | fprintf(stderr, " -s use secondary pipe\n"); | ||
102 | exit(0); | 107 | exit(0); |
103 | } | 108 | } |
104 | 109 | ||
105 | int main(int argc, char **argv) | 110 | int main(int argc, char **argv) |
106 | { | 111 | { |
107 | unsigned i; | 112 | const char *device = NULL, *module = NULL; |
108 | int c, fd, ret; | 113 | int c, fd, ret; |
109 | const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "exynos", "omapdrm", "tilcdc", "msm", "tegra", "imx-drm" , "rockchip" }; | ||
110 | drmVBlank vbl; | 114 | drmVBlank vbl; |
111 | drmEventContext evctx; | 115 | drmEventContext evctx; |
112 | struct vbl_info handler_info; | 116 | struct vbl_info handler_info; |
@@ -114,6 +118,12 @@ int main(int argc, char **argv) | |||
114 | opterr = 0; | 118 | opterr = 0; |
115 | while ((c = getopt(argc, argv, optstr)) != -1) { | 119 | while ((c = getopt(argc, argv, optstr)) != -1) { |
116 | switch (c) { | 120 | switch (c) { |
121 | case 'D': | ||
122 | device = optarg; | ||
123 | break; | ||
124 | case 'M': | ||
125 | module = optarg; | ||
126 | break; | ||
117 | case 's': | 127 | case 's': |
118 | secondary = 1; | 128 | secondary = 1; |
119 | break; | 129 | break; |
@@ -123,21 +133,9 @@ int main(int argc, char **argv) | |||
123 | } | 133 | } |
124 | } | 134 | } |
125 | 135 | ||
126 | for (i = 0; i < ARRAY_SIZE(modules); i++) { | 136 | fd = util_open(module, device); |
127 | printf("trying to load module %s...", modules[i]); | 137 | if (fd < 0) |
128 | fd = drmOpen(modules[i], NULL); | 138 | return 1; |
129 | if (fd < 0) { | ||
130 | printf("failed.\n"); | ||
131 | } else { | ||
132 | printf("success.\n"); | ||
133 | break; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | if (i == ARRAY_SIZE(modules)) { | ||
138 | fprintf(stderr, "failed to load any modules, aborting.\n"); | ||
139 | return -1; | ||
140 | } | ||
141 | 139 | ||
142 | /* Get current count first */ | 140 | /* Get current count first */ |
143 | vbl.request.type = DRM_VBLANK_RELATIVE; | 141 | vbl.request.type = DRM_VBLANK_RELATIVE; |